Glenn Randers-Pehrson | 5b5dcf8 | 2004-07-17 22:45:44 -0500 | [diff] [blame] | 1 | |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 2 | /* pngconf.h - machine configurable file for libpng |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 3 | * |
Glenn Randers-Pehrson | d3a726d | 2010-08-03 20:26:34 -0500 | [diff] [blame^] | 4 | * libpng version 1.5.0beta40 - August 4, 2010 |
Glenn Randers-Pehrson | c17c957 | 2010-03-08 21:26:48 -0600 | [diff] [blame] | 5 | * |
Glenn Randers-Pehrson | e69b55d | 2010-01-01 10:29:06 -0600 | [diff] [blame] | 6 | * Copyright (c) 1998-2010 Glenn Randers-Pehrson |
Glenn Randers-Pehrson | d436672 | 2000-06-04 14:29:29 -0500 | [diff] [blame] | 7 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
| 8 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
Glenn Randers-Pehrson | 3e61d79 | 2009-06-24 09:31:28 -0500 | [diff] [blame] | 9 | * |
Glenn Randers-Pehrson | bfbf865 | 2009-06-26 21:46:52 -0500 | [diff] [blame] | 10 | * This code is released under the libpng license. |
Glenn Randers-Pehrson | c332bbc | 2009-06-25 13:43:50 -0500 | [diff] [blame] | 11 | * For conditions of distribution and use, see the disclaimer |
Glenn Randers-Pehrson | 037023b | 2009-06-24 10:27:36 -0500 | [diff] [blame] | 12 | * and license in png.h |
Glenn Randers-Pehrson | 3e61d79 | 2009-06-24 09:31:28 -0500 | [diff] [blame] | 13 | * |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 14 | */ |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 15 | |
| 16 | /* Any machine specific code is near the front of this file, so if you |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 17 | * are configuring libpng for a machine, you may want to read the section |
| 18 | * starting here down to where it starts to typedef png_color, png_text, |
| 19 | * and png_info. |
| 20 | */ |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 21 | |
| 22 | #ifndef PNGCONF_H |
| 23 | #define PNGCONF_H |
| 24 | |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 25 | /* PNG_NO_LIMITS_H may be used to turn off the use of the standard C |
| 26 | * definition file for machine specific limits, this may impact the |
| 27 | * correctness of the definitons below (see uses of INT_MAX). |
| 28 | */ |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 29 | #ifndef PNG_NO_LIMITS_H |
Glenn Randers-Pehrson | 6076da8 | 2009-09-30 12:28:07 -0500 | [diff] [blame] | 30 | # include <limits.h> |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 31 | #endif |
| 32 | |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 33 | /* For the memory copy APIs (i.e. the standard definitions of these), |
| 34 | * because this file defines png_memcpy and so on the base APIs must |
| 35 | * be defined here. |
| 36 | */ |
| 37 | #ifdef BSD |
| 38 | # include <strings.h> |
| 39 | #else |
| 40 | # include <string.h> |
| 41 | #endif |
| 42 | |
| 43 | /* For png_FILE_p - this provides the standard definition of a |
| 44 | * FILE |
| 45 | */ |
| 46 | #ifdef PNG_STDIO_SUPPORTED |
| 47 | # include <stdio.h> |
| 48 | #endif |
| 49 | |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 50 | /* This controls optimization of the reading of 16 and 32 bit values |
| 51 | * from PNG files. It can be set on a per-app-file basis - it |
| 52 | * just changes whether a macro is used to the function is called. |
Glenn Randers-Pehrson | c3d73f4 | 2010-04-24 09:18:57 -0500 | [diff] [blame] | 53 | * The library builder sets the default, if read functions are not |
| 54 | * built into the library the macro implementation is forced on. |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 55 | */ |
Glenn Randers-Pehrson | c3d73f4 | 2010-04-24 09:18:57 -0500 | [diff] [blame] | 56 | #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED |
| 57 | # define PNG_USE_READ_MACROS |
| 58 | #endif |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 59 | #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) |
| 60 | # if PNG_DEFAULT_READ_MACROS |
| 61 | # define PNG_USE_READ_MACROS |
| 62 | # endif |
| 63 | #endif |
| 64 | |
Glenn Randers-Pehrson | 8fc3604 | 2010-04-17 10:17:46 -0500 | [diff] [blame] | 65 | /* COMPILER SPECIFIC OPTIONS. |
Glenn Randers-Pehrson | 7824a70 | 2009-06-13 10:05:05 -0500 | [diff] [blame] | 66 | * |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 67 | * These options are provided so that a variety of difficult compilers |
| 68 | * can be used. Some are fixed at build time (e.g. PNG_API_RULE |
| 69 | * below) but still have compiler specific implementations, others |
| 70 | * may be changed on a per-file basis when compiling against libpng. |
Glenn Randers-Pehrson | 86dc981 | 2006-05-10 07:27:44 -0500 | [diff] [blame] | 71 | */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 72 | /* This macro protects us against machines that don't have function |
| 73 | * prototypes (ie K&R style headers). If your compiler does not handle |
| 74 | * function prototypes, define this macro and use the included ansi2knr. |
| 75 | * I've always been able to use _NO_PROTO as the indicator, but you may |
| 76 | * need to drag the empty declaration out in front of here, or change the |
| 77 | * ifdef to suit your own needs. |
Glenn Randers-Pehrson | a4d54bd | 2000-07-14 08:15:12 -0500 | [diff] [blame] | 78 | */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 79 | #ifndef PNGARG |
| 80 | |
| 81 | # ifdef OF /* zlib prototype munger */ |
| 82 | # define PNGARG(arglist) OF(arglist) |
Glenn Randers-Pehrson | e68f5a3 | 2001-05-14 09:20:53 -0500 | [diff] [blame] | 83 | # else |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 84 | |
| 85 | # ifdef _NO_PROTO |
| 86 | # define PNGARG(arglist) () |
Glenn Randers-Pehrson | a4d54bd | 2000-07-14 08:15:12 -0500 | [diff] [blame] | 87 | # else |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 88 | # define PNGARG(arglist) arglist |
| 89 | # endif /* _NO_PROTO */ |
| 90 | |
| 91 | # endif /* OF */ |
| 92 | |
| 93 | #endif /* PNGARG */ |
| 94 | |
| 95 | /* Function calling conventions. |
| 96 | * ============================= |
| 97 | * Normally it is not necessary to specify to the compiler how to call |
| 98 | * a function - it just does it - however on x86 systems derived from |
| 99 | * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems |
| 100 | * and some others) there are multiple ways to call a function and the |
| 101 | * default can be changed on the compiler command line. For this reason |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 102 | * libpng specifies the calling convention of every exported function and |
| 103 | * every function called via a user supplied function pointer. This is |
| 104 | * done in this file by defining the following macros: |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 105 | * |
| 106 | * PNGAPI Calling convention for exported functions. |
| 107 | * PNGCBAPI Calling convention for user provided (callback) functions. |
| 108 | * PNGCAPI Calling convention used by the ANSI-C library (required |
| 109 | * for longjmp callbacks and sometimes used internally to |
| 110 | * specify the calling convention for zlib). |
| 111 | * |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 112 | * These macros should never be overridden. If it is necessary to |
| 113 | * change calling convention in a private build this can be done |
| 114 | * by setting PNG_API_RULE (which defaults to 0) to one of the values |
| 115 | * below to select the correct 'API' variants. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 116 | * |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 117 | * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. |
| 118 | * This is correct in every known environment. |
| 119 | * PNG_API_RULE=1 Use the operating system convention for PNGAPI and |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 120 | * the 'C' calling convention (from PNGCAPI) for |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 121 | * callbacks (PNGCBAPI). This is no longer required |
| 122 | * in any known environment - if it has to be used |
| 123 | * please post an explanation of the problem to the |
| 124 | * libpng mailing list. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 125 | * |
| 126 | * These cases only differ if the operating system does not use the C |
| 127 | * calling convention, at present this just means the above cases |
| 128 | * (x86 DOS/Windows sytems) and, even then, this does not apply to |
| 129 | * Cygwin running on those systems. |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 130 | * |
Glenn Randers-Pehrson | 98b4f00 | 2010-04-16 22:30:26 -0500 | [diff] [blame] | 131 | * Note that the value must be defined in pnglibconf.h so that what |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 132 | * the application uses to call the library matches the conventions |
| 133 | * set when building the library. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 134 | */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 135 | |
| 136 | /* Symbol export |
| 137 | * ============= |
| 138 | * When building a shared library it is almost always necessary to tell |
| 139 | * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' |
| 140 | * is used to mark the symbols. On some systems these symbols can be |
| 141 | * extracted at link time and need no special processing by the compiler, |
| 142 | * on other systems the symbols are flagged by the compiler and just |
| 143 | * the declaration requires a special tag applied (unfortunately) in a |
| 144 | * compiler dependent way. Some systems can do either. |
| 145 | * |
| 146 | * A small number of older systems also require a symbol from a DLL to |
| 147 | * be flagged to the program that calls it. This is a problem because |
| 148 | * we do not know in the header file included by application code that |
| 149 | * the symbol will come from a shared library, as opposed to a statically |
| 150 | * linked one. For this reason the application must tell us by setting |
| 151 | * the magic flag PNG_USE_DLL to turn on the special processing before |
| 152 | * it includes png.h. |
Glenn Randers-Pehrson | 821b710 | 2010-06-24 16:16:32 -0500 | [diff] [blame] | 153 | * |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 154 | * Four additional macros are used to make this happen: |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 155 | * |
| 156 | * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from |
| 157 | * the build or imported if PNG_USE_DLL is set - compiler |
| 158 | * and system specific. |
| 159 | * |
| 160 | * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to |
| 161 | * 'type', compiler specific. |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 162 | * |
| 163 | * PNG_DLL_EXPORT Set to the magic to use during a libpng build to |
| 164 | * make a symbol exported from the DLL. |
| 165 | * |
| 166 | * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come |
| 167 | * from a DLL - used to define PNG_IMPEXP when |
| 168 | * PNG_USE_DLL is set. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 169 | */ |
| 170 | |
| 171 | /* System specific discovery. |
| 172 | * ========================== |
| 173 | * This code is used at build time to find PNG_IMPEXP, the API settings |
| 174 | * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 175 | * import processing is possible. On Windows/x86 systems it also sets |
| 176 | * compiler-specific macros to the values required to change the calling |
| 177 | * conventions of the various functions. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 178 | */ |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 179 | #if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ |
| 180 | defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\ |
| 181 | ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\ |
| 182 | defined(_M_X64) || defined(_M_IA64) ) |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 183 | /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes |
| 184 | * builds under Cygwin or MinGW. Also includes Watcom builds but these need |
| 185 | * special treatment because they are not compatible with GCC or Visual C |
| 186 | * because of different calling conventions. |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 187 | */ |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 188 | # if PNG_API_RULE == 2 |
| 189 | /* If this line results in an error, either because __watcall is not |
| 190 | * understood or because of a redefine just below you cannot use *this* |
| 191 | * build of the library with the compiler you are using. *This* build was |
| 192 | * build using Watcom and applications must also be built using Watcom! |
| 193 | */ |
| 194 | # define PNGCAPI __watcall |
| 195 | # endif |
| 196 | |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 197 | # if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) |
| 198 | # define PNGCAPI __cdecl |
| 199 | # if PNG_API_RULE == 1 |
| 200 | # define PNGAPI __stdcall |
| 201 | # endif |
| 202 | # else |
| 203 | /* An older compiler, or one not detected (erroneously) above, |
| 204 | * if necessary override on the command line to get the correct |
| 205 | * variants for the compiler. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 206 | */ |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 207 | # ifndef PNGCAPI |
| 208 | # define PNGCAPI _cdecl |
| 209 | # endif |
| 210 | # if PNG_API_RULE == 1 && !defined(PNGAPI) |
| 211 | # define PNGAPI _stdcall |
| 212 | # endif |
| 213 | # endif /* compiler/api */ |
| 214 | /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 215 | |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 216 | # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) |
| 217 | ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed |
| 218 | # endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 219 | |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 220 | # if (defined(_MSC_VER) && _MSC_VER < 800) ||\ |
| 221 | (defined(__BORLANDC__) && __BORLANDC__ < 0x500) |
| 222 | /* older Borland and MSC |
| 223 | * compilers used '__export' and required this to be after |
| 224 | * the type. |
| 225 | */ |
| 226 | # ifndef PNG_EXPORT_TYPE |
| 227 | # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP |
| 228 | # endif |
| 229 | # define PNG_DLL_EXPORT __export |
| 230 | # else /* newer compiler */ |
| 231 | # define PNG_DLL_EXPORT __declspec(dllexport) |
| 232 | # ifndef PNG_DLL_IMPORT |
| 233 | # define PNG_DLL_IMPORT __declspec(dllimport) |
| 234 | # endif |
| 235 | # endif /* compiler */ |
| 236 | |
| 237 | #else /* !Windows/x86 */ |
| 238 | # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) |
| 239 | # define PNGAPI _System |
| 240 | # else /* !Windows/x86 && !OS/2 */ |
| 241 | /* Use the defaults, or define PNG*API on the command line (but |
| 242 | * this will have to be done for every compile!) |
| 243 | */ |
| 244 | # endif /* other system, !OS/2 */ |
| 245 | #endif /* !Windows/x86 */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 246 | |
| 247 | /* Now do all the defaulting . */ |
| 248 | #ifndef PNGCAPI |
| 249 | # define PNGCAPI |
| 250 | #endif |
| 251 | #ifndef PNGCBAPI |
| 252 | # define PNGCBAPI PNGCAPI |
| 253 | #endif |
| 254 | #ifndef PNGAPI |
| 255 | # define PNGAPI PNGCAPI |
| 256 | #endif |
| 257 | |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 258 | /* The default for PNG_IMPEXP depends on whether the library is |
| 259 | * being built or used. |
| 260 | */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 261 | #ifndef PNG_IMPEXP |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 262 | # ifdef PNGLIB_BUILD |
| 263 | /* Building the library */ |
| 264 | # if (defined(DLL_EXPORT)/*from libtool*/ ||\ |
Glenn Randers-Pehrson | d9d4cec | 2010-07-12 07:12:09 -0500 | [diff] [blame] | 265 | defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\ |
| 266 | defined(_USRDLL) ||\ |
| 267 | defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT) |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 268 | /* Building a DLL. */ |
| 269 | # define PNG_IMPEXP PNG_DLL_EXPORT |
| 270 | # endif /* DLL */ |
| 271 | # else |
| 272 | /* Using the library */ |
| 273 | # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) |
| 274 | /* This forces use of a DLL, disallowing static linking */ |
| 275 | # define PNG_IMPEXP PNG_DLL_IMPORT |
| 276 | # endif |
| 277 | # endif |
| 278 | |
| 279 | # ifndef PNG_IMPEXP |
| 280 | # define PNG_IMPEXP |
| 281 | # endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 282 | #endif |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 283 | |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 284 | /* THe following complexity is concerned with getting the 'attributes' of the |
| 285 | * declared function in the correct place. This potentially requires a separate |
| 286 | * PNG_EXPORT function for every compiler. |
| 287 | */ |
| 288 | #ifndef PNG_FUNCTION |
| 289 | # ifdef __GNUC__ |
| 290 | # define PNG_FUNCTION(type, name, args, attributes)\ |
| 291 | attributes type name args |
| 292 | # else /* !GNUC */ |
| 293 | # ifdef _MSC_VER |
| 294 | # define PNG_FUNCTION(type, name, args, attributes)\ |
| 295 | attributes type name args |
| 296 | # else /* !MSC */ |
| 297 | # define PNG_FUNCTION(type, name, args, attributes)\ |
| 298 | type name args |
| 299 | # endif |
| 300 | # endif |
| 301 | #endif |
| 302 | |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 303 | #ifndef PNG_EXPORT_TYPE |
| 304 | # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type |
| 305 | #endif |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 306 | |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 307 | #ifndef PNG_EXPORT |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 308 | /* The ordinal value is only relevant when preprocessing png.h for symbol |
| 309 | * table entries. |
| 310 | */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 311 | # define PNG_EXPORT(type, name, args, attributes, ordinal)\ |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 312 | extern PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args),\ |
| 313 | attributes) |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 314 | #endif |
| 315 | |
| 316 | /* Use PNG_REMOVED to comment out a removed interface. */ |
| 317 | #ifndef PNG_REMOVED |
Glenn Randers-Pehrson | 5905484 | 2010-04-28 13:21:03 -0500 | [diff] [blame] | 318 | # define PNG_REMOVED(type, name, args, attributes, ordinal) |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 319 | #endif |
| 320 | |
| 321 | #ifndef PNG_CALLBACK |
| 322 | # define PNG_CALLBACK(type, name, args, attributes)\ |
| 323 | type (PNGCBAPI name) PNGARG(args) attributes |
| 324 | #endif |
| 325 | |
| 326 | /* Support for compiler specific function attributes. These are used |
| 327 | * so that where compiler support is available incorrect use of API |
| 328 | * functions in png.h will generate compiler warnings. |
| 329 | * |
| 330 | * Added at libpng-1.2.41. |
| 331 | */ |
| 332 | |
| 333 | #ifndef PNG_NO_PEDANTIC_WARNINGS |
Glenn Randers-Pehrson | c44253f | 2010-03-13 20:58:39 -0600 | [diff] [blame] | 334 | # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED |
| 335 | # define PNG_PEDANTIC_WARNINGS_SUPPORTED |
| 336 | # endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 337 | #endif |
| 338 | |
| 339 | #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED |
Glenn Randers-Pehrson | 882340c | 2010-03-13 21:19:51 -0600 | [diff] [blame] | 340 | /* Support for compiler specific function attributes. These are used |
| 341 | * so that where compiler support is available incorrect use of API |
| 342 | * functions in png.h will generate compiler warnings. Added at libpng |
| 343 | * version 1.2.41. |
| 344 | */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 345 | # ifdef __GNUC__ |
| 346 | # ifndef PNG_USE_RESULT |
| 347 | # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) |
| 348 | # endif |
| 349 | # ifndef PNG_NORETURN |
| 350 | # define PNG_NORETURN __attribute__((__noreturn__)) |
| 351 | # endif |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 352 | # ifndef PNG_PTR_NORETURN |
| 353 | # define PNG_PTR_NORETURN __attribute__((__noreturn__)) |
| 354 | # endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 355 | # ifndef PNG_ALLOCATED |
| 356 | # define PNG_ALLOCATED __attribute__((__malloc__)) |
| 357 | # endif |
| 358 | |
| 359 | /* This specifically protects structure members that should only be |
| 360 | * accessed from within the library, therefore should be empty during |
| 361 | * a library build. |
| 362 | */ |
| 363 | # ifndef PNGLIB_BUILD |
| 364 | # ifndef PNG_DEPRECATED |
| 365 | # define PNG_DEPRECATED __attribute__((__deprecated__)) |
| 366 | # endif |
| 367 | # ifndef PNG_DEPSTRUCT |
| 368 | # define PNG_DEPSTRUCT __attribute__((__deprecated__)) |
| 369 | # endif |
| 370 | # ifndef PNG_PRIVATE |
| 371 | # if 0 /* Doesn't work so we use deprecated instead*/ |
| 372 | # define PNG_PRIVATE \ |
| 373 | __attribute__((warning("This function is not exported by libpng."))) |
| 374 | # else |
| 375 | # define PNG_PRIVATE \ |
| 376 | __attribute__((__deprecated__)) |
| 377 | # endif |
| 378 | # endif /* PNG_PRIVATE */ |
| 379 | # endif /* PNGLIB_BUILD */ |
| 380 | # endif /* __GNUC__ */ |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 381 | # ifdef _MSC_VER /* may need to check value */ |
| 382 | # ifndef PNG_USE_RESULT |
| 383 | # define PNG_USE_RESULT /*not supported*/ |
| 384 | # endif |
| 385 | # ifndef PNG_NORETURN |
| 386 | # define PNG_NORETURN __declspec(noreturn) |
| 387 | # endif |
| 388 | # ifndef PNG_PTR_NORETURN |
| 389 | # define PNG_PTR_NORETURN /*not supported*/ |
| 390 | # endif |
| 391 | # ifndef PNG_ALLOCATED |
| 392 | # define PNG_ALLOCATED __declspec(restrict) |
| 393 | # endif |
| 394 | |
| 395 | /* This specifically protects structure members that should only be |
| 396 | * accessed from within the library, therefore should be empty during |
| 397 | * a library build. |
| 398 | */ |
| 399 | # ifndef PNGLIB_BUILD |
| 400 | # ifndef PNG_DEPRECATED |
| 401 | # define PNG_DEPRECATED __declspec(deprecated) |
| 402 | # endif |
| 403 | # ifndef PNG_DEPSTRUCT |
| 404 | # define PNG_DEPSTRUCT __declspec(deprecated) |
| 405 | # endif |
| 406 | # ifndef PNG_PRIVATE |
| 407 | # define PNG_PRIVATE __declspec(deprecated) |
| 408 | # endif /* PNG_PRIVATE */ |
| 409 | # endif /* PNGLIB_BUILD */ |
| 410 | # endif /* __GNUC__ */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 411 | #endif /* PNG_PEDANTIC_WARNINGS */ |
| 412 | |
| 413 | #ifndef PNG_DEPRECATED |
| 414 | # define PNG_DEPRECATED /* Use of this function is deprecated */ |
| 415 | #endif |
| 416 | #ifndef PNG_USE_RESULT |
| 417 | # define PNG_USE_RESULT /* The result of this function must be checked */ |
| 418 | #endif |
| 419 | #ifndef PNG_NORETURN |
| 420 | # define PNG_NORETURN /* This function does not return */ |
| 421 | #endif |
| 422 | #ifndef PNG_ALLOCATED |
| 423 | # define PNG_ALLOCATED /* The result of the function is new memory */ |
| 424 | #endif |
| 425 | #ifndef PNG_DEPSTRUCT |
| 426 | # define PNG_DEPSTRUCT /* Access to this struct member is deprecated */ |
| 427 | #endif |
| 428 | #ifndef PNG_PRIVATE |
| 429 | # define PNG_PRIVATE /* This is a private libpng function */ |
Glenn Randers-Pehrson | a4d54bd | 2000-07-14 08:15:12 -0500 | [diff] [blame] | 430 | #endif |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 431 | #ifndef PNG_FP_EXPORT /* A floating point API. */ |
| 432 | # ifdef PNG_FLOATING_POINT_SUPPORTED |
| 433 | # define PNG_FP_EXPORT(type, name, args, attributes, ordinal)\ |
| 434 | PNG_EXPORT(type, name, args, attributes, ordinal) |
| 435 | # else /* No floating point APIs */ |
| 436 | # define PNG_FP_EXPORT(type, name, args, attributes, ordinal) |
| 437 | # endif |
| 438 | #endif |
| 439 | #ifndef PNG_FIXED_EXPORT /* A fixed point API. */ |
| 440 | # ifdef PNG_FIXED_POINT_SUPPORTED |
| 441 | # define PNG_FIXED_EXPORT(type, name, args, attributes, ordinal)\ |
| 442 | PNG_EXPORT(type, name, args, attributes, ordinal) |
| 443 | # else /* No fixed point APIs */ |
| 444 | # define PNG_FIXED_EXPORT(type, name, args, attributes, ordinal) |
| 445 | # endif |
| 446 | #endif |
Glenn Randers-Pehrson | a4d54bd | 2000-07-14 08:15:12 -0500 | [diff] [blame] | 447 | |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 448 | /* The following uses const char * instead of char * for error |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 449 | * and warning message functions, so some compilers won't complain. |
Glenn Randers-Pehrson | c4a2ae6 | 1998-01-16 22:06:18 -0600 | [diff] [blame] | 450 | * If you do not want to use const, define PNG_NO_CONST here. |
Glenn Randers-Pehrson | 7253144 | 2010-04-17 08:17:51 -0500 | [diff] [blame] | 451 | * |
| 452 | * This should not change how the APIs are called, so it can be done |
| 453 | * on a per-file basis in the application. |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 454 | */ |
Glenn Randers-Pehrson | 28d4aae | 2009-11-13 16:29:45 -0600 | [diff] [blame] | 455 | #ifndef PNG_CONST |
| 456 | # ifndef PNG_NO_CONST |
| 457 | # define PNG_CONST const |
| 458 | # else |
| 459 | # define PNG_CONST |
| 460 | # endif |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 461 | #endif |
| 462 | |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 463 | /* Some typedefs to get us started. These should be safe on most of the |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 464 | * common platforms. The typedefs should be at least as large as the |
| 465 | * numbers suggest (a png_uint_32 must be at least 32 bits long), but they |
| 466 | * don't have to be exactly that size. Some compilers dislike passing |
| 467 | * unsigned shorts as function parameters, so you may be better off using |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 468 | * unsigned int for png_uint_16. |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 469 | */ |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 470 | |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 471 | #if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL) |
| 472 | typedef unsigned int png_uint_32; |
| 473 | typedef int png_int_32; |
| 474 | #else |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 475 | typedef unsigned long png_uint_32; |
| 476 | typedef long png_int_32; |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 477 | #endif |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 478 | typedef unsigned short png_uint_16; |
| 479 | typedef short png_int_16; |
| 480 | typedef unsigned char png_byte; |
| 481 | |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 482 | #ifdef PNG_NO_SIZE_T |
Glenn Randers-Pehrson | 882340c | 2010-03-13 21:19:51 -0600 | [diff] [blame] | 483 | typedef unsigned int png_size_t; |
Glenn Randers-Pehrson | 5fea36f | 2004-07-28 08:20:44 -0500 | [diff] [blame] | 484 | #else |
Glenn Randers-Pehrson | 882340c | 2010-03-13 21:19:51 -0600 | [diff] [blame] | 485 | typedef size_t png_size_t; |
Glenn Randers-Pehrson | 5fea36f | 2004-07-28 08:20:44 -0500 | [diff] [blame] | 486 | #endif |
Glenn Randers-Pehrson | d3a726d | 2010-08-03 20:26:34 -0500 | [diff] [blame^] | 487 | #define png_sizeof(x) (sizeof (x)) |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 488 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 489 | /* The following is needed for medium model support. It cannot be in the |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 490 | * pngpriv.h header. Needs modification for other compilers besides |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 491 | * MSC. Model independent support declares all arrays and pointers to be |
| 492 | * large using the far keyword. The zlib version used must also support |
| 493 | * model independent data. As of version zlib 1.0.4, the necessary changes |
| 494 | * have been made in zlib. The USE_FAR_KEYWORD define triggers other |
| 495 | * changes that are needed. (Tim Wegner) |
| 496 | */ |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 497 | |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 498 | /* Separate compiler dependencies (problem here is that zlib.h always |
Glenn Randers-Pehrson | 6076da8 | 2009-09-30 12:28:07 -0500 | [diff] [blame] | 499 | * defines FAR. (SJT) |
| 500 | */ |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 501 | #ifdef __BORLANDC__ |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 502 | # if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) |
| 503 | # define LDATA 1 |
| 504 | # else |
| 505 | # define LDATA 0 |
| 506 | # endif |
Glenn Randers-Pehrson | 882340c | 2010-03-13 21:19:51 -0600 | [diff] [blame] | 507 | /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 508 | # if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 509 | # define PNG_MAX_MALLOC_64K /* only used in build */ |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 510 | # if (LDATA != 1) |
| 511 | # ifndef FAR |
| 512 | # define FAR __far |
| 513 | # endif |
| 514 | # define USE_FAR_KEYWORD |
| 515 | # endif /* LDATA != 1 */ |
Glenn Randers-Pehrson | c44253f | 2010-03-13 20:58:39 -0600 | [diff] [blame] | 516 | /* Possibly useful for moving data out of default segment. |
| 517 | * Uncomment it if you want. Could also define FARDATA as |
| 518 | * const if your compiler supports it. (SJT) |
Glenn Randers-Pehrson | d4df36c | 2010-03-06 10:45:55 -0600 | [diff] [blame] | 519 | # define FARDATA FAR |
Glenn Randers-Pehrson | c44253f | 2010-03-13 20:58:39 -0600 | [diff] [blame] | 520 | */ |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 521 | # endif /* __WIN32__, __FLAT__, __CYGWIN__ */ |
Guy Schalnat | b2e01bd | 1996-01-26 01:38:47 -0600 | [diff] [blame] | 522 | #endif /* __BORLANDC__ */ |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 523 | |
| 524 | |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 525 | /* Suggest testing for specific compiler first before testing for |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 526 | * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, |
| 527 | * making reliance oncertain keywords suspect. (SJT) |
| 528 | */ |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 529 | |
| 530 | /* MSC Medium model */ |
Glenn Randers-Pehrson | 4e6b5e9 | 2009-09-23 10:24:53 -0500 | [diff] [blame] | 531 | #ifdef FAR |
| 532 | # ifdef M_I86MM |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 533 | # define USE_FAR_KEYWORD |
| 534 | # define FARDATA FAR |
| 535 | # include <dos.h> |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 536 | # endif |
| 537 | #endif |
| 538 | |
| 539 | /* SJT: default case */ |
| 540 | #ifndef FAR |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 541 | # define FAR |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 542 | #endif |
| 543 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 544 | /* At this point FAR is always defined */ |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 545 | #ifndef FARDATA |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 546 | # define FARDATA |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 547 | #endif |
| 548 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 549 | /* Typedef for floating-point numbers that are converted |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 550 | * to fixed-point with a multiple of 100,000, e.g., gamma |
Glenn Randers-Pehrson | e8b1aa0 | 2010-03-06 11:39:29 -0600 | [diff] [blame] | 551 | */ |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 552 | typedef png_int_32 png_fixed_point; |
| 553 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 554 | /* Add typedefs for pointers */ |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 555 | typedef void FAR * png_voidp; |
| 556 | typedef png_byte FAR * png_bytep; |
| 557 | typedef PNG_CONST png_byte FAR * png_const_bytep; |
| 558 | typedef png_uint_32 FAR * png_uint_32p; |
| 559 | typedef png_int_32 FAR * png_int_32p; |
| 560 | typedef png_uint_16 FAR * png_uint_16p; |
| 561 | typedef png_int_16 FAR * png_int_16p; |
| 562 | typedef PNG_CONST char FAR * png_const_charp; |
| 563 | typedef char FAR * png_charp; |
| 564 | typedef png_fixed_point FAR * png_fixed_point_p; |
| 565 | typedef png_size_t FAR * png_size_tp; |
Glenn Randers-Pehrson | be9de0f | 2001-01-22 08:52:16 -0600 | [diff] [blame] | 566 | |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 567 | #ifdef PNG_STDIO_SUPPORTED |
Glenn Randers-Pehrson | 882340c | 2010-03-13 21:19:51 -0600 | [diff] [blame] | 568 | typedef FILE * png_FILE_p; |
Glenn Randers-Pehrson | be9de0f | 2001-01-22 08:52:16 -0600 | [diff] [blame] | 569 | #endif |
| 570 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 571 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 572 | typedef double FAR * png_doublep; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 573 | #endif |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 574 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 575 | /* Pointers to pointers; i.e. arrays */ |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 576 | typedef png_byte FAR * FAR * png_bytepp; |
| 577 | typedef png_uint_32 FAR * FAR * png_uint_32pp; |
| 578 | typedef png_int_32 FAR * FAR * png_int_32pp; |
| 579 | typedef png_uint_16 FAR * FAR * png_uint_16pp; |
| 580 | typedef png_int_16 FAR * FAR * png_int_16pp; |
| 581 | typedef PNG_CONST char FAR * FAR * png_const_charpp; |
| 582 | typedef char FAR * FAR * png_charpp; |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 583 | typedef png_fixed_point FAR * FAR * png_fixed_point_pp; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 584 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 585 | typedef double FAR * FAR * png_doublepp; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 586 | #endif |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 587 | |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 588 | /* Pointers to pointers to pointers; i.e., pointer to array */ |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 589 | typedef char FAR * FAR * FAR * png_charppp; |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 590 | |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 591 | /* png_alloc_size_t is guaranteed to be no smaller than png_size_t, |
| 592 | * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32 |
| 593 | * to png_alloc_size_t are not necessary; in fact, it is recommended |
| 594 | * not to use them at all so that the compiler can complain when something |
| 595 | * turns out to be problematic. |
| 596 | * Casts in the other direction (from png_alloc_size_t to png_size_t or |
| 597 | * png_uint_32) should be explicitly applied; however, we do not expect |
| 598 | * to encounter practical situations that require such conversions. |
| 599 | */ |
Glenn Randers-Pehrson | 1721829 | 2006-04-20 07:20:46 -0500 | [diff] [blame] | 600 | #if defined(__TURBOC__) && !defined(__FLAT__) |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 601 | typedef unsigned long png_alloc_size_t; |
Glenn Randers-Pehrson | 1721829 | 2006-04-20 07:20:46 -0500 | [diff] [blame] | 602 | #else |
| 603 | # if defined(_MSC_VER) && defined(MAXSEG_64K) |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 604 | typedef unsigned long png_alloc_size_t; |
| 605 | # else |
Glenn Randers-Pehrson | d3a726d | 2010-08-03 20:26:34 -0500 | [diff] [blame^] | 606 | /* This is an attempt to detect an old Windows system where (int) is |
| 607 | * actually 16 bits, in that case png_malloc must have an argument with a |
| 608 | * bigger size to accomodate the requirements of the library. |
| 609 | */ |
| 610 | # if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \ |
| 611 | (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL) |
| 612 | typedef DWORD png_alloc_size_t; |
Glenn Randers-Pehrson | 1721829 | 2006-04-20 07:20:46 -0500 | [diff] [blame] | 613 | # else |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 614 | typedef png_size_t png_alloc_size_t; |
Glenn Randers-Pehrson | 1721829 | 2006-04-20 07:20:46 -0500 | [diff] [blame] | 615 | # endif |
| 616 | # endif |
| 617 | #endif |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 618 | |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 619 | #endif /* PNGCONF_H */ |