2 /* pngconf.h - machine configurable file for libpng
4 * libpng version 1.5.2 - March 31, 2011
6 * Copyright (c) 1998-2011 Glenn Randers-Pehrson
7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
10 * This code is released under the libpng license.
11 * For conditions of distribution and use, see the disclaimer
12 * and license in png.h
16 /* Any machine specific code is near the front of this file, so if you
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,
25 #ifndef PNG_BUILDING_SYMBOL_TABLE
26 /* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
27 * definition file for machine specific limits, this may impact the
28 * correctness of the definitons below (see uses of INT_MAX).
30 # ifndef PNG_NO_LIMITS_H
34 /* For the memory copy APIs (i.e. the standard definitions of these),
35 * because this file defines png_memcpy and so on the base APIs must
44 /* For png_FILE_p - this provides the standard definition of a
47 # ifdef PNG_STDIO_SUPPORTED
52 /* This controls optimization of the reading of 16 and 32 bit values
53 * from PNG files. It can be set on a per-app-file basis - it
54 * just changes whether a macro is used to the function is called.
55 * The library builder sets the default, if read functions are not
56 * built into the library the macro implementation is forced on.
58 #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
59 # define PNG_USE_READ_MACROS
61 #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
62 # if PNG_DEFAULT_READ_MACROS
63 # define PNG_USE_READ_MACROS
67 /* COMPILER SPECIFIC OPTIONS.
69 * These options are provided so that a variety of difficult compilers
70 * can be used. Some are fixed at build time (e.g. PNG_API_RULE
71 * below) but still have compiler specific implementations, others
72 * may be changed on a per-file basis when compiling against libpng.
75 /* The PNGARG macro protects us against machines that don't have function
76 * prototypes (ie K&R style headers). If your compiler does not handle
77 * function prototypes, define this macro and use the included ansi2knr.
78 * I've always been able to use _NO_PROTO as the indicator, but you may
79 * need to drag the empty declaration out in front of here, or change the
80 * ifdef to suit your own needs.
84 # ifdef OF /* zlib prototype munger */
85 # define PNGARG(arglist) OF(arglist)
89 # define PNGARG(arglist) ()
91 # define PNGARG(arglist) arglist
92 # endif /* _NO_PROTO */
98 /* Function calling conventions.
99 * =============================
100 * Normally it is not necessary to specify to the compiler how to call
101 * a function - it just does it - however on x86 systems derived from
102 * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
103 * and some others) there are multiple ways to call a function and the
104 * default can be changed on the compiler command line. For this reason
105 * libpng specifies the calling convention of every exported function and
106 * every function called via a user supplied function pointer. This is
107 * done in this file by defining the following macros:
109 * PNGAPI Calling convention for exported functions.
110 * PNGCBAPI Calling convention for user provided (callback) functions.
111 * PNGCAPI Calling convention used by the ANSI-C library (required
112 * for longjmp callbacks and sometimes used internally to
113 * specify the calling convention for zlib).
115 * These macros should never be overridden. If it is necessary to
116 * change calling convention in a private build this can be done
117 * by setting PNG_API_RULE (which defaults to 0) to one of the values
118 * below to select the correct 'API' variants.
120 * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
121 * This is correct in every known environment.
122 * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
123 * the 'C' calling convention (from PNGCAPI) for
124 * callbacks (PNGCBAPI). This is no longer required
125 * in any known environment - if it has to be used
126 * please post an explanation of the problem to the
127 * libpng mailing list.
129 * These cases only differ if the operating system does not use the C
130 * calling convention, at present this just means the above cases
131 * (x86 DOS/Windows sytems) and, even then, this does not apply to
132 * Cygwin running on those systems.
134 * Note that the value must be defined in pnglibconf.h so that what
135 * the application uses to call the library matches the conventions
136 * set when building the library.
141 * When building a shared library it is almost always necessary to tell
142 * the compiler which symbols to export. The png.h macro 'PNG_EXPORT'
143 * is used to mark the symbols. On some systems these symbols can be
144 * extracted at link time and need no special processing by the compiler,
145 * on other systems the symbols are flagged by the compiler and just
146 * the declaration requires a special tag applied (unfortunately) in a
147 * compiler dependent way. Some systems can do either.
149 * A small number of older systems also require a symbol from a DLL to
150 * be flagged to the program that calls it. This is a problem because
151 * we do not know in the header file included by application code that
152 * the symbol will come from a shared library, as opposed to a statically
153 * linked one. For this reason the application must tell us by setting
154 * the magic flag PNG_USE_DLL to turn on the special processing before
157 * Four additional macros are used to make this happen:
159 * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
160 * the build or imported if PNG_USE_DLL is set - compiler
161 * and system specific.
163 * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
164 * 'type', compiler specific.
166 * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
167 * make a symbol exported from the DLL.
169 * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
170 * from a DLL - used to define PNG_IMPEXP when
171 * PNG_USE_DLL is set.
174 /* System specific discovery.
175 * ==========================
176 * This code is used at build time to find PNG_IMPEXP, the API settings
177 * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
178 * import processing is possible. On Windows/x86 systems it also sets
179 * compiler-specific macros to the values required to change the calling
180 * conventions of the various functions.
182 #if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
183 defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
184 ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
185 defined(_M_X64) || defined(_M_IA64) )
186 /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
187 * builds under Cygwin or MinGW. Also includes Watcom builds but these need
188 * special treatment because they are not compatible with GCC or Visual C
189 * because of different calling conventions.
191 # if PNG_API_RULE == 2
192 /* If this line results in an error, either because __watcall is not
193 * understood or because of a redefine just below you cannot use *this*
194 * build of the library with the compiler you are using. *This* build was
195 * build using Watcom and applications must also be built using Watcom!
197 # define PNGCAPI __watcall
200 # if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
201 # define PNGCAPI __cdecl
202 # if PNG_API_RULE == 1
203 # define PNGAPI __stdcall
206 /* An older compiler, or one not detected (erroneously) above,
207 * if necessary override on the command line to get the correct
208 * variants for the compiler.
211 # define PNGCAPI _cdecl
213 # if PNG_API_RULE == 1 && !defined(PNGAPI)
214 # define PNGAPI _stdcall
216 # endif /* compiler/api */
217 /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
219 # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
220 ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
223 # if (defined(_MSC_VER) && _MSC_VER < 800) ||\
224 (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
225 /* older Borland and MSC
226 * compilers used '__export' and required this to be after
229 # ifndef PNG_EXPORT_TYPE
230 # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
232 # define PNG_DLL_EXPORT __export
233 # else /* newer compiler */
234 # define PNG_DLL_EXPORT __declspec(dllexport)
235 # ifndef PNG_DLL_IMPORT
236 # define PNG_DLL_IMPORT __declspec(dllimport)
238 # endif /* compiler */
240 #else /* !Windows/x86 */
241 # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
242 # define PNGAPI _System
243 # else /* !Windows/x86 && !OS/2 */
244 /* Use the defaults, or define PNG*API on the command line (but
245 * this will have to be done for every compile!)
247 # endif /* other system, !OS/2 */
248 #endif /* !Windows/x86 */
250 /* Now do all the defaulting . */
255 # define PNGCBAPI PNGCAPI
258 # define PNGAPI PNGCAPI
261 /* The default for PNG_IMPEXP depends on whether the library is
262 * being built or used.
266 /* Building the library */
267 # if (defined(DLL_EXPORT)/*from libtool*/ ||\
268 defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\
270 defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT)
271 /* Building a DLL. */
272 # define PNG_IMPEXP PNG_DLL_EXPORT
275 /* Using the library */
276 # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
277 /* This forces use of a DLL, disallowing static linking */
278 # define PNG_IMPEXP PNG_DLL_IMPORT
287 /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
288 * 'attributes' as a storage class - the attributes go at the start of the
289 * function definition, and attributes are always appended regardless of the
290 * compiler. This considerably simplifies these macros but may cause problems
291 * if any compilers both need function attributes and fail to handle them as
292 * a storage class (this is unlikely.)
295 # define PNG_FUNCTION(type, name, args, attributes) attributes type name args
298 #ifndef PNG_EXPORT_TYPE
299 # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
302 /* The ordinal value is only relevant when preprocessing png.h for symbol
303 * table entries, so we discard it here. See the .dfn files in the
308 # define PNG_EXPORTA(ordinal, type, name, args, attributes)\
309 PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
313 /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
314 * so make something non-empty to satisfy the requirement:
316 #define PNG_EMPTY /*empty list*/
318 #define PNG_EXPORT(ordinal, type, name, args)\
319 PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
321 /* Use PNG_REMOVED to comment out a removed interface. */
323 # define PNG_REMOVED(ordinal, type, name, args, attributes)
327 # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
330 /* Support for compiler specific function attributes. These are used
331 * so that where compiler support is available incorrect use of API
332 * functions in png.h will generate compiler warnings.
334 * Added at libpng-1.2.41.
337 #ifndef PNG_NO_PEDANTIC_WARNINGS
338 # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
339 # define PNG_PEDANTIC_WARNINGS_SUPPORTED
343 #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
344 /* Support for compiler specific function attributes. These are used
345 * so that where compiler support is available incorrect use of API
346 * functions in png.h will generate compiler warnings. Added at libpng
349 # if defined(__GNUC__)
350 # ifndef PNG_USE_RESULT
351 # define PNG_USE_RESULT __attribute__((__warn_unused_result__))
353 # ifndef PNG_NORETURN
354 # define PNG_NORETURN __attribute__((__noreturn__))
356 # ifndef PNG_PTR_NORETURN
357 /* It's not enough to have the compiler be the correct compiler at
358 * this point - it's necessary for the library (which defines
359 * the type of the library longjmp) to also be the GNU library.
360 * This is because many systems use the GNU compiler with a
361 * non-GNU libc implementation. Min/GW headers are also compatible
362 * with GCC as well as uclibc, so it seems best to exclude known
363 * problem libcs here rather than just including known libcs.
365 * NOTE: this relies on the only use of PNG_PTR_NORETURN being with
366 * the system longjmp. If the same type is used elsewhere then this
367 * will need to be changed.
369 # if !defined(__CYGWIN__)
370 # define PNG_PTR_NORETURN __attribute__((__noreturn__))
373 # ifndef PNG_ALLOCATED
374 # define PNG_ALLOCATED __attribute__((__malloc__))
377 /* This specifically protects structure members that should only be
378 * accessed from within the library, therefore should be empty during
381 # ifndef PNGLIB_BUILD
382 # ifndef PNG_DEPRECATED
383 # define PNG_DEPRECATED __attribute__((__deprecated__))
385 # ifndef PNG_DEPSTRUCT
386 # define PNG_DEPSTRUCT __attribute__((__deprecated__))
389 # if 0 /* Doesn't work so we use deprecated instead*/
390 # define PNG_PRIVATE \
391 __attribute__((warning("This function is not exported by libpng.")))
393 # define PNG_PRIVATE \
394 __attribute__((__deprecated__))
397 # endif /* PNGLIB_BUILD */
398 # endif /* __GNUC__ */
400 # if defined(_MSC_VER) && (_MSC_VER >= 1300)
401 # ifndef PNG_USE_RESULT
402 # define PNG_USE_RESULT /* not supported */
404 # ifndef PNG_NORETURN
405 # define PNG_NORETURN __declspec(noreturn)
407 # ifndef PNG_PTR_NORETURN
408 # define PNG_PTR_NORETURN /* not supported */
410 # ifndef PNG_ALLOCATED
411 # define PNG_ALLOCATED __declspec(restrict)
414 /* This specifically protects structure members that should only be
415 * accessed from within the library, therefore should be empty during
418 # ifndef PNGLIB_BUILD
419 # ifndef PNG_DEPRECATED
420 # define PNG_DEPRECATED __declspec(deprecated)
422 # ifndef PNG_DEPSTRUCT
423 # define PNG_DEPSTRUCT __declspec(deprecated)
426 # define PNG_PRIVATE __declspec(deprecated)
428 # endif /* PNGLIB_BUILD */
429 # endif /* _MSC_VER */
430 #endif /* PNG_PEDANTIC_WARNINGS */
432 #ifndef PNG_DEPRECATED
433 # define PNG_DEPRECATED /* Use of this function is deprecated */
435 #ifndef PNG_USE_RESULT
436 # define PNG_USE_RESULT /* The result of this function must be checked */
439 # define PNG_NORETURN /* This function does not return */
441 #ifndef PNG_PTR_NORETURN
442 # define PNG_PTR_NORETURN /* This function does not return */
444 #ifndef PNG_ALLOCATED
445 # define PNG_ALLOCATED /* The result of the function is new memory */
447 #ifndef PNG_DEPSTRUCT
448 # define PNG_DEPSTRUCT /* Access to this struct member is deprecated */
451 # define PNG_PRIVATE /* This is a private libpng function */
453 #ifndef PNG_FP_EXPORT /* A floating point API. */
454 # ifdef PNG_FLOATING_POINT_SUPPORTED
455 # define PNG_FP_EXPORT(ordinal, type, name, args)\
456 PNG_EXPORT(ordinal, type, name, args)
457 # else /* No floating point APIs */
458 # define PNG_FP_EXPORT(ordinal, type, name, args)
461 #ifndef PNG_FIXED_EXPORT /* A fixed point API. */
462 # ifdef PNG_FIXED_POINT_SUPPORTED
463 # define PNG_FIXED_EXPORT(ordinal, type, name, args)\
464 PNG_EXPORT(ordinal, type, name, args)
465 # else /* No fixed point APIs */
466 # define PNG_FIXED_EXPORT(ordinal, type, name, args)
470 /* The following uses const char * instead of char * for error
471 * and warning message functions, so some compilers won't complain.
472 * If you do not want to use const, define PNG_NO_CONST here.
474 * This should not change how the APIs are called, so it can be done
475 * on a per-file basis in the application.
478 # ifndef PNG_NO_CONST
479 # define PNG_CONST const
485 /* Some typedefs to get us started. These should be safe on most of the
486 * common platforms. The typedefs should be at least as large as the
487 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
488 * don't have to be exactly that size. Some compilers dislike passing
489 * unsigned shorts as function parameters, so you may be better off using
490 * unsigned int for png_uint_16.
493 #if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
494 typedef unsigned int png_uint_32;
495 typedef int png_int_32;
497 typedef unsigned long png_uint_32;
498 typedef long png_int_32;
500 typedef unsigned short png_uint_16;
501 typedef short png_int_16;
502 typedef unsigned char png_byte;
505 typedef unsigned int png_size_t;
507 typedef size_t png_size_t;
509 #define png_sizeof(x) (sizeof (x))
511 /* The following is needed for medium model support. It cannot be in the
512 * pngpriv.h header. Needs modification for other compilers besides
513 * MSC. Model independent support declares all arrays and pointers to be
514 * large using the far keyword. The zlib version used must also support
515 * model independent data. As of version zlib 1.0.4, the necessary changes
516 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
517 * changes that are needed. (Tim Wegner)
520 /* Separate compiler dependencies (problem here is that zlib.h always
524 # if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
529 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
530 # if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
531 # define PNG_MAX_MALLOC_64K /* only used in build */
536 # define USE_FAR_KEYWORD
537 # endif /* LDATA != 1 */
538 /* Possibly useful for moving data out of default segment.
539 * Uncomment it if you want. Could also define FARDATA as
540 * const if your compiler supports it. (SJT)
543 # endif /* __WIN32__, __FLAT__, __CYGWIN__ */
544 #endif /* __BORLANDC__ */
547 /* Suggest testing for specific compiler first before testing for
548 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
549 * making reliance oncertain keywords suspect. (SJT)
552 /* MSC Medium model */
555 # define USE_FAR_KEYWORD
561 /* SJT: default case */
566 /* At this point FAR is always defined */
571 /* Typedef for floating-point numbers that are converted
572 * to fixed-point with a multiple of 100,000, e.g., gamma
574 typedef png_int_32 png_fixed_point;
576 /* Add typedefs for pointers */
577 typedef void FAR * png_voidp;
578 typedef PNG_CONST void FAR * png_const_voidp;
579 typedef png_byte FAR * png_bytep;
580 typedef PNG_CONST png_byte FAR * png_const_bytep;
581 typedef png_uint_32 FAR * png_uint_32p;
582 typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p;
583 typedef png_int_32 FAR * png_int_32p;
584 typedef PNG_CONST png_int_32 FAR * png_const_int_32p;
585 typedef png_uint_16 FAR * png_uint_16p;
586 typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p;
587 typedef png_int_16 FAR * png_int_16p;
588 typedef PNG_CONST png_int_16 FAR * png_const_int_16p;
589 typedef char FAR * png_charp;
590 typedef PNG_CONST char FAR * png_const_charp;
591 typedef png_fixed_point FAR * png_fixed_point_p;
592 typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;
593 typedef png_size_t FAR * png_size_tp;
594 typedef PNG_CONST png_size_t FAR * png_const_size_tp;
596 #ifdef PNG_STDIO_SUPPORTED
597 typedef FILE * png_FILE_p;
600 #ifdef PNG_FLOATING_POINT_SUPPORTED
601 typedef double FAR * png_doublep;
602 typedef PNG_CONST double FAR * png_const_doublep;
605 /* Pointers to pointers; i.e. arrays */
606 typedef png_byte FAR * FAR * png_bytepp;
607 typedef png_uint_32 FAR * FAR * png_uint_32pp;
608 typedef png_int_32 FAR * FAR * png_int_32pp;
609 typedef png_uint_16 FAR * FAR * png_uint_16pp;
610 typedef png_int_16 FAR * FAR * png_int_16pp;
611 typedef PNG_CONST char FAR * FAR * png_const_charpp;
612 typedef char FAR * FAR * png_charpp;
613 typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
614 #ifdef PNG_FLOATING_POINT_SUPPORTED
615 typedef double FAR * FAR * png_doublepp;
618 /* Pointers to pointers to pointers; i.e., pointer to array */
619 typedef char FAR * FAR * FAR * png_charppp;
621 /* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
622 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
623 * to png_alloc_size_t are not necessary; in fact, it is recommended
624 * not to use them at all so that the compiler can complain when something
625 * turns out to be problematic.
626 * Casts in the other direction (from png_alloc_size_t to png_size_t or
627 * png_uint_32) should be explicitly applied; however, we do not expect
628 * to encounter practical situations that require such conversions.
630 #if defined(__TURBOC__) && !defined(__FLAT__)
631 typedef unsigned long png_alloc_size_t;
633 # if defined(_MSC_VER) && defined(MAXSEG_64K)
634 typedef unsigned long png_alloc_size_t;
636 /* This is an attempt to detect an old Windows system where (int) is
637 * actually 16 bits, in that case png_malloc must have an argument with a
638 * bigger size to accomodate the requirements of the library.
640 # if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
641 (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
642 typedef DWORD png_alloc_size_t;
644 typedef png_size_t png_alloc_size_t;
649 #endif /* PNGCONF_H */