1 2/* pngconf.h - machine configurable file for libpng 3 * 4 * libpng version 1.5.12 - July 11, 2012 5 * 6 * Copyright (c) 1998-2012 Glenn Randers-Pehrson 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 9 * 10 * This code is released under the libpng license. 11 * For conditions of distribution and use, see the disclaimer 12 * and license in png.h 13 * 14 */ 15 16/* Any machine specific code is near the front of this file, so if you 17 * are configuring libpng for a machine, you may want to read the section 18 * starting here down to where it starts to typedef png_color, png_text, 19 * and png_info. 20 */ 21 22#ifndef PNGCONF_H 23#define PNGCONF_H 24 25#ifndef PNG_BUILDING_SYMBOL_TABLE 26/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C 27 * definition file for machine specific limits, this may impact the 28 * correctness of the definitions below (see uses of INT_MAX). 29 */ 30# ifndef PNG_NO_LIMITS_H 31# include <limits.h> 32# endif 33 34/* For the memory copy APIs (i.e. the standard definitions of these), 35 * because this file defines png_memcpy and so on the base APIs must 36 * be defined here. 37 */ 38# ifdef BSD 39# include <strings.h> 40# else 41# include <string.h> 42# endif 43 44/* For png_FILE_p - this provides the standard definition of a 45 * FILE 46 */ 47# ifdef PNG_STDIO_SUPPORTED 48# include <stdio.h> 49# endif 50#endif 51 52/* This controls optimization of the reading of 16 and 32 bit values 53 * from PNG files. It can be set on a per-app-file basis - it 54 * just changes whether a macro is used when the function is called. 55 * The library builder sets the default; if read functions are not 56 * built into the library the macro implementation is forced on. 57 */ 58#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED 59# define PNG_USE_READ_MACROS 60#endif 61#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) 62# if PNG_DEFAULT_READ_MACROS 63# define PNG_USE_READ_MACROS 64# endif 65#endif 66 67/* COMPILER SPECIFIC OPTIONS. 68 * 69 * These options are provided so that a variety of difficult compilers 70 * can be used. Some are fixed at build time (e.g. PNG_API_RULE 71 * below) but still have compiler specific implementations, others 72 * may be changed on a per-file basis when compiling against libpng. 73 */ 74 75/* The PNGARG macro protects us against machines that don't have function 76 * prototypes (ie K&R style headers). If your compiler does not handle 77 * function prototypes, define this macro and use the included ansi2knr. 78 * I've always been able to use _NO_PROTO as the indicator, but you may 79 * need to drag the empty declaration out in front of here, or change the 80 * ifdef to suit your own needs. 81 */ 82#ifndef PNGARG 83 84# ifdef OF /* zlib prototype munger */ 85# define PNGARG(arglist) OF(arglist) 86# else 87 88# ifdef _NO_PROTO 89# define PNGARG(arglist) () 90# else 91# define PNGARG(arglist) arglist 92# endif /* _NO_PROTO */ 93 94# endif /* OF */ 95 96#endif /* PNGARG */ 97 98/* Function calling conventions. 99 * ============================= 100 * Normally it is not necessary to specify to the compiler how to call 101 * a function - it just does it - however on x86 systems derived from 102 * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems 103 * and some others) there are multiple ways to call a function and the 104 * default can be changed on the compiler command line. For this reason 105 * libpng specifies the calling convention of every exported function and 106 * every function called via a user supplied function pointer. This is 107 * done in this file by defining the following macros: 108 * 109 * PNGAPI Calling convention for exported functions. 110 * PNGCBAPI Calling convention for user provided (callback) functions. 111 * PNGCAPI Calling convention used by the ANSI-C library (required 112 * for longjmp callbacks and sometimes used internally to 113 * specify the calling convention for zlib). 114 * 115 * These macros should never be overridden. If it is necessary to 116 * change calling convention in a private build this can be done 117 * by setting PNG_API_RULE (which defaults to 0) to one of the values 118 * below to select the correct 'API' variants. 119 * 120 * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. 121 * This is correct in every known environment. 122 * PNG_API_RULE=1 Use the operating system convention for PNGAPI and 123 * the 'C' calling convention (from PNGCAPI) for 124 * callbacks (PNGCBAPI). This is no longer required 125 * in any known environment - if it has to be used 126 * please post an explanation of the problem to the 127 * libpng mailing list. 128 * 129 * These cases only differ if the operating system does not use the C 130 * calling convention, at present this just means the above cases 131 * (x86 DOS/Windows sytems) and, even then, this does not apply to 132 * Cygwin running on those systems. 133 * 134 * Note that the value must be defined in pnglibconf.h so that what 135 * the application uses to call the library matches the conventions 136 * set when building the library. 137 */ 138 139/* Symbol export 140 * ============= 141 * When building a shared library it is almost always necessary to tell 142 * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' 143 * is used to mark the symbols. On some systems these symbols can be 144 * extracted at link time and need no special processing by the compiler, 145 * on other systems the symbols are flagged by the compiler and just 146 * the declaration requires a special tag applied (unfortunately) in a 147 * compiler dependent way. Some systems can do either. 148 * 149 * A small number of older systems also require a symbol from a DLL to 150 * be flagged to the program that calls it. This is a problem because 151 * we do not know in the header file included by application code that 152 * the symbol will come from a shared library, as opposed to a statically 153 * linked one. For this reason the application must tell us by setting 154 * the magic flag PNG_USE_DLL to turn on the special processing before 155 * it includes png.h. 156 * 157 * Four additional macros are used to make this happen: 158 * 159 * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from 160 * the build or imported if PNG_USE_DLL is set - compiler 161 * and system specific. 162 * 163 * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to 164 * 'type', compiler specific. 165 * 166 * PNG_DLL_EXPORT Set to the magic to use during a libpng build to 167 * make a symbol exported from the DLL. Not used in the 168 * public header files; see pngpriv.h for how it is used 169 * in the libpng build. 170 * 171 * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come 172 * from a DLL - used to define PNG_IMPEXP when 173 * PNG_USE_DLL is set. 174 */ 175 176/* System specific discovery. 177 * ========================== 178 * This code is used at build time to find PNG_IMPEXP, the API settings 179 * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL 180 * import processing is possible. On Windows/x86 systems it also sets 181 * compiler-specific macros to the values required to change the calling 182 * conventions of the various functions. 183 */ 184#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ 185 defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\ 186 ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\ 187 defined(_M_X64) || defined(_M_IA64) ) 188 /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes 189 * builds under Cygwin or MinGW. Also includes Watcom builds but these need 190 * special treatment because they are not compatible with GCC or Visual C 191 * because of different calling conventions. 192 */ 193# if PNG_API_RULE == 2 194 /* If this line results in an error, either because __watcall is not 195 * understood or because of a redefine just below you cannot use *this* 196 * build of the library with the compiler you are using. *This* build was 197 * build using Watcom and applications must also be built using Watcom! 198 */ 199# define PNGCAPI __watcall 200# endif 201 202# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) 203# define PNGCAPI __cdecl 204# if PNG_API_RULE == 1 205# define PNGAPI __stdcall 206# endif 207# else 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 */ 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 */ 219 /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ 220 221# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) 222 ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed 223# endif 224 225# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ 226 (defined(__BORLANDC__) && __BORLANDC__ < 0x500) 227 /* older Borland and MSC 228 * compilers used '__export' and required this to be after 229 * the type. 230 */ 231# ifndef PNG_EXPORT_TYPE 232# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP 233# endif 234# define PNG_DLL_EXPORT __export 235# else /* newer compiler */ 236# define PNG_DLL_EXPORT __declspec(dllexport) 237# ifndef PNG_DLL_IMPORT 238# define PNG_DLL_IMPORT __declspec(dllimport) 239# endif 240# endif /* compiler */ 241 242#else /* !Windows/x86 */ 243# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) 244# define PNGAPI _System 245# else /* !Windows/x86 && !OS/2 */ 246 /* Use the defaults, or define PNG*API on the command line (but 247 * this will have to be done for every compile!) 248 */ 249# endif /* other system, !OS/2 */ 250#endif /* !Windows/x86 */ 251 252/* Now do all the defaulting . */ 253#ifndef PNGCAPI 254# define PNGCAPI 255#endif 256#ifndef PNGCBAPI 257# define PNGCBAPI PNGCAPI 258#endif 259#ifndef PNGAPI 260# define PNGAPI PNGCAPI 261#endif 262 263/* PNG_IMPEXP may be set on the compilation system command line or (if not set) 264 * then in an internal header file when building the library, otherwise (when 265 * using the library) it is set here. 266 */ 267#ifndef PNG_IMPEXP 268# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) 269 /* This forces use of a DLL, disallowing static linking */ 270# define PNG_IMPEXP PNG_DLL_IMPORT 271# endif 272 273# ifndef PNG_IMPEXP 274# define PNG_IMPEXP 275# endif 276#endif 277 278/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat 279 * 'attributes' as a storage class - the attributes go at the start of the 280 * function definition, and attributes are always appended regardless of the 281 * compiler. This considerably simplifies these macros but may cause problems 282 * if any compilers both need function attributes and fail to handle them as 283 * a storage class (this is unlikely.) 284 */ 285#ifndef PNG_FUNCTION 286# define PNG_FUNCTION(type, name, args, attributes) attributes type name args 287#endif 288 289#ifndef PNG_EXPORT_TYPE 290# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type 291#endif 292 293 /* The ordinal value is only relevant when preprocessing png.h for symbol 294 * table entries, so we discard it here. See the .dfn files in the 295 * scripts directory. 296 */ 297#ifndef PNG_EXPORTA 298 299# define PNG_EXPORTA(ordinal, type, name, args, attributes)\ 300 PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ 301 extern attributes) 302#endif 303 304/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, 305 * so make something non-empty to satisfy the requirement: 306 */ 307#define PNG_EMPTY /*empty list*/ 308 309#define PNG_EXPORT(ordinal, type, name, args)\ 310 PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) 311 312/* Use PNG_REMOVED to comment out a removed interface. */ 313#ifndef PNG_REMOVED 314# define PNG_REMOVED(ordinal, type, name, args, attributes) 315#endif 316 317#ifndef PNG_CALLBACK 318# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) 319#endif 320 321/* Support for compiler specific function attributes. These are used 322 * so that where compiler support is available incorrect use of API 323 * functions in png.h will generate compiler warnings. 324 * 325 * Added at libpng-1.2.41. 326 */ 327 328#ifndef PNG_NO_PEDANTIC_WARNINGS 329# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED 330# define PNG_PEDANTIC_WARNINGS_SUPPORTED 331# endif 332#endif 333 334#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED 335 /* Support for compiler specific function attributes. These are used 336 * so that where compiler support is available incorrect use of API 337 * functions in png.h will generate compiler warnings. Added at libpng 338 * version 1.2.41. 339 */ 340# if defined(__GNUC__) 341# ifndef PNG_USE_RESULT 342# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) 343# endif 344# ifndef PNG_NORETURN 345# define PNG_NORETURN __attribute__((__noreturn__)) 346# endif 347# ifndef PNG_ALLOCATED 348# define PNG_ALLOCATED __attribute__((__malloc__)) 349# endif 350# ifndef PNG_DEPRECATED 351# define PNG_DEPRECATED __attribute__((__deprecated__)) 352# endif 353# ifndef PNG_PRIVATE 354# if 0 /* Doesn't work so we use deprecated instead*/ 355# define PNG_PRIVATE \ 356 __attribute__((warning("This function is not exported by libpng."))) 357# else 358# define PNG_PRIVATE \ 359 __attribute__((__deprecated__)) 360# endif 361# endif 362# endif /* __GNUC__ */ 363 364# if defined(_MSC_VER) && (_MSC_VER >= 1300) 365# ifndef PNG_USE_RESULT 366# define PNG_USE_RESULT /* not supported */ 367# endif 368# ifndef PNG_NORETURN 369# define PNG_NORETURN __declspec(noreturn) 370# endif 371# ifndef PNG_ALLOCATED 372# if (_MSC_VER >= 1400) 373# define PNG_ALLOCATED __declspec(restrict) 374# endif 375# endif 376# ifndef PNG_DEPRECATED 377# define PNG_DEPRECATED __declspec(deprecated) 378# endif 379# ifndef PNG_PRIVATE 380# define PNG_PRIVATE __declspec(deprecated) 381# endif 382# endif /* _MSC_VER */ 383#endif /* PNG_PEDANTIC_WARNINGS */ 384 385#ifndef PNG_DEPRECATED 386# define PNG_DEPRECATED /* Use of this function is deprecated */ 387#endif 388#ifndef PNG_USE_RESULT 389# define PNG_USE_RESULT /* The result of this function must be checked */ 390#endif 391#ifndef PNG_NORETURN 392# define PNG_NORETURN /* This function does not return */ 393#endif 394#ifndef PNG_ALLOCATED 395# define PNG_ALLOCATED /* The result of the function is new memory */ 396#endif 397#ifndef PNG_PRIVATE 398# define PNG_PRIVATE /* This is a private libpng function */ 399#endif 400#ifndef PNG_FP_EXPORT /* A floating point API. */ 401# ifdef PNG_FLOATING_POINT_SUPPORTED 402# define PNG_FP_EXPORT(ordinal, type, name, args)\ 403 PNG_EXPORT(ordinal, type, name, args) 404# else /* No floating point APIs */ 405# define PNG_FP_EXPORT(ordinal, type, name, args) 406# endif 407#endif 408#ifndef PNG_FIXED_EXPORT /* A fixed point API. */ 409# ifdef PNG_FIXED_POINT_SUPPORTED 410# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ 411 PNG_EXPORT(ordinal, type, name, args) 412# else /* No fixed point APIs */ 413# define PNG_FIXED_EXPORT(ordinal, type, name, args) 414# endif 415#endif 416 417/* The following uses const char * instead of char * for error 418 * and warning message functions, so some compilers won't complain. 419 * If you do not want to use const, define PNG_NO_CONST here. 420 * 421 * This should not change how the APIs are called, so it can be done 422 * on a per-file basis in the application. 423 */ 424#ifndef PNG_CONST 425# ifndef PNG_NO_CONST 426# define PNG_CONST const 427# else 428# define PNG_CONST 429# endif 430#endif 431 432/* Some typedefs to get us started. These should be safe on most of the 433 * common platforms. The typedefs should be at least as large as the 434 * numbers suggest (a png_uint_32 must be at least 32 bits long), but they 435 * don't have to be exactly that size. Some compilers dislike passing 436 * unsigned shorts as function parameters, so you may be better off using 437 * unsigned int for png_uint_16. 438 */ 439 440#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL) 441typedef unsigned int png_uint_32; 442typedef int png_int_32; 443#else 444typedef unsigned long png_uint_32; 445typedef long png_int_32; 446#endif 447typedef unsigned short png_uint_16; 448typedef short png_int_16; 449typedef unsigned char png_byte; 450 451#ifdef PNG_NO_SIZE_T 452typedef unsigned int png_size_t; 453#else 454typedef size_t png_size_t; 455#endif 456#define png_sizeof(x) (sizeof (x)) 457 458/* The following is needed for medium model support. It cannot be in the 459 * pngpriv.h header. Needs modification for other compilers besides 460 * MSC. Model independent support declares all arrays and pointers to be 461 * large using the far keyword. The zlib version used must also support 462 * model independent data. As of version zlib 1.0.4, the necessary changes 463 * have been made in zlib. The USE_FAR_KEYWORD define triggers other 464 * changes that are needed. (Tim Wegner) 465 */ 466 467/* Separate compiler dependencies (problem here is that zlib.h always 468 * defines FAR. (SJT) 469 */ 470#ifdef __BORLANDC__ 471# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) 472# define LDATA 1 473# else 474# define LDATA 0 475# endif 476 /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ 477# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) 478# define PNG_MAX_MALLOC_64K /* only used in build */ 479# if (LDATA != 1) 480# ifndef FAR 481# define FAR __far 482# endif 483# define USE_FAR_KEYWORD 484# endif /* LDATA != 1 */ 485 /* Possibly useful for moving data out of default segment. 486 * Uncomment it if you want. Could also define FARDATA as 487 * const if your compiler supports it. (SJT) 488# define FARDATA FAR 489 */ 490# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ 491#endif /* __BORLANDC__ */ 492 493 494/* Suggest testing for specific compiler first before testing for 495 * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, 496 * making reliance oncertain keywords suspect. (SJT) 497 */ 498 499/* MSC Medium model */ 500#ifdef FAR 501# ifdef M_I86MM 502# define USE_FAR_KEYWORD 503# define FARDATA FAR 504# include <dos.h> 505# endif 506#endif 507 508/* SJT: default case */ 509#ifndef FAR 510# define FAR 511#endif 512 513/* At this point FAR is always defined */ 514#ifndef FARDATA 515# define FARDATA 516#endif 517 518/* Typedef for floating-point numbers that are converted 519 * to fixed-point with a multiple of 100,000, e.g., gamma 520 */ 521typedef png_int_32 png_fixed_point; 522 523/* Add typedefs for pointers */ 524typedef void FAR * png_voidp; 525typedef PNG_CONST void FAR * png_const_voidp; 526typedef png_byte FAR * png_bytep; 527typedef PNG_CONST png_byte FAR * png_const_bytep; 528typedef png_uint_32 FAR * png_uint_32p; 529typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p; 530typedef png_int_32 FAR * png_int_32p; 531typedef PNG_CONST png_int_32 FAR * png_const_int_32p; 532typedef png_uint_16 FAR * png_uint_16p; 533typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p; 534typedef png_int_16 FAR * png_int_16p; 535typedef PNG_CONST png_int_16 FAR * png_const_int_16p; 536typedef char FAR * png_charp; 537typedef PNG_CONST char FAR * png_const_charp; 538typedef png_fixed_point FAR * png_fixed_point_p; 539typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p; 540typedef png_size_t FAR * png_size_tp; 541typedef PNG_CONST png_size_t FAR * png_const_size_tp; 542 543#ifdef PNG_STDIO_SUPPORTED 544typedef FILE * png_FILE_p; 545#endif 546 547#ifdef PNG_FLOATING_POINT_SUPPORTED 548typedef double FAR * png_doublep; 549typedef PNG_CONST double FAR * png_const_doublep; 550#endif 551 552/* Pointers to pointers; i.e. arrays */ 553typedef png_byte FAR * FAR * png_bytepp; 554typedef png_uint_32 FAR * FAR * png_uint_32pp; 555typedef png_int_32 FAR * FAR * png_int_32pp; 556typedef png_uint_16 FAR * FAR * png_uint_16pp; 557typedef png_int_16 FAR * FAR * png_int_16pp; 558typedef PNG_CONST char FAR * FAR * png_const_charpp; 559typedef char FAR * FAR * png_charpp; 560typedef png_fixed_point FAR * FAR * png_fixed_point_pp; 561#ifdef PNG_FLOATING_POINT_SUPPORTED 562typedef double FAR * FAR * png_doublepp; 563#endif 564 565/* Pointers to pointers to pointers; i.e., pointer to array */ 566typedef char FAR * FAR * FAR * png_charppp; 567 568/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, 569 * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32 570 * to png_alloc_size_t are not necessary; in fact, it is recommended 571 * not to use them at all so that the compiler can complain when something 572 * turns out to be problematic. 573 * Casts in the other direction (from png_alloc_size_t to png_size_t or 574 * png_uint_32) should be explicitly applied; however, we do not expect 575 * to encounter practical situations that require such conversions. 576 */ 577#if defined(__TURBOC__) && !defined(__FLAT__) 578 typedef unsigned long png_alloc_size_t; 579#else 580# if defined(_MSC_VER) && defined(MAXSEG_64K) 581 typedef unsigned long png_alloc_size_t; 582# else 583 /* This is an attempt to detect an old Windows system where (int) is 584 * actually 16 bits, in that case png_malloc must have an argument with a 585 * bigger size to accomodate the requirements of the library. 586 */ 587# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \ 588 (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL) 589 typedef DWORD png_alloc_size_t; 590# else 591 typedef png_size_t png_alloc_size_t; 592# endif 593# endif 594#endif 595 596#endif /* PNGCONF_H */ 597