1 #ifndef INCLUDED_TYPES_H
2 #define INCLUDED_TYPES_H
3 /* vim: set ts=8 sts=4 sw=4 tw=80 noet: */
4 /*======================================================================
5 Copyright (C) 2004,2005,2009,2011 Walter Doekes <walter+tthsum@wjd.nu>
6 This file is part of tthsum.
7 
8 tthsum is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 tthsum is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with tthsum.  If not, see <http://www.gnu.org/licenses/>.
20 ======================================================================*/
21 
22 /**
23  * A portable way to get fixed width integer types, most notably the
24  * 64-bit unsigned integer and its printf formatting macro. (And a
25  * macro for portable function inlining.)
26  */
27 
28 #ifdef __cplusplus
29     /* Request PRI* macros */
30 #   define __STDC_FORMAT_MACROS
31 #endif
32 
33 #include <limits.h>
34 
35 /* define (u)int*_t types */
36 #ifdef _MSC_VER
37     typedef signed __int8 int8_t;
38     typedef signed __int16 int16_t;
39     typedef signed __int32 int32_t;
40     typedef signed __int64 int64_t;
41     typedef unsigned __int8 uint8_t;
42     typedef unsigned __int16 uint16_t;
43     typedef unsigned __int32 uint32_t;
44     typedef unsigned __int64 uint64_t;
45     typedef signed long ssize_t;
46 #else /* !_MSC_VER */
47 #   include <inttypes.h>
48 #endif /* !_MSC_VER */
49 
50 /* define initialization and formatting types */
51 #ifdef _MSC_VER
52 #   define _LL(x) x##LL
53 #   define _ULL(x) x##ULL
54 #   define PRIu64 "I64u"
55 #   define PRIx64 "I64x"
56 #elif ULONG_MAX == 4294967295U
57 #   define _LL(x) x##LL
58 #   define _ULL(x) x##ULL
59 #else /* !_MSC_VER && ULONG_MAX != 4294967295u */
60 #   define _LL(x) x##L
61 #   define _ULL(x) x##UL
62 #endif /* !_MSC_VER && ULONG_MAX != 4294967295u */
63 
64 /* use inline if compiler supports it */
65 #if _MSC_VER
66 #   define _INLINE __inline
67 #elif __STRICT_ANSI__
68 #   define _INLINE
69 #else
70 #   define _INLINE inline
71 #endif
72 
73 #endif /* INCLUDED_TYPES_H */
74