blob: 6d6f29b36476aa4a2a86238bba500154f26a8acc [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-Pehrsond3a726d2010-08-03 20:26:34 -05004 * libpng version 1.5.0beta40 - August 4, 2010
Glenn Randers-Pehrsonc17c9572010-03-08 21:26:48 -06005 *
Glenn Randers-Pehrsone69b55d2010-01-01 10:29:06 -06006 * Copyright (c) 1998-2010 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-Pehrson862cb202010-04-16 22:12:51 -050025/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
26 * definition file for machine specific limits, this may impact the
27 * correctness of the definitons below (see uses of INT_MAX).
28 */
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050029#ifndef PNG_NO_LIMITS_H
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -050030# include <limits.h>
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050031#endif
32
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -050033/* For the memory copy APIs (i.e. the standard definitions of these),
34 * because this file defines png_memcpy and so on the base APIs must
35 * be defined here.
36 */
37#ifdef BSD
38# include <strings.h>
39#else
40# include <string.h>
41#endif
42
43/* For png_FILE_p - this provides the standard definition of a
44 * FILE
45 */
46#ifdef PNG_STDIO_SUPPORTED
47# include <stdio.h>
48#endif
49
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050050/* This controls optimization of the reading of 16 and 32 bit values
51 * from PNG files. It can be set on a per-app-file basis - it
52 * just changes whether a macro is used to the function is called.
Glenn Randers-Pehrsonc3d73f42010-04-24 09:18:57 -050053 * The library builder sets the default, if read functions are not
54 * built into the library the macro implementation is forced on.
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050055 */
Glenn Randers-Pehrsonc3d73f42010-04-24 09:18:57 -050056#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
57# define PNG_USE_READ_MACROS
58#endif
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050059#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
60# if PNG_DEFAULT_READ_MACROS
61# define PNG_USE_READ_MACROS
62# endif
63#endif
64
Glenn Randers-Pehrson8fc36042010-04-17 10:17:46 -050065/* COMPILER SPECIFIC OPTIONS.
Glenn Randers-Pehrson7824a702009-06-13 10:05:05 -050066 *
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050067 * These options are provided so that a variety of difficult compilers
68 * can be used. Some are fixed at build time (e.g. PNG_API_RULE
69 * below) but still have compiler specific implementations, others
70 * may be changed on a per-file basis when compiling against libpng.
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -050071 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -060072/* This macro protects us against machines that don't have function
73 * prototypes (ie K&R style headers). If your compiler does not handle
74 * function prototypes, define this macro and use the included ansi2knr.
75 * I've always been able to use _NO_PROTO as the indicator, but you may
76 * need to drag the empty declaration out in front of here, or change the
77 * ifdef to suit your own needs.
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -050078 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -060079#ifndef PNGARG
80
81# ifdef OF /* zlib prototype munger */
82# define PNGARG(arglist) OF(arglist)
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -050083# else
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -060084
85# ifdef _NO_PROTO
86# define PNGARG(arglist) ()
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -050087# else
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -060088# define PNGARG(arglist) arglist
89# endif /* _NO_PROTO */
90
91# endif /* OF */
92
93#endif /* PNGARG */
94
95/* Function calling conventions.
96 * =============================
97 * Normally it is not necessary to specify to the compiler how to call
98 * a function - it just does it - however on x86 systems derived from
99 * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
100 * and some others) there are multiple ways to call a function and the
101 * default can be changed on the compiler command line. For this reason
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500102 * libpng specifies the calling convention of every exported function and
103 * every function called via a user supplied function pointer. This is
104 * done in this file by defining the following macros:
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600105 *
106 * PNGAPI Calling convention for exported functions.
107 * PNGCBAPI Calling convention for user provided (callback) functions.
108 * PNGCAPI Calling convention used by the ANSI-C library (required
109 * for longjmp callbacks and sometimes used internally to
110 * specify the calling convention for zlib).
111 *
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500112 * These macros should never be overridden. If it is necessary to
113 * change calling convention in a private build this can be done
114 * by setting PNG_API_RULE (which defaults to 0) to one of the values
115 * below to select the correct 'API' variants.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600116 *
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500117 * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
118 * This is correct in every known environment.
119 * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600120 * the 'C' calling convention (from PNGCAPI) for
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500121 * callbacks (PNGCBAPI). This is no longer required
122 * in any known environment - if it has to be used
123 * please post an explanation of the problem to the
124 * libpng mailing list.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600125 *
126 * These cases only differ if the operating system does not use the C
127 * calling convention, at present this just means the above cases
128 * (x86 DOS/Windows sytems) and, even then, this does not apply to
129 * Cygwin running on those systems.
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500130 *
Glenn Randers-Pehrson98b4f002010-04-16 22:30:26 -0500131 * Note that the value must be defined in pnglibconf.h so that what
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500132 * the application uses to call the library matches the conventions
133 * set when building the library.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600134 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600135
136/* Symbol export
137 * =============
138 * When building a shared library it is almost always necessary to tell
139 * the compiler which symbols to export. The png.h macro 'PNG_EXPORT'
140 * is used to mark the symbols. On some systems these symbols can be
141 * extracted at link time and need no special processing by the compiler,
142 * on other systems the symbols are flagged by the compiler and just
143 * the declaration requires a special tag applied (unfortunately) in a
144 * compiler dependent way. Some systems can do either.
145 *
146 * A small number of older systems also require a symbol from a DLL to
147 * be flagged to the program that calls it. This is a problem because
148 * we do not know in the header file included by application code that
149 * the symbol will come from a shared library, as opposed to a statically
150 * linked one. For this reason the application must tell us by setting
151 * the magic flag PNG_USE_DLL to turn on the special processing before
152 * it includes png.h.
Glenn Randers-Pehrson821b7102010-06-24 16:16:32 -0500153 *
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500154 * Four additional macros are used to make this happen:
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600155 *
156 * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
157 * the build or imported if PNG_USE_DLL is set - compiler
158 * and system specific.
159 *
160 * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
161 * 'type', compiler specific.
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500162 *
163 * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
164 * make a symbol exported from the DLL.
165 *
166 * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
167 * from a DLL - used to define PNG_IMPEXP when
168 * PNG_USE_DLL is set.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600169 */
170
171/* System specific discovery.
172 * ==========================
173 * This code is used at build time to find PNG_IMPEXP, the API settings
174 * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500175 * import processing is possible. On Windows/x86 systems it also sets
176 * compiler-specific macros to the values required to change the calling
177 * conventions of the various functions.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600178 */
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500179#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
180 defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
181 ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
182 defined(_M_X64) || defined(_M_IA64) )
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500183 /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
184 * builds under Cygwin or MinGW. Also includes Watcom builds but these need
185 * special treatment because they are not compatible with GCC or Visual C
186 * because of different calling conventions.
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500187 */
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500188# if PNG_API_RULE == 2
189 /* If this line results in an error, either because __watcall is not
190 * understood or because of a redefine just below you cannot use *this*
191 * build of the library with the compiler you are using. *This* build was
192 * build using Watcom and applications must also be built using Watcom!
193 */
194# define PNGCAPI __watcall
195# endif
196
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500197# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
198# define PNGCAPI __cdecl
199# if PNG_API_RULE == 1
200# define PNGAPI __stdcall
201# endif
202# else
203 /* An older compiler, or one not detected (erroneously) above,
204 * if necessary override on the command line to get the correct
205 * variants for the compiler.
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600206 */
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500207# ifndef PNGCAPI
208# define PNGCAPI _cdecl
209# endif
210# if PNG_API_RULE == 1 && !defined(PNGAPI)
211# define PNGAPI _stdcall
212# endif
213# endif /* compiler/api */
214 /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600215
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500216# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
217 ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
218# endif
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600219
Glenn Randers-Pehrson9ee577c2010-04-24 09:40:44 -0500220# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
221 (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
222 /* older Borland and MSC
223 * compilers used '__export' and required this to be after
224 * the type.
225 */
226# ifndef PNG_EXPORT_TYPE
227# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
228# endif
229# define PNG_DLL_EXPORT __export
230# else /* newer compiler */
231# define PNG_DLL_EXPORT __declspec(dllexport)
232# ifndef PNG_DLL_IMPORT
233# define PNG_DLL_IMPORT __declspec(dllimport)
234# endif
235# endif /* compiler */
236
237#else /* !Windows/x86 */
238# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
239# define PNGAPI _System
240# else /* !Windows/x86 && !OS/2 */
241 /* Use the defaults, or define PNG*API on the command line (but
242 * this will have to be done for every compile!)
243 */
244# endif /* other system, !OS/2 */
245#endif /* !Windows/x86 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600246
247/* Now do all the defaulting . */
248#ifndef PNGCAPI
249# define PNGCAPI
250#endif
251#ifndef PNGCBAPI
252# define PNGCBAPI PNGCAPI
253#endif
254#ifndef PNGAPI
255# define PNGAPI PNGCAPI
256#endif
257
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500258/* The default for PNG_IMPEXP depends on whether the library is
259 * being built or used.
260 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600261#ifndef PNG_IMPEXP
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500262# ifdef PNGLIB_BUILD
263 /* Building the library */
264# if (defined(DLL_EXPORT)/*from libtool*/ ||\
Glenn Randers-Pehrsond9d4cec2010-07-12 07:12:09 -0500265 defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\
266 defined(_USRDLL) ||\
267 defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT)
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500268 /* Building a DLL. */
269# define PNG_IMPEXP PNG_DLL_EXPORT
270# endif /* DLL */
271# else
272 /* Using the library */
273# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
274 /* This forces use of a DLL, disallowing static linking */
275# define PNG_IMPEXP PNG_DLL_IMPORT
276# endif
277# endif
278
279# ifndef PNG_IMPEXP
280# define PNG_IMPEXP
281# endif
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600282#endif
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500283
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500284/* THe following complexity is concerned with getting the 'attributes' of the
285 * declared function in the correct place. This potentially requires a separate
286 * PNG_EXPORT function for every compiler.
287 */
288#ifndef PNG_FUNCTION
289# ifdef __GNUC__
290# define PNG_FUNCTION(type, name, args, attributes)\
291 attributes type name args
292# else /* !GNUC */
293# ifdef _MSC_VER
294# define PNG_FUNCTION(type, name, args, attributes)\
295 attributes type name args
296# else /* !MSC */
297# define PNG_FUNCTION(type, name, args, attributes)\
298 type name args
299# endif
300# endif
301#endif
302
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600303#ifndef PNG_EXPORT_TYPE
304# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
305#endif
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500306
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600307#ifndef PNG_EXPORT
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500308 /* The ordinal value is only relevant when preprocessing png.h for symbol
309 * table entries.
310 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600311# define PNG_EXPORT(type, name, args, attributes, ordinal)\
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500312 extern PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args),\
313 attributes)
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600314#endif
315
316/* Use PNG_REMOVED to comment out a removed interface. */
317#ifndef PNG_REMOVED
Glenn Randers-Pehrson59054842010-04-28 13:21:03 -0500318# define PNG_REMOVED(type, name, args, attributes, ordinal)
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600319#endif
320
321#ifndef PNG_CALLBACK
322# define PNG_CALLBACK(type, name, args, attributes)\
323 type (PNGCBAPI name) PNGARG(args) attributes
324#endif
325
326/* Support for compiler specific function attributes. These are used
327 * so that where compiler support is available incorrect use of API
328 * functions in png.h will generate compiler warnings.
329 *
330 * Added at libpng-1.2.41.
331 */
332
333#ifndef PNG_NO_PEDANTIC_WARNINGS
Glenn Randers-Pehrsonc44253f2010-03-13 20:58:39 -0600334# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
335# define PNG_PEDANTIC_WARNINGS_SUPPORTED
336# endif
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600337#endif
338
339#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
Glenn Randers-Pehrson882340c2010-03-13 21:19:51 -0600340 /* Support for compiler specific function attributes. These are used
341 * so that where compiler support is available incorrect use of API
342 * functions in png.h will generate compiler warnings. Added at libpng
343 * version 1.2.41.
344 */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600345# ifdef __GNUC__
346# ifndef PNG_USE_RESULT
347# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
348# endif
349# ifndef PNG_NORETURN
350# define PNG_NORETURN __attribute__((__noreturn__))
351# endif
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500352# ifndef PNG_PTR_NORETURN
353# define PNG_PTR_NORETURN __attribute__((__noreturn__))
354# endif
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600355# ifndef PNG_ALLOCATED
356# define PNG_ALLOCATED __attribute__((__malloc__))
357# endif
358
359 /* This specifically protects structure members that should only be
360 * accessed from within the library, therefore should be empty during
361 * a library build.
362 */
363# ifndef PNGLIB_BUILD
364# ifndef PNG_DEPRECATED
365# define PNG_DEPRECATED __attribute__((__deprecated__))
366# endif
367# ifndef PNG_DEPSTRUCT
368# define PNG_DEPSTRUCT __attribute__((__deprecated__))
369# endif
370# ifndef PNG_PRIVATE
371# if 0 /* Doesn't work so we use deprecated instead*/
372# define PNG_PRIVATE \
373 __attribute__((warning("This function is not exported by libpng.")))
374# else
375# define PNG_PRIVATE \
376 __attribute__((__deprecated__))
377# endif
378# endif /* PNG_PRIVATE */
379# endif /* PNGLIB_BUILD */
380# endif /* __GNUC__ */
Glenn Randers-Pehrson77396b62010-08-02 08:00:10 -0500381# ifdef _MSC_VER /* may need to check value */
382# ifndef PNG_USE_RESULT
383# define PNG_USE_RESULT /*not supported*/
384# endif
385# ifndef PNG_NORETURN
386# define PNG_NORETURN __declspec(noreturn)
387# endif
388# ifndef PNG_PTR_NORETURN
389# define PNG_PTR_NORETURN /*not supported*/
390# endif
391# ifndef PNG_ALLOCATED
392# define PNG_ALLOCATED __declspec(restrict)
393# endif
394
395 /* This specifically protects structure members that should only be
396 * accessed from within the library, therefore should be empty during
397 * a library build.
398 */
399# ifndef PNGLIB_BUILD
400# ifndef PNG_DEPRECATED
401# define PNG_DEPRECATED __declspec(deprecated)
402# endif
403# ifndef PNG_DEPSTRUCT
404# define PNG_DEPSTRUCT __declspec(deprecated)
405# endif
406# ifndef PNG_PRIVATE
407# define PNG_PRIVATE __declspec(deprecated)
408# endif /* PNG_PRIVATE */
409# endif /* PNGLIB_BUILD */
410# endif /* __GNUC__ */
Glenn Randers-Pehrsond7da8bb2010-03-13 20:30:10 -0600411#endif /* PNG_PEDANTIC_WARNINGS */
412
413#ifndef PNG_DEPRECATED
414# define PNG_DEPRECATED /* Use of this function is deprecated */
415#endif
416#ifndef PNG_USE_RESULT
417# define PNG_USE_RESULT /* The result of this function must be checked */
418#endif
419#ifndef PNG_NORETURN
420# define PNG_NORETURN /* This function does not return */
421#endif
422#ifndef PNG_ALLOCATED
423# define PNG_ALLOCATED /* The result of the function is new memory */
424#endif
425#ifndef PNG_DEPSTRUCT
426# define PNG_DEPSTRUCT /* Access to this struct member is deprecated */
427#endif
428#ifndef PNG_PRIVATE
429# define PNG_PRIVATE /* This is a private libpng function */
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500430#endif
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500431#ifndef PNG_FP_EXPORT /* A floating point API. */
432# ifdef PNG_FLOATING_POINT_SUPPORTED
433# define PNG_FP_EXPORT(type, name, args, attributes, ordinal)\
434 PNG_EXPORT(type, name, args, attributes, ordinal)
435# else /* No floating point APIs */
436# define PNG_FP_EXPORT(type, name, args, attributes, ordinal)
437# endif
438#endif
439#ifndef PNG_FIXED_EXPORT /* A fixed point API. */
440# ifdef PNG_FIXED_POINT_SUPPORTED
441# define PNG_FIXED_EXPORT(type, name, args, attributes, ordinal)\
442 PNG_EXPORT(type, name, args, attributes, ordinal)
443# else /* No fixed point APIs */
444# define PNG_FIXED_EXPORT(type, name, args, attributes, ordinal)
445# endif
446#endif
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -0500447
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600448/* The following uses const char * instead of char * for error
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600449 * and warning message functions, so some compilers won't complain.
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600450 * If you do not want to use const, define PNG_NO_CONST here.
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500451 *
452 * This should not change how the APIs are called, so it can be done
453 * on a per-file basis in the application.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600454 */
Glenn Randers-Pehrson28d4aae2009-11-13 16:29:45 -0600455#ifndef PNG_CONST
456# ifndef PNG_NO_CONST
457# define PNG_CONST const
458# else
459# define PNG_CONST
460# endif
Guy Schalnat6d764711995-12-19 03:22:19 -0600461#endif
462
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600463/* Some typedefs to get us started. These should be safe on most of the
Andreas Dilger47a0c421997-05-16 02:46:07 -0500464 * common platforms. The typedefs should be at least as large as the
465 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
466 * don't have to be exactly that size. Some compilers dislike passing
467 * unsigned shorts as function parameters, so you may be better off using
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500468 * unsigned int for png_uint_16.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500469 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500470
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500471#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
472typedef unsigned int png_uint_32;
473typedef int png_int_32;
474#else
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500475typedef unsigned long png_uint_32;
476typedef long png_int_32;
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500477#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500478typedef unsigned short png_uint_16;
479typedef short png_int_16;
480typedef unsigned char png_byte;
481
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500482#ifdef PNG_NO_SIZE_T
Glenn Randers-Pehrson882340c2010-03-13 21:19:51 -0600483typedef unsigned int png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -0500484#else
Glenn Randers-Pehrson882340c2010-03-13 21:19:51 -0600485typedef size_t png_size_t;
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -0500486#endif
Glenn Randers-Pehrsond3a726d2010-08-03 20:26:34 -0500487#define png_sizeof(x) (sizeof (x))
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500488
Andreas Dilger47a0c421997-05-16 02:46:07 -0500489/* The following is needed for medium model support. It cannot be in the
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -0500490 * pngpriv.h header. Needs modification for other compilers besides
Andreas Dilger47a0c421997-05-16 02:46:07 -0500491 * MSC. Model independent support declares all arrays and pointers to be
492 * large using the far keyword. The zlib version used must also support
493 * model independent data. As of version zlib 1.0.4, the necessary changes
494 * have been made in zlib. The USE_FAR_KEYWORD define triggers other
495 * changes that are needed. (Tim Wegner)
496 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500497
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600498/* Separate compiler dependencies (problem here is that zlib.h always
Glenn Randers-Pehrson6076da82009-09-30 12:28:07 -0500499 * defines FAR. (SJT)
500 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600501#ifdef __BORLANDC__
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600502# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
503# define LDATA 1
504# else
505# define LDATA 0
506# endif
Glenn Randers-Pehrson882340c2010-03-13 21:19:51 -0600507 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600508# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500509# define PNG_MAX_MALLOC_64K /* only used in build */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600510# if (LDATA != 1)
511# ifndef FAR
512# define FAR __far
513# endif
514# define USE_FAR_KEYWORD
515# endif /* LDATA != 1 */
Glenn Randers-Pehrsonc44253f2010-03-13 20:58:39 -0600516 /* Possibly useful for moving data out of default segment.
517 * Uncomment it if you want. Could also define FARDATA as
518 * const if your compiler supports it. (SJT)
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600519# define FARDATA FAR
Glenn Randers-Pehrsonc44253f2010-03-13 20:58:39 -0600520 */
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600521# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
Guy Schalnatb2e01bd1996-01-26 01:38:47 -0600522#endif /* __BORLANDC__ */
Guy Schalnat6d764711995-12-19 03:22:19 -0600523
524
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600525/* Suggest testing for specific compiler first before testing for
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600526 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
527 * making reliance oncertain keywords suspect. (SJT)
528 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600529
530/* MSC Medium model */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500531#ifdef FAR
532# ifdef M_I86MM
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600533# define USE_FAR_KEYWORD
534# define FARDATA FAR
535# include <dos.h>
Guy Schalnat6d764711995-12-19 03:22:19 -0600536# endif
537#endif
538
539/* SJT: default case */
540#ifndef FAR
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600541# define FAR
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500542#endif
543
Andreas Dilger47a0c421997-05-16 02:46:07 -0500544/* At this point FAR is always defined */
Guy Schalnat6d764711995-12-19 03:22:19 -0600545#ifndef FARDATA
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600546# define FARDATA
Guy Schalnat6d764711995-12-19 03:22:19 -0600547#endif
548
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600549/* Typedef for floating-point numbers that are converted
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500550 * to fixed-point with a multiple of 100,000, e.g., gamma
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600551 */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600552typedef png_int_32 png_fixed_point;
553
Andreas Dilger47a0c421997-05-16 02:46:07 -0500554/* Add typedefs for pointers */
Glenn Randers-Pehrson31aee0d2010-07-29 17:39:14 -0500555typedef void FAR * png_voidp;
556typedef png_byte FAR * png_bytep;
557typedef PNG_CONST png_byte FAR * png_const_bytep;
558typedef png_uint_32 FAR * png_uint_32p;
559typedef png_int_32 FAR * png_int_32p;
560typedef png_uint_16 FAR * png_uint_16p;
561typedef png_int_16 FAR * png_int_16p;
562typedef PNG_CONST char FAR * png_const_charp;
563typedef char FAR * png_charp;
564typedef png_fixed_point FAR * png_fixed_point_p;
565typedef png_size_t FAR * png_size_tp;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -0600566
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500567#ifdef PNG_STDIO_SUPPORTED
Glenn Randers-Pehrson882340c2010-03-13 21:19:51 -0600568typedef FILE * png_FILE_p;
Glenn Randers-Pehrsonbe9de0f2001-01-22 08:52:16 -0600569#endif
570
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600571#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500572typedef double FAR * png_doublep;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600573#endif
Guy Schalnat6d764711995-12-19 03:22:19 -0600574
Andreas Dilger47a0c421997-05-16 02:46:07 -0500575/* Pointers to pointers; i.e. arrays */
Guy Schalnat6d764711995-12-19 03:22:19 -0600576typedef png_byte FAR * FAR * png_bytepp;
577typedef png_uint_32 FAR * FAR * png_uint_32pp;
578typedef png_int_32 FAR * FAR * png_int_32pp;
579typedef png_uint_16 FAR * FAR * png_uint_16pp;
580typedef png_int_16 FAR * FAR * png_int_16pp;
581typedef PNG_CONST char FAR * FAR * png_const_charpp;
582typedef char FAR * FAR * png_charpp;
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600583typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600584#ifdef PNG_FLOATING_POINT_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500585typedef double FAR * FAR * png_doublepp;
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600586#endif
Guy Schalnat6d764711995-12-19 03:22:19 -0600587
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600588/* Pointers to pointers to pointers; i.e., pointer to array */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500589typedef char FAR * FAR * FAR * png_charppp;
Guy Schalnat6d764711995-12-19 03:22:19 -0600590
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500591/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
592 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
593 * to png_alloc_size_t are not necessary; in fact, it is recommended
594 * not to use them at all so that the compiler can complain when something
595 * turns out to be problematic.
596 * Casts in the other direction (from png_alloc_size_t to png_size_t or
597 * png_uint_32) should be explicitly applied; however, we do not expect
598 * to encounter practical situations that require such conversions.
599 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500600#if defined(__TURBOC__) && !defined(__FLAT__)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500601 typedef unsigned long png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500602#else
603# if defined(_MSC_VER) && defined(MAXSEG_64K)
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500604 typedef unsigned long png_alloc_size_t;
605# else
Glenn Randers-Pehrsond3a726d2010-08-03 20:26:34 -0500606 /* This is an attempt to detect an old Windows system where (int) is
607 * actually 16 bits, in that case png_malloc must have an argument with a
608 * bigger size to accomodate the requirements of the library.
609 */
610# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
611 (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
612 typedef DWORD png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500613# else
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500614 typedef png_size_t png_alloc_size_t;
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500615# endif
616# endif
617#endif
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500618
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500619#endif /* PNGCONF_H */