OLD | NEW |
1 /////////////////////////////////////////////////////////////////////////////// | 1 /////////////////////////////////////////////////////////////////////////////// |
2 // | 2 // |
3 /// \file sysdefs.h | 3 /// \file sysdefs.h |
4 /// \brief Common includes, definitions, system-specific things etc. | 4 /// \brief Common includes, definitions, system-specific things etc. |
5 /// | 5 /// |
6 /// This file is used also by the lzma command line tool, that's why this | 6 /// This file is used also by the lzma command line tool, that's why this |
7 /// file is separate from common.h. | 7 /// file is separate from common.h. |
8 // | 8 // |
9 // Author: Lasse Collin | 9 // Author: Lasse Collin |
10 // | 10 // |
11 // This file has been put into the public domain. | 11 // This file has been put into the public domain. |
12 // You can do whatever you want with this file. | 12 // You can do whatever you want with this file. |
13 // | 13 // |
14 /////////////////////////////////////////////////////////////////////////////// | 14 /////////////////////////////////////////////////////////////////////////////// |
15 | 15 |
16 #ifndef LZMA_SYSDEFS_H | 16 #ifndef LZMA_SYSDEFS_H |
17 #define LZMA_SYSDEFS_H | 17 #define LZMA_SYSDEFS_H |
18 | 18 |
19 ////////////// | 19 ////////////// |
20 // Includes // | 20 // Includes // |
21 ////////////// | 21 ////////////// |
22 | 22 |
23 #ifdef HAVE_CONFIG_H | 23 #ifdef HAVE_CONFIG_H |
24 # include <config.h> | 24 # include <config.h> |
25 #endif | 25 #endif |
26 | 26 |
| 27 // Get standard-compliant stdio functions under MinGW and MinGW-w64. |
| 28 #ifdef __MINGW32__ |
| 29 # define __USE_MINGW_ANSI_STDIO 1 |
| 30 #endif |
| 31 |
27 // size_t and NULL | 32 // size_t and NULL |
28 #include <stddef.h> | 33 #include <stddef.h> |
29 | 34 |
30 #ifdef HAVE_INTTYPES_H | 35 #ifdef HAVE_INTTYPES_H |
31 # include <inttypes.h> | 36 # include <inttypes.h> |
32 #endif | 37 #endif |
33 | 38 |
34 // C99 says that inttypes.h always includes stdint.h, but some systems | 39 // C99 says that inttypes.h always includes stdint.h, but some systems |
35 // don't do that, and require including stdint.h separately. | 40 // don't do that, and require including stdint.h separately. |
36 #ifdef HAVE_STDINT_H | 41 #ifdef HAVE_STDINT_H |
(...skipping 16 matching lines...) Expand all Loading... |
53 # error UINT32_C is not defined and unsigned int is not 32-bit. | 58 # error UINT32_C is not defined and unsigned int is not 32-bit. |
54 # endif | 59 # endif |
55 # define UINT32_C(n) n ## U | 60 # define UINT32_C(n) n ## U |
56 #endif | 61 #endif |
57 #ifndef UINT32_MAX | 62 #ifndef UINT32_MAX |
58 # define UINT32_MAX UINT32_C(4294967295) | 63 # define UINT32_MAX UINT32_C(4294967295) |
59 #endif | 64 #endif |
60 #ifndef PRIu32 | 65 #ifndef PRIu32 |
61 # define PRIu32 "u" | 66 # define PRIu32 "u" |
62 #endif | 67 #endif |
| 68 #ifndef PRIx32 |
| 69 # define PRIx32 "x" |
| 70 #endif |
63 #ifndef PRIX32 | 71 #ifndef PRIX32 |
64 # define PRIX32 "X" | 72 # define PRIX32 "X" |
65 #endif | 73 #endif |
66 | 74 |
67 #if ULONG_MAX == 4294967295UL | 75 #if ULONG_MAX == 4294967295UL |
68 # ifndef UINT64_C | 76 # ifndef UINT64_C |
69 # define UINT64_C(n) n ## ULL | 77 # define UINT64_C(n) n ## ULL |
70 # endif | 78 # endif |
71 # ifndef PRIu64 | 79 # ifndef PRIu64 |
72 # define PRIu64 "llu" | 80 # define PRIu64 "llu" |
73 # endif | 81 # endif |
| 82 # ifndef PRIx64 |
| 83 # define PRIx64 "llx" |
| 84 # endif |
74 # ifndef PRIX64 | 85 # ifndef PRIX64 |
75 # define PRIX64 "llX" | 86 # define PRIX64 "llX" |
76 # endif | 87 # endif |
77 #else | 88 #else |
78 # ifndef UINT64_C | 89 # ifndef UINT64_C |
79 # define UINT64_C(n) n ## UL | 90 # define UINT64_C(n) n ## UL |
80 # endif | 91 # endif |
81 # ifndef PRIu64 | 92 # ifndef PRIu64 |
82 # define PRIu64 "lu" | 93 # define PRIu64 "lu" |
83 # endif | 94 # endif |
| 95 # ifndef PRIx64 |
| 96 # define PRIx64 "lx" |
| 97 # endif |
84 # ifndef PRIX64 | 98 # ifndef PRIX64 |
85 # define PRIX64 "lX" | 99 # define PRIX64 "lX" |
86 # endif | 100 # endif |
87 #endif | 101 #endif |
88 #ifndef UINT64_MAX | 102 #ifndef UINT64_MAX |
89 # define UINT64_MAX UINT64_C(18446744073709551615) | 103 # define UINT64_MAX UINT64_C(18446744073709551615) |
90 #endif | 104 #endif |
91 | 105 |
92 // Interix has broken header files, which typedef size_t to unsigned long, | 106 // Interix has broken header files, which typedef size_t to unsigned long, |
93 // but a few lines later define SIZE_MAX to INT32_MAX. | 107 // but a few lines later define SIZE_MAX to INT32_MAX. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // NOTE: Avoid using MIN() and MAX(), because even conditionally defining | 173 // NOTE: Avoid using MIN() and MAX(), because even conditionally defining |
160 // those macros can cause some portability trouble, since on some systems | 174 // those macros can cause some portability trouble, since on some systems |
161 // the system headers insist defining their own versions. | 175 // the system headers insist defining their own versions. |
162 #define my_min(x, y) ((x) < (y) ? (x) : (y)) | 176 #define my_min(x, y) ((x) < (y) ? (x) : (y)) |
163 #define my_max(x, y) ((x) > (y) ? (x) : (y)) | 177 #define my_max(x, y) ((x) > (y) ? (x) : (y)) |
164 | 178 |
165 #ifndef ARRAY_SIZE | 179 #ifndef ARRAY_SIZE |
166 # define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) | 180 # define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) |
167 #endif | 181 #endif |
168 | 182 |
| 183 #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 |
| 184 # define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x))) |
| 185 #else |
| 186 # define lzma_attr_alloc_size(x) |
169 #endif | 187 #endif |
| 188 |
| 189 #endif |
OLD | NEW |