1 /* Copyright (C) 2001-2006 Artifex Software, Inc.
2    All Rights Reserved.
3 
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6 
7    This software is distributed under license and may not be copied, modified
8    or distributed except as expressly authorized under the terms of that
9    license.  Refer to licensing information at http://www.artifex.com/
10    or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11    San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12 */
13 
14 /* $Id: stdint_.h 8541 2008-02-24 01:12:18Z alexcher $ */
15 /* Generic substitute for stdint.h */
16 
17 #ifndef stdint__INCLUDED
18 #  define stdint__INCLUDED
19 
20 /*
21  * ensure our standard defines have been included
22  */
23 #include "std.h"
24 
25 /* Define some stdint.h types. The jbig2dec headers and ttf bytecode
26  * interpreter require these and they're generally useful to have around
27  * now that there's a standard.
28  */
29 
30 /* Some systems are guaranteed to have stdint.h
31  * but don't use the autoconf detection
32  */
33 #ifndef HAVE_STDINT_H
34 # ifdef __MACOS__
35 #   define HAVE_STDINT_H
36 # endif
37 #endif
38 
39 /* try a generic header first */
40 #if defined(HAVE_STDINT_H)
41 # include <stdint.h>
42 # define STDINT_TYPES_DEFINED
43 #elif defined(SYS_TYPES_HAS_STDINT_TYPES)
44   /* std.h will have included sys/types.h */
45 # define STDINT_TYPES_DEFINED
46 #endif
47 
48 /* try platform-specific defines */
49 #ifndef STDINT_TYPES_DEFINED
50 # if defined(__WIN32__) /* MSVC currently doesn't provide C99 headers */
51    typedef signed char             int8_t;
52    typedef short int               int16_t;
53    typedef int                     int32_t;
54    typedef __int64                 int64_t;
55    typedef unsigned char           uint8_t;
56    typedef unsigned short int      uint16_t;
57    typedef unsigned int            uint32_t;
58    typedef unsigned __int64        uint64_t;
59 #  define STDINT_TYPES_DEFINED
60 # elif defined(__VMS) /* OpenVMS provides these types in inttypes.h */
61 #  include <inttypes.h>
62 #  define STDINT_TYPES_DEFINED
63 # elif defined(__CYGWIN__)
64 #  include <sys/types.h>  /* Old Cygwin has some of C99 types here. */
65    typedef unsigned char uint8_t;
66    typedef unsigned short uint16_t;
67    typedef unsigned int uint32_t;
68    typedef unsigned long long uint64_t;
69 #  define STDINT_TYPES_DEFINED
70 # endif
71    /* other archs may want to add defines here,
72       or use the fallbacks in std.h */
73 #endif
74 
75 /* fall back to tests based on arch.h */
76 #ifndef STDINT_TYPES_DEFINED
77 /* 8 bit types */
78 # if ARCH_SIZEOF_CHAR == 1
79 typedef signed char int8_t;
80 typedef unsigned char uint8_t;
81 # endif
82 /* 16 bit types */
83 # if ARCH_SIZEOF_SHORT == 2
84 typedef signed short int16_t;
85 typedef unsigned short uint16_t;
86 # else
87 #  if ARCH_SIZEOF_INT == 2
88 typedef signed int int16_t;
89 typedef unsigned int uint16_t;
90 #  endif
91 # endif
92 /* 32 bit types */
93 # if ARCH_SIZEOF_INT == 4
94 typedef signed int int32_t;
95 typedef unsigned int uint32_t;
96 # else
97 #  if ARCH_SIZEOF_LONG == 4
98 typedef signed long int32_t;
99 typedef unsigned long uint32_t;
100 #  else
101 #   if ARCH_SIZEOF_SHORT == 4
102 typedef signed short int32_t;
103 typedef unsigned short uint32_t;
104 #   endif
105 #  endif
106 # endif
107 /* 64 bit types */
108 # if ARCH_SIZEOF_INT == 8
109 typedef signed int int64_t;
110 typedef unsigned int uint64_t;
111 # else
112 #  if ARCH_SIZEOF_LONG == 8
113 typedef signed long int64_t;
114 typedef unsigned long uint64_t;
115 #  else
116 #   ifdef ARCH_SIZEOF_LONG_LONG
117 #    if ARCH_SIZEOF_LONG_LONG == 8
118 typedef signed long long int64_t;
119 typedef unsigned long long uint64_t;
120 #    endif
121 #   endif
122 #  endif
123 # endif
124 #  define STDINT_TYPES_DEFINED
125 #endif /* STDINT_TYPES_DEFINED */
126 
127 #endif /* stdint__INCLUDED */
128