2 /* pngconf.h - machine configurable file for libpng
4 * libpng version 1.5.6 - November 3, 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,
26 #define PNG_NO_SNPRINTF
29 #ifndef PNG_BUILDING_SYMBOL_TABLE
30 /* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
31 * definition file for machine specific limits, this may impact the
32 * correctness of the definitons below (see uses of INT_MAX).
34 # ifndef PNG_NO_LIMITS_H
38 /* For the memory copy APIs (i.e. the standard definitions of these),
39 * because this file defines png_memcpy and so on the base APIs must
48 /* For png_FILE_p - this provides the standard definition of a
51 # ifdef PNG_STDIO_SUPPORTED
56 /* This controls optimization of the reading of 16 and 32 bit values
57 * from PNG files. It can be set on a per-app-file basis - it
58 * just changes whether a macro is used to the function is called.
59 * The library builder sets the default, if read functions are not
60 * built into the library the macro implementation is forced on.
62 #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
63 # define PNG_USE_READ_MACROS
65 #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
66 # if PNG_DEFAULT_READ_MACROS
67 # define PNG_USE_READ_MACROS
71 /* COMPILER SPECIFIC OPTIONS.
73 * These options are provided so that a variety of difficult compilers
74 * can be used. Some are fixed at build time (e.g. PNG_API_RULE
75 * below) but still have compiler specific implementations, others
76 * may be changed on a per-file basis when compiling against libpng.
79 /* The PNGARG macro protects us against machines that don't have function
80 * prototypes (ie K&R style headers). If your compiler does not handle
81 * function prototypes, define this macro and use the included ansi2knr.
82 * I've always been able to use _NO_PROTO as the indicator, but you may
83 * need to drag the empty declaration out in front of here, or change the
84 * ifdef to suit your own needs.
88 # ifdef OF /* zlib prototype munger */
89 # define PNGARG(arglist) OF(arglist)
93 # define PNGARG(arglist) ()
95 # define PNGARG(arglist) arglist
96 # endif /* _NO_PROTO */
102 /* Function calling conventions.
103 * =============================
104 * Normally it is not necessary to specify to the compiler how to call
105 * a function - it just does it - however on x86 systems derived from
106 * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
107 * and some others) there are multiple ways to call a function and the
108 * default can be changed on the compiler command line. For this reason
109 * libpng specifies the calling convention of every exported function and
110 * every function called via a user supplied function pointer. This is
111 * done in this file by defining the following macros:
113 * PNGAPI Calling convention for exported functions.
114 * PNGCBAPI Calling convention for user provided (callback) functions.
115 * PNGCAPI Calling convention used by the ANSI-C library (required
116 * for longjmp callbacks and sometimes used internally to
117 * specify the calling convention for zlib).
119 * These macros should never be overridden. If it is necessary to
120 * change calling convention in a private build this can be done
121 * by setting PNG_API_RULE (which defaults to 0) to one of the values
122 * below to select the correct 'API' variants.
124 * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
125 * This is correct in every known environment.
126 * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
127 * the 'C' calling convention (from PNGCAPI) for
128 * callbacks (PNGCBAPI). This is no longer required
129 * in any known environment - if it has to be used
130 * please post an explanation of the problem to the
131 * libpng mailing list.
133 * These cases only differ if the operating system does not use the C
134 * calling convention, at present this just means the above cases
135 * (x86 DOS/Windows sytems) and, even then, this does not apply to
136 * Cygwin running on those systems.
138 * Note that the value must be defined in pnglibconf.h so that what
139 * the application uses to call the library matches the conventions
140 * set when building the library.
145 * When building a shared library it is almost always necessary to tell
146 * the compiler which symbols to export. The png.h macro 'PNG_EXPORT'
147 * is used to mark the symbols. On some systems these symbols can be
148 * extracted at link time and need no special processing by the compiler,
149 * on other systems the symbols are flagged by the compiler and just
150 * the declaration requires a special tag applied (unfortunately) in a
151 * compiler dependent way. Some systems can do either.
153 * A small number of older systems also require a symbol from a DLL to
154 * be flagged to the program that calls it. This is a problem because
155 * we do not know in the header file included by application code that
156 * the symbol will come from a shared library, as opposed to a statically
157 * linked one. For this reason the application must tell us by setting
158 * the magic flag PNG_USE_DLL to turn on the special processing before
161 * Four additional macros are used to make this happen:
163 * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
164 * the build or imported if PNG_USE_DLL is set - compiler
165 * and system specific.
167 * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
168 * 'type', compiler specific.
170 * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
171 * make a symbol exported from the DLL. Not used in the
172 * public header files; see pngpriv.h for how it is used
173 * in the libpng build.
175 * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
176 * from a DLL - used to define PNG_IMPEXP when
177 * PNG_USE_DLL is set.
180 /* System specific discovery.
181 * ==========================
182 * This code is used at build time to find PNG_IMPEXP, the API settings
183 * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
184 * import processing is possible. On Windows/x86 systems it also sets
185 * compiler-specific macros to the values required to change the calling
186 * conventions of the various functions.
188 #if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
189 defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
190 ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
191 defined(_M_X64) || defined(_M_IA64) )
192 /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
193 * builds under Cygwin or MinGW. Also includes Watcom builds but these need
194 * special treatment because they are not compatible with GCC or Visual C
195 * because of different calling conventions.
197 # if PNG_API_RULE == 2
198 /* If this line results in an error, either because __watcall is not
199 * understood or because of a redefine just below you cannot use *this*
200 * build of the library with the compiler you are using. *This* build was
201 * build using Watcom and applications must also be built using Watcom!
203 # define PNGCAPI __watcall
206 # if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
207 # define PNGCAPI __cdecl
208 # if PNG_API_RULE == 1
209 # define PNGAPI __stdcall
212 /* An older compiler, or one not detected (erroneously) above,
213 * if necessary override on the command line to get the correct
214 * variants for the compiler.
217 # define PNGCAPI _cdecl
219 # if PNG_API_RULE == 1 && !defined(PNGAPI)
220 # define PNGAPI _stdcall
222 # endif /* compiler/api */
223 /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
225 # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
226 ERROR
: PNG_USER_PRIVATEBUILD must be defined
if PNGAPI is changed
229 # if (defined(_MSC_VER) && _MSC_VER < 800) ||\
230 (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
231 /* older Borland and MSC
232 * compilers used '__export' and required this to be after
235 # ifndef PNG_EXPORT_TYPE
236 # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
238 # define PNG_DLL_EXPORT __export
239 # else /* newer compiler */
240 # define PNG_DLL_EXPORT __declspec(dllexport)
241 # ifndef PNG_DLL_IMPORT
242 # define PNG_DLL_IMPORT __declspec(dllimport)
244 # endif /* compiler */
246 #else /* !Windows/x86 */
247 # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
248 # define PNGAPI _System
249 # else /* !Windows/x86 && !OS/2 */
250 /* Use the defaults, or define PNG*API on the command line (but
251 * this will have to be done for every compile!)
253 # endif /* other system, !OS/2 */
254 #endif /* !Windows/x86 */
256 /* Now do all the defaulting . */
261 # define PNGCBAPI PNGCAPI
264 # define PNGAPI PNGCAPI
267 /* PNG_IMPEXP may be set on the compilation system command line or (if not set)
268 * then in an internal header file when building the library, otherwise (when
269 * using the library) it is set here.
272 # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
273 /* This forces use of a DLL, disallowing static linking */
274 # define PNG_IMPEXP PNG_DLL_IMPORT
282 /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
283 * 'attributes' as a storage class - the attributes go at the start of the
284 * function definition, and attributes are always appended regardless of the
285 * compiler. This considerably simplifies these macros but may cause problems
286 * if any compilers both need function attributes and fail to handle them as
287 * a storage class (this is unlikely.)
290 # define PNG_FUNCTION(type, name, args, attributes) attributes type name args
293 #ifndef PNG_EXPORT_TYPE
294 # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
297 /* The ordinal value is only relevant when preprocessing png.h for symbol
298 * table entries, so we discard it here. See the .dfn files in the
303 # define PNG_EXPORTA(ordinal, type, name, args, attributes)\
304 PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
308 /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
309 * so make something non-empty to satisfy the requirement:
311 #define PNG_EMPTY /*empty list*/
313 #define PNG_EXPORT(ordinal, type, name, args)\
314 PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
316 /* Use PNG_REMOVED to comment out a removed interface. */
318 # define PNG_REMOVED(ordinal, type, name, args, attributes)
322 # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
325 /* Support for compiler specific function attributes. These are used
326 * so that where compiler support is available incorrect use of API
327 * functions in png.h will generate compiler warnings.
329 * Added at libpng-1.2.41.
332 #ifndef PNG_NO_PEDANTIC_WARNINGS
333 # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
334 # define PNG_PEDANTIC_WARNINGS_SUPPORTED
338 #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
339 /* Support for compiler specific function attributes. These are used
340 * so that where compiler support is available incorrect use of API
341 * functions in png.h will generate compiler warnings. Added at libpng
344 # if defined(__GNUC__)
345 # ifndef PNG_USE_RESULT
346 # define PNG_USE_RESULT __attribute__((__warn_unused_result__))
348 # ifndef PNG_NORETURN
349 # define PNG_NORETURN __attribute__((__noreturn__))
351 # ifndef PNG_ALLOCATED
352 # define PNG_ALLOCATED __attribute__((__malloc__))
354 # ifndef PNG_DEPRECATED
355 # define PNG_DEPRECATED __attribute__((__deprecated__))
358 # if 0 /* Doesn't work so we use deprecated instead*/
359 # define PNG_PRIVATE \
360 __attribute__((warning("This function is not exported by libpng.")))
362 # define PNG_PRIVATE \
363 __attribute__((__deprecated__))
366 # endif /* __GNUC__ */
368 # if defined(_MSC_VER) && (_MSC_VER >= 1300)
369 # ifndef PNG_USE_RESULT
370 # define PNG_USE_RESULT /* not supported */
372 # ifndef PNG_NORETURN
373 # define PNG_NORETURN __declspec(noreturn)
375 # ifndef PNG_ALLOCATED
376 # if defined(_MSC_VER) && (_MSC_VER >= 1400)
377 # define PNG_ALLOCATED __declspec(restrict)
380 # ifndef PNG_DEPRECATED
381 # define PNG_DEPRECATED __declspec(deprecated)
384 # define PNG_PRIVATE __declspec(deprecated)
386 # endif /* _MSC_VER */
387 #endif /* PNG_PEDANTIC_WARNINGS */
389 #ifndef PNG_DEPRECATED
390 # define PNG_DEPRECATED /* Use of this function is deprecated */
392 #ifndef PNG_USE_RESULT
393 # define PNG_USE_RESULT /* The result of this function must be checked */
396 # define PNG_NORETURN /* This function does not return */
398 #ifndef PNG_ALLOCATED
399 # define PNG_ALLOCATED /* The result of the function is new memory */
402 # define PNG_PRIVATE /* This is a private libpng function */
404 #ifndef PNG_FP_EXPORT /* A floating point API. */
405 # ifdef PNG_FLOATING_POINT_SUPPORTED
406 # define PNG_FP_EXPORT(ordinal, type, name, args)\
407 PNG_EXPORT(ordinal, type, name, args)
408 # else /* No floating point APIs */
409 # define PNG_FP_EXPORT(ordinal, type, name, args)
412 #ifndef PNG_FIXED_EXPORT /* A fixed point API. */
413 # ifdef PNG_FIXED_POINT_SUPPORTED
414 # define PNG_FIXED_EXPORT(ordinal, type, name, args)\
415 PNG_EXPORT(ordinal, type, name, args)
416 # else /* No fixed point APIs */
417 # define PNG_FIXED_EXPORT(ordinal, type, name, args)
421 /* The following uses const char * instead of char * for error
422 * and warning message functions, so some compilers won't complain.
423 * If you do not want to use const, define PNG_NO_CONST here.
425 * This should not change how the APIs are called, so it can be done
426 * on a per-file basis in the application.
429 # ifndef PNG_NO_CONST
430 # define PNG_CONST const
436 /* Some typedefs to get us started. These should be safe on most of the
437 * common platforms. The typedefs should be at least as large as the
438 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
439 * don't have to be exactly that size. Some compilers dislike passing
440 * unsigned shorts as function parameters, so you may be better off using
441 * unsigned int for png_uint_16.
444 #if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
445 typedef unsigned int png_uint_32
;
446 typedef int png_int_32
;
448 typedef unsigned long png_uint_32
;
449 typedef long png_int_32
;
451 typedef unsigned short png_uint_16
;
452 typedef short png_int_16
;
453 typedef unsigned char png_byte
;
456 typedef unsigned int png_size_t
;
458 typedef size_t png_size_t
;
460 #define png_sizeof(x) (sizeof (x))
462 /* The following is needed for medium model support. It cannot be in the
463 * pngpriv.h header. Needs modification for other compilers besides
464 * MSC. Model independent support declares all arrays and pointers to be
465 * large using the far keyword. The zlib version used must also support
466 * model independent data. As of version zlib 1.0.4, the necessary changes
467 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
468 * changes that are needed. (Tim Wegner)
471 /* Separate compiler dependencies (problem here is that zlib.h always
475 # if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
480 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
481 # if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
482 # define PNG_MAX_MALLOC_64K /* only used in build */
487 # define USE_FAR_KEYWORD
488 # endif /* LDATA != 1 */
489 /* Possibly useful for moving data out of default segment.
490 * Uncomment it if you want. Could also define FARDATA as
491 * const if your compiler supports it. (SJT)
494 # endif /* __WIN32__, __FLAT__, __CYGWIN__ */
495 #endif /* __BORLANDC__ */
498 /* Suggest testing for specific compiler first before testing for
499 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
500 * making reliance oncertain keywords suspect. (SJT)
503 /* MSC Medium model */
506 # define USE_FAR_KEYWORD
512 /* SJT: default case */
517 /* At this point FAR is always defined */
522 /* Typedef for floating-point numbers that are converted
523 * to fixed-point with a multiple of 100,000, e.g., gamma
525 typedef png_int_32 png_fixed_point
;
527 /* Add typedefs for pointers */
528 typedef void FAR
* png_voidp
;
529 typedef PNG_CONST
void FAR
* png_const_voidp
;
530 typedef png_byte FAR
* png_bytep
;
531 typedef PNG_CONST png_byte FAR
* png_const_bytep
;
532 typedef png_uint_32 FAR
* png_uint_32p
;
533 typedef PNG_CONST png_uint_32 FAR
* png_const_uint_32p
;
534 typedef png_int_32 FAR
* png_int_32p
;
535 typedef PNG_CONST png_int_32 FAR
* png_const_int_32p
;
536 typedef png_uint_16 FAR
* png_uint_16p
;
537 typedef PNG_CONST png_uint_16 FAR
* png_const_uint_16p
;
538 typedef png_int_16 FAR
* png_int_16p
;
539 typedef PNG_CONST png_int_16 FAR
* png_const_int_16p
;
540 typedef char FAR
* png_charp
;
541 typedef PNG_CONST
char FAR
* png_const_charp
;
542 typedef png_fixed_point FAR
* png_fixed_point_p
;
543 typedef PNG_CONST png_fixed_point FAR
* png_const_fixed_point_p
;
544 typedef png_size_t FAR
* png_size_tp
;
545 typedef PNG_CONST png_size_t FAR
* png_const_size_tp
;
547 #ifdef PNG_STDIO_SUPPORTED
548 typedef FILE * png_FILE_p
;
551 #ifdef PNG_FLOATING_POINT_SUPPORTED
552 typedef double FAR
* png_doublep
;
553 typedef PNG_CONST
double FAR
* png_const_doublep
;
556 /* Pointers to pointers; i.e. arrays */
557 typedef png_byte FAR
* FAR
* png_bytepp
;
558 typedef png_uint_32 FAR
* FAR
* png_uint_32pp
;
559 typedef png_int_32 FAR
* FAR
* png_int_32pp
;
560 typedef png_uint_16 FAR
* FAR
* png_uint_16pp
;
561 typedef png_int_16 FAR
* FAR
* png_int_16pp
;
562 typedef PNG_CONST
char FAR
* FAR
* png_const_charpp
;
563 typedef char FAR
* FAR
* png_charpp
;
564 typedef png_fixed_point FAR
* FAR
* png_fixed_point_pp
;
565 #ifdef PNG_FLOATING_POINT_SUPPORTED
566 typedef double FAR
* FAR
* png_doublepp
;
569 /* Pointers to pointers to pointers; i.e., pointer to array */
570 typedef char FAR
* FAR
* FAR
* png_charppp
;
572 /* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
573 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
574 * to png_alloc_size_t are not necessary; in fact, it is recommended
575 * not to use them at all so that the compiler can complain when something
576 * turns out to be problematic.
577 * Casts in the other direction (from png_alloc_size_t to png_size_t or
578 * png_uint_32) should be explicitly applied; however, we do not expect
579 * to encounter practical situations that require such conversions.
581 #if defined(__TURBOC__) && !defined(__FLAT__)
582 typedef unsigned long png_alloc_size_t
;
584 # if defined(_MSC_VER) && defined(MAXSEG_64K)
585 typedef unsigned long png_alloc_size_t
;
587 /* This is an attempt to detect an old Windows system where (int) is
588 * actually 16 bits, in that case png_malloc must have an argument with a
589 * bigger size to accomodate the requirements of the library.
591 # if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
592 (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
593 typedef DWORD png_alloc_size_t
;
595 typedef png_size_t png_alloc_size_t
;
600 #endif /* PNGCONF_H */