2 /* pngconf.h - machine configurable file for libpng
4 * libpng version 1.6.7 - November 14, 2013
6 * Copyright (c) 1998-2013 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,
26 #undef PNG_CONSOLE_IO_SUPPORTED
27 #undef PNG_MNG_FEATURES_SUPPORTED
28 #undef PNG_FLOATING_POINT_SUPPORTED
29 #undef PNG_FLOATING_ARITHMETIC_SUPPORTED
30 #undef PNG_PROGRESSIVE_READ_SUPPORTED
31 #undef PNG_STDIO_SUPPORTED
32 #define PNG_NO_MNG_FEATURES
33 #define PNG_NO_FLOATING_POINT_SUPPORTED
34 #define PNG_NO_CONSOLE_IO
36 #define PNG_NO_PROGRESSIVE_READ
37 #undef PNG_WRITE_FLUSH_SUPPORTED
40 /* To do: Do all of this in scripts/pnglibconf.dfa */
41 #ifdef PNG_SAFE_LIMITS_SUPPORTED
42 # ifdef PNG_USER_WIDTH_MAX
43 # undef PNG_USER_WIDTH_MAX
44 # define PNG_USER_WIDTH_MAX 1000000L
46 # ifdef PNG_USER_HEIGHT_MAX
47 # undef PNG_USER_HEIGHT_MAX
48 # define PNG_USER_HEIGHT_MAX 1000000L
50 # ifdef PNG_USER_CHUNK_MALLOC_MAX
51 # undef PNG_USER_CHUNK_MALLOC_MAX
52 # define PNG_USER_CHUNK_MALLOC_MAX 4000000L
54 # ifdef PNG_USER_CHUNK_CACHE_MAX
55 # undef PNG_USER_CHUNK_CACHE_MAX
56 # define PNG_USER_CHUNK_CACHE_MAX 128
60 #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
62 /* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
63 * compiler for correct compilation. The following header files are required by
64 * the standard. If your compiler doesn't provide these header files, or they
65 * do not match the standard, you will need to provide/improve them.
70 /* Library header files. These header files are all defined by ISOC90; libpng
71 * expects conformant implementations, however, an ISOC90 conformant system need
72 * not provide these header files if the functionality cannot be implemented.
73 * In this case it will be necessary to disable the relevant parts of libpng in
74 * the build of pnglibconf.h.
76 * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
77 * include this unnecessary header file.
80 #ifdef PNG_STDIO_SUPPORTED
81 /* Required for the definition of FILE: */
85 #ifdef PNG_SETJMP_SUPPORTED
86 /* Required for the definition of jmp_buf and the declaration of longjmp: */
90 #ifdef PNG_CONVERT_tIME_SUPPORTED
91 /* Required for struct tm: */
95 #endif /* PNG_BUILDING_SYMBOL_TABLE */
97 /* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
98 * PNG_NO_CONST; this is no longer supported except for data declarations which
99 * apparently still cause problems in 2011 on some compilers.
101 #define PNG_CONST const /* backward compatibility only */
103 /* This controls optimization of the reading of 16 and 32 bit values
104 * from PNG files. It can be set on a per-app-file basis - it
105 * just changes whether a macro is used when the function is called.
106 * The library builder sets the default; if read functions are not
107 * built into the library the macro implementation is forced on.
109 #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
110 # define PNG_USE_READ_MACROS
112 #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
113 # if PNG_DEFAULT_READ_MACROS
114 # define PNG_USE_READ_MACROS
118 /* COMPILER SPECIFIC OPTIONS.
120 * These options are provided so that a variety of difficult compilers
121 * can be used. Some are fixed at build time (e.g. PNG_API_RULE
122 * below) but still have compiler specific implementations, others
123 * may be changed on a per-file basis when compiling against libpng.
126 /* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
127 * against legacy (pre ISOC90) compilers that did not understand function
128 * prototypes. It is not required for modern C compilers.
131 # define PNGARG(arglist) arglist
134 /* Function calling conventions.
135 * =============================
136 * Normally it is not necessary to specify to the compiler how to call
137 * a function - it just does it - however on x86 systems derived from
138 * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
139 * and some others) there are multiple ways to call a function and the
140 * default can be changed on the compiler command line. For this reason
141 * libpng specifies the calling convention of every exported function and
142 * every function called via a user supplied function pointer. This is
143 * done in this file by defining the following macros:
145 * PNGAPI Calling convention for exported functions.
146 * PNGCBAPI Calling convention for user provided (callback) functions.
147 * PNGCAPI Calling convention used by the ANSI-C library (required
148 * for longjmp callbacks and sometimes used internally to
149 * specify the calling convention for zlib).
151 * These macros should never be overridden. If it is necessary to
152 * change calling convention in a private build this can be done
153 * by setting PNG_API_RULE (which defaults to 0) to one of the values
154 * below to select the correct 'API' variants.
156 * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
157 * This is correct in every known environment.
158 * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
159 * the 'C' calling convention (from PNGCAPI) for
160 * callbacks (PNGCBAPI). This is no longer required
161 * in any known environment - if it has to be used
162 * please post an explanation of the problem to the
163 * libpng mailing list.
165 * These cases only differ if the operating system does not use the C
166 * calling convention, at present this just means the above cases
167 * (x86 DOS/Windows sytems) and, even then, this does not apply to
168 * Cygwin running on those systems.
170 * Note that the value must be defined in pnglibconf.h so that what
171 * the application uses to call the library matches the conventions
172 * set when building the library.
177 * When building a shared library it is almost always necessary to tell
178 * the compiler which symbols to export. The png.h macro 'PNG_EXPORT'
179 * is used to mark the symbols. On some systems these symbols can be
180 * extracted at link time and need no special processing by the compiler,
181 * on other systems the symbols are flagged by the compiler and just
182 * the declaration requires a special tag applied (unfortunately) in a
183 * compiler dependent way. Some systems can do either.
185 * A small number of older systems also require a symbol from a DLL to
186 * be flagged to the program that calls it. This is a problem because
187 * we do not know in the header file included by application code that
188 * the symbol will come from a shared library, as opposed to a statically
189 * linked one. For this reason the application must tell us by setting
190 * the magic flag PNG_USE_DLL to turn on the special processing before
193 * Four additional macros are used to make this happen:
195 * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
196 * the build or imported if PNG_USE_DLL is set - compiler
197 * and system specific.
199 * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
200 * 'type', compiler specific.
202 * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
203 * make a symbol exported from the DLL. Not used in the
204 * public header files; see pngpriv.h for how it is used
205 * in the libpng build.
207 * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
208 * from a DLL - used to define PNG_IMPEXP when
209 * PNG_USE_DLL is set.
212 /* System specific discovery.
213 * ==========================
214 * This code is used at build time to find PNG_IMPEXP, the API settings
215 * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
216 * import processing is possible. On Windows systems it also sets
217 * compiler-specific macros to the values required to change the calling
218 * conventions of the various functions.
220 #if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
221 defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
222 /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
223 * MinGW on any architecture currently supported by Windows. Also includes
224 * Watcom builds but these need special treatment because they are not
225 * compatible with GCC or Visual C because of different calling conventions.
227 # if PNG_API_RULE == 2
228 /* If this line results in an error, either because __watcall is not
229 * understood or because of a redefine just below you cannot use *this*
230 * build of the library with the compiler you are using. *This* build was
231 * build using Watcom and applications must also be built using Watcom!
233 # define PNGCAPI __watcall
236 # if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
237 # define PNGCAPI __cdecl
238 # if PNG_API_RULE == 1
239 /* If this line results in an error __stdcall is not understood and
240 * PNG_API_RULE should not have been set to '1'.
242 # define PNGAPI __stdcall
245 /* An older compiler, or one not detected (erroneously) above,
246 * if necessary override on the command line to get the correct
247 * variants for the compiler.
250 # define PNGCAPI _cdecl
252 # if PNG_API_RULE == 1 && !defined(PNGAPI)
253 # define PNGAPI _stdcall
255 # endif /* compiler/api */
257 /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
259 # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
260 # error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
263 # if (defined(_MSC_VER) && _MSC_VER < 800) ||\
264 (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
265 /* older Borland and MSC
266 * compilers used '__export' and required this to be after
269 # ifndef PNG_EXPORT_TYPE
270 # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
272 # define PNG_DLL_EXPORT __export
273 # else /* newer compiler */
274 # define PNG_DLL_EXPORT __declspec(dllexport)
275 # ifndef PNG_DLL_IMPORT
276 # define PNG_DLL_IMPORT __declspec(dllimport)
278 # endif /* compiler */
281 # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
282 # define PNGAPI _System
283 # else /* !Windows/x86 && !OS/2 */
284 /* Use the defaults, or define PNG*API on the command line (but
285 * this will have to be done for every compile!)
287 # endif /* other system, !OS/2 */
288 #endif /* !Windows/x86 */
290 /* Now do all the defaulting . */
295 # define PNGCBAPI PNGCAPI
298 # define PNGAPI PNGCAPI
301 /* PNG_IMPEXP may be set on the compilation system command line or (if not set)
302 * then in an internal header file when building the library, otherwise (when
303 * using the library) it is set here.
306 # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
307 /* This forces use of a DLL, disallowing static linking */
308 # define PNG_IMPEXP PNG_DLL_IMPORT
316 /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
317 * 'attributes' as a storage class - the attributes go at the start of the
318 * function definition, and attributes are always appended regardless of the
319 * compiler. This considerably simplifies these macros but may cause problems
320 * if any compilers both need function attributes and fail to handle them as
321 * a storage class (this is unlikely.)
324 # define PNG_FUNCTION(type, name, args, attributes) attributes type name args
327 #ifndef PNG_EXPORT_TYPE
328 # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
331 /* The ordinal value is only relevant when preprocessing png.h for symbol
332 * table entries, so we discard it here. See the .dfn files in the
337 # define PNG_EXPORTA(ordinal, type, name, args, attributes)\
338 PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
342 /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
343 * so make something non-empty to satisfy the requirement:
345 #define PNG_EMPTY /*empty list*/
347 #define PNG_EXPORT(ordinal, type, name, args)\
348 PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
350 /* Use PNG_REMOVED to comment out a removed interface. */
352 # define PNG_REMOVED(ordinal, type, name, args, attributes)
356 # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
359 /* Support for compiler specific function attributes. These are used
360 * so that where compiler support is available incorrect use of API
361 * functions in png.h will generate compiler warnings.
363 * Added at libpng-1.2.41.
366 #ifndef PNG_NO_PEDANTIC_WARNINGS
367 # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
368 # define PNG_PEDANTIC_WARNINGS_SUPPORTED
372 #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
373 /* Support for compiler specific function attributes. These are used
374 * so that where compiler support is available, incorrect use of API
375 * functions in png.h will generate compiler warnings. Added at libpng
376 * version 1.2.41. Disabling these removes the warnings but may also produce
377 * less efficient code.
379 # if defined(__GNUC__)
380 # ifndef PNG_USE_RESULT
381 # define PNG_USE_RESULT __attribute__((__warn_unused_result__))
383 # ifndef PNG_NORETURN
384 # define PNG_NORETURN __attribute__((__noreturn__))
387 # ifndef PNG_ALLOCATED
388 # define PNG_ALLOCATED __attribute__((__malloc__))
390 # ifndef PNG_DEPRECATED
391 # define PNG_DEPRECATED __attribute__((__deprecated__))
394 # if 0 /* Doesn't work so we use deprecated instead*/
395 # define PNG_PRIVATE \
396 __attribute__((warning("This function is not exported by libpng.")))
398 # define PNG_PRIVATE \
399 __attribute__((__deprecated__))
402 # if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
403 # ifndef PNG_RESTRICT
404 # define PNG_RESTRICT __restrict
406 # endif /* __GNUC__ == 3.0 */
407 # endif /* __GNUC__ >= 3 */
409 # elif defined(_MSC_VER) && (_MSC_VER >= 1300)
410 # ifndef PNG_USE_RESULT
411 # define PNG_USE_RESULT /* not supported */
413 # ifndef PNG_NORETURN
414 # define PNG_NORETURN __declspec(noreturn)
416 # ifndef PNG_ALLOCATED
417 # if (_MSC_VER >= 1400)
418 # define PNG_ALLOCATED __declspec(restrict)
421 # ifndef PNG_DEPRECATED
422 # define PNG_DEPRECATED __declspec(deprecated)
425 # define PNG_PRIVATE __declspec(deprecated)
427 # ifndef PNG_RESTRICT
428 # if (_MSC_VER >= 1400)
429 # define PNG_RESTRICT __restrict
433 # elif defined(__WATCOMC__)
434 # ifndef PNG_RESTRICT
435 # define PNG_RESTRICT __restrict
437 # endif /* _MSC_VER */
438 #endif /* PNG_PEDANTIC_WARNINGS */
440 #ifndef PNG_DEPRECATED
441 # define PNG_DEPRECATED /* Use of this function is deprecated */
443 #ifndef PNG_USE_RESULT
444 # define PNG_USE_RESULT /* The result of this function must be checked */
447 # define PNG_NORETURN /* This function does not return */
449 #ifndef PNG_ALLOCATED
450 # define PNG_ALLOCATED /* The result of the function is new memory */
453 # define PNG_PRIVATE /* This is a private libpng function */
456 # define PNG_RESTRICT /* The C99 "restrict" feature */
458 #ifndef PNG_FP_EXPORT /* A floating point API. */
459 # ifdef PNG_FLOATING_POINT_SUPPORTED
460 # define PNG_FP_EXPORT(ordinal, type, name, args)\
461 PNG_EXPORT(ordinal, type, name, args);
462 # else /* No floating point APIs */
463 # define PNG_FP_EXPORT(ordinal, type, name, args)
466 #ifndef PNG_FIXED_EXPORT /* A fixed point API. */
467 # ifdef PNG_FIXED_POINT_SUPPORTED
468 # define PNG_FIXED_EXPORT(ordinal, type, name, args)\
469 PNG_EXPORT(ordinal, type, name, args);
470 # else /* No fixed point APIs */
471 # define PNG_FIXED_EXPORT(ordinal, type, name, args)
475 #ifndef PNG_BUILDING_SYMBOL_TABLE
476 /* Some typedefs to get us started. These should be safe on most of the common
479 * png_uint_32 and png_int_32 may, currently, be larger than required to hold a
480 * 32-bit value however this is not normally advisable.
482 * png_uint_16 and png_int_16 should always be two bytes in size - this is
483 * verified at library build time.
485 * png_byte must always be one byte in size.
487 * The checks below use constants from limits.h, as defined by the ISOC90
490 #if CHAR_BIT == 8 && UCHAR_MAX == 255
491 typedef unsigned char png_byte
;
493 # error "libpng requires 8 bit bytes"
496 #if INT_MIN == -32768 && INT_MAX == 32767
497 typedef int png_int_16
;
498 #elif SHRT_MIN == -32768 && SHRT_MAX == 32767
499 typedef short png_int_16
;
501 # error "libpng requires a signed 16 bit type"
504 #if UINT_MAX == 65535
505 typedef unsigned int png_uint_16
;
506 #elif USHRT_MAX == 65535
507 typedef unsigned short png_uint_16
;
509 # error "libpng requires an unsigned 16 bit type"
512 #if INT_MIN < -2147483646 && INT_MAX > 2147483646
513 typedef int png_int_32
;
514 #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
515 typedef long int png_int_32
;
517 # error "libpng requires a signed 32 bit (or more) type"
520 #if UINT_MAX > 4294967294
521 typedef unsigned int png_uint_32
;
522 #elif ULONG_MAX > 4294967294
523 typedef unsigned long int png_uint_32
;
525 # error "libpng requires an unsigned 32 bit (or more) type"
528 /* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
529 * requires an ISOC90 compiler and relies on consistent behavior of sizeof.
531 typedef size_t png_size_t
;
532 typedef ptrdiff_t png_ptrdiff_t
;
534 /* libpng needs to know the maximum value of 'size_t' and this controls the
535 * definition of png_alloc_size_t, below. This maximum value of size_t limits
536 * but does not control the maximum allocations the library makes - there is
537 * direct application control of this through png_set_user_limits().
539 #ifndef PNG_SMALL_SIZE_T
540 /* Compiler specific tests for systems where size_t is known to be less than
541 * 32 bits (some of these systems may no longer work because of the lack of
542 * 'far' support; see above.)
544 # if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
545 (defined(_MSC_VER) && defined(MAXSEG_64K))
546 # define PNG_SMALL_SIZE_T
550 /* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
551 * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
552 * png_alloc_size_t are not necessary; in fact, it is recommended not to use
553 * them at all so that the compiler can complain when something turns out to be
556 * Casts in the other direction (from png_alloc_size_t to png_size_t or
557 * png_uint_32) should be explicitly applied; however, we do not expect to
558 * encounter practical situations that require such conversions.
560 * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
561 * 4294967295 - i.e. less than the maximum value of png_uint_32.
563 #ifdef PNG_SMALL_SIZE_T
564 typedef png_uint_32 png_alloc_size_t
;
566 typedef png_size_t png_alloc_size_t
;
569 /* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
570 * implementations of Intel CPU specific support of user-mode segmented address
571 * spaces, where 16-bit pointers address more than 65536 bytes of memory using
572 * separate 'segment' registers. The implementation requires two different
573 * types of pointer (only one of which includes the segment value.)
575 * If required this support is available in version 1.2 of libpng and may be
576 * available in versions through 1.5, although the correctness of the code has
577 * not been verified recently.
580 /* Typedef for floating-point numbers that are converted to fixed-point with a
581 * multiple of 100,000, e.g., gamma
583 typedef png_int_32 png_fixed_point
;
585 /* Add typedefs for pointers */
586 typedef void * png_voidp
;
587 typedef const void * png_const_voidp
;
588 typedef png_byte
* png_bytep
;
589 typedef const png_byte
* png_const_bytep
;
590 typedef png_uint_32
* png_uint_32p
;
591 typedef const png_uint_32
* png_const_uint_32p
;
592 typedef png_int_32
* png_int_32p
;
593 typedef const png_int_32
* png_const_int_32p
;
594 typedef png_uint_16
* png_uint_16p
;
595 typedef const png_uint_16
* png_const_uint_16p
;
596 typedef png_int_16
* png_int_16p
;
597 typedef const png_int_16
* png_const_int_16p
;
598 typedef char * png_charp
;
599 typedef const char * png_const_charp
;
600 typedef png_fixed_point
* png_fixed_point_p
;
601 typedef const png_fixed_point
* png_const_fixed_point_p
;
602 typedef png_size_t
* png_size_tp
;
603 typedef const png_size_t
* png_const_size_tp
;
605 #ifdef PNG_STDIO_SUPPORTED
606 typedef FILE * png_FILE_p
;
609 #ifdef PNG_FLOATING_POINT_SUPPORTED
610 typedef double * png_doublep
;
611 typedef const double * png_const_doublep
;
614 /* Pointers to pointers; i.e. arrays */
615 typedef png_byte
* * png_bytepp
;
616 typedef png_uint_32
* * png_uint_32pp
;
617 typedef png_int_32
* * png_int_32pp
;
618 typedef png_uint_16
* * png_uint_16pp
;
619 typedef png_int_16
* * png_int_16pp
;
620 typedef const char * * png_const_charpp
;
621 typedef char * * png_charpp
;
622 typedef png_fixed_point
* * png_fixed_point_pp
;
623 #ifdef PNG_FLOATING_POINT_SUPPORTED
624 typedef double * * png_doublepp
;
627 /* Pointers to pointers to pointers; i.e., pointer to array */
628 typedef char * * * png_charppp
;
630 #endif /* PNG_BUILDING_SYMBOL_TABLE */
632 #endif /* PNGCONF_H */