blob: 89390bd09b06bb59331e445cadf3438b2bcabccc [file] [log] [blame]
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002/* pngconf.h - machine configurable file for libpng
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06003 *
Glenn Randers-Pehrson432c1742012-08-09 20:14:48 -05004 * libpng version 1.6.0beta27 - August 10, 2012
Glenn Randers-Pehrsonc17c9572010-03-08 21:26:48 -06005 *
Glenn Randers-Pehrson1531bd62012-01-01 14:45:04 -06006 * Copyright (c) 1998-2012 Glenn Randers-Pehrson
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05007 * (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-Pehrson3e61d792009-06-24 09:31:28 -05009 *
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -050010 * This code is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -050011 * For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -050012 * and license in png.h
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -050013 *
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060014 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050015
16/* Any machine specific code is near the front of this file, so if you
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060017 * 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 Schalnat51f0eb41995-09-26 05:22:39 -050021
22#ifndef PNGCONF_H
23#define PNGCONF_H
24
Glenn Randers-Pehrson4690b892012-02-24 11:43:31 -060025/* To do: Do all of this in scripts/pnglibconf.dfa */
26#ifdef PNG_SAFE_LIMITS_SUPPORTED
27# ifdef PNG_USER_WIDTH_MAX
28# undef PNG_USER_WIDTH_MAX
29# define PNG_USER_WIDTH_MAX 1000000L
30# endif
31# ifdef PNG_USER_HEIGHT_MAX
32# undef PNG_USER_HEIGHT_MAX
33# define PNG_USER_HEIGHT_MAX 1000000L
34# endif
35# ifdef PNG_USER_CHUNK_MALLOC_MAX
36# undef PNG_USER_CHUNK_MALLOC_MAX
37# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
38# endif
39# ifdef PNG_USER_CHUNK_CACHE_MAX
40# undef PNG_USER_CHUNK_CACHE_MAX
41# define PNG_USER_CHUNK_CACHE_MAX 128
42# endif
43#endif
44
John Bowlerbaeb6d12011-11-26 18:21:02 -060045#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050046
John Bowlerbaeb6d12011-11-26 18:21:02 -060047/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
48 * compiler for correct compilation. The following header files are required by
49 * the standard. If your compiler doesn't provide these header files, or they
50 * do not match the standard, you will need to provide/improve them.
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -050051 */
John Bowlerbaeb6d12011-11-26 18:21:02 -060052#include <limits.h>
53#include <stddef.h>
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -050054
Glenn Randers-Pehrson4c7e8202011-11-26 19:00:01 -060055/* Library header files. These header files are all defined by ISOC90; libpng
56 * expects conformant implementations, however, an ISOC90 conformant system need
John Bowlerbaeb6d12011-11-26 18:21:02 -060057 * not provide these header files if the functionality cannot be implemented.
58 * In this case it will be necessary to disable the relevant parts of libpng in
59 * the build of pnglibconf.h.
60 *
61 * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
62 * include this unnecessary header file.
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -050063 */
John Bowlerbaeb6d12011-11-26 18:21:02 -060064
65#ifdef PNG_STDIO_SUPPORTED
66 /* Required for the definition of FILE: */
67# include <stdio.h>
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -050068#endif
69
John Bowlerbaeb6d12011-11-26 18:21:02 -060070#ifdef PNG_SETJMP_SUPPORTED
71 /* Required for the definition of jmp_buf and the declaration of longjmp: */
72# include <setjmp.h>
73#endif
74
75#ifdef PNG_CONVERT_tIME_SUPPORTED
76 /* Required for struct tm: */
77# include <time.h>
78#endif
79
80#endif /* PNG_BUILDING_SYMBOL_TABLE */
81
82/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
83 * PNG_NO_CONST; this is no longer supported except for data declarations which
84 * apparently still cause problems in 2011 on some compilers.
85 */
86#define PNG_CONST const /* backward compatibility only */
87
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050088/* This controls optimization of the reading of 16 and 32 bit values
89 * from PNG files. It can be set on a per-app-file basis - it
Glenn Randers-Pehrsonbf7661f2012-03-09 21:55:02 -060090 * just changes whether a macro is used when the function is called.
91 * The library builder sets the default; if read functions are not
Glenn Randers-Pehrsonc3d73f42010-04-24 09:18:57 -050092 * built into the library the macro implementation is forced on.
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050093 */
Glenn Randers-Pehrsonc3d73f42010-04-24 09:18:57 -050094#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
95# define PNG_USE_READ_MACROS
96#endif
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050097#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
98# if PNG_DEFAULT_READ_MACROS
99# define PNG_USE_READ_MACROS
100# endif
101#endif
102
Glenn Randers-Pehrson8fc36042010-04-17 10:17:46 -0500103/* COMPILER SPECIFIC OPTIONS.
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -0500104 *
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500105 * These options are provided so that a variety of difficult compilers
106 * can be used. Some are fixed at build time (e.g. PNG_API_RULE
107 * below) but still have compiler specific implementations, others
108 * may be changed on a per-file basis when compiling against libpng.
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -0500109 */
Glenn Randers-Pehrsona4517252010-12-06 08:54:55 -0600110
John Bowlerbaeb6d12011-11-26 18:21:02 -0600111/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
112 * against legacy (pre ISOC90) compilers that did not understand function
113 * prototypes. It is not required for modern C compilers.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500114 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600115#ifndef PNGARG
John Bowlerbaeb6d12011-11-26 18:21:02 -0600116# define PNGARG(arglist) arglist
117#endif
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600118
119/* Function calling conventions.
120 * =============================
121 * Normally it is not necessary to specify to the compiler how to call
122 * a function - it just does it - however on x86 systems derived from
123 * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
124 * and some others) there are multiple ways to call a function and the
125 * default can be changed on the compiler command line. For this reason
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500126 * libpng specifies the calling convention of every exported function and
127 * every function called via a user supplied function pointer. This is
128 * done in this file by defining the following macros:
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600129 *
130 * PNGAPI Calling convention for exported functions.
131 * PNGCBAPI Calling convention for user provided (callback) functions.
132 * PNGCAPI Calling convention used by the ANSI-C library (required
133 * for longjmp callbacks and sometimes used internally to
134 * specify the calling convention for zlib).
135 *
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500136 * These macros should never be overridden. If it is necessary to
137 * change calling convention in a private build this can be done
138 * by setting PNG_API_RULE (which defaults to 0) to one of the values
139 * below to select the correct 'API' variants.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600140 *
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500141 * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
142 * This is correct in every known environment.
143 * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600144 * the 'C' calling convention (from PNGCAPI) for
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500145 * callbacks (PNGCBAPI). This is no longer required
146 * in any known environment - if it has to be used
147 * please post an explanation of the problem to the
148 * libpng mailing list.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600149 *
150 * These cases only differ if the operating system does not use the C
151 * calling convention, at present this just means the above cases
152 * (x86 DOS/Windows sytems) and, even then, this does not apply to
153 * Cygwin running on those systems.
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500154 *
Glenn Randers-Pehrson98b4f002010-04-16 22:30:26 -0500155 * Note that the value must be defined in pnglibconf.h so that what
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500156 * the application uses to call the library matches the conventions
157 * set when building the library.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600158 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600159
160/* Symbol export
161 * =============
162 * When building a shared library it is almost always necessary to tell
163 * the compiler which symbols to export. The png.h macro 'PNG_EXPORT'
164 * is used to mark the symbols. On some systems these symbols can be
165 * extracted at link time and need no special processing by the compiler,
166 * on other systems the symbols are flagged by the compiler and just
167 * the declaration requires a special tag applied (unfortunately) in a
168 * compiler dependent way. Some systems can do either.
169 *
170 * A small number of older systems also require a symbol from a DLL to
171 * be flagged to the program that calls it. This is a problem because
172 * we do not know in the header file included by application code that
173 * the symbol will come from a shared library, as opposed to a statically
174 * linked one. For this reason the application must tell us by setting
175 * the magic flag PNG_USE_DLL to turn on the special processing before
176 * it includes png.h.
Glenn Randers-Pehrson821b7102010-06-24 16:16:32 -0500177 *
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500178 * Four additional macros are used to make this happen:
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600179 *
180 * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
181 * the build or imported if PNG_USE_DLL is set - compiler
182 * and system specific.
183 *
184 * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
185 * 'type', compiler specific.
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500186 *
187 * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
John Bowler7b979652011-08-16 22:36:43 -0500188 * make a symbol exported from the DLL. Not used in the
189 * public header files; see pngpriv.h for how it is used
190 * in the libpng build.
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500191 *
192 * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
193 * from a DLL - used to define PNG_IMPEXP when
194 * PNG_USE_DLL is set.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600195 */
196
197/* System specific discovery.
198 * ==========================
199 * This code is used at build time to find PNG_IMPEXP, the API settings
200 * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500201 * import processing is possible. On Windows/x86 systems it also sets
202 * compiler-specific macros to the values required to change the calling
203 * conventions of the various functions.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600204 */
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500205#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
206 defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
207 ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
208 defined(_M_X64) || defined(_M_IA64) )
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500209 /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
210 * builds under Cygwin or MinGW. Also includes Watcom builds but these need
211 * special treatment because they are not compatible with GCC or Visual C
212 * because of different calling conventions.
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500213 */
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500214# if PNG_API_RULE == 2
215 /* If this line results in an error, either because __watcall is not
216 * understood or because of a redefine just below you cannot use *this*
217 * build of the library with the compiler you are using. *This* build was
218 * build using Watcom and applications must also be built using Watcom!
219 */
220# define PNGCAPI __watcall
221# endif
222
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500223# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
224# define PNGCAPI __cdecl
225# if PNG_API_RULE == 1
226# define PNGAPI __stdcall
227# endif
228# else
229 /* An older compiler, or one not detected (erroneously) above,
230 * if necessary override on the command line to get the correct
231 * variants for the compiler.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600232 */
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500233# ifndef PNGCAPI
234# define PNGCAPI _cdecl
235# endif
236# if PNG_API_RULE == 1 && !defined(PNGAPI)
237# define PNGAPI _stdcall
238# endif
239# endif /* compiler/api */
240 /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600241
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500242# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
John Bowlerbaeb6d12011-11-26 18:21:02 -0600243# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500244# endif
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600245
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500246# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
247 (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
248 /* older Borland and MSC
249 * compilers used '__export' and required this to be after
250 * the type.
251 */
252# ifndef PNG_EXPORT_TYPE
253# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
254# endif
255# define PNG_DLL_EXPORT __export
256# else /* newer compiler */
257# define PNG_DLL_EXPORT __declspec(dllexport)
258# ifndef PNG_DLL_IMPORT
259# define PNG_DLL_IMPORT __declspec(dllimport)
260# endif
261# endif /* compiler */
262
263#else /* !Windows/x86 */
264# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
265# define PNGAPI _System
266# else /* !Windows/x86 && !OS/2 */
267 /* Use the defaults, or define PNG*API on the command line (but
268 * this will have to be done for every compile!)
269 */
270# endif /* other system, !OS/2 */
271#endif /* !Windows/x86 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600272
273/* Now do all the defaulting . */
274#ifndef PNGCAPI
275# define PNGCAPI
276#endif
277#ifndef PNGCBAPI
278# define PNGCBAPI PNGCAPI
279#endif
280#ifndef PNGAPI
281# define PNGAPI PNGCAPI
282#endif
283
John Bowler7b979652011-08-16 22:36:43 -0500284/* PNG_IMPEXP may be set on the compilation system command line or (if not set)
285 * then in an internal header file when building the library, otherwise (when
286 * using the library) it is set here.
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500287 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600288#ifndef PNG_IMPEXP
John Bowler7b979652011-08-16 22:36:43 -0500289# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
290 /* This forces use of a DLL, disallowing static linking */
291# define PNG_IMPEXP PNG_DLL_IMPORT
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500292# endif
293
294# ifndef PNG_IMPEXP
295# define PNG_IMPEXP
296# endif
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600297#endif
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500298
John Bowler9c693602011-02-12 08:58:21 -0600299/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
300 * 'attributes' as a storage class - the attributes go at the start of the
301 * function definition, and attributes are always appended regardless of the
302 * compiler. This considerably simplifies these macros but may cause problems
303 * if any compilers both need function attributes and fail to handle them as
304 * a storage class (this is unlikely.)
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500305 */
306#ifndef PNG_FUNCTION
John Bowler9c693602011-02-12 08:58:21 -0600307# define PNG_FUNCTION(type, name, args, attributes) attributes type name args
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500308#endif
309
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600310#ifndef PNG_EXPORT_TYPE
311# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
312#endif
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500313
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500314 /* The ordinal value is only relevant when preprocessing png.h for symbol
Glenn Randers-Pehrsona4517252010-12-06 08:54:55 -0600315 * table entries, so we discard it here. See the .dfn files in the
316 * scripts directory.
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500317 */
Glenn Randers-Pehrson23d39702010-12-06 18:28:02 -0600318#ifndef PNG_EXPORTA
Glenn Randers-Pehrsond32a6712011-03-06 16:49:10 -0600319
Glenn Randers-Pehrson23d39702010-12-06 18:28:02 -0600320# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
Glenn Randers-Pehrsond32a6712011-03-06 16:49:10 -0600321 PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
322 extern attributes)
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600323#endif
324
John Bowler9c693602011-02-12 08:58:21 -0600325/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
326 * so make something non-empty to satisfy the requirement:
327 */
328#define PNG_EMPTY /*empty list*/
329
Glenn Randers-Pehrson234e5432010-12-06 20:18:51 -0600330#define PNG_EXPORT(ordinal, type, name, args)\
John Bowler9c693602011-02-12 08:58:21 -0600331 PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
Glenn Randers-Pehrson234e5432010-12-06 20:18:51 -0600332
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600333/* Use PNG_REMOVED to comment out a removed interface. */
334#ifndef PNG_REMOVED
Glenn Randers-Pehrson23d39702010-12-06 18:28:02 -0600335# define PNG_REMOVED(ordinal, type, name, args, attributes)
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600336#endif
337
338#ifndef PNG_CALLBACK
John Bowler9c693602011-02-12 08:58:21 -0600339# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600340#endif
341
342/* Support for compiler specific function attributes. These are used
343 * so that where compiler support is available incorrect use of API
344 * functions in png.h will generate compiler warnings.
345 *
346 * Added at libpng-1.2.41.
347 */
348
349#ifndef PNG_NO_PEDANTIC_WARNINGS
Glenn Randers-Pehrsonc44253f2010-03-13 20:58:39 -0600350# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
351# define PNG_PEDANTIC_WARNINGS_SUPPORTED
352# endif
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600353#endif
354
355#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
Glenn Randers-Pehrson882340c2010-03-13 21:19:51 -0600356 /* Support for compiler specific function attributes. These are used
John Bowler5d567862011-12-24 09:12:00 -0600357 * so that where compiler support is available, incorrect use of API
Glenn Randers-Pehrson882340c2010-03-13 21:19:51 -0600358 * functions in png.h will generate compiler warnings. Added at libpng
John Bowler5d567862011-12-24 09:12:00 -0600359 * version 1.2.41. Disabling these removes the warnings but may also produce
360 * less efficient code.
Glenn Randers-Pehrson882340c2010-03-13 21:19:51 -0600361 */
Glenn Randers-Pehrsonc83d4212011-02-12 08:54:42 -0600362# if defined(__GNUC__)
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600363# ifndef PNG_USE_RESULT
364# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
365# endif
366# ifndef PNG_NORETURN
367# define PNG_NORETURN __attribute__((__noreturn__))
368# endif
Glenn Randers-Pehrson0a9f26e2012-07-21 11:16:17 -0500369# if __GNUC__ >= 3
370# ifndef PNG_ALLOCATED
371# define PNG_ALLOCATED __attribute__((__malloc__))
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600372# endif
Glenn Randers-Pehrson0a9f26e2012-07-21 11:16:17 -0500373# ifndef PNG_DEPRECATED
374# define PNG_DEPRECATED __attribute__((__deprecated__))
375# endif
376# ifndef PNG_PRIVATE
377# if 0 /* Doesn't work so we use deprecated instead*/
378# define PNG_PRIVATE \
379 __attribute__((warning("This function is not exported by libpng.")))
380# else
381# define PNG_PRIVATE \
382 __attribute__((__deprecated__))
383# endif
384# endif
Glenn Randers-Pehrson449db5a2012-07-21 13:18:42 -0500385# if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
Glenn Randers-Pehrson0a9f26e2012-07-21 11:16:17 -0500386# ifndef PNG_RESTRICT
387# define PNG_RESTRICT __restrict
388# endif
389# endif /* __GNUC__ == 3.0 */
390# endif /* __GNUC__ >= 3 */
Glenn Randers-Pehrsond32a6712011-03-06 16:49:10 -0600391
John Bowler5d567862011-12-24 09:12:00 -0600392# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500393# ifndef PNG_USE_RESULT
Glenn Randers-Pehrsonc36bb792011-02-12 09:49:07 -0600394# define PNG_USE_RESULT /* not supported */
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500395# endif
396# ifndef PNG_NORETURN
397# define PNG_NORETURN __declspec(noreturn)
398# endif
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500399# ifndef PNG_ALLOCATED
Glenn Randers-Pehrson1f0eaa02011-12-01 21:45:34 -0600400# if (_MSC_VER >= 1400)
Glenn Randers-Pehrson4fca2552011-06-27 12:01:01 -0500401# define PNG_ALLOCATED __declspec(restrict)
402# endif
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500403# endif
John Bowler7b979652011-08-16 22:36:43 -0500404# ifndef PNG_DEPRECATED
405# define PNG_DEPRECATED __declspec(deprecated)
406# endif
407# ifndef PNG_PRIVATE
408# define PNG_PRIVATE __declspec(deprecated)
409# endif
John Bowler5d567862011-12-24 09:12:00 -0600410# ifndef PNG_RESTRICT
411# if (_MSC_VER >= 1400)
412# define PNG_RESTRICT __restrict
413# endif
414# endif
415
416# elif defined(__WATCOMC__)
417# ifndef PNG_RESTRICT
418# define PNG_RESTRICT __restrict
419# endif
John Bowler9c693602011-02-12 08:58:21 -0600420# endif /* _MSC_VER */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600421#endif /* PNG_PEDANTIC_WARNINGS */
422
423#ifndef PNG_DEPRECATED
424# define PNG_DEPRECATED /* Use of this function is deprecated */
425#endif
426#ifndef PNG_USE_RESULT
427# define PNG_USE_RESULT /* The result of this function must be checked */
428#endif
429#ifndef PNG_NORETURN
430# define PNG_NORETURN /* This function does not return */
431#endif
432#ifndef PNG_ALLOCATED
433# define PNG_ALLOCATED /* The result of the function is new memory */
434#endif
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600435#ifndef PNG_PRIVATE
436# define PNG_PRIVATE /* This is a private libpng function */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500437#endif
Glenn Randers-Pehrson80b67e42012-07-21 12:56:46 -0500438#ifndef PNG_RESTRICT
439# define PNG_RESTRICT /* The C99 "restrict" feature */
440#endif
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500441#ifndef PNG_FP_EXPORT /* A floating point API. */
442# ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson23d39702010-12-06 18:28:02 -0600443# define PNG_FP_EXPORT(ordinal, type, name, args)\
John Bowlerbce79882012-02-13 11:45:22 -0600444 PNG_EXPORT(ordinal, type, name, args);
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500445# else /* No floating point APIs */
Glenn Randers-Pehrson23d39702010-12-06 18:28:02 -0600446# define PNG_FP_EXPORT(ordinal, type, name, args)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500447# endif
448#endif
449#ifndef PNG_FIXED_EXPORT /* A fixed point API. */
450# ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson23d39702010-12-06 18:28:02 -0600451# define PNG_FIXED_EXPORT(ordinal, type, name, args)\
John Bowlerbce79882012-02-13 11:45:22 -0600452 PNG_EXPORT(ordinal, type, name, args);
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500453# else /* No fixed point APIs */
Glenn Randers-Pehrson23d39702010-12-06 18:28:02 -0600454# define PNG_FIXED_EXPORT(ordinal, type, name, args)
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500455# endif
456#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500457
John Bowlerbaeb6d12011-11-26 18:21:02 -0600458#ifndef PNG_BUILDING_SYMBOL_TABLE
459/* Some typedefs to get us started. These should be safe on most of the common
460 * platforms.
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500461 *
John Bowlerbaeb6d12011-11-26 18:21:02 -0600462 * png_uint_32 and png_int_32 may, currently, be larger than required to hold a
463 * 32-bit value however this is not normally advisable.
464 *
465 * png_uint_16 and png_int_16 should always be two bytes in size - this is
466 * verified at library build time.
467 *
468 * png_byte must always be one byte in size.
469 *
470 * The checks below use constants from limits.h, as defined by the ISOC90
471 * standard.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600472 */
John Bowlerbaeb6d12011-11-26 18:21:02 -0600473#if CHAR_BIT == 8 && UCHAR_MAX == 255
474 typedef unsigned char png_byte;
475#else
476# error "libpng requires 8 bit bytes"
477#endif
478
479#if INT_MIN == -32768 && INT_MAX == 32767
480 typedef int png_int_16;
481#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
482 typedef short png_int_16;
483#else
484# error "libpng requires a signed 16 bit type"
485#endif
486
487#if UINT_MAX == 65535
488 typedef unsigned int png_uint_16;
489#elif USHRT_MAX == 65535
490 typedef unsigned short png_uint_16;
491#else
492# error "libpng requires an unsigned 16 bit type"
493#endif
494
John Bowler6f237b62012-03-02 13:13:15 -0600495#if INT_MIN < -2147483646 && INT_MAX > 2147483646
John Bowlerbaeb6d12011-11-26 18:21:02 -0600496 typedef int png_int_32;
John Bowler6f237b62012-03-02 13:13:15 -0600497#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
John Bowlerbaeb6d12011-11-26 18:21:02 -0600498 typedef long int png_int_32;
499#else
500# error "libpng requires a signed 32 bit (or more) type"
501#endif
502
503#if UINT_MAX > 4294967294
504 typedef unsigned int png_uint_32;
505#elif ULONG_MAX > 4294967294
506 typedef unsigned long int png_uint_32;
507#else
508# error "libpng requires an unsigned 32 bit (or more) type"
509#endif
510
511/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
512 * requires an ISOC90 compiler and relies on consistent behavior of sizeof.
513 */
514typedef size_t png_size_t;
515typedef ptrdiff_t png_ptrdiff_t;
516
517/* libpng needs to know the maximum value of 'size_t' and this controls the
518 * definition of png_alloc_size_t, below. This maximum value of size_t limits
519 * but does not control the maximum allocations the library makes - there is
520 * direct application control of this through png_set_user_limits().
521 */
522#ifndef PNG_SMALL_SIZE_T
523 /* Compiler specific tests for systems where size_t is known to be less than
524 * 32 bits (some of these systems may no longer work because of the lack of
525 * 'far' support; see above.)
526 */
527# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
528 (defined(_MSC_VER) && defined(MAXSEG_64K))
529# define PNG_SMALL_SIZE_T
Glenn Randers-Pehrson28d4aae2009-11-13 16:29:45 -0600530# endif
Guy Schalnat6d764711995-12-19 03:22:19 -0600531#endif
532
John Bowlerbaeb6d12011-11-26 18:21:02 -0600533/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
534 * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
535 * png_alloc_size_t are not necessary; in fact, it is recommended not to use
536 * them at all so that the compiler can complain when something turns out to be
537 * problematic.
538 *
539 * Casts in the other direction (from png_alloc_size_t to png_size_t or
540 * png_uint_32) should be explicitly applied; however, we do not expect to
541 * encounter practical situations that require such conversions.
542 *
John Bowler6f237b62012-03-02 13:13:15 -0600543 * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
John Bowlerbaeb6d12011-11-26 18:21:02 -0600544 * 4294967295 - i.e. less than the maximum value of png_uint_32.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500545 */
John Bowlerbaeb6d12011-11-26 18:21:02 -0600546#ifdef PNG_SMALL_SIZE_T
547 typedef png_uint_32 png_alloc_size_t;
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500548#else
John Bowlerbaeb6d12011-11-26 18:21:02 -0600549 typedef png_size_t png_alloc_size_t;
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500550#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500551
John Bowlerbaeb6d12011-11-26 18:21:02 -0600552/* This macro makes the sizeof operator look and behave like a function, except
553 * that it can take a type without the enclosing () as an argument so long as
Glenn Randers-Pehrson432c1742012-08-09 20:14:48 -0500554 * the type contains no "," characters. As of libpng-1.6.0, this macro is no
555 * longer used in the libpng source code.
John Bowlerbaeb6d12011-11-26 18:21:02 -0600556 */
Glenn Randers-Pehrsond3a726d2010-08-03 20:26:34 -0500557#define png_sizeof(x) (sizeof (x))
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500558
John Bowlerbaeb6d12011-11-26 18:21:02 -0600559/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
560 * implementations of Intel CPU specific support of user-mode segmented address
561 * spaces, where 16-bit pointers address more than 65536 bytes of memory using
562 * separate 'segment' registers. The implementation requires two different
563 * types of pointer (only one of which includes the segment value.)
564 *
565 * If required this support is available in version 1.2 of libpng and may be
566 * available in versions through 1.5, although the correctness of the code has
567 * not been verified recently.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500568 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500569
John Bowlerbaeb6d12011-11-26 18:21:02 -0600570/* Typedef for floating-point numbers that are converted to fixed-point with a
571 * multiple of 100,000, e.g., gamma
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600572 */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600573typedef png_int_32 png_fixed_point;
574
Andreas Dilger47a0c421997-05-16 02:46:07 -0500575/* Add typedefs for pointers */
John Bowlerbaeb6d12011-11-26 18:21:02 -0600576typedef void * png_voidp;
577typedef const void * png_const_voidp;
578typedef png_byte * png_bytep;
579typedef const png_byte * png_const_bytep;
580typedef png_uint_32 * png_uint_32p;
581typedef const png_uint_32 * png_const_uint_32p;
582typedef png_int_32 * png_int_32p;
583typedef const png_int_32 * png_const_int_32p;
584typedef png_uint_16 * png_uint_16p;
585typedef const png_uint_16 * png_const_uint_16p;
586typedef png_int_16 * png_int_16p;
587typedef const png_int_16 * png_const_int_16p;
588typedef char * png_charp;
589typedef const char * png_const_charp;
590typedef png_fixed_point * png_fixed_point_p;
591typedef const png_fixed_point * png_const_fixed_point_p;
592typedef png_size_t * png_size_tp;
593typedef const png_size_t * png_const_size_tp;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -0600594
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500595#ifdef PNG_STDIO_SUPPORTED
Glenn Randers-Pehrson882340c2010-03-13 21:19:51 -0600596typedef FILE * png_FILE_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -0600597#endif
598
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600599#ifdef PNG_FLOATING_POINT_SUPPORTED
John Bowlerbaeb6d12011-11-26 18:21:02 -0600600typedef double * png_doublep;
601typedef const double * png_const_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600602#endif
Guy Schalnat6d764711995-12-19 03:22:19 -0600603
Andreas Dilger47a0c421997-05-16 02:46:07 -0500604/* Pointers to pointers; i.e. arrays */
John Bowlerbaeb6d12011-11-26 18:21:02 -0600605typedef png_byte * * png_bytepp;
606typedef png_uint_32 * * png_uint_32pp;
607typedef png_int_32 * * png_int_32pp;
608typedef png_uint_16 * * png_uint_16pp;
609typedef png_int_16 * * png_int_16pp;
610typedef const char * * png_const_charpp;
611typedef char * * png_charpp;
612typedef png_fixed_point * * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600613#ifdef PNG_FLOATING_POINT_SUPPORTED
John Bowlerbaeb6d12011-11-26 18:21:02 -0600614typedef double * * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600615#endif
Guy Schalnat6d764711995-12-19 03:22:19 -0600616
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600617/* Pointers to pointers to pointers; i.e., pointer to array */
John Bowlerbaeb6d12011-11-26 18:21:02 -0600618typedef char * * * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -0600619
John Bowlerbaeb6d12011-11-26 18:21:02 -0600620#endif /* PNG_BUILDING_SYMBOL_TABLE */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500621
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500622#endif /* PNGCONF_H */