1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
4  *                         University Research and Technology
5  *                         Corporation.  All rights reserved.
6  * Copyright (c) 2004-2005 The University of Tennessee and The University
7  *                         of Tennessee Research Foundation.  All rights
8  *                         reserved.
9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10  *                         University of Stuttgart.  All rights reserved.
11  * Copyright (c) 2004-2005 The Regents of the University of California.
12  *                         All rights reserved.
13  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
14  *                         reserved.
15  * Copyright (c) 2016      Research Organization for Information Science
16  *                         and Technology (RIST). All rights reserved.
17  * $COPYRIGHT$
18  *
19  * Additional copyrights may follow
20  *
21  * $HEADER$
22  *
23  * This file includes the C99 stdint.h file if available, and otherwise
24  * defines fixed-width types according to the SIZEOF information
25  * gathered by configure.
26  */
27 
28 #ifndef OPAL_STDINT_H
29 #define OPAL_STDINT_H 1
30 
31 /*
32  * Include what we can and define what is missing.
33  */
34 #include <limits.h>
35 #include <stdint.h>
36 
37 #ifdef HAVE_SYS_TYPES_H
38 #include <sys/types.h>
39 #endif
40 
41 /* 128-bit */
42 
43 #ifdef HAVE_INT128_T
44 
45 typedef int128_t opal_int128_t;
46 typedef uint128_t opal_uint128_t;
47 
48 #define HAVE_OPAL_INT128_T 1
49 
50 #elif defined(HAVE___INT128)
51 
52 /* suppress warning about __int128 type */
53 #pragma GCC diagnostic push
54 /* Clang won't quietly accept "-pedantic", but GCC versions older than ~4.8
55  * won't quietly accept "-Wpedanic".  The whole "#pragma GCC diagnostic ..."
56  * facility only was added to GCC as of version 4.6. */
57 #if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 6)
58 #pragma GCC diagnostic ignored "-Wpedantic"
59 #else
60 #pragma GCC diagnostic ignored "-pedantic"
61 #endif
62 typedef __int128 opal_int128_t;
63 typedef unsigned __int128 opal_uint128_t;
64 #pragma GCC diagnostic pop
65 
66 #define HAVE_OPAL_INT128_T 1
67 
68 #else
69 
70 #define HAVE_OPAL_INT128_T 0
71 
72 #endif
73 
74 /* Pointers */
75 
76 #if SIZEOF_VOID_P == SIZEOF_INT
77 
78 #ifndef HAVE_INTPTR_T
79 typedef signed int intptr_t;
80 #endif
81 
82 #ifndef HAVE_UINTPTR_T
83 typedef unsigned int uintptr_t;
84 #endif
85 
86 #elif SIZEOF_VOID_P == SIZEOF_LONG
87 
88 #ifndef HAVE_INTPTR_T
89 typedef signed long intptr_t;
90 #endif
91 
92 #ifndef HAVE_UINTPTR_T
93 typedef unsigned long uintptr_t;
94 #endif
95 
96 #elif HAVE_LONG_LONG && SIZEOF_VOID_P == SIZEOF_LONG_LONG
97 
98 #ifndef HAVE_INTPTR_T
99 typedef signed long long intptr_t;
100 #endif
101 #ifndef HAVE_UINTPTR_T
102 typedef unsigned long long uintptr_t;
103 #endif
104 
105 #else
106 
107 #error Failed to define pointer-sized integer types
108 
109 #endif
110 
111 /* inttypes.h printf specifiers */
112 # include <inttypes.h>
113 
114 #ifndef PRIsize_t
115 # if defined(ACCEPT_C99)
116 #   define PRIsize_t "zu"
117 # elif SIZEOF_SIZE_T == SIZEOF_LONG
118 #   define PRIsize_t "lu"
119 # elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
120 #   define PRIsize_t "llu"
121 # else
122 #   define PRIsize_t "u"
123 # endif
124 #endif
125 
126 #endif /* OPAL_STDINT_H */
127 
128