1893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
2893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project/* pngconf.h - machine configurable file for libpng
3893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project *
4b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari * libpng version 1.6.10 - March 6, 2014
5b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
6b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * Copyright (c) 1998-2013 Glenn Randers-Pehrson
7893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9a0bb96c34e65378853ee518bac502842d26c2d1aPatrick Scott *
10a0bb96c34e65378853ee518bac502842d26c2d1aPatrick Scott * This code is released under the libpng license.
11a0bb96c34e65378853ee518bac502842d26c2d1aPatrick Scott * For conditions of distribution and use, see the disclaimer
12a0bb96c34e65378853ee518bac502842d26c2d1aPatrick Scott * and license in png.h
13b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
14893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project */
15893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
16893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project/* Any machine specific code is near the front of this file, so if you
17893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project * are configuring libpng for a machine, you may want to read the section
18893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project * starting here down to where it starts to typedef png_color, png_text,
19893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project * and png_info.
20893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project */
21893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
22893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#ifndef PNGCONF_H
23893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#define PNGCONF_H
24893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
25b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* To do: Do all of this in scripts/pnglibconf.dfa */
26b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifdef PNG_SAFE_LIMITS_SUPPORTED
27b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  ifdef PNG_USER_WIDTH_MAX
28b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    undef PNG_USER_WIDTH_MAX
29b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_USER_WIDTH_MAX 1000000L
30b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  endif
31b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  ifdef PNG_USER_HEIGHT_MAX
32b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    undef PNG_USER_HEIGHT_MAX
33b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_USER_HEIGHT_MAX 1000000L
34b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  endif
35b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  ifdef PNG_USER_CHUNK_MALLOC_MAX
36b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    undef PNG_USER_CHUNK_MALLOC_MAX
37b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_USER_CHUNK_MALLOC_MAX 4000000L
38b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  endif
39b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  ifdef PNG_USER_CHUNK_CACHE_MAX
40b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    undef PNG_USER_CHUNK_CACHE_MAX
41b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_USER_CHUNK_CACHE_MAX 128
42893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  endif
43893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
44893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
45b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
46893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
47b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
48b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * compiler for correct compilation.  The following header files are required by
49b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * the standard.  If your compiler doesn't provide these header files, or they
50b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * do not match the standard, you will need to provide/improve them.
51893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project */
52b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#include <limits.h>
53b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#include <stddef.h>
54893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
55b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Library header files.  These header files are all defined by ISOC90; libpng
56b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * expects conformant implementations, however, an ISOC90 conformant system need
57b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * not provide these header files if the functionality cannot be implemented.
58b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * In this case it will be necessary to disable the relevant parts of libpng in
59b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * the build of pnglibconf.h.
60b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
61b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
62b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * include this unnecessary header file.
63893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project */
64893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
65b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifdef PNG_STDIO_SUPPORTED
66b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   /* Required for the definition of FILE: */
67b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  include <stdio.h>
68893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
69893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
70b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifdef PNG_SETJMP_SUPPORTED
71b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   /* Required for the definition of jmp_buf and the declaration of longjmp: */
72b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  include <setjmp.h>
735f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott#endif
745f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott
75b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifdef PNG_CONVERT_tIME_SUPPORTED
76b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   /* Required for struct tm: */
77b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  include <time.h>
785f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott#endif
795f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott
80b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#endif /* PNG_BUILDING_SYMBOL_TABLE */
815f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott
82b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
83b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNG_NO_CONST; this is no longer supported except for data declarations which
84b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * apparently still cause problems in 2011 on some compilers.
85b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
86b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#define PNG_CONST const /* backward compatibility only */
875f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott
88b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* This controls optimization of the reading of 16 and 32 bit values
89b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * from PNG files.  It can be set on a per-app-file basis - it
90b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * just changes whether a macro is used when the function is called.
91b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * The library builder sets the default; if read functions are not
92b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * built into the library the macro implementation is forced on.
935f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott */
94b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
95b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_USE_READ_MACROS
96893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
97b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
98b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  if PNG_DEFAULT_READ_MACROS
99b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_USE_READ_MACROS
100893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  endif
101893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
102893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
103b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* COMPILER SPECIFIC OPTIONS.
104b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
105b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * These options are provided so that a variety of difficult compilers
106b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * can be used.  Some are fixed at build time (e.g. PNG_API_RULE
107b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * below) but still have compiler specific implementations, others
108b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * may be changed on a per-file basis when compiling against libpng.
109b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
110b50c217251b086440efcdb273c22f86a06c80cbaChris Craik
111b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
112b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * against legacy (pre ISOC90) compilers that did not understand function
113b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * prototypes.  It is not required for modern C compilers.
114893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project */
115b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNGARG
116b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNGARG(arglist) arglist
117893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
118893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
119b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Function calling conventions.
120b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * =============================
121b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * Normally it is not necessary to specify to the compiler how to call
122b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * a function - it just does it - however on x86 systems derived from
123b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
124b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * and some others) there are multiple ways to call a function and the
125b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * default can be changed on the compiler command line.  For this reason
126b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * libpng specifies the calling convention of every exported function and
127b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * every function called via a user supplied function pointer.  This is
128b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * done in this file by defining the following macros:
129893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project *
130b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNGAPI    Calling convention for exported functions.
131b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNGCBAPI  Calling convention for user provided (callback) functions.
132b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNGCAPI   Calling convention used by the ANSI-C library (required
133b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *           for longjmp callbacks and sometimes used internally to
134b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *           specify the calling convention for zlib).
135a0bb96c34e65378853ee518bac502842d26c2d1aPatrick Scott *
136b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * These macros should never be overridden.  If it is necessary to
137b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * change calling convention in a private build this can be done
138b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * by setting PNG_API_RULE (which defaults to 0) to one of the values
139b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * below to select the correct 'API' variants.
140b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
141b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
142b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                This is correct in every known environment.
143b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNG_API_RULE=1 Use the operating system convention for PNGAPI and
144b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                the 'C' calling convention (from PNGCAPI) for
145b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                callbacks (PNGCBAPI).  This is no longer required
146b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                in any known environment - if it has to be used
147b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                please post an explanation of the problem to the
148b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                libpng mailing list.
149b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
150b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * These cases only differ if the operating system does not use the C
151b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * calling convention, at present this just means the above cases
152b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * (x86 DOS/Windows sytems) and, even then, this does not apply to
153b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * Cygwin running on those systems.
154b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
155b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * Note that the value must be defined in pnglibconf.h so that what
156b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * the application uses to call the library matches the conventions
157b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * set when building the library.
158b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
159b50c217251b086440efcdb273c22f86a06c80cbaChris Craik
160b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Symbol export
161b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * =============
162b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * When building a shared library it is almost always necessary to tell
163b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * the compiler which symbols to export.  The png.h macro 'PNG_EXPORT'
164b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * is used to mark the symbols.  On some systems these symbols can be
165b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * extracted at link time and need no special processing by the compiler,
166b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * on other systems the symbols are flagged by the compiler and just
167b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * the declaration requires a special tag applied (unfortunately) in a
168b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * compiler dependent way.  Some systems can do either.
169b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
170b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * A small number of older systems also require a symbol from a DLL to
171b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * be flagged to the program that calls it.  This is a problem because
172b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * we do not know in the header file included by application code that
173b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * the symbol will come from a shared library, as opposed to a statically
174b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * linked one.  For this reason the application must tell us by setting
175b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * the magic flag PNG_USE_DLL to turn on the special processing before
176b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * it includes png.h.
177b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
178b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * Four additional macros are used to make this happen:
179b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
180b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
181b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *            the build or imported if PNG_USE_DLL is set - compiler
182b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *            and system specific.
183b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
184b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
185b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                       'type', compiler specific.
186b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
187b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
188b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                make a symbol exported from the DLL.  Not used in the
189b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                public header files; see pngpriv.h for how it is used
190b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                in the libpng build.
191b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
192b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
193b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                from a DLL - used to define PNG_IMPEXP when
194b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *                PNG_USE_DLL is set.
195b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
196b50c217251b086440efcdb273c22f86a06c80cbaChris Craik
197b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* System specific discovery.
198b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * ==========================
199b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * This code is used at build time to find PNG_IMPEXP, the API settings
200b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
201b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * import processing is possible.  On Windows systems it also sets
202b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * compiler-specific macros to the values required to change the calling
203b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * conventions of the various functions.
204b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
205b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
206b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
207b50c217251b086440efcdb273c22f86a06c80cbaChris Craik  /* Windows system (DOS doesn't support DLLs).  Includes builds under Cygwin or
208b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   * MinGW on any architecture currently supported by Windows.  Also includes
209b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   * Watcom builds but these need special treatment because they are not
210b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   * compatible with GCC or Visual C because of different calling conventions.
211b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   */
212b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  if PNG_API_RULE == 2
213b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    /* If this line results in an error, either because __watcall is not
214b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     * understood or because of a redefine just below you cannot use *this*
215b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     * build of the library with the compiler you are using.  *This* build was
216b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     * build using Watcom and applications must also be built using Watcom!
217b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     */
218b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNGCAPI __watcall
219b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  endif
220b50c217251b086440efcdb273c22f86a06c80cbaChris Craik
221b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
222b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNGCAPI __cdecl
223b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    if PNG_API_RULE == 1
224b50c217251b086440efcdb273c22f86a06c80cbaChris Craik       /* If this line results in an error __stdcall is not understood and
225b50c217251b086440efcdb273c22f86a06c80cbaChris Craik        * PNG_API_RULE should not have been set to '1'.
226b50c217251b086440efcdb273c22f86a06c80cbaChris Craik        */
227b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNGAPI __stdcall
228893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#    endif
229893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  else
230b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    /* An older compiler, or one not detected (erroneously) above,
231b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     * if necessary override on the command line to get the correct
232b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     * variants for the compiler.
233b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     */
234b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNGCAPI
235b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNGCAPI _cdecl
236a0bb96c34e65378853ee518bac502842d26c2d1aPatrick Scott#    endif
237b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    if PNG_API_RULE == 1 && !defined(PNGAPI)
238b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNGAPI _stdcall
239b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
240b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  endif /* compiler/api */
2415f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott
242b50c217251b086440efcdb273c22f86a06c80cbaChris Craik  /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
243893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
244b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
245b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#     error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
246893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  endif
247893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
248b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  if (defined(_MSC_VER) && _MSC_VER < 800) ||\
249b50c217251b086440efcdb273c22f86a06c80cbaChris Craik      (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
250b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    /* older Borland and MSC
251b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     * compilers used '__export' and required this to be after
252b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     * the type.
253b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     */
254b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_EXPORT_TYPE
255b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
256893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#    endif
257b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_DLL_EXPORT __export
258b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  else /* newer compiler */
259b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_DLL_EXPORT __declspec(dllexport)
260b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_DLL_IMPORT
261b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNG_DLL_IMPORT __declspec(dllimport)
262893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#    endif
263b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  endif /* compiler */
264b50c217251b086440efcdb273c22f86a06c80cbaChris Craik
265b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#else /* !Windows */
266b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
267b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNGAPI _System
268b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  else /* !Windows/x86 && !OS/2 */
269b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    /* Use the defaults, or define PNG*API on the command line (but
270b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     * this will have to be done for every compile!)
271b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     */
272b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  endif /* other system, !OS/2 */
273b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#endif /* !Windows/x86 */
274893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
275b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Now do all the defaulting . */
276b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNGCAPI
277b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNGCAPI
278b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#endif
279b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNGCBAPI
280b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNGCBAPI PNGCAPI
281b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#endif
282b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNGAPI
283b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNGAPI PNGCAPI
2845f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott#endif
2855f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott
286b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* PNG_IMPEXP may be set on the compilation system command line or (if not set)
287b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * then in an internal header file when building the library, otherwise (when
288b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * using the library) it is set here.
289893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project */
290b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_IMPEXP
291b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
292b50c217251b086440efcdb273c22f86a06c80cbaChris Craik     /* This forces use of a DLL, disallowing static linking */
293b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_IMPEXP PNG_DLL_IMPORT
294893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  endif
295893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
296b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  ifndef PNG_IMPEXP
297b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_IMPEXP
298893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  endif
299893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
300893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
301b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
302b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * 'attributes' as a storage class - the attributes go at the start of the
303b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * function definition, and attributes are always appended regardless of the
304b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * compiler.  This considerably simplifies these macros but may cause problems
305b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * if any compilers both need function attributes and fail to handle them as
306b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * a storage class (this is unlikely.)
307b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
308b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_FUNCTION
309b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_FUNCTION(type, name, args, attributes) attributes type name args
310893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
311893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
312b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_EXPORT_TYPE
313b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
314893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
315893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
316b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   /* The ordinal value is only relevant when preprocessing png.h for symbol
317b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    * table entries, so we discard it here.  See the .dfn files in the
318b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    * scripts directory.
319b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    */
320b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_EXPORTA
321893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
322b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_EXPORTA(ordinal, type, name, args, attributes)\
323b50c217251b086440efcdb273c22f86a06c80cbaChris Craik      PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
324b50c217251b086440efcdb273c22f86a06c80cbaChris Craik        extern attributes)
325b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#endif
326893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
327b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
328b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * so make something non-empty to satisfy the requirement:
329b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
330b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#define PNG_EMPTY /*empty list*/
331893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
332b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#define PNG_EXPORT(ordinal, type, name, args)\
333b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
334893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
335b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Use PNG_REMOVED to comment out a removed interface. */
336b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_REMOVED
337b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_REMOVED(ordinal, type, name, args, attributes)
338893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
339893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
340b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_CALLBACK
341b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
342b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#endif
343893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
344b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Support for compiler specific function attributes.  These are used
345b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * so that where compiler support is available incorrect use of API
346b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * functions in png.h will generate compiler warnings.
347b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
348b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * Added at libpng-1.2.41.
349893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project */
350893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
351b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_NO_PEDANTIC_WARNINGS
352b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
353b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    define PNG_PEDANTIC_WARNINGS_SUPPORTED
354893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  endif
355893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
356893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
357b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
358b50c217251b086440efcdb273c22f86a06c80cbaChris Craik  /* Support for compiler specific function attributes.  These are used
359b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   * so that where compiler support is available, incorrect use of API
360b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   * functions in png.h will generate compiler warnings.  Added at libpng
361b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   * version 1.2.41.  Disabling these removes the warnings but may also produce
362b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   * less efficient code.
363b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   */
364b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#  if defined(__clang__)
365b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari     /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
366b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
367b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))
368b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    endif
369b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)
370b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#      define PNG_NORETURN __attribute__((__noreturn__))
371b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    endif
372b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)
373b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#      define PNG_ALLOCATED __attribute__((__malloc__))
374b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    endif
375b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)
376b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#      define PNG_DEPRECATED __attribute__((__deprecated__))
377b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    endif
378b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    if !defined(PNG_PRIVATE)
379b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#      ifdef __has_extension
380b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#        if __has_extension(attribute_unavailable_with_message)
381b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#          define PNG_PRIVATE __attribute__((__unavailable__(\
382b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari             "This function is not exported by libpng.")))
383b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#        endif
384b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#      endif
385b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    endif
386b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    ifndef PNG_RESTRICT
387b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#      define PNG_RESTRICT __restrict
388b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    endif
389b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari
390b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#  elif defined(__GNUC__)
391b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_USE_RESULT
392b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))
393b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
394b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_NORETURN
395b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNG_NORETURN   __attribute__((__noreturn__))
396b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
397b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    if __GNUC__ >= 3
398b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      ifndef PNG_ALLOCATED
399b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#        define PNG_ALLOCATED  __attribute__((__malloc__))
400b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      endif
401b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      ifndef PNG_DEPRECATED
402b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#        define PNG_DEPRECATED __attribute__((__deprecated__))
403b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      endif
404b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      ifndef PNG_PRIVATE
405b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#        if 0 /* Doesn't work so we use deprecated instead*/
406b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#          define PNG_PRIVATE \
407b50c217251b086440efcdb273c22f86a06c80cbaChris Craik            __attribute__((warning("This function is not exported by libpng.")))
408b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#        else
409b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#          define PNG_PRIVATE \
410b50c217251b086440efcdb273c22f86a06c80cbaChris Craik            __attribute__((__deprecated__))
411b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#        endif
412b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      endif
413b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#      if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
414b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#        ifndef PNG_RESTRICT
415b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#          define PNG_RESTRICT __restrict
416b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#        endif
417b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#      endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */
418b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#    endif /* __GNUC__ >= 3 */
419893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
420b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  elif defined(_MSC_VER)  && (_MSC_VER >= 1300)
421b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_USE_RESULT
422b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNG_USE_RESULT /* not supported */
423b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
424b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_NORETURN
425b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNG_NORETURN   __declspec(noreturn)
426b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
427b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_ALLOCATED
428b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      if (_MSC_VER >= 1400)
429b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#        define PNG_ALLOCATED __declspec(restrict)
430b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      endif
431b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
432b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_DEPRECATED
433b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNG_DEPRECATED __declspec(deprecated)
434b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
435b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_PRIVATE
436b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNG_PRIVATE __declspec(deprecated)
437b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
438b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_RESTRICT
439b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      if (_MSC_VER >= 1400)
440b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#        define PNG_RESTRICT __restrict
441b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      endif
442b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
443893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
444b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  elif defined(__WATCOMC__)
445b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    ifndef PNG_RESTRICT
446b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#      define PNG_RESTRICT __restrict
447b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#    endif
448b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari#  endif
449b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#endif /* PNG_PEDANTIC_WARNINGS */
450893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
451b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_DEPRECATED
452b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_DEPRECATED  /* Use of this function is deprecated */
453893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
454b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_USE_RESULT
455b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_USE_RESULT  /* The result of this function must be checked */
456893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
457b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_NORETURN
458b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_NORETURN    /* This function does not return */
459893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
460b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_ALLOCATED
461b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_ALLOCATED   /* The result of the function is new memory */
462893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
463b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_PRIVATE
464b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_PRIVATE     /* This is a private libpng function */
465893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
466b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_RESTRICT
467b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  define PNG_RESTRICT    /* The C99 "restrict" feature */
468893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
469b478e66e7c2621eef5f465e4629ce642db00716bSireesh Tripurari
470b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_FP_EXPORT     /* A floating point API. */
471b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  ifdef PNG_FLOATING_POINT_SUPPORTED
472b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#     define PNG_FP_EXPORT(ordinal, type, name, args)\
473b50c217251b086440efcdb273c22f86a06c80cbaChris Craik         PNG_EXPORT(ordinal, type, name, args);
474b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  else                   /* No floating point APIs */
475b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#     define PNG_FP_EXPORT(ordinal, type, name, args)
476893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  endif
477893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
478b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_FIXED_EXPORT  /* A fixed point API. */
479b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  ifdef PNG_FIXED_POINT_SUPPORTED
480b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\
481b50c217251b086440efcdb273c22f86a06c80cbaChris Craik         PNG_EXPORT(ordinal, type, name, args);
482b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  else                   /* No fixed point APIs */
483b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#     define PNG_FIXED_EXPORT(ordinal, type, name, args)
484893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  endif
485893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
486893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
487b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_BUILDING_SYMBOL_TABLE
488b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Some typedefs to get us started.  These should be safe on most of the common
489b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * platforms.
490b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
491b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * png_uint_32 and png_int_32 may, currently, be larger than required to hold a
492b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * 32-bit value however this is not normally advisable.
493b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
494b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * png_uint_16 and png_int_16 should always be two bytes in size - this is
495b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * verified at library build time.
496b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
497b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * png_byte must always be one byte in size.
498b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
499b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * The checks below use constants from limits.h, as defined by the ISOC90
500b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * standard.
501893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project */
502b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#if CHAR_BIT == 8 && UCHAR_MAX == 255
503b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef unsigned char png_byte;
504b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#else
505b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  error "libpng requires 8 bit bytes"
506893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
507893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
508b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#if INT_MIN == -32768 && INT_MAX == 32767
509b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef int png_int_16;
510b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
511b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef short png_int_16;
512b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#else
513b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  error "libpng requires a signed 16 bit type"
514893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
515893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
516b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#if UINT_MAX == 65535
517b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef unsigned int png_uint_16;
518b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#elif USHRT_MAX == 65535
519b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef unsigned short png_uint_16;
520b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#else
521b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  error "libpng requires an unsigned 16 bit type"
522893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
523893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
524b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#if INT_MIN < -2147483646 && INT_MAX > 2147483646
525b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef int png_int_32;
526b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
527b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef long int png_int_32;
528b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#else
529b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  error "libpng requires a signed 32 bit (or more) type"
530893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
531893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
532b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#if UINT_MAX > 4294967294
533b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef unsigned int png_uint_32;
534b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#elif ULONG_MAX > 4294967294
535b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef unsigned long int png_uint_32;
536b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#else
537b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  error "libpng requires an unsigned 32 bit (or more) type"
5385f6bd84e375226bf228fc8ac90318957ec9e1e7fPatrick Scott#endif
539893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
540b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
541b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * requires an ISOC90 compiler and relies on consistent behavior of sizeof.
542b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
543b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef size_t png_size_t;
544b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef ptrdiff_t png_ptrdiff_t;
545893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
546b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* libpng needs to know the maximum value of 'size_t' and this controls the
547b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * definition of png_alloc_size_t, below.  This maximum value of size_t limits
548b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * but does not control the maximum allocations the library makes - there is
549b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * direct application control of this through png_set_user_limits().
550b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
551b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifndef PNG_SMALL_SIZE_T
552b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   /* Compiler specific tests for systems where size_t is known to be less than
553b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    * 32 bits (some of these systems may no longer work because of the lack of
554b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    * 'far' support; see above.)
555b50c217251b086440efcdb273c22f86a06c80cbaChris Craik    */
556b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#  if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
557b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   (defined(_MSC_VER) && defined(MAXSEG_64K))
558b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#     define PNG_SMALL_SIZE_T
559893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#  endif
560893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
561893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
562b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
563b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * smaller than png_uint_32.  Casts from png_size_t or png_uint_32 to
564b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * png_alloc_size_t are not necessary; in fact, it is recommended not to use
565b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * them at all so that the compiler can complain when something turns out to be
566b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * problematic.
567b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
568b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * Casts in the other direction (from png_alloc_size_t to png_size_t or
569b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * png_uint_32) should be explicitly applied; however, we do not expect to
570b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * encounter practical situations that require such conversions.
571b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
572b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
573b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * 4294967295 - i.e. less than the maximum value of png_uint_32.
574b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
575b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifdef PNG_SMALL_SIZE_T
576b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef png_uint_32 png_alloc_size_t;
577b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#else
578b50c217251b086440efcdb273c22f86a06c80cbaChris Craik   typedef png_size_t png_alloc_size_t;
579893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
580893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
581b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
582b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * implementations of Intel CPU specific support of user-mode segmented address
583b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * spaces, where 16-bit pointers address more than 65536 bytes of memory using
584b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * separate 'segment' registers.  The implementation requires two different
585b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * types of pointer (only one of which includes the segment value.)
586b50c217251b086440efcdb273c22f86a06c80cbaChris Craik *
587b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * If required this support is available in version 1.2 of libpng and may be
588b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * available in versions through 1.5, although the correctness of the code has
589b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * not been verified recently.
590b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
591893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
592b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Typedef for floating-point numbers that are converted to fixed-point with a
593b50c217251b086440efcdb273c22f86a06c80cbaChris Craik * multiple of 100,000, e.g., gamma
594b50c217251b086440efcdb273c22f86a06c80cbaChris Craik */
595b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_int_32 png_fixed_point;
596893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
597b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Add typedefs for pointers */
598b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef void                  * png_voidp;
599b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const void            * png_const_voidp;
600b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_byte              * png_bytep;
601b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const png_byte        * png_const_bytep;
602b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_uint_32           * png_uint_32p;
603b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const png_uint_32     * png_const_uint_32p;
604b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_int_32            * png_int_32p;
605b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const png_int_32      * png_const_int_32p;
606b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_uint_16           * png_uint_16p;
607b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const png_uint_16     * png_const_uint_16p;
608b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_int_16            * png_int_16p;
609b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const png_int_16      * png_const_int_16p;
610b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef char                  * png_charp;
611b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const char            * png_const_charp;
612b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_fixed_point       * png_fixed_point_p;
613b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const png_fixed_point * png_const_fixed_point_p;
614b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_size_t            * png_size_tp;
615b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const png_size_t      * png_const_size_tp;
616b50c217251b086440efcdb273c22f86a06c80cbaChris Craik
617b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifdef PNG_STDIO_SUPPORTED
618b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef FILE            * png_FILE_p;
619893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
620893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
621b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifdef PNG_FLOATING_POINT_SUPPORTED
622b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef double       * png_doublep;
623b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const double * png_const_doublep;
624893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
625893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
626b50c217251b086440efcdb273c22f86a06c80cbaChris Craik/* Pointers to pointers; i.e. arrays */
627b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_byte        * * png_bytepp;
628b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_uint_32     * * png_uint_32pp;
629b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_int_32      * * png_int_32pp;
630b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_uint_16     * * png_uint_16pp;
631b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_int_16      * * png_int_16pp;
632b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef const char      * * png_const_charpp;
633b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef char            * * png_charpp;
634b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef png_fixed_point * * png_fixed_point_pp;
635b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#ifdef PNG_FLOATING_POINT_SUPPORTED
636b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef double          * * png_doublepp;
637893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif
638893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
639893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project/* Pointers to pointers to pointers; i.e., pointer to array */
640b50c217251b086440efcdb273c22f86a06c80cbaChris Craiktypedef char            * * * png_charppp;
641893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
642b50c217251b086440efcdb273c22f86a06c80cbaChris Craik#endif /* PNG_BUILDING_SYMBOL_TABLE */
643893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project
644893912bfc2683463dc3e2c445336752d012563d3The Android Open Source Project#endif /* PNGCONF_H */
645