460b9539 |
1 | /* |
2 | * This file is part of DisOrder. |
3 | * Copyright (C) 2004, 2005 Richard Kettlewell |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
18 | * USA |
19 | */ |
20 | |
21 | #ifndef TYPES_H |
22 | #define TYPES_H |
23 | |
24 | #if HAVE_INTTYPES_H |
25 | # include <inttypes.h> |
26 | #endif |
27 | #include <limits.h> |
28 | #include <sys/types.h> |
29 | |
30 | /* had better be before atol/atoll redefinition */ |
31 | #include <stdlib.h> |
32 | |
33 | #if HAVE_LONG_LONG |
34 | typedef long long long_long; |
35 | typedef unsigned long long u_long_long; |
36 | # if ! DECLARES_STRTOLL |
37 | long long strtoll(const char *, char **, int); |
38 | # endif |
39 | # if ! DECLARES_ATOLL |
40 | long long atoll(const char *); |
41 | # endif |
42 | #else |
43 | typedef long long_long; |
44 | typedef unsigned long u_long_long; |
45 | # define atoll atol |
46 | # define strtoll strtol |
47 | #endif |
48 | |
49 | #if __APPLE__ |
50 | /* apple define these to j[dxu], which gcc -std=c99 -pedantic then rejects */ |
51 | # undef PRIdMAX |
52 | # undef PRIxMAX |
53 | # undef PRIuMAX |
54 | #endif |
55 | |
56 | #if HAVE_INTMAX_T |
57 | # ifndef PRIdMAX |
58 | # define PRIdMAX "jd" |
59 | # endif |
60 | #elif HAVE_LONG_LONG |
61 | typedef long long intmax_t; |
62 | # define PRIdMAX "lld" |
63 | #else |
64 | typedef long intmax_t; |
65 | # define PRIdMAX "ld" |
66 | #endif |
67 | |
68 | #if HAVE_UINTMAX_T |
69 | # ifndef PRIuMAX |
70 | # define PRIuMAX "ju" |
71 | # endif |
72 | # ifndef PRIxMAX |
73 | # define PRIxMAX "jx" |
74 | # endif |
75 | #elif HAVE_LONG_LONG |
76 | typedef unsigned long long uintmax_t; |
77 | # define PRIuMAX "llu" |
78 | # define PRIxMAX "llx" |
79 | #else |
80 | typedef unsigned long uintmax_t; |
81 | # define PRIuMAX "lu" |
82 | # define PRIxMAX "lx" |
83 | #endif |
84 | |
85 | #if ! HAVE_UINT8_T |
86 | # if CHAR_BIT == 8 |
87 | typedef unsigned char uint8_t; |
88 | # else |
89 | # error cannot determine uint8_t |
90 | # endif |
91 | #endif |
92 | |
93 | #if ! HAVE_UINT32_T |
94 | # if UINT_MAX == 4294967295 |
95 | typedef unsigned int uint32_t; |
96 | # elif ULONG_MAX == 4294967295 |
97 | typedef unsigned long uint32_t; |
98 | # elif USHRT_MAX == 4294967295 |
99 | typedef unsigned short uint32_t; |
100 | # elif UCHAR_MAX == 4294967295 |
101 | typedef unsigned char uint32_t; |
102 | # else |
103 | # error cannot determine uint32_t |
104 | # endif |
105 | #endif |
106 | |
107 | #endif /* TYPES_H */ |
108 | |
109 | /* |
110 | Local Variables: |
111 | c-basic-offset:2 |
112 | comment-column:40 |
113 | End: |
114 | */ |