Debian Codegraph @

c/include/proton/type_compat.h

raw
1 #ifndef PROTON_TYPE_COMPAT_H
2 #define PROTON_TYPE_COMPAT_H 1
3
4 /*
5 *
6 * Licensed to the Apache Software Foundation (ASF) under one
7 * or more contributor license agreements. See the NOTICE file
8 * distributed with this work for additional information
9 * regarding copyright ownership. The ASF licenses this file
10 * to you under the Apache License, Version 2.0 (the
11 * "License"); you may not use this file except in compliance
12 * with the License. You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an
18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 * KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations
21 * under the License.
22 *
23 */
24
25 /**
26 * @cond INTERNAL
27 */
28
29 /* Get Boolean */
30 #if !defined(__cplusplus) && !defined(__bool_true_false_are_defined)
31 # if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3 || _MSC_VER >=1800
32 # include <stdbool.h>
33 # else
34 /* Need to get bool/true/false manually */
35 # if _MSC_VER
36 # define bool char
37 # define false 0
38 # define true 1
39 # define __bool_true_false_are_defined
40 # else
41 # error "No definitions for bool/true/false"
42 # endif
43 # endif
44 #endif
45 /*
46 * Handle special cases for stdint.h and the definition for ssize_t.
47 * Third party libraries (e.g. Boost) may provide competing solutions.
48 *
49 * The effects of this include file may be controlled by overrides:
50 * PN_DEFINE_STDINT/PN_NODEFINE_STDINT : turn on/off definition of int64_t etc.
51 * PN_DEFINE_SSIZE_T/PN_NODEFINE_SSIZE_T : turn on/off definition of ssize_t
52 * PN_INCLUDE_STDINT/PN_NOINCLUDE_STDINT : include (or not) stdint.h
53 */
54
55 /* Honor positive overrides */
56 #if defined(PN_DEFINE_STDINT)
57 # define PNI_DEFINE_STDINT
58 #endif
59 #if defined(PN_INCLUDE_STDINT)
60 # define PNI_INCLUDE_STDINT)
61 #endif
62 #if defined(PN_DEFINE_SSIZE_T)
63 # define PNI_DEFINE_SSIZE_T
64 #endif
65
66 /* Determine default action */
67 #ifndef _MSC_VER
68 /* Not Windows and not using Visual Studio */
69
70 /* MBED_BUILD_TIMESTAMP is used to detect whether Proton is being built on www.mbed.org with
71 the ARM compiler. In that case ssize_t needs to be defined in this file. */
72 #if defined(MBED_BUILD_TIMESTAMP)
73 # define PNI_DEFINE_SSIZE_T
74 #else
75 #include <sys/types.h>
76 #endif /* defined(MBED_LIBRARY_VERSION) */
77
78 # ifndef PNI_INCLUDE_STDINT
79 # define PNI_INCLUDE_STDINT
80 # endif
81 #else
82 /* all versions of Visual Studio */
83 # ifndef PNI_DEFINE_SSIZE_T
84 /* ssize_t def is needed, unless third party definition interferes, e.g. python/swig */
85 # ifndef Py_CONFIG_H
86 # define PNI_DEFINE_SSIZE_T
87 # endif
88 # endif
89
90 # if (_MSC_VER < 1600)
91 /* VS 2008 and earlier */
92 # ifndef PNI_DEFINE_STDINT
93 # define PNI_DEFINE_STDINT
94 # endif
95 # else
96 /* VS 2010 and newer */
97 # ifndef PNI_INCLUDE_STDINT
98 # define PNI_INCLUDE_STDINT
99 # endif
100
101 # endif /* (_MSC_VER < 1600) */
102 #endif /*_MSC_VER */
103
104 /* Honor negative overrides */
105 #ifdef PN_NODEFINE_SSIZE_T
106 # undef PNI_DEFINE_SSIZE_T
107 #endif
108 #ifdef PN_NODEFINE_STDINT
109 # undef PNI_DEFINE_STDINT
110 #endif
111 #ifdef PN_NOINCLUDE_STDINT
112 # undef PNI_INCLUDE_STDINT
113 #endif
114
115 #ifdef PNI_INCLUDE_STDINT
116 # include <stdint.h>
117 #endif
118
119 #ifdef PNI_DEFINE_SSIZE_T
120 # ifdef _MSC_VER
121 # include <BaseTsd.h>
122 typedef SSIZE_T ssize_t;
123 # else
124 typedef intptr_t ssize_t;
125 # endif
126 #endif /* PNI_DEFINE_SSIZE_T */
127
128 #ifdef PNI_DEFINE_STDINT
129 # ifdef _MSC_VER
130
131 typedef signed __int8 int8_t;
132 typedef signed __int16 int16_t;
133 typedef signed __int32 int32_t;
134 typedef signed __int64 int64_t;
135
136 typedef unsigned __int8 uint8_t;
137 typedef unsigned __int16 uint16_t;
138 typedef unsigned __int32 uint32_t;
139 typedef unsigned __int64 uint64_t;
140
141 #define INT32_MAX (2147483647)
142
143 # else /* _MSC_VER */
144 # error stdint.h definitions not kown
145 # endif
146 #endif /* PNI_DEFINE_SSIZE_T */
147 /**
148 * @endcond
149 */
150
151 #endif /* type_compat.h */