]>
Commit | Line | Data |
---|---|---|
832b75ed GG |
1 | /* |
2 | * int64.h | |
3 | * | |
a86ec89e | 4 | * Home page of code is: http://www.smartmontools.org |
832b75ed | 5 | * |
d008864d GI |
6 | * Copyright (C) 2002-11 Bruce Allen <smartmontools-support@lists.sourceforge.net> |
7 | * Copyright (C) 2004-11 Christian Franke | |
832b75ed GG |
8 | * |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2, or (at your option) | |
12 | * any later version. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
ee38a438 GI |
15 | * (for example COPYING); if not, write to the Free Software Foundation, |
16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
832b75ed GG |
17 | * |
18 | */ | |
19 | ||
20 | #ifndef INT64_H_ | |
21 | #define INT64_H_ | |
22 | ||
a86ec89e | 23 | #define INT64_H_CVSID "$Id: int64.h 4120 2015-08-27 16:12:21Z samm2 $" |
832b75ed | 24 | |
ba59cff1 | 25 | // 64 bit integer typedefs and format strings |
832b75ed GG |
26 | |
27 | #ifdef HAVE_INTTYPES_H | |
ba59cff1 GG |
28 | // The ISO C99 standard specifies that in C++ implementations the PRI* macros |
29 | // from <inttypes.h> should only be defined if explicitly requested | |
30 | #define __STDC_FORMAT_MACROS 1 | |
31 | #include <inttypes.h> // PRId64, PRIu64, PRIx64 (also includes <stdint.h>) | |
832b75ed GG |
32 | #else |
33 | #ifdef HAVE_STDINT_H | |
ba59cff1 | 34 | #include <stdint.h> // int64_t, uint64_t (usually included above) |
832b75ed GG |
35 | #else |
36 | #ifdef HAVE_SYS_INTTYPES_H | |
37 | #include <sys/inttypes.h> | |
38 | #else | |
39 | #ifdef HAVE_SYS_INT_TYPES_H | |
40 | #include <sys/int_types.h> | |
41 | #else | |
42 | #if defined(_WIN32) && defined(_MSC_VER) | |
d008864d | 43 | // for MSVC <= 9 (MSVC10 and MinGW provide <stdint.h>) |
832b75ed GG |
44 | typedef __int64 int64_t; |
45 | typedef unsigned __int64 uint64_t; | |
46 | #else | |
47 | // for systems with above includes missing (like ix86-pc-linux-gnulibc1), | |
48 | // default to GCC if types are undefined in types.h | |
49 | #include <sys/types.h> | |
50 | #ifndef HAVE_INT64_T | |
51 | typedef long long int64_t; | |
52 | #endif | |
53 | #ifndef HAVE_UINT64_T | |
54 | typedef unsigned long long uint64_t; | |
55 | #endif | |
56 | #endif // _WIN32 && _MSC_VER | |
57 | #endif // HAVE_SYS_INT_TYPES_H | |
58 | #endif // HAVE_SYS_INTTYPES_H | |
59 | #endif // HAVE_STDINT_H | |
60 | #endif // HAVE_INTTYPES_H | |
61 | ||
d008864d GI |
62 | #if defined(_WIN32) && !defined(PRId64) |
63 | // for MSVC (MinGW provides <inttypes.h>) | |
832b75ed GG |
64 | #define PRId64 "I64d" |
65 | #define PRIu64 "I64u" | |
66 | #define PRIx64 "I64x" | |
d008864d | 67 | #endif // _WIN32 && !PRId64 |
832b75ed GG |
68 | |
69 | // If macros not defined in inttypes.h, fix here. Default is GCC | |
70 | // style | |
ba59cff1 | 71 | #ifndef PRId64 |
832b75ed GG |
72 | #define PRId64 "lld" |
73 | #endif // ndef PRId64 | |
74 | ||
75 | #ifndef PRIu64 | |
76 | #define PRIu64 "llu" | |
77 | #endif // ndef PRIu64 | |
78 | ||
79 | #ifndef PRIx64 | |
80 | #define PRIx64 "llx" | |
81 | #endif // ndef PRIx64 | |
82 | ||
832b75ed | 83 | #endif // INT64_H |