annotate th_types.h @ 747:57ccf6402d2a

No need to check for both __MINGW32__ and __MINGW64__, the former is enough.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 21 Dec 2022 13:20:06 +0200
parents a557d1b2a356
children c6b2546d3ae3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Type definations
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
726
29e44a58bc73 Bump copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
4 * (C) Copyright 2002-2022 Tecnic Software productions (TNSP)
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
622
6d99150a8f89 Some more slight Doxygenisation.
Matti Hamalainen <ccr@tnsp.org>
parents: 582
diff changeset
7 *
6d99150a8f89 Some more slight Doxygenisation.
Matti Hamalainen <ccr@tnsp.org>
parents: 582
diff changeset
8 * If your code uses "config.h", you need to #include
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 * it before including this header.
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 */
622
6d99150a8f89 Some more slight Doxygenisation.
Matti Hamalainen <ccr@tnsp.org>
parents: 582
diff changeset
11 /// @file
6d99150a8f89 Some more slight Doxygenisation.
Matti Hamalainen <ccr@tnsp.org>
parents: 582
diff changeset
12 /// @brief Various platform-specific type and macro definitions.
392
851468fda833 s/_TH_TYPES_H/TH_TYPES_H/g
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
13 #ifndef TH_TYPES_H
851468fda833 s/_TH_TYPES_H/TH_TYPES_H/g
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
14 #define TH_TYPES_H 1
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
573
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
16
723
10f2eba7c59b Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents: 722
diff changeset
17 // Meh, this is a hack due to the crap non-portability of 64bit
747
57ccf6402d2a No need to check for both __MINGW32__ and __MINGW64__, the former is enough.
Matti Hamalainen <ccr@tnsp.org>
parents: 746
diff changeset
18 // printf() PRI* type specifiers/modifiers
57ccf6402d2a No need to check for both __MINGW32__ and __MINGW64__, the former is enough.
Matti Hamalainen <ccr@tnsp.org>
parents: 746
diff changeset
19 #if !defined(TH_USE_BONK_TYPES) && defined(__MINGW32__)
723
10f2eba7c59b Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents: 722
diff changeset
20 # define __USE_MINGW_ANSI_STDIO 1
10f2eba7c59b Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents: 722
diff changeset
21 #endif
10f2eba7c59b Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents: 722
diff changeset
22
10f2eba7c59b Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents: 722
diff changeset
23
746
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
24 // Older MinGW-w64 versions do not play well with certain PRI* and type
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
25 // checking of printf() format specifiers, so .. only define the attribute
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
26 // macro for GCC/clang and new enough MinGW-w64.
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
27 #if (defined(__GNUC__) || defined(__clang__)) && (!defined(__MINGW64__) || __GNUC__ >= 12)
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
28 # define TH_ATTR_PRINTF_FMT(xstart, xend) __attribute__ ((__format__ (__printf__, (xstart), (xend))))
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
29 #else
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
30 # define TH_ATTR_PRINTF_FMT(xstart, xend)
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
31 #endif
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
32
a557d1b2a356 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the
Matti Hamalainen <ccr@tnsp.org>
parents: 735
diff changeset
33
573
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
34 // Check for system type
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
35 #if defined(__WIN64) || defined(_WIN64) || defined(__WIN32) || defined(_WIN32)
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
36 # define TH_PLAT_WINDOWS 1
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
37 #elif defined(__DJGPP__) && __DJGPP__ >= 2
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
38 # define TH_PLAT_DOS 1
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
39 # undef __STRICT_ANSI__
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
40 #else
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
41 # define TH_PLAT_UNIX 1
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
42 #endif
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
43
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
44
150
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
45 // Check for standard headers
575
ebdfc1fe1c98 Fixes to the type definitions.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
46 #if defined(HAVE_INTTYPES_H)
ebdfc1fe1c98 Fixes to the type definitions.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
47 # include <inttypes.h>
ebdfc1fe1c98 Fixes to the type definitions.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
48 # ifndef HAVE_STDINT_H
ebdfc1fe1c98 Fixes to the type definitions.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
49 # define HAVE_STDINT_H 1
ebdfc1fe1c98 Fixes to the type definitions.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
50 # endif
ebdfc1fe1c98 Fixes to the type definitions.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
51 #elif defined(HAVE_STDINT_H)
150
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
52 # include <stdint.h>
394
7df5991a0ed3 Handle HAVE_STDINT_H vs HAVE_SYS_TYPES_H somewhat more sanely.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
53 #elif defined(HAVE_SYS_TYPES_H)
150
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
54 # include <sys/types.h>
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
55 #endif
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
56
391
6e6c8c4fc210 Buildsystem improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 308
diff changeset
57
6e6c8c4fc210 Buildsystem improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 308
diff changeset
58 // Check for arch bitness
573
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
59 #if !defined(TH_ARCH) && (defined(__WIN64) || defined(_WIN64))
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
60 # define TH_ARCH 64
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
61 #endif
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
62
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
63 #if !defined(TH_ARCH) && (defined(__WIN32) || defined(_WIN32))
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
64 # define TH_ARCH 32
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
65 #endif
7c0aa6bf484a Improve system bit-ness handling and target platform.
Matti Hamalainen <ccr@tnsp.org>
parents: 553
diff changeset
66
495
30c57a9ea3be Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
67 #if !defined(TH_ARCH)
30c57a9ea3be Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
68 # if UINTPTR_MAX == 0xffffffff
30c57a9ea3be Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
69 # define TH_ARCH 32
30c57a9ea3be Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
70 # elif UINTPTR_MAX == 0xffffffffffffffff
30c57a9ea3be Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
71 # define TH_ARCH 64
30c57a9ea3be Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 494
diff changeset
72 # endif
391
6e6c8c4fc210 Buildsystem improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 308
diff changeset
73 #endif
6e6c8c4fc210 Buildsystem improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 308
diff changeset
74
6e6c8c4fc210 Buildsystem improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 308
diff changeset
75
150
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
76 #if !defined(TH_ARCH)
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
77 # if defined(__LP64__) || defined(_LP64)
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
78 # define TH_ARCH 64
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
79 # else
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
80 # define TH_ARCH 32
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
81 # endif
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
82 #endif
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
83
579
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
84
150
9bc7f60f3013 More portability stuff. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
85 // Do we have a valid arch?
579
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
86 // If we don't have ISO C99 inttypes.h, define PRI* macros
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
87 #ifndef HAVE_INTTYPES_H
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
88 # if TH_ARCH == 32
395
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
89 # define PRIu32 "u"
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
90 # define PRId32 "d"
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
91 # define PRIx32 "x"
396
337f224b99fd Add PRIi{32,64} macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
92 # define PRIi32 "i"
397
dd95ea5901da Add PRIo{32,64} macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
93 # define PRIo32 "o"
395
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
94 # define PRIu64 "llu"
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
95 # define PRId64 "lld"
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
96 # define PRIx64 "llx"
396
337f224b99fd Add PRIi{32,64} macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
97 # define PRIi64 "lli"
397
dd95ea5901da Add PRIo{32,64} macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
98 # define PRIo64 "llo"
579
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
99 # elif TH_ARCH == 64
395
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
100 # define PRIu32 "u"
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
101 # define PRId32 "d"
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
102 # define PRIx32 "x"
396
337f224b99fd Add PRIi{32,64} macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
103 # define PRIi32 "i"
397
dd95ea5901da Add PRIo{32,64} macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
104 # define PRIo32 "o"
395
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
105 # define PRIu64 "lu"
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
106 # define PRId64 "ld"
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
107 # define PRIx64 "lx"
396
337f224b99fd Add PRIi{32,64} macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
108 # define PRIi64 "li"
397
dd95ea5901da Add PRIo{32,64} macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 396
diff changeset
109 # define PRIo64 "lo"
579
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
110 # else
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
111 # error Could not determine architecture (32/64bit), please define TH_ARCH=32 or 64
395
bffd3caf2d2c Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*.
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
112 # endif
579
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
113 #endif
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
114
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
115
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
116 // Define some printf specifiers and other useful things
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
117 #if TH_ARCH == 32
672
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
118 # define PRIu_SIZE_T PRIu32
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
119 # define PRId_SSIZE_T PRId32
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
120 # define PRIx_SIZE_T PRIx32
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
121 # define PRIX_SIZE_T PRIX32
723
10f2eba7c59b Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents: 722
diff changeset
122 # ifdef TH_USE_BONK_TYPES
672
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
123 # define PRId_OFF_T "ld"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
124 # define PRIx_OFF_T "lx"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
125 # define PRIX_OFF_T "lX"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
126 # else
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
127 # define PRId_OFF_T PRId32
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
128 # define PRIx_OFF_T PRIx32
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
129 # define PRIX_OFF_T PRIX32
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
130 # endif
579
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
131 # ifndef TH_PTRSIZE
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
132 # define TH_PTRSIZE 32
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
133 # endif
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
134 # ifndef INTPTR_MIN
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
135 # define INTPTR_MIN (-0x7fffffffL - 1)
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
136 # define INTPTR_MAX ( 0x7fffffffL)
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
137 # define UINTPTR_MAX ( 0xffffffffUL)
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
138 # endif
c054e5831dfb Clean up the th_types.h header #ifdef mess slightly.
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
139 #elif TH_ARCH == 64
723
10f2eba7c59b Perhaps improve type definitions for MinGW v8+
Matti Hamalainen <ccr@tnsp.org>
parents: 722
diff changeset
140 # ifdef TH_USE_BONK_TYPES
672
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
141 # define PRIu_SIZE_T "I64u"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
142 # define PRId_SSIZE_T "I64d"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
143 # define PRIx_SIZE_T "I64x"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
144 # define PRIX_SIZE_T "I64X"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
145 # define PRId_OFF_T "I64d"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
146 # define PRIx_OFF_T "I64x"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
147 # define PRIX_OFF_T "I64X"
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
148 # else
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
149 # define PRIu_SIZE_T PRIu64
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
150 # define PRId_SSIZE_T PRId64
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
151 # define PRIx_SIZE_T PRIx64
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
152 # define PRIX_SIZE_T PRIX64
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
153 # define PRId_OFF_T PRId64
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
154 # define PRIx_OFF_T PRIx64
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
155 # define PRIX_OFF_T PRIX64
1d4d22c862ed Mess with PRI* types again.
Matti Hamalainen <ccr@tnsp.org>
parents: 663
diff changeset
156 # endif
308
0078dc5f6260 Define TH_PTRSIZE and UINTPTR_MAX if not defined already.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
157 # ifndef TH_PTRSIZE
0078dc5f6260 Define TH_PTRSIZE and UINTPTR_MAX if not defined already.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
158 # define TH_PTRSIZE 64
0078dc5f6260 Define TH_PTRSIZE and UINTPTR_MAX if not defined already.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
159 # endif
400
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
160 # ifndef INTPTR_MIN
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
161 # define INTPTR_MIN (-0x7fffffffffffffffL - 1)
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
162 # define INTPTR_MAX ( 0x7fffffffffffffffL)
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
163 # define UINTPTR_MAX ( 0xffffffffffffffffUL)
308
0078dc5f6260 Define TH_PTRSIZE and UINTPTR_MAX if not defined already.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
164 # endif
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 #endif
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166
400
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
167
575
ebdfc1fe1c98 Fixes to the type definitions.
Matti Hamalainen <ccr@tnsp.org>
parents: 573
diff changeset
168 /* Default assumptions for these types should be ok for most 32/64bit platforms...
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 */
582
8c516309037e Check for !defined(HAVE_STDINT_H) && !defined(HAVE_SYS_TYPES_H) before
Matti Hamalainen <ccr@tnsp.org>
parents: 579
diff changeset
170 #if !defined(HAVE_STDINT_H) && !defined(HAVE_SYS_TYPES_H)
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 typedef unsigned char uint8_t;
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 typedef signed char int8_t;
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 typedef unsigned short int uint16_t;
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 typedef signed short int int16_t;
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 typedef unsigned int uint32_t;
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 typedef signed int int32_t;
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 typedef unsigned long long uint64_t;
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 typedef signed long long int64_t;
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179
400
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
180 #if TH_ARCH == 32
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
181 typedef long long int intmax_t;
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
182 typedef unsigned long long int uintmax_t;
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
183 #elif TH_ARCH == 64
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
184 typedef long int intmax_t;
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
185 typedef unsigned long int uintmax_t;
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
186 #endif
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
187 #endif
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
188
f7919a143fcb Add some missing types and macros when we do not have inttypes.h or stdint.h
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
189
453
efd33accdc81 Break backwards compatibility by renaming BOOL, TRUE and FALSE to lowercase.
Matti Hamalainen <ccr@tnsp.org>
parents: 432
diff changeset
190 /* Define a boolean type, if needed
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 */
735
31bc1ed07cf5 Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
192 #if defined(HAVE_STDBOOL_H)
31bc1ed07cf5 Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
193 # include <stdbool.h>
31bc1ed07cf5 Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
194 #elif !defined(false) && !defined(true) && !defined(bool)
31bc1ed07cf5 Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
195 typedef enum { false = 0, true = 1 } bool;
31bc1ed07cf5 Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
196 #else
31bc1ed07cf5 Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
Matti Hamalainen <ccr@tnsp.org>
parents: 726
diff changeset
197 # error Missing boolean definition and could not define our own.
457
85fa3d333556 Actually, revert the boolean changes .. meh.
Matti Hamalainen <ccr@tnsp.org>
parents: 456
diff changeset
198 #endif
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199
663
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
200
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
201 /** @brief th_char_t
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
202 * Character type. Currently it is not recommended to re-define this,
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
203 * but in distant future it may be possible to change to uint32_t for
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
204 * Unicode 32bit handling.
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
205 */
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
206 #ifdef TH_CHAR_TYPE
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
207 typedef TH_CHAR_TYPE th_char_t;
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
208 #else
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
209 typedef char th_char_t;
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
210 #endif
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
211
284d5b789b7c Add th_char_t type.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
212
392
851468fda833 s/_TH_TYPES_H/TH_TYPES_H/g
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
213 #endif // TH_TYPES_H