/* pngconf.h - machine-configurable file for libpng1*2* libpng version 1.6.483*4* Copyright (c) 2018-2025 Cosmin Truta5* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson6* Copyright (c) 1996-1997 Andreas Dilger7* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.8*9* This code is released under the libpng license.10* For conditions of distribution and use, see the disclaimer11* and license in png.h12*13* Any machine specific code is near the front of this file, so if you14* are configuring libpng for a machine, you may want to read the section15* starting here down to where it starts to typedef png_color, png_text,16* and png_info.17*/1819#ifndef PNGCONF_H20#define PNGCONF_H2122#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */2324/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C25* compiler for correct compilation. The following header files are required by26* the standard. If your compiler doesn't provide these header files, or they27* do not match the standard, you will need to provide/improve them.28*/29#include <limits.h>30#include <stddef.h>3132/* Library header files. These header files are all defined by ISOC90; libpng33* expects conformant implementations, however, an ISOC90 conformant system need34* not provide these header files if the functionality cannot be implemented.35* In this case it will be necessary to disable the relevant parts of libpng in36* the build of pnglibconf.h.37*38* Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not39* include this unnecessary header file.40*/4142#ifdef PNG_STDIO_SUPPORTED43/* Required for the definition of FILE: */44# include <stdio.h>45#endif4647#ifdef PNG_SETJMP_SUPPORTED48/* Required for the definition of jmp_buf and the declaration of longjmp: */49# include <setjmp.h>50#endif5152#ifdef PNG_CONVERT_tIME_SUPPORTED53/* Required for struct tm: */54# include <time.h>55#endif5657#endif /* PNG_BUILDING_SYMBOL_TABLE */5859/* Prior to 1.6.0, it was possible to turn off 'const' in declarations,60* using PNG_NO_CONST. This is no longer supported.61*/62#define PNG_CONST const /* backward compatibility only */6364/* This controls optimization of the reading of 16-bit and 32-bit65* values from PNG files. It can be set on a per-app-file basis: it66* just changes whether a macro is used when the function is called.67* The library builder sets the default; if read functions are not68* built into the library the macro implementation is forced on.69*/70#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED71# define PNG_USE_READ_MACROS72#endif73#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)74# if PNG_DEFAULT_READ_MACROS75# define PNG_USE_READ_MACROS76# endif77#endif7879/* COMPILER SPECIFIC OPTIONS.80*81* These options are provided so that a variety of difficult compilers82* can be used. Some are fixed at build time (e.g. PNG_API_RULE83* below) but still have compiler specific implementations, others84* may be changed on a per-file basis when compiling against libpng.85*/8687/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect88* against legacy (pre ISOC90) compilers that did not understand function89* prototypes. [Deprecated.]90*/91#ifndef PNGARG92# define PNGARG(arglist) arglist93#endif9495/* Function calling conventions.96* =============================97* Normally it is not necessary to specify to the compiler how to call98* a function - it just does it - however on x86 systems derived from99* Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems100* and some others) there are multiple ways to call a function and the101* default can be changed on the compiler command line. For this reason102* libpng specifies the calling convention of every exported function and103* every function called via a user supplied function pointer. This is104* done in this file by defining the following macros:105*106* PNGAPI Calling convention for exported functions.107* PNGCBAPI Calling convention for user provided (callback) functions.108* PNGCAPI Calling convention used by the ANSI-C library (required109* for longjmp callbacks and sometimes used internally to110* specify the calling convention for zlib).111*112* These macros should never be overridden. If it is necessary to113* change calling convention in a private build this can be done114* by setting PNG_API_RULE (which defaults to 0) to one of the values115* below to select the correct 'API' variants.116*117* PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.118* This is correct in every known environment.119* PNG_API_RULE=1 Use the operating system convention for PNGAPI and120* the 'C' calling convention (from PNGCAPI) for121* callbacks (PNGCBAPI). This is no longer required122* in any known environment - if it has to be used123* please post an explanation of the problem to the124* libpng mailing list.125*126* These cases only differ if the operating system does not use the C127* calling convention, at present this just means the above cases128* (x86 DOS/Windows systems) and, even then, this does not apply to129* Cygwin running on those systems.130*131* Note that the value must be defined in pnglibconf.h so that what132* the application uses to call the library matches the conventions133* set when building the library.134*/135136/* Symbol export137* =============138* When building a shared library it is almost always necessary to tell139* the compiler which symbols to export. The png.h macro 'PNG_EXPORT'140* is used to mark the symbols. On some systems these symbols can be141* extracted at link time and need no special processing by the compiler,142* on other systems the symbols are flagged by the compiler and just143* the declaration requires a special tag applied (unfortunately) in a144* compiler dependent way. Some systems can do either.145*146* A small number of older systems also require a symbol from a DLL to147* be flagged to the program that calls it. This is a problem because148* we do not know in the header file included by application code that149* the symbol will come from a shared library, as opposed to a statically150* linked one. For this reason the application must tell us by setting151* the magic flag PNG_USE_DLL to turn on the special processing before152* it includes png.h.153*154* Four additional macros are used to make this happen:155*156* PNG_IMPEXP The magic (if any) to cause a symbol to be exported from157* the build or imported if PNG_USE_DLL is set - compiler158* and system specific.159*160* PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to161* 'type', compiler specific.162*163* PNG_DLL_EXPORT Set to the magic to use during a libpng build to164* make a symbol exported from the DLL. Not used in the165* public header files; see pngpriv.h for how it is used166* in the libpng build.167*168* PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come169* from a DLL - used to define PNG_IMPEXP when170* PNG_USE_DLL is set.171*/172173/* System specific discovery.174* ==========================175* This code is used at build time to find PNG_IMPEXP, the API settings176* and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL177* import processing is possible. On Windows systems it also sets178* compiler-specific macros to the values required to change the calling179* conventions of the various functions.180*/181#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || \182defined(__CYGWIN__)183/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or184* MinGW on any architecture currently supported by Windows. Also includes185* Watcom builds but these need special treatment because they are not186* compatible with GCC or Visual C because of different calling conventions.187*/188# if PNG_API_RULE == 2189/* If this line results in an error, either because __watcall is not190* understood or because of a redefine just below you cannot use *this*191* build of the library with the compiler you are using. *This* build was192* build using Watcom and applications must also be built using Watcom!193*/194# define PNGCAPI __watcall195# endif196197# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))198# define PNGCAPI __cdecl199# if PNG_API_RULE == 1200/* If this line results in an error __stdcall is not understood and201* PNG_API_RULE should not have been set to '1'.202*/203# define PNGAPI __stdcall204# endif205# else206/* An older compiler, or one not detected (erroneously) above,207* if necessary override on the command line to get the correct208* variants for the compiler.209*/210# ifndef PNGCAPI211# define PNGCAPI _cdecl212# endif213# if PNG_API_RULE == 1 && !defined(PNGAPI)214# define PNGAPI _stdcall215# endif216# endif /* compiler/api */217218/* NOTE: PNGCBAPI always defaults to PNGCAPI. */219220# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)221# error PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed222# endif223224# define PNG_DLL_EXPORT __declspec(dllexport)225# ifndef PNG_DLL_IMPORT226# define PNG_DLL_IMPORT __declspec(dllimport)227# endif228229#else /* !Windows */230# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)231# define PNGAPI _System232# else /* !Windows/x86 && !OS/2 */233/* Use the defaults, or define PNG*API on the command line (but234* this will have to be done for every compile!)235*/236# endif /* other system, !OS/2 */237#endif /* !Windows/x86 */238239/* Now do all the defaulting . */240#ifndef PNGCAPI241# define PNGCAPI242#endif243#ifndef PNGCBAPI244# define PNGCBAPI PNGCAPI245#endif246#ifndef PNGAPI247# define PNGAPI PNGCAPI248#endif249250/* PNG_IMPEXP may be set on the compilation system command line or (if not set)251* then in an internal header file when building the library, otherwise (when252* using the library) it is set here.253*/254#ifndef PNG_IMPEXP255# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)256/* This forces use of a DLL, disallowing static linking */257# define PNG_IMPEXP PNG_DLL_IMPORT258# endif259260# ifndef PNG_IMPEXP261# define PNG_IMPEXP262# endif263#endif264265/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat266* 'attributes' as a storage class - the attributes go at the start of the267* function definition, and attributes are always appended regardless of the268* compiler. This considerably simplifies these macros but may cause problems269* if any compilers both need function attributes and fail to handle them as270* a storage class (this is unlikely.)271*/272#ifndef PNG_FUNCTION273# define PNG_FUNCTION(type, name, args, attributes) attributes type name args274#endif275276#ifndef PNG_EXPORT_TYPE277# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type278#endif279280/* The ordinal value is only relevant when preprocessing png.h for symbol281* table entries, so we discard it here. See the .dfn files in the282* scripts directory.283*/284285#ifndef PNG_EXPORTA286# define PNG_EXPORTA(ordinal, type, name, args, attributes) \287PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), args, \288PNG_LINKAGE_API attributes)289#endif290291/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,292* so make something non-empty to satisfy the requirement:293*/294#define PNG_EMPTY /*empty list*/295296#define PNG_EXPORT(ordinal, type, name, args) \297PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)298299/* Use PNG_REMOVED to comment out a removed interface. */300#ifndef PNG_REMOVED301# define PNG_REMOVED(ordinal, type, name, args, attributes)302#endif303304#ifndef PNG_CALLBACK305# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) args306#endif307308/* Support for compiler specific function attributes. These are used309* so that where compiler support is available incorrect use of API310* functions in png.h will generate compiler warnings.311*312* Added at libpng-1.2.41.313*/314315#ifndef PNG_NO_PEDANTIC_WARNINGS316# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED317# define PNG_PEDANTIC_WARNINGS_SUPPORTED318# endif319#endif320321#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED322/* Support for compiler specific function attributes. These are used323* so that where compiler support is available, incorrect use of API324* functions in png.h will generate compiler warnings. Added at libpng325* version 1.2.41. Disabling these removes the warnings but may also produce326* less efficient code.327*/328# if defined(__clang__) && defined(__has_attribute)329/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */330# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)331# define PNG_USE_RESULT __attribute__((__warn_unused_result__))332# endif333# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)334# define PNG_NORETURN __attribute__((__noreturn__))335# endif336# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)337# define PNG_ALLOCATED __attribute__((__malloc__))338# endif339# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)340# define PNG_DEPRECATED __attribute__((__deprecated__))341# endif342# if !defined(PNG_PRIVATE)343# ifdef __has_extension344# if __has_extension(attribute_unavailable_with_message)345# define PNG_PRIVATE __attribute__((__unavailable__(\346"This function is not exported by libpng.")))347# endif348# endif349# endif350# ifndef PNG_RESTRICT351# define PNG_RESTRICT __restrict352# endif353354# elif defined(__GNUC__)355# ifndef PNG_USE_RESULT356# define PNG_USE_RESULT __attribute__((__warn_unused_result__))357# endif358# ifndef PNG_NORETURN359# define PNG_NORETURN __attribute__((__noreturn__))360# endif361# if __GNUC__ >= 3362# ifndef PNG_ALLOCATED363# define PNG_ALLOCATED __attribute__((__malloc__))364# endif365# ifndef PNG_DEPRECATED366# define PNG_DEPRECATED __attribute__((__deprecated__))367# endif368# ifndef PNG_PRIVATE369# if 0 /* Doesn't work so we use deprecated instead*/370# define PNG_PRIVATE \371__attribute__((warning("This function is not exported by libpng.")))372# else373# define PNG_PRIVATE \374__attribute__((__deprecated__))375# endif376# endif377# if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))378# ifndef PNG_RESTRICT379# define PNG_RESTRICT __restrict380# endif381# endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */382# endif /* __GNUC__ >= 3 */383384# elif defined(_MSC_VER) && (_MSC_VER >= 1300)385# ifndef PNG_USE_RESULT386# define PNG_USE_RESULT /* not supported */387# endif388# ifndef PNG_NORETURN389# define PNG_NORETURN __declspec(noreturn)390# endif391# ifndef PNG_ALLOCATED392# if (_MSC_VER >= 1400)393# define PNG_ALLOCATED __declspec(restrict)394# endif395# endif396# ifndef PNG_DEPRECATED397# define PNG_DEPRECATED __declspec(deprecated)398# endif399# ifndef PNG_PRIVATE400# define PNG_PRIVATE __declspec(deprecated)401# endif402# ifndef PNG_RESTRICT403# if (_MSC_VER >= 1400)404# define PNG_RESTRICT __restrict405# endif406# endif407408# elif defined(__WATCOMC__)409# ifndef PNG_RESTRICT410# define PNG_RESTRICT __restrict411# endif412# endif413#endif /* PNG_PEDANTIC_WARNINGS */414415#ifndef PNG_DEPRECATED416# define PNG_DEPRECATED /* Use of this function is deprecated */417#endif418#ifndef PNG_USE_RESULT419# define PNG_USE_RESULT /* The result of this function must be checked */420#endif421#ifndef PNG_NORETURN422# define PNG_NORETURN /* This function does not return */423#endif424#ifndef PNG_ALLOCATED425# define PNG_ALLOCATED /* The result of the function is new memory */426#endif427#ifndef PNG_PRIVATE428# define PNG_PRIVATE /* This is a private libpng function */429#endif430#ifndef PNG_RESTRICT431# define PNG_RESTRICT /* The C99 "restrict" feature */432#endif433434#ifndef PNG_FP_EXPORT /* A floating point API. */435# ifdef PNG_FLOATING_POINT_SUPPORTED436# define PNG_FP_EXPORT(ordinal, type, name, args)\437PNG_EXPORT(ordinal, type, name, args);438# else /* No floating point APIs */439# define PNG_FP_EXPORT(ordinal, type, name, args)440# endif441#endif442#ifndef PNG_FIXED_EXPORT /* A fixed point API. */443# ifdef PNG_FIXED_POINT_SUPPORTED444# define PNG_FIXED_EXPORT(ordinal, type, name, args)\445PNG_EXPORT(ordinal, type, name, args);446# else /* No fixed point APIs */447# define PNG_FIXED_EXPORT(ordinal, type, name, args)448# endif449#endif450451#ifndef PNG_BUILDING_SYMBOL_TABLE452/* Some typedefs to get us started. These should be safe on most of the common453* platforms.454*455* png_uint_32 and png_int_32 may, currently, be larger than required to hold a456* 32-bit value however this is not normally advisable.457*458* png_uint_16 and png_int_16 should always be two bytes in size - this is459* verified at library build time.460*461* png_byte must always be one byte in size.462*463* The checks below use constants from limits.h, as defined by the ISOC90464* standard.465*/466#if CHAR_BIT == 8 && UCHAR_MAX == 255467typedef unsigned char png_byte;468#else469# error libpng requires 8-bit bytes470#endif471472#if INT_MIN == -32768 && INT_MAX == 32767473typedef int png_int_16;474#elif SHRT_MIN == -32768 && SHRT_MAX == 32767475typedef short png_int_16;476#else477# error libpng requires a signed 16-bit integer type478#endif479480#if UINT_MAX == 65535481typedef unsigned int png_uint_16;482#elif USHRT_MAX == 65535483typedef unsigned short png_uint_16;484#else485# error libpng requires an unsigned 16-bit integer type486#endif487488#if INT_MIN < -2147483646 && INT_MAX > 2147483646489typedef int png_int_32;490#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646491typedef long int png_int_32;492#else493# error libpng requires a signed 32-bit (or longer) integer type494#endif495496#if UINT_MAX > 4294967294U497typedef unsigned int png_uint_32;498#elif ULONG_MAX > 4294967294U499typedef unsigned long int png_uint_32;500#else501# error libpng requires an unsigned 32-bit (or longer) integer type502#endif503504/* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t.505* From 1.6.0 onwards, an ISO C90 compiler, as well as a standard-compliant506* behavior of sizeof and ptrdiff_t are required.507* The legacy typedefs are provided here for backwards compatibility.508*/509typedef size_t png_size_t;510typedef ptrdiff_t png_ptrdiff_t;511512/* libpng needs to know the maximum value of 'size_t' and this controls the513* definition of png_alloc_size_t, below. This maximum value of size_t limits514* but does not control the maximum allocations the library makes - there is515* direct application control of this through png_set_user_limits().516*/517#ifndef PNG_SMALL_SIZE_T518/* Compiler specific tests for systems where size_t is known to be less than519* 32 bits (some of these systems may no longer work because of the lack of520* 'far' support; see above.)521*/522# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\523(defined(_MSC_VER) && defined(MAXSEG_64K))524# define PNG_SMALL_SIZE_T525# endif526#endif527528/* png_alloc_size_t is guaranteed to be no smaller than size_t, and no smaller529* than png_uint_32. Casts from size_t or png_uint_32 to png_alloc_size_t are530* not necessary; in fact, it is recommended not to use them at all, so that531* the compiler can complain when something turns out to be problematic.532*533* Casts in the other direction (from png_alloc_size_t to size_t or534* png_uint_32) should be explicitly applied; however, we do not expect to535* encounter practical situations that require such conversions.536*537* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than538* 4294967295 - i.e. less than the maximum value of png_uint_32.539*/540#ifdef PNG_SMALL_SIZE_T541typedef png_uint_32 png_alloc_size_t;542#else543typedef size_t png_alloc_size_t;544#endif545546/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler547* implementations of Intel CPU specific support of user-mode segmented address548* spaces, where 16-bit pointers address more than 65536 bytes of memory using549* separate 'segment' registers. The implementation requires two different550* types of pointer (only one of which includes the segment value.)551*552* If required this support is available in version 1.2 of libpng and may be553* available in versions through 1.5, although the correctness of the code has554* not been verified recently.555*/556557/* Typedef for floating-point numbers that are converted to fixed-point with a558* multiple of 100,000, e.g., gamma559*/560typedef png_int_32 png_fixed_point;561562/* Add typedefs for pointers */563typedef void * png_voidp;564typedef const void * png_const_voidp;565typedef png_byte * png_bytep;566typedef const png_byte * png_const_bytep;567typedef png_uint_32 * png_uint_32p;568typedef const png_uint_32 * png_const_uint_32p;569typedef png_int_32 * png_int_32p;570typedef const png_int_32 * png_const_int_32p;571typedef png_uint_16 * png_uint_16p;572typedef const png_uint_16 * png_const_uint_16p;573typedef png_int_16 * png_int_16p;574typedef const png_int_16 * png_const_int_16p;575typedef char * png_charp;576typedef const char * png_const_charp;577typedef png_fixed_point * png_fixed_point_p;578typedef const png_fixed_point * png_const_fixed_point_p;579typedef size_t * png_size_tp;580typedef const size_t * png_const_size_tp;581582#ifdef PNG_FLOATING_POINT_SUPPORTED583typedef double * png_doublep;584typedef const double * png_const_doublep;585#endif586587/* Pointers to pointers; i.e. arrays */588typedef png_byte * * png_bytepp;589typedef png_uint_32 * * png_uint_32pp;590typedef png_int_32 * * png_int_32pp;591typedef png_uint_16 * * png_uint_16pp;592typedef png_int_16 * * png_int_16pp;593typedef const char * * png_const_charpp;594typedef char * * png_charpp;595typedef png_fixed_point * * png_fixed_point_pp;596#ifdef PNG_FLOATING_POINT_SUPPORTED597typedef double * * png_doublepp;598#endif599600/* Pointers to pointers to pointers; i.e., pointer to array */601typedef char * * * png_charppp;602603#ifdef PNG_STDIO_SUPPORTED604/* With PNG_STDIO_SUPPORTED it was possible to use I/O streams that were605* not necessarily stdio FILE streams, to allow building Windows applications606* before Win32 and Windows CE applications before WinCE 3.0, but that kind607* of support has long been discontinued.608*/609typedef FILE * png_FILE_p; /* [Deprecated] */610#endif611612#endif /* PNG_BUILDING_SYMBOL_TABLE */613614#endif /* PNGCONF_H */615616617