2 /* pngconf.h - machine configurable file for libpng
\r
4 * libpng version 1.5.7 - December 15, 2011
\r
6 * Copyright (c) 1998-2011 Glenn Randers-Pehrson
\r
7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
\r
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
\r
10 * This code is released under the libpng license.
\r
11 * For conditions of distribution and use, see the disclaimer
\r
12 * and license in png.h
\r
16 /* Any machine specific code is near the front of this file, so if you
\r
17 * are configuring libpng for a machine, you may want to read the section
\r
18 * starting here down to where it starts to typedef png_color, png_text,
\r
25 #ifndef PNG_BUILDING_SYMBOL_TABLE
\r
26 /* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
\r
27 * definition file for machine specific limits, this may impact the
\r
28 * correctness of the definitons below (see uses of INT_MAX).
\r
30 # ifndef PNG_NO_LIMITS_H
\r
31 # include <limits.h>
\r
34 /* For the memory copy APIs (i.e. the standard definitions of these),
\r
35 * because this file defines png_memcpy and so on the base APIs must
\r
39 # include <strings.h>
\r
41 # include <string.h>
\r
44 /* For png_FILE_p - this provides the standard definition of a
\r
47 # ifdef PNG_STDIO_SUPPORTED
\r
52 /* This controls optimization of the reading of 16 and 32 bit values
\r
53 * from PNG files. It can be set on a per-app-file basis - it
\r
54 * just changes whether a macro is used to the function is called.
\r
55 * The library builder sets the default, if read functions are not
\r
56 * built into the library the macro implementation is forced on.
\r
58 #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
\r
59 # define PNG_USE_READ_MACROS
\r
61 #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
\r
62 # if PNG_DEFAULT_READ_MACROS
\r
63 # define PNG_USE_READ_MACROS
\r
67 /* COMPILER SPECIFIC OPTIONS.
\r
69 * These options are provided so that a variety of difficult compilers
\r
70 * can be used. Some are fixed at build time (e.g. PNG_API_RULE
\r
71 * below) but still have compiler specific implementations, others
\r
72 * may be changed on a per-file basis when compiling against libpng.
\r
75 /* The PNGARG macro protects us against machines that don't have function
\r
76 * prototypes (ie K&R style headers). If your compiler does not handle
\r
77 * function prototypes, define this macro and use the included ansi2knr.
\r
78 * I've always been able to use _NO_PROTO as the indicator, but you may
\r
79 * need to drag the empty declaration out in front of here, or change the
\r
80 * ifdef to suit your own needs.
\r
84 # ifdef OF /* zlib prototype munger */
\r
85 # define PNGARG(arglist) OF(arglist)
\r
89 # define PNGARG(arglist) ()
\r
91 # define PNGARG(arglist) arglist
\r
92 # endif /* _NO_PROTO */
\r
98 /* Function calling conventions.
\r
99 * =============================
\r
100 * Normally it is not necessary to specify to the compiler how to call
\r
101 * a function - it just does it - however on x86 systems derived from
\r
102 * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
\r
103 * and some others) there are multiple ways to call a function and the
\r
104 * default can be changed on the compiler command line. For this reason
\r
105 * libpng specifies the calling convention of every exported function and
\r
106 * every function called via a user supplied function pointer. This is
\r
107 * done in this file by defining the following macros:
\r
109 * PNGAPI Calling convention for exported functions.
\r
110 * PNGCBAPI Calling convention for user provided (callback) functions.
\r
111 * PNGCAPI Calling convention used by the ANSI-C library (required
\r
112 * for longjmp callbacks and sometimes used internally to
\r
113 * specify the calling convention for zlib).
\r
115 * These macros should never be overridden. If it is necessary to
\r
116 * change calling convention in a private build this can be done
\r
117 * by setting PNG_API_RULE (which defaults to 0) to one of the values
\r
118 * below to select the correct 'API' variants.
\r
120 * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
\r
121 * This is correct in every known environment.
\r
122 * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
\r
123 * the 'C' calling convention (from PNGCAPI) for
\r
124 * callbacks (PNGCBAPI). This is no longer required
\r
125 * in any known environment - if it has to be used
\r
126 * please post an explanation of the problem to the
\r
127 * libpng mailing list.
\r
129 * These cases only differ if the operating system does not use the C
\r
130 * calling convention, at present this just means the above cases
\r
131 * (x86 DOS/Windows sytems) and, even then, this does not apply to
\r
132 * Cygwin running on those systems.
\r
134 * Note that the value must be defined in pnglibconf.h so that what
\r
135 * the application uses to call the library matches the conventions
\r
136 * set when building the library.
\r
141 * When building a shared library it is almost always necessary to tell
\r
142 * the compiler which symbols to export. The png.h macro 'PNG_EXPORT'
\r
143 * is used to mark the symbols. On some systems these symbols can be
\r
144 * extracted at link time and need no special processing by the compiler,
\r
145 * on other systems the symbols are flagged by the compiler and just
\r
146 * the declaration requires a special tag applied (unfortunately) in a
\r
147 * compiler dependent way. Some systems can do either.
\r
149 * A small number of older systems also require a symbol from a DLL to
\r
150 * be flagged to the program that calls it. This is a problem because
\r
151 * we do not know in the header file included by application code that
\r
152 * the symbol will come from a shared library, as opposed to a statically
\r
153 * linked one. For this reason the application must tell us by setting
\r
154 * the magic flag PNG_USE_DLL to turn on the special processing before
\r
155 * it includes png.h.
\r
157 * Four additional macros are used to make this happen:
\r
159 * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
\r
160 * the build or imported if PNG_USE_DLL is set - compiler
\r
161 * and system specific.
\r
163 * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
\r
164 * 'type', compiler specific.
\r
166 * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
\r
167 * make a symbol exported from the DLL. Not used in the
\r
168 * public header files; see pngpriv.h for how it is used
\r
169 * in the libpng build.
\r
171 * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
\r
172 * from a DLL - used to define PNG_IMPEXP when
\r
173 * PNG_USE_DLL is set.
\r
176 /* System specific discovery.
\r
177 * ==========================
\r
178 * This code is used at build time to find PNG_IMPEXP, the API settings
\r
179 * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
\r
180 * import processing is possible. On Windows/x86 systems it also sets
\r
181 * compiler-specific macros to the values required to change the calling
\r
182 * conventions of the various functions.
\r
184 #if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
\r
185 defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
\r
186 ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
\r
187 defined(_M_X64) || defined(_M_IA64) )
\r
188 /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
\r
189 * builds under Cygwin or MinGW. Also includes Watcom builds but these need
\r
190 * special treatment because they are not compatible with GCC or Visual C
\r
191 * because of different calling conventions.
\r
193 # if PNG_API_RULE == 2
\r
194 /* If this line results in an error, either because __watcall is not
\r
195 * understood or because of a redefine just below you cannot use *this*
\r
196 * build of the library with the compiler you are using. *This* build was
\r
197 * build using Watcom and applications must also be built using Watcom!
\r
199 # define PNGCAPI __watcall
\r
202 # if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
\r
203 # define PNGCAPI __cdecl
\r
204 # if PNG_API_RULE == 1
\r
205 # define PNGAPI __stdcall
\r
208 /* An older compiler, or one not detected (erroneously) above,
\r
209 * if necessary override on the command line to get the correct
\r
210 * variants for the compiler.
\r
213 # define PNGCAPI _cdecl
\r
215 # if PNG_API_RULE == 1 && !defined(PNGAPI)
\r
216 # define PNGAPI _stdcall
\r
218 # endif /* compiler/api */
\r
219 /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
\r
221 # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
\r
222 ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
\r
225 # if (defined(_MSC_VER) && _MSC_VER < 800) ||\
\r
226 (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
\r
227 /* older Borland and MSC
\r
228 * compilers used '__export' and required this to be after
\r
231 # ifndef PNG_EXPORT_TYPE
\r
232 # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
\r
234 # define PNG_DLL_EXPORT __export
\r
235 # else /* newer compiler */
\r
236 # define PNG_DLL_EXPORT __declspec(dllexport)
\r
237 # ifndef PNG_DLL_IMPORT
\r
238 # define PNG_DLL_IMPORT __declspec(dllimport)
\r
240 # endif /* compiler */
\r
242 #else /* !Windows/x86 */
\r
243 # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
\r
244 # define PNGAPI _System
\r
245 # else /* !Windows/x86 && !OS/2 */
\r
246 /* Use the defaults, or define PNG*API on the command line (but
\r
247 * this will have to be done for every compile!)
\r
249 # endif /* other system, !OS/2 */
\r
250 #endif /* !Windows/x86 */
\r
252 /* Now do all the defaulting . */
\r
257 # define PNGCBAPI PNGCAPI
\r
260 # define PNGAPI PNGCAPI
\r
263 /* PNG_IMPEXP may be set on the compilation system command line or (if not set)
\r
264 * then in an internal header file when building the library, otherwise (when
\r
265 * using the library) it is set here.
\r
268 # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
\r
269 /* This forces use of a DLL, disallowing static linking */
\r
270 # define PNG_IMPEXP PNG_DLL_IMPORT
\r
273 # ifndef PNG_IMPEXP
\r
274 # define PNG_IMPEXP
\r
278 /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
\r
279 * 'attributes' as a storage class - the attributes go at the start of the
\r
280 * function definition, and attributes are always appended regardless of the
\r
281 * compiler. This considerably simplifies these macros but may cause problems
\r
282 * if any compilers both need function attributes and fail to handle them as
\r
283 * a storage class (this is unlikely.)
\r
285 #ifndef PNG_FUNCTION
\r
286 # define PNG_FUNCTION(type, name, args, attributes) attributes type name args
\r
289 #ifndef PNG_EXPORT_TYPE
\r
290 # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
\r
293 /* The ordinal value is only relevant when preprocessing png.h for symbol
\r
294 * table entries, so we discard it here. See the .dfn files in the
\r
295 * scripts directory.
\r
297 #ifndef PNG_EXPORTA
\r
299 # define PNG_EXPORTA(ordinal, type, name, args, attributes)\
\r
300 PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
\r
304 /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
\r
305 * so make something non-empty to satisfy the requirement:
\r
307 #define PNG_EMPTY /*empty list*/
\r
309 #define PNG_EXPORT(ordinal, type, name, args)\
\r
310 PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
\r
312 /* Use PNG_REMOVED to comment out a removed interface. */
\r
313 #ifndef PNG_REMOVED
\r
314 # define PNG_REMOVED(ordinal, type, name, args, attributes)
\r
317 #ifndef PNG_CALLBACK
\r
318 # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
\r
321 /* Support for compiler specific function attributes. These are used
\r
322 * so that where compiler support is available incorrect use of API
\r
323 * functions in png.h will generate compiler warnings.
\r
325 * Added at libpng-1.2.41.
\r
328 #ifndef PNG_NO_PEDANTIC_WARNINGS
\r
329 # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
\r
330 # define PNG_PEDANTIC_WARNINGS_SUPPORTED
\r
334 #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
\r
335 /* Support for compiler specific function attributes. These are used
\r
336 * so that where compiler support is available incorrect use of API
\r
337 * functions in png.h will generate compiler warnings. Added at libpng
\r
340 # if defined(__GNUC__)
\r
341 # ifndef PNG_USE_RESULT
\r
342 # define PNG_USE_RESULT __attribute__((__warn_unused_result__))
\r
344 # ifndef PNG_NORETURN
\r
345 # define PNG_NORETURN __attribute__((__noreturn__))
\r
347 # ifndef PNG_ALLOCATED
\r
348 # define PNG_ALLOCATED __attribute__((__malloc__))
\r
350 # ifndef PNG_DEPRECATED
\r
351 # define PNG_DEPRECATED __attribute__((__deprecated__))
\r
353 # ifndef PNG_PRIVATE
\r
354 # if 0 /* Doesn't work so we use deprecated instead*/
\r
355 # define PNG_PRIVATE \
\r
356 __attribute__((warning("This function is not exported by libpng.")))
\r
358 # define PNG_PRIVATE \
\r
359 __attribute__((__deprecated__))
\r
362 # endif /* __GNUC__ */
\r
364 # if defined(_MSC_VER) && (_MSC_VER >= 1300)
\r
365 # ifndef PNG_USE_RESULT
\r
366 # define PNG_USE_RESULT /* not supported */
\r
368 # ifndef PNG_NORETURN
\r
369 # define PNG_NORETURN __declspec(noreturn)
\r
371 # ifndef PNG_ALLOCATED
\r
372 # if (_MSC_VER >= 1400)
\r
373 # define PNG_ALLOCATED __declspec(restrict)
\r
376 # ifndef PNG_DEPRECATED
\r
377 # define PNG_DEPRECATED __declspec(deprecated)
\r
379 # ifndef PNG_PRIVATE
\r
380 # define PNG_PRIVATE __declspec(deprecated)
\r
382 # endif /* _MSC_VER */
\r
383 #endif /* PNG_PEDANTIC_WARNINGS */
\r
385 #ifndef PNG_DEPRECATED
\r
386 # define PNG_DEPRECATED /* Use of this function is deprecated */
\r
388 #ifndef PNG_USE_RESULT
\r
389 # define PNG_USE_RESULT /* The result of this function must be checked */
\r
391 #ifndef PNG_NORETURN
\r
392 # define PNG_NORETURN /* This function does not return */
\r
394 #ifndef PNG_ALLOCATED
\r
395 # define PNG_ALLOCATED /* The result of the function is new memory */
\r
397 #ifndef PNG_PRIVATE
\r
398 # define PNG_PRIVATE /* This is a private libpng function */
\r
400 #ifndef PNG_FP_EXPORT /* A floating point API. */
\r
401 # ifdef PNG_FLOATING_POINT_SUPPORTED
\r
402 # define PNG_FP_EXPORT(ordinal, type, name, args)\
\r
403 PNG_EXPORT(ordinal, type, name, args)
\r
404 # else /* No floating point APIs */
\r
405 # define PNG_FP_EXPORT(ordinal, type, name, args)
\r
408 #ifndef PNG_FIXED_EXPORT /* A fixed point API. */
\r
409 # ifdef PNG_FIXED_POINT_SUPPORTED
\r
410 # define PNG_FIXED_EXPORT(ordinal, type, name, args)\
\r
411 PNG_EXPORT(ordinal, type, name, args)
\r
412 # else /* No fixed point APIs */
\r
413 # define PNG_FIXED_EXPORT(ordinal, type, name, args)
\r
417 /* The following uses const char * instead of char * for error
\r
418 * and warning message functions, so some compilers won't complain.
\r
419 * If you do not want to use const, define PNG_NO_CONST here.
\r
421 * This should not change how the APIs are called, so it can be done
\r
422 * on a per-file basis in the application.
\r
425 # ifndef PNG_NO_CONST
\r
426 # define PNG_CONST const
\r
432 /* Some typedefs to get us started. These should be safe on most of the
\r
433 * common platforms. The typedefs should be at least as large as the
\r
434 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
\r
435 * don't have to be exactly that size. Some compilers dislike passing
\r
436 * unsigned shorts as function parameters, so you may be better off using
\r
437 * unsigned int for png_uint_16.
\r
440 #if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
\r
441 typedef unsigned int png_uint_32;
\r
442 typedef int png_int_32;
\r
444 typedef unsigned long png_uint_32;
\r
445 typedef long png_int_32;
\r
447 typedef unsigned short png_uint_16;
\r
448 typedef short png_int_16;
\r
449 typedef unsigned char png_byte;
\r
451 #ifdef PNG_NO_SIZE_T
\r
452 typedef unsigned int png_size_t;
\r
454 typedef size_t png_size_t;
\r
456 #define png_sizeof(x) (sizeof (x))
\r
458 /* The following is needed for medium model support. It cannot be in the
\r
459 * pngpriv.h header. Needs modification for other compilers besides
\r
460 * MSC. Model independent support declares all arrays and pointers to be
\r
461 * large using the far keyword. The zlib version used must also support
\r
462 * model independent data. As of version zlib 1.0.4, the necessary changes
\r
463 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
\r
464 * changes that are needed. (Tim Wegner)
\r
467 /* Separate compiler dependencies (problem here is that zlib.h always
\r
468 * defines FAR. (SJT)
\r
470 #ifdef __BORLANDC__
\r
471 # if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
\r
476 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
\r
477 # if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
\r
478 # define PNG_MAX_MALLOC_64K /* only used in build */
\r
483 # define USE_FAR_KEYWORD
\r
484 # endif /* LDATA != 1 */
\r
485 /* Possibly useful for moving data out of default segment.
\r
486 * Uncomment it if you want. Could also define FARDATA as
\r
487 * const if your compiler supports it. (SJT)
\r
488 # define FARDATA FAR
\r
490 # endif /* __WIN32__, __FLAT__, __CYGWIN__ */
\r
491 #endif /* __BORLANDC__ */
\r
494 /* Suggest testing for specific compiler first before testing for
\r
495 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
\r
496 * making reliance oncertain keywords suspect. (SJT)
\r
499 /* MSC Medium model */
\r
502 # define USE_FAR_KEYWORD
\r
503 # define FARDATA FAR
\r
508 /* SJT: default case */
\r
513 /* At this point FAR is always defined */
\r
518 /* Typedef for floating-point numbers that are converted
\r
519 * to fixed-point with a multiple of 100,000, e.g., gamma
\r
521 typedef png_int_32 png_fixed_point;
\r
523 /* Add typedefs for pointers */
\r
524 typedef void FAR * png_voidp;
\r
525 typedef PNG_CONST void FAR * png_const_voidp;
\r
526 typedef png_byte FAR * png_bytep;
\r
527 typedef PNG_CONST png_byte FAR * png_const_bytep;
\r
528 typedef png_uint_32 FAR * png_uint_32p;
\r
529 typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p;
\r
530 typedef png_int_32 FAR * png_int_32p;
\r
531 typedef PNG_CONST png_int_32 FAR * png_const_int_32p;
\r
532 typedef png_uint_16 FAR * png_uint_16p;
\r
533 typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p;
\r
534 typedef png_int_16 FAR * png_int_16p;
\r
535 typedef PNG_CONST png_int_16 FAR * png_const_int_16p;
\r
536 typedef char FAR * png_charp;
\r
537 typedef PNG_CONST char FAR * png_const_charp;
\r
538 typedef png_fixed_point FAR * png_fixed_point_p;
\r
539 typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;
\r
540 typedef png_size_t FAR * png_size_tp;
\r
541 typedef PNG_CONST png_size_t FAR * png_const_size_tp;
\r
543 #ifdef PNG_STDIO_SUPPORTED
\r
544 typedef FILE * png_FILE_p;
\r
547 #ifdef PNG_FLOATING_POINT_SUPPORTED
\r
548 typedef double FAR * png_doublep;
\r
549 typedef PNG_CONST double FAR * png_const_doublep;
\r
552 /* Pointers to pointers; i.e. arrays */
\r
553 typedef png_byte FAR * FAR * png_bytepp;
\r
554 typedef png_uint_32 FAR * FAR * png_uint_32pp;
\r
555 typedef png_int_32 FAR * FAR * png_int_32pp;
\r
556 typedef png_uint_16 FAR * FAR * png_uint_16pp;
\r
557 typedef png_int_16 FAR * FAR * png_int_16pp;
\r
558 typedef PNG_CONST char FAR * FAR * png_const_charpp;
\r
559 typedef char FAR * FAR * png_charpp;
\r
560 typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
\r
561 #ifdef PNG_FLOATING_POINT_SUPPORTED
\r
562 typedef double FAR * FAR * png_doublepp;
\r
565 /* Pointers to pointers to pointers; i.e., pointer to array */
\r
566 typedef char FAR * FAR * FAR * png_charppp;
\r
568 /* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
\r
569 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
\r
570 * to png_alloc_size_t are not necessary; in fact, it is recommended
\r
571 * not to use them at all so that the compiler can complain when something
\r
572 * turns out to be problematic.
\r
573 * Casts in the other direction (from png_alloc_size_t to png_size_t or
\r
574 * png_uint_32) should be explicitly applied; however, we do not expect
\r
575 * to encounter practical situations that require such conversions.
\r
577 #if defined(__TURBOC__) && !defined(__FLAT__)
\r
578 typedef unsigned long png_alloc_size_t;
\r
580 # if defined(_MSC_VER) && defined(MAXSEG_64K)
\r
581 typedef unsigned long png_alloc_size_t;
\r
583 /* This is an attempt to detect an old Windows system where (int) is
\r
584 * actually 16 bits, in that case png_malloc must have an argument with a
\r
585 * bigger size to accomodate the requirements of the library.
\r
587 # if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
\r
588 (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
\r
589 typedef DWORD png_alloc_size_t;
\r
591 typedef png_size_t png_alloc_size_t;
\r
596 #endif /* PNGCONF_H */
\r