Glenn Randers-Pehrson | 5b5dcf8 | 2004-07-17 22:45:44 -0500 | [diff] [blame] | 1 | |
Cosmin Truta | a40189c | 2019-04-14 14:10:32 -0400 | [diff] [blame] | 2 | /* pngconf.h - machine-configurable file for libpng |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 3 | * |
Cosmin Truta | a40189c | 2019-04-14 14:10:32 -0400 | [diff] [blame] | 4 | * libpng version 1.6.37 |
Glenn Randers-Pehrson | c17c957 | 2010-03-08 21:26:48 -0600 | [diff] [blame] | 5 | * |
Cosmin Truta | a40189c | 2019-04-14 14:10:32 -0400 | [diff] [blame] | 6 | * Copyright (c) 2018-2019 Cosmin Truta |
Cosmin Truta | 46aedd8 | 2018-07-15 23:58:00 -0400 | [diff] [blame] | 7 | * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson |
Cosmin Truta | d4fb621 | 2018-07-28 18:34:58 -0400 | [diff] [blame] | 8 | * Copyright (c) 1996-1997 Andreas Dilger |
| 9 | * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. |
Glenn Randers-Pehrson | 3e61d79 | 2009-06-24 09:31:28 -0500 | [diff] [blame] | 10 | * |
Glenn Randers-Pehrson | bfbf865 | 2009-06-26 21:46:52 -0500 | [diff] [blame] | 11 | * This code is released under the libpng license. |
Glenn Randers-Pehrson | c332bbc | 2009-06-25 13:43:50 -0500 | [diff] [blame] | 12 | * For conditions of distribution and use, see the disclaimer |
Glenn Randers-Pehrson | 037023b | 2009-06-24 10:27:36 -0500 | [diff] [blame] | 13 | * and license in png.h |
Glenn Randers-Pehrson | 3e61d79 | 2009-06-24 09:31:28 -0500 | [diff] [blame] | 14 | * |
Glenn Randers-Pehrson | 3e0bef6 | 2015-03-04 09:45:57 -0600 | [diff] [blame] | 15 | * Any machine specific code is near the front of this file, so if you |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 16 | * are configuring libpng for a machine, you may want to read the section |
| 17 | * starting here down to where it starts to typedef png_color, png_text, |
| 18 | * and png_info. |
| 19 | */ |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 20 | |
| 21 | #ifndef PNGCONF_H |
| 22 | #define PNGCONF_H |
| 23 | |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 24 | #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 25 | |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 26 | /* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C |
| 27 | * compiler for correct compilation. The following header files are required by |
| 28 | * the standard. If your compiler doesn't provide these header files, or they |
| 29 | * do not match the standard, you will need to provide/improve them. |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 30 | */ |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 31 | #include <limits.h> |
| 32 | #include <stddef.h> |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 33 | |
Glenn Randers-Pehrson | 4c7e820 | 2011-11-26 19:00:01 -0600 | [diff] [blame] | 34 | /* Library header files. These header files are all defined by ISOC90; libpng |
| 35 | * expects conformant implementations, however, an ISOC90 conformant system need |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 36 | * not provide these header files if the functionality cannot be implemented. |
| 37 | * In this case it will be necessary to disable the relevant parts of libpng in |
| 38 | * the build of pnglibconf.h. |
| 39 | * |
| 40 | * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not |
| 41 | * include this unnecessary header file. |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 42 | */ |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 43 | |
| 44 | #ifdef PNG_STDIO_SUPPORTED |
| 45 | /* Required for the definition of FILE: */ |
| 46 | # include <stdio.h> |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 47 | #endif |
| 48 | |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 49 | #ifdef PNG_SETJMP_SUPPORTED |
| 50 | /* Required for the definition of jmp_buf and the declaration of longjmp: */ |
| 51 | # include <setjmp.h> |
| 52 | #endif |
| 53 | |
| 54 | #ifdef PNG_CONVERT_tIME_SUPPORTED |
| 55 | /* Required for struct tm: */ |
| 56 | # include <time.h> |
| 57 | #endif |
| 58 | |
| 59 | #endif /* PNG_BUILDING_SYMBOL_TABLE */ |
| 60 | |
Cosmin Truta | 1ef8882 | 2018-08-18 21:01:02 -0400 | [diff] [blame] | 61 | /* Prior to 1.6.0, it was possible to turn off 'const' in declarations, |
| 62 | * using PNG_NO_CONST. This is no longer supported. |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 63 | */ |
| 64 | #define PNG_CONST const /* backward compatibility only */ |
| 65 | |
Cosmin Truta | 81a65de | 2018-11-25 20:27:04 -0500 | [diff] [blame] | 66 | /* This controls optimization of the reading of 16-bit and 32-bit |
| 67 | * values from PNG files. It can be set on a per-app-file basis: it |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 68 | * just changes whether a macro is used when the function is called. |
| 69 | * The library builder sets the default; if read functions are not |
Glenn Randers-Pehrson | c3d73f4 | 2010-04-24 09:18:57 -0500 | [diff] [blame] | 70 | * built into the library the macro implementation is forced on. |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 71 | */ |
Glenn Randers-Pehrson | c3d73f4 | 2010-04-24 09:18:57 -0500 | [diff] [blame] | 72 | #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED |
| 73 | # define PNG_USE_READ_MACROS |
| 74 | #endif |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 75 | #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) |
| 76 | # if PNG_DEFAULT_READ_MACROS |
| 77 | # define PNG_USE_READ_MACROS |
| 78 | # endif |
| 79 | #endif |
| 80 | |
Glenn Randers-Pehrson | 8fc3604 | 2010-04-17 10:17:46 -0500 | [diff] [blame] | 81 | /* COMPILER SPECIFIC OPTIONS. |
Glenn Randers-Pehrson | 7824a70 | 2009-06-13 10:05:05 -0500 | [diff] [blame] | 82 | * |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 83 | * These options are provided so that a variety of difficult compilers |
| 84 | * can be used. Some are fixed at build time (e.g. PNG_API_RULE |
| 85 | * below) but still have compiler specific implementations, others |
| 86 | * may be changed on a per-file basis when compiling against libpng. |
Glenn Randers-Pehrson | 86dc981 | 2006-05-10 07:27:44 -0500 | [diff] [blame] | 87 | */ |
Glenn Randers-Pehrson | a451725 | 2010-12-06 08:54:55 -0600 | [diff] [blame] | 88 | |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 89 | /* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect |
| 90 | * against legacy (pre ISOC90) compilers that did not understand function |
| 91 | * prototypes. It is not required for modern C compilers. |
Glenn Randers-Pehrson | a4d54bd | 2000-07-14 08:15:12 -0500 | [diff] [blame] | 92 | */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 93 | #ifndef PNGARG |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 94 | # define PNGARG(arglist) arglist |
| 95 | #endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 96 | |
| 97 | /* Function calling conventions. |
| 98 | * ============================= |
| 99 | * Normally it is not necessary to specify to the compiler how to call |
| 100 | * a function - it just does it - however on x86 systems derived from |
| 101 | * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems |
| 102 | * and some others) there are multiple ways to call a function and the |
| 103 | * default can be changed on the compiler command line. For this reason |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 104 | * libpng specifies the calling convention of every exported function and |
| 105 | * every function called via a user supplied function pointer. This is |
| 106 | * done in this file by defining the following macros: |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 107 | * |
| 108 | * PNGAPI Calling convention for exported functions. |
| 109 | * PNGCBAPI Calling convention for user provided (callback) functions. |
| 110 | * PNGCAPI Calling convention used by the ANSI-C library (required |
| 111 | * for longjmp callbacks and sometimes used internally to |
| 112 | * specify the calling convention for zlib). |
| 113 | * |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 114 | * These macros should never be overridden. If it is necessary to |
| 115 | * change calling convention in a private build this can be done |
| 116 | * by setting PNG_API_RULE (which defaults to 0) to one of the values |
| 117 | * below to select the correct 'API' variants. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 118 | * |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 119 | * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. |
| 120 | * This is correct in every known environment. |
| 121 | * PNG_API_RULE=1 Use the operating system convention for PNGAPI and |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 122 | * the 'C' calling convention (from PNGCAPI) for |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 123 | * callbacks (PNGCBAPI). This is no longer required |
| 124 | * in any known environment - if it has to be used |
| 125 | * please post an explanation of the problem to the |
| 126 | * libpng mailing list. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 127 | * |
| 128 | * These cases only differ if the operating system does not use the C |
| 129 | * calling convention, at present this just means the above cases |
Unknown | f23b41d | 2017-11-03 00:52:06 -0400 | [diff] [blame] | 130 | * (x86 DOS/Windows systems) and, even then, this does not apply to |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 131 | * Cygwin running on those systems. |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 132 | * |
Glenn Randers-Pehrson | 98b4f00 | 2010-04-16 22:30:26 -0500 | [diff] [blame] | 133 | * Note that the value must be defined in pnglibconf.h so that what |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 134 | * the application uses to call the library matches the conventions |
| 135 | * set when building the library. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 136 | */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 137 | |
| 138 | /* Symbol export |
| 139 | * ============= |
| 140 | * When building a shared library it is almost always necessary to tell |
| 141 | * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' |
| 142 | * is used to mark the symbols. On some systems these symbols can be |
| 143 | * extracted at link time and need no special processing by the compiler, |
| 144 | * on other systems the symbols are flagged by the compiler and just |
| 145 | * the declaration requires a special tag applied (unfortunately) in a |
| 146 | * compiler dependent way. Some systems can do either. |
| 147 | * |
| 148 | * A small number of older systems also require a symbol from a DLL to |
| 149 | * be flagged to the program that calls it. This is a problem because |
| 150 | * we do not know in the header file included by application code that |
| 151 | * the symbol will come from a shared library, as opposed to a statically |
| 152 | * linked one. For this reason the application must tell us by setting |
| 153 | * the magic flag PNG_USE_DLL to turn on the special processing before |
| 154 | * it includes png.h. |
Glenn Randers-Pehrson | 821b710 | 2010-06-24 16:16:32 -0500 | [diff] [blame] | 155 | * |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 156 | * Four additional macros are used to make this happen: |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 157 | * |
| 158 | * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from |
| 159 | * the build or imported if PNG_USE_DLL is set - compiler |
| 160 | * and system specific. |
| 161 | * |
| 162 | * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to |
| 163 | * 'type', compiler specific. |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 164 | * |
| 165 | * PNG_DLL_EXPORT Set to the magic to use during a libpng build to |
John Bowler | 7b97965 | 2011-08-16 22:36:43 -0500 | [diff] [blame] | 166 | * make a symbol exported from the DLL. Not used in the |
| 167 | * public header files; see pngpriv.h for how it is used |
| 168 | * in the libpng build. |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 169 | * |
| 170 | * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come |
| 171 | * from a DLL - used to define PNG_IMPEXP when |
| 172 | * PNG_USE_DLL is set. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 173 | */ |
| 174 | |
| 175 | /* System specific discovery. |
| 176 | * ========================== |
| 177 | * This code is used at build time to find PNG_IMPEXP, the API settings |
| 178 | * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 179 | * import processing is possible. On Windows systems it also sets |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 180 | * compiler-specific macros to the values required to change the calling |
| 181 | * conventions of the various functions. |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 182 | */ |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 183 | #if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ |
| 184 | defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) |
| 185 | /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or |
| 186 | * MinGW on any architecture currently supported by Windows. Also includes |
| 187 | * Watcom builds but these need special treatment because they are not |
| 188 | * compatible with GCC or Visual C because of different calling conventions. |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 189 | */ |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 190 | # if PNG_API_RULE == 2 |
Glenn Randers-Pehrson | 192e92d | 2016-07-13 14:43:42 -0500 | [diff] [blame] | 191 | /* If this line results in an error, either because __watcall is not |
| 192 | * understood or because of a redefine just below you cannot use *this* |
| 193 | * build of the library with the compiler you are using. *This* build was |
| 194 | * build using Watcom and applications must also be built using Watcom! |
| 195 | */ |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 196 | # define PNGCAPI __watcall |
| 197 | # endif |
| 198 | |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 199 | # if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 200 | # define PNGCAPI __cdecl |
| 201 | # if PNG_API_RULE == 1 |
Glenn Randers-Pehrson | 192e92d | 2016-07-13 14:43:42 -0500 | [diff] [blame] | 202 | /* If this line results in an error __stdcall is not understood and |
| 203 | * PNG_API_RULE should not have been set to '1'. |
| 204 | */ |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 205 | # define PNGAPI __stdcall |
| 206 | # endif |
| 207 | # else |
Glenn Randers-Pehrson | 192e92d | 2016-07-13 14:43:42 -0500 | [diff] [blame] | 208 | /* An older compiler, or one not detected (erroneously) above, |
| 209 | * if necessary override on the command line to get the correct |
| 210 | * variants for the compiler. |
| 211 | */ |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 212 | # ifndef PNGCAPI |
| 213 | # define PNGCAPI _cdecl |
| 214 | # endif |
| 215 | # if PNG_API_RULE == 1 && !defined(PNGAPI) |
| 216 | # define PNGAPI _stdcall |
| 217 | # endif |
| 218 | # endif /* compiler/api */ |
John Bowler | 18dd07e | 2013-06-08 13:07:13 -0500 | [diff] [blame] | 219 | |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 220 | /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 221 | |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 222 | # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 223 | # error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 224 | # endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 225 | |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 226 | # if (defined(_MSC_VER) && _MSC_VER < 800) ||\ |
| 227 | (defined(__BORLANDC__) && __BORLANDC__ < 0x500) |
Glenn Randers-Pehrson | 192e92d | 2016-07-13 14:43:42 -0500 | [diff] [blame] | 228 | /* older Borland and MSC |
| 229 | * compilers used '__export' and required this to be after |
| 230 | * the type. |
| 231 | */ |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 232 | # ifndef PNG_EXPORT_TYPE |
| 233 | # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP |
| 234 | # endif |
| 235 | # define PNG_DLL_EXPORT __export |
| 236 | # else /* newer compiler */ |
| 237 | # define PNG_DLL_EXPORT __declspec(dllexport) |
| 238 | # ifndef PNG_DLL_IMPORT |
| 239 | # define PNG_DLL_IMPORT __declspec(dllimport) |
| 240 | # endif |
| 241 | # endif /* compiler */ |
| 242 | |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 243 | #else /* !Windows */ |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 244 | # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) |
| 245 | # define PNGAPI _System |
| 246 | # else /* !Windows/x86 && !OS/2 */ |
Glenn Randers-Pehrson | 192e92d | 2016-07-13 14:43:42 -0500 | [diff] [blame] | 247 | /* Use the defaults, or define PNG*API on the command line (but |
| 248 | * this will have to be done for every compile!) |
| 249 | */ |
Glenn Randers-Pehrson | 9ee577c | 2010-04-24 09:40:44 -0500 | [diff] [blame] | 250 | # endif /* other system, !OS/2 */ |
| 251 | #endif /* !Windows/x86 */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 252 | |
| 253 | /* Now do all the defaulting . */ |
| 254 | #ifndef PNGCAPI |
| 255 | # define PNGCAPI |
| 256 | #endif |
| 257 | #ifndef PNGCBAPI |
| 258 | # define PNGCBAPI PNGCAPI |
| 259 | #endif |
| 260 | #ifndef PNGAPI |
| 261 | # define PNGAPI PNGCAPI |
| 262 | #endif |
| 263 | |
John Bowler | 7b97965 | 2011-08-16 22:36:43 -0500 | [diff] [blame] | 264 | /* PNG_IMPEXP may be set on the compilation system command line or (if not set) |
| 265 | * then in an internal header file when building the library, otherwise (when |
| 266 | * using the library) it is set here. |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 267 | */ |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 268 | #ifndef PNG_IMPEXP |
John Bowler | 7b97965 | 2011-08-16 22:36:43 -0500 | [diff] [blame] | 269 | # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) |
Glenn Randers-Pehrson | 192e92d | 2016-07-13 14:43:42 -0500 | [diff] [blame] | 270 | /* This forces use of a DLL, disallowing static linking */ |
John Bowler | 7b97965 | 2011-08-16 22:36:43 -0500 | [diff] [blame] | 271 | # define PNG_IMPEXP PNG_DLL_IMPORT |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 272 | # endif |
| 273 | |
| 274 | # ifndef PNG_IMPEXP |
| 275 | # define PNG_IMPEXP |
| 276 | # endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 277 | #endif |
Glenn Randers-Pehrson | d00bbb2 | 2010-03-14 09:15:49 -0500 | [diff] [blame] | 278 | |
John Bowler | 9c69360 | 2011-02-12 08:58:21 -0600 | [diff] [blame] | 279 | /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat |
| 280 | * 'attributes' as a storage class - the attributes go at the start of the |
| 281 | * function definition, and attributes are always appended regardless of the |
| 282 | * compiler. This considerably simplifies these macros but may cause problems |
| 283 | * if any compilers both need function attributes and fail to handle them as |
| 284 | * a storage class (this is unlikely.) |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 285 | */ |
| 286 | #ifndef PNG_FUNCTION |
John Bowler | 9c69360 | 2011-02-12 08:58:21 -0600 | [diff] [blame] | 287 | # define PNG_FUNCTION(type, name, args, attributes) attributes type name args |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 288 | #endif |
| 289 | |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 290 | #ifndef PNG_EXPORT_TYPE |
| 291 | # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type |
| 292 | #endif |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 293 | |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 294 | /* The ordinal value is only relevant when preprocessing png.h for symbol |
Glenn Randers-Pehrson | a451725 | 2010-12-06 08:54:55 -0600 | [diff] [blame] | 295 | * table entries, so we discard it here. See the .dfn files in the |
| 296 | * scripts directory. |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 297 | */ |
Glenn Randers-Pehrson | d32a671 | 2011-03-06 16:49:10 -0600 | [diff] [blame] | 298 | |
Glenn Randers-Pehrson | b9e5e5f | 2015-07-03 16:07:54 -0500 | [diff] [blame] | 299 | #ifndef PNG_EXPORTA |
| 300 | # define PNG_EXPORTA(ordinal, type, name, args, attributes) \ |
| 301 | PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \ |
| 302 | PNG_LINKAGE_API attributes) |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 303 | #endif |
| 304 | |
John Bowler | 9c69360 | 2011-02-12 08:58:21 -0600 | [diff] [blame] | 305 | /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, |
| 306 | * so make something non-empty to satisfy the requirement: |
| 307 | */ |
| 308 | #define PNG_EMPTY /*empty list*/ |
| 309 | |
Glenn Randers-Pehrson | b9e5e5f | 2015-07-03 16:07:54 -0500 | [diff] [blame] | 310 | #define PNG_EXPORT(ordinal, type, name, args) \ |
John Bowler | 9c69360 | 2011-02-12 08:58:21 -0600 | [diff] [blame] | 311 | PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) |
Glenn Randers-Pehrson | 234e543 | 2010-12-06 20:18:51 -0600 | [diff] [blame] | 312 | |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 313 | /* Use PNG_REMOVED to comment out a removed interface. */ |
| 314 | #ifndef PNG_REMOVED |
Glenn Randers-Pehrson | 23d3970 | 2010-12-06 18:28:02 -0600 | [diff] [blame] | 315 | # define PNG_REMOVED(ordinal, type, name, args, attributes) |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 316 | #endif |
| 317 | |
| 318 | #ifndef PNG_CALLBACK |
John Bowler | 9c69360 | 2011-02-12 08:58:21 -0600 | [diff] [blame] | 319 | # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 320 | #endif |
| 321 | |
| 322 | /* Support for compiler specific function attributes. These are used |
| 323 | * so that where compiler support is available incorrect use of API |
| 324 | * functions in png.h will generate compiler warnings. |
| 325 | * |
| 326 | * Added at libpng-1.2.41. |
| 327 | */ |
| 328 | |
| 329 | #ifndef PNG_NO_PEDANTIC_WARNINGS |
Glenn Randers-Pehrson | c44253f | 2010-03-13 20:58:39 -0600 | [diff] [blame] | 330 | # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED |
| 331 | # define PNG_PEDANTIC_WARNINGS_SUPPORTED |
| 332 | # endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 333 | #endif |
| 334 | |
| 335 | #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED |
Glenn Randers-Pehrson | 882340c | 2010-03-13 21:19:51 -0600 | [diff] [blame] | 336 | /* Support for compiler specific function attributes. These are used |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 337 | * so that where compiler support is available, incorrect use of API |
Glenn Randers-Pehrson | 882340c | 2010-03-13 21:19:51 -0600 | [diff] [blame] | 338 | * functions in png.h will generate compiler warnings. Added at libpng |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 339 | * version 1.2.41. Disabling these removes the warnings but may also produce |
| 340 | * less efficient code. |
Glenn Randers-Pehrson | 882340c | 2010-03-13 21:19:51 -0600 | [diff] [blame] | 341 | */ |
Glenn Randers-Pehrson | 41694dc | 2014-06-07 22:27:44 -0500 | [diff] [blame] | 342 | # if defined(__clang__) && defined(__has_attribute) |
Glenn Randers-Pehrson | 192e92d | 2016-07-13 14:43:42 -0500 | [diff] [blame] | 343 | /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */ |
Glenn Randers-Pehrson | bda94b1 | 2014-01-13 21:16:17 -0600 | [diff] [blame] | 344 | # if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__) |
| 345 | # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) |
| 346 | # endif |
| 347 | # if !defined(PNG_NORETURN) && __has_attribute(__noreturn__) |
| 348 | # define PNG_NORETURN __attribute__((__noreturn__)) |
| 349 | # endif |
| 350 | # if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__) |
| 351 | # define PNG_ALLOCATED __attribute__((__malloc__)) |
| 352 | # endif |
| 353 | # if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__) |
| 354 | # define PNG_DEPRECATED __attribute__((__deprecated__)) |
| 355 | # endif |
| 356 | # if !defined(PNG_PRIVATE) |
Glenn Randers-Pehrson | dd6679d | 2014-02-20 06:57:57 -0600 | [diff] [blame] | 357 | # ifdef __has_extension |
| 358 | # if __has_extension(attribute_unavailable_with_message) |
| 359 | # define PNG_PRIVATE __attribute__((__unavailable__(\ |
| 360 | "This function is not exported by libpng."))) |
| 361 | # endif |
Glenn Randers-Pehrson | bda94b1 | 2014-01-13 21:16:17 -0600 | [diff] [blame] | 362 | # endif |
| 363 | # endif |
| 364 | # ifndef PNG_RESTRICT |
| 365 | # define PNG_RESTRICT __restrict |
| 366 | # endif |
| 367 | |
| 368 | # elif defined(__GNUC__) |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 369 | # ifndef PNG_USE_RESULT |
| 370 | # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) |
| 371 | # endif |
| 372 | # ifndef PNG_NORETURN |
| 373 | # define PNG_NORETURN __attribute__((__noreturn__)) |
| 374 | # endif |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 375 | # if __GNUC__ >= 3 |
| 376 | # ifndef PNG_ALLOCATED |
| 377 | # define PNG_ALLOCATED __attribute__((__malloc__)) |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 378 | # endif |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 379 | # ifndef PNG_DEPRECATED |
| 380 | # define PNG_DEPRECATED __attribute__((__deprecated__)) |
| 381 | # endif |
| 382 | # ifndef PNG_PRIVATE |
| 383 | # if 0 /* Doesn't work so we use deprecated instead*/ |
| 384 | # define PNG_PRIVATE \ |
| 385 | __attribute__((warning("This function is not exported by libpng."))) |
| 386 | # else |
| 387 | # define PNG_PRIVATE \ |
| 388 | __attribute__((__deprecated__)) |
| 389 | # endif |
| 390 | # endif |
Glenn Randers-Pehrson | bda94b1 | 2014-01-13 21:16:17 -0600 | [diff] [blame] | 391 | # if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 392 | # ifndef PNG_RESTRICT |
| 393 | # define PNG_RESTRICT __restrict |
| 394 | # endif |
Glenn Randers-Pehrson | efaaad7 | 2014-01-13 21:43:51 -0600 | [diff] [blame] | 395 | # endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */ |
Glenn Randers-Pehrson | bda94b1 | 2014-01-13 21:16:17 -0600 | [diff] [blame] | 396 | # endif /* __GNUC__ >= 3 */ |
Glenn Randers-Pehrson | d32a671 | 2011-03-06 16:49:10 -0600 | [diff] [blame] | 397 | |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 398 | # elif defined(_MSC_VER) && (_MSC_VER >= 1300) |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 399 | # ifndef PNG_USE_RESULT |
Glenn Randers-Pehrson | c36bb79 | 2011-02-12 09:49:07 -0600 | [diff] [blame] | 400 | # define PNG_USE_RESULT /* not supported */ |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 401 | # endif |
| 402 | # ifndef PNG_NORETURN |
| 403 | # define PNG_NORETURN __declspec(noreturn) |
| 404 | # endif |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 405 | # ifndef PNG_ALLOCATED |
Glenn Randers-Pehrson | 1f0eaa0 | 2011-12-01 21:45:34 -0600 | [diff] [blame] | 406 | # if (_MSC_VER >= 1400) |
Glenn Randers-Pehrson | 4fca255 | 2011-06-27 12:01:01 -0500 | [diff] [blame] | 407 | # define PNG_ALLOCATED __declspec(restrict) |
| 408 | # endif |
Glenn Randers-Pehrson | 77396b6 | 2010-08-02 08:00:10 -0500 | [diff] [blame] | 409 | # endif |
John Bowler | 7b97965 | 2011-08-16 22:36:43 -0500 | [diff] [blame] | 410 | # ifndef PNG_DEPRECATED |
| 411 | # define PNG_DEPRECATED __declspec(deprecated) |
| 412 | # endif |
| 413 | # ifndef PNG_PRIVATE |
| 414 | # define PNG_PRIVATE __declspec(deprecated) |
| 415 | # endif |
John Bowler | 5d56786 | 2011-12-24 09:12:00 -0600 | [diff] [blame] | 416 | # ifndef PNG_RESTRICT |
| 417 | # if (_MSC_VER >= 1400) |
| 418 | # define PNG_RESTRICT __restrict |
| 419 | # endif |
| 420 | # endif |
| 421 | |
| 422 | # elif defined(__WATCOMC__) |
| 423 | # ifndef PNG_RESTRICT |
| 424 | # define PNG_RESTRICT __restrict |
| 425 | # endif |
Glenn Randers-Pehrson | bda94b1 | 2014-01-13 21:16:17 -0600 | [diff] [blame] | 426 | # endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 427 | #endif /* PNG_PEDANTIC_WARNINGS */ |
| 428 | |
| 429 | #ifndef PNG_DEPRECATED |
| 430 | # define PNG_DEPRECATED /* Use of this function is deprecated */ |
| 431 | #endif |
| 432 | #ifndef PNG_USE_RESULT |
| 433 | # define PNG_USE_RESULT /* The result of this function must be checked */ |
| 434 | #endif |
| 435 | #ifndef PNG_NORETURN |
| 436 | # define PNG_NORETURN /* This function does not return */ |
| 437 | #endif |
| 438 | #ifndef PNG_ALLOCATED |
| 439 | # define PNG_ALLOCATED /* The result of the function is new memory */ |
| 440 | #endif |
Glenn Randers-Pehrson | d7da8bb | 2010-03-13 20:30:10 -0600 | [diff] [blame] | 441 | #ifndef PNG_PRIVATE |
| 442 | # define PNG_PRIVATE /* This is a private libpng function */ |
Glenn Randers-Pehrson | a4d54bd | 2000-07-14 08:15:12 -0500 | [diff] [blame] | 443 | #endif |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 444 | #ifndef PNG_RESTRICT |
| 445 | # define PNG_RESTRICT /* The C99 "restrict" feature */ |
| 446 | #endif |
Glenn Randers-Pehrson | bda94b1 | 2014-01-13 21:16:17 -0600 | [diff] [blame] | 447 | |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 448 | #ifndef PNG_FP_EXPORT /* A floating point API. */ |
| 449 | # ifdef PNG_FLOATING_POINT_SUPPORTED |
Glenn Randers-Pehrson | 23d3970 | 2010-12-06 18:28:02 -0600 | [diff] [blame] | 450 | # define PNG_FP_EXPORT(ordinal, type, name, args)\ |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 451 | PNG_EXPORT(ordinal, type, name, args); |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 452 | # else /* No floating point APIs */ |
Glenn Randers-Pehrson | 23d3970 | 2010-12-06 18:28:02 -0600 | [diff] [blame] | 453 | # define PNG_FP_EXPORT(ordinal, type, name, args) |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 454 | # endif |
| 455 | #endif |
| 456 | #ifndef PNG_FIXED_EXPORT /* A fixed point API. */ |
| 457 | # ifdef PNG_FIXED_POINT_SUPPORTED |
Glenn Randers-Pehrson | 23d3970 | 2010-12-06 18:28:02 -0600 | [diff] [blame] | 458 | # define PNG_FIXED_EXPORT(ordinal, type, name, args)\ |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 459 | PNG_EXPORT(ordinal, type, name, args); |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 460 | # else /* No fixed point APIs */ |
Glenn Randers-Pehrson | 23d3970 | 2010-12-06 18:28:02 -0600 | [diff] [blame] | 461 | # define PNG_FIXED_EXPORT(ordinal, type, name, args) |
Glenn Randers-Pehrson | 31aee0d | 2010-07-29 17:39:14 -0500 | [diff] [blame] | 462 | # endif |
| 463 | #endif |
Glenn Randers-Pehrson | a4d54bd | 2000-07-14 08:15:12 -0500 | [diff] [blame] | 464 | |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 465 | #ifndef PNG_BUILDING_SYMBOL_TABLE |
| 466 | /* Some typedefs to get us started. These should be safe on most of the common |
| 467 | * platforms. |
Glenn Randers-Pehrson | 7253144 | 2010-04-17 08:17:51 -0500 | [diff] [blame] | 468 | * |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 469 | * png_uint_32 and png_int_32 may, currently, be larger than required to hold a |
| 470 | * 32-bit value however this is not normally advisable. |
| 471 | * |
| 472 | * png_uint_16 and png_int_16 should always be two bytes in size - this is |
| 473 | * verified at library build time. |
| 474 | * |
| 475 | * png_byte must always be one byte in size. |
| 476 | * |
| 477 | * The checks below use constants from limits.h, as defined by the ISOC90 |
| 478 | * standard. |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 479 | */ |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 480 | #if CHAR_BIT == 8 && UCHAR_MAX == 255 |
| 481 | typedef unsigned char png_byte; |
| 482 | #else |
Glenn Randers-Pehrson | 8b83ff3 | 2015-08-13 20:57:18 -0500 | [diff] [blame] | 483 | # error "libpng requires 8-bit bytes" |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 484 | #endif |
| 485 | |
| 486 | #if INT_MIN == -32768 && INT_MAX == 32767 |
| 487 | typedef int png_int_16; |
| 488 | #elif SHRT_MIN == -32768 && SHRT_MAX == 32767 |
| 489 | typedef short png_int_16; |
| 490 | #else |
Glenn Randers-Pehrson | 8b83ff3 | 2015-08-13 20:57:18 -0500 | [diff] [blame] | 491 | # error "libpng requires a signed 16-bit type" |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 492 | #endif |
| 493 | |
| 494 | #if UINT_MAX == 65535 |
| 495 | typedef unsigned int png_uint_16; |
| 496 | #elif USHRT_MAX == 65535 |
| 497 | typedef unsigned short png_uint_16; |
| 498 | #else |
Glenn Randers-Pehrson | 8b83ff3 | 2015-08-13 20:57:18 -0500 | [diff] [blame] | 499 | # error "libpng requires an unsigned 16-bit type" |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 500 | #endif |
| 501 | |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 502 | #if INT_MIN < -2147483646 && INT_MAX > 2147483646 |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 503 | typedef int png_int_32; |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 504 | #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 505 | typedef long int png_int_32; |
| 506 | #else |
Glenn Randers-Pehrson | 8b83ff3 | 2015-08-13 20:57:18 -0500 | [diff] [blame] | 507 | # error "libpng requires a signed 32-bit (or more) type" |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 508 | #endif |
| 509 | |
Glenn Randers-Pehrson | 7d7694a | 2016-10-05 09:23:08 -0500 | [diff] [blame] | 510 | #if UINT_MAX > 4294967294U |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 511 | typedef unsigned int png_uint_32; |
Glenn Randers-Pehrson | 7d7694a | 2016-10-05 09:23:08 -0500 | [diff] [blame] | 512 | #elif ULONG_MAX > 4294967294U |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 513 | typedef unsigned long int png_uint_32; |
| 514 | #else |
Glenn Randers-Pehrson | 8b83ff3 | 2015-08-13 20:57:18 -0500 | [diff] [blame] | 515 | # error "libpng requires an unsigned 32-bit (or more) type" |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 516 | #endif |
| 517 | |
Cosmin Truta | a74aa9a | 2018-06-17 22:37:44 -0400 | [diff] [blame] | 518 | /* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t. |
| 519 | * From 1.6.0 onwards, an ISO C90 compiler, as well as a standard-compliant |
| 520 | * behavior of sizeof and ptrdiff_t are required. |
| 521 | * The legacy typedefs are provided here for backwards compatibility. |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 522 | */ |
| 523 | typedef size_t png_size_t; |
| 524 | typedef ptrdiff_t png_ptrdiff_t; |
| 525 | |
| 526 | /* libpng needs to know the maximum value of 'size_t' and this controls the |
| 527 | * definition of png_alloc_size_t, below. This maximum value of size_t limits |
| 528 | * but does not control the maximum allocations the library makes - there is |
| 529 | * direct application control of this through png_set_user_limits(). |
| 530 | */ |
| 531 | #ifndef PNG_SMALL_SIZE_T |
| 532 | /* Compiler specific tests for systems where size_t is known to be less than |
| 533 | * 32 bits (some of these systems may no longer work because of the lack of |
| 534 | * 'far' support; see above.) |
| 535 | */ |
| 536 | # if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ |
| 537 | (defined(_MSC_VER) && defined(MAXSEG_64K)) |
| 538 | # define PNG_SMALL_SIZE_T |
Glenn Randers-Pehrson | 28d4aae | 2009-11-13 16:29:45 -0600 | [diff] [blame] | 539 | # endif |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 540 | #endif |
| 541 | |
Cosmin Truta | a74aa9a | 2018-06-17 22:37:44 -0400 | [diff] [blame] | 542 | /* png_alloc_size_t is guaranteed to be no smaller than size_t, and no smaller |
| 543 | * than png_uint_32. Casts from size_t or png_uint_32 to png_alloc_size_t are |
| 544 | * not necessary; in fact, it is recommended not to use them at all, so that |
| 545 | * the compiler can complain when something turns out to be problematic. |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 546 | * |
Cosmin Truta | a74aa9a | 2018-06-17 22:37:44 -0400 | [diff] [blame] | 547 | * Casts in the other direction (from png_alloc_size_t to size_t or |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 548 | * png_uint_32) should be explicitly applied; however, we do not expect to |
| 549 | * encounter practical situations that require such conversions. |
| 550 | * |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 551 | * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 552 | * 4294967295 - i.e. less than the maximum value of png_uint_32. |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 553 | */ |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 554 | #ifdef PNG_SMALL_SIZE_T |
| 555 | typedef png_uint_32 png_alloc_size_t; |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 556 | #else |
Cosmin Truta | a74aa9a | 2018-06-17 22:37:44 -0400 | [diff] [blame] | 557 | typedef size_t png_alloc_size_t; |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 558 | #endif |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 559 | |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 560 | /* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler |
| 561 | * implementations of Intel CPU specific support of user-mode segmented address |
| 562 | * spaces, where 16-bit pointers address more than 65536 bytes of memory using |
| 563 | * separate 'segment' registers. The implementation requires two different |
| 564 | * types of pointer (only one of which includes the segment value.) |
| 565 | * |
| 566 | * If required this support is available in version 1.2 of libpng and may be |
| 567 | * available in versions through 1.5, although the correctness of the code has |
| 568 | * not been verified recently. |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 569 | */ |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 570 | |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 571 | /* Typedef for floating-point numbers that are converted to fixed-point with a |
| 572 | * multiple of 100,000, e.g., gamma |
Glenn Randers-Pehrson | e8b1aa0 | 2010-03-06 11:39:29 -0600 | [diff] [blame] | 573 | */ |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 574 | typedef png_int_32 png_fixed_point; |
| 575 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 576 | /* Add typedefs for pointers */ |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 577 | typedef void * png_voidp; |
| 578 | typedef const void * png_const_voidp; |
| 579 | typedef png_byte * png_bytep; |
| 580 | typedef const png_byte * png_const_bytep; |
| 581 | typedef png_uint_32 * png_uint_32p; |
| 582 | typedef const png_uint_32 * png_const_uint_32p; |
| 583 | typedef png_int_32 * png_int_32p; |
| 584 | typedef const png_int_32 * png_const_int_32p; |
| 585 | typedef png_uint_16 * png_uint_16p; |
| 586 | typedef const png_uint_16 * png_const_uint_16p; |
| 587 | typedef png_int_16 * png_int_16p; |
| 588 | typedef const png_int_16 * png_const_int_16p; |
| 589 | typedef char * png_charp; |
| 590 | typedef const char * png_const_charp; |
| 591 | typedef png_fixed_point * png_fixed_point_p; |
| 592 | typedef const png_fixed_point * png_const_fixed_point_p; |
Cosmin Truta | a74aa9a | 2018-06-17 22:37:44 -0400 | [diff] [blame] | 593 | typedef size_t * png_size_tp; |
| 594 | typedef const size_t * png_const_size_tp; |
Glenn Randers-Pehrson | be9de0f | 2001-01-22 08:52:16 -0600 | [diff] [blame] | 595 | |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 596 | #ifdef PNG_STDIO_SUPPORTED |
Glenn Randers-Pehrson | 882340c | 2010-03-13 21:19:51 -0600 | [diff] [blame] | 597 | typedef FILE * png_FILE_p; |
Glenn Randers-Pehrson | be9de0f | 2001-01-22 08:52:16 -0600 | [diff] [blame] | 598 | #endif |
| 599 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 600 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 601 | typedef double * png_doublep; |
| 602 | typedef const double * png_const_doublep; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 603 | #endif |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 604 | |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 605 | /* Pointers to pointers; i.e. arrays */ |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 606 | typedef png_byte * * png_bytepp; |
| 607 | typedef png_uint_32 * * png_uint_32pp; |
| 608 | typedef png_int_32 * * png_int_32pp; |
| 609 | typedef png_uint_16 * * png_uint_16pp; |
| 610 | typedef png_int_16 * * png_int_16pp; |
| 611 | typedef const char * * png_const_charpp; |
| 612 | typedef char * * png_charpp; |
| 613 | typedef png_fixed_point * * png_fixed_point_pp; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 614 | #ifdef PNG_FLOATING_POINT_SUPPORTED |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 615 | typedef double * * png_doublepp; |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 616 | #endif |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 617 | |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 618 | /* Pointers to pointers to pointers; i.e., pointer to array */ |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 619 | typedef char * * * png_charppp; |
Guy Schalnat | 6d76471 | 1995-12-19 03:22:19 -0600 | [diff] [blame] | 620 | |
John Bowler | baeb6d1 | 2011-11-26 18:21:02 -0600 | [diff] [blame] | 621 | #endif /* PNG_BUILDING_SYMBOL_TABLE */ |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 622 | |
Guy Schalnat | 51f0eb4 | 1995-09-26 05:22:39 -0500 | [diff] [blame] | 623 | #endif /* PNGCONF_H */ |