1//
2// Platform.h
3//
4// Library: Foundation
5// Package: Core
6// Module: Platform
7//
8// Platform and architecture identification macros.
9//
10// NOTE: This file may be included from both C++ and C code, so it
11// must not contain any C++ specific things.
12//
13// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
14// and Contributors.
15//
16// SPDX-License-Identifier: BSL-1.0
17//
18
19
20#ifndef Foundation_Platform_INCLUDED
21#define Foundation_Platform_INCLUDED
22
23
24//
25// Platform Identification
26//
27#define POCO_OS_FREE_BSD 0x0001
28#define POCO_OS_AIX 0x0002
29#define POCO_OS_HPUX 0x0003
30#define POCO_OS_TRU64 0x0004
31#define POCO_OS_LINUX 0x0005
32#define POCO_OS_MAC_OS_X 0x0006
33#define POCO_OS_NET_BSD 0x0007
34#define POCO_OS_OPEN_BSD 0x0008
35#define POCO_OS_IRIX 0x0009
36#define POCO_OS_SOLARIS 0x000a
37#define POCO_OS_QNX 0x000b
38#define POCO_OS_VXWORKS 0x000c
39#define POCO_OS_CYGWIN 0x000d
40#define POCO_OS_NACL 0x000e
41#define POCO_OS_ANDROID 0x000f
42#define POCO_OS_EMSCRIPTEN 0x0010
43#define POCO_OS_UNKNOWN_UNIX 0x00ff
44#define POCO_OS_WINDOWS_NT 0x1001
45#define POCO_OS_WINDOWS_CE 0x1011
46#define POCO_OS_VMS 0x2001
47
48
49#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
50 #define POCO_OS_FAMILY_UNIX 1
51 #define POCO_OS_FAMILY_BSD 1
52 #define POCO_OS POCO_OS_FREE_BSD
53#elif defined(_AIX) || defined(__TOS_AIX__)
54 #define POCO_OS_FAMILY_UNIX 1
55 #define POCO_OS POCO_OS_AIX
56#elif defined(hpux) || defined(_hpux) || defined(__hpux)
57 #define POCO_OS_FAMILY_UNIX 1
58 #define POCO_OS POCO_OS_HPUX
59#elif defined(__digital__) || defined(__osf__)
60 #define POCO_OS_FAMILY_UNIX 1
61 #define POCO_OS POCO_OS_TRU64
62#elif defined(__NACL__)
63 #define POCO_OS_FAMILY_UNIX 1
64 #define POCO_OS POCO_OS_NACL
65#elif defined(__EMSCRIPTEN__) || defined(EMSCRIPTEN)
66 #define POCO_OS_FAMILY_UNIX 1
67 #define POCO_OS POCO_OS_EMSCRIPTEN
68#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__TOS_LINUX__)
69 #define POCO_OS_FAMILY_UNIX 1
70 #if defined(__ANDROID__)
71 #define POCO_OS POCO_OS_ANDROID
72 #else
73 #define POCO_OS POCO_OS_LINUX
74 #endif
75#elif defined(__APPLE__) || defined(__TOS_MACOS__)
76 #define POCO_OS_FAMILY_UNIX 1
77 #define POCO_OS_FAMILY_BSD 1
78 #define POCO_OS POCO_OS_MAC_OS_X
79#elif defined(__NetBSD__)
80 #define POCO_OS_FAMILY_UNIX 1
81 #define POCO_OS_FAMILY_BSD 1
82 #define POCO_OS POCO_OS_NET_BSD
83#elif defined(__OpenBSD__)
84 #define POCO_OS_FAMILY_UNIX 1
85 #define POCO_OS_FAMILY_BSD 1
86 #define POCO_OS POCO_OS_OPEN_BSD
87#elif defined(sgi) || defined(__sgi)
88 #define POCO_OS_FAMILY_UNIX 1
89 #define POCO_OS POCO_OS_IRIX
90#elif defined(sun) || defined(__sun)
91 #define POCO_OS_FAMILY_UNIX 1
92 #define POCO_OS POCO_OS_SOLARIS
93#elif defined(__QNX__)
94 #define POCO_OS_FAMILY_UNIX 1
95 #define POCO_OS POCO_OS_QNX
96#elif defined(__CYGWIN__)
97 #define POCO_OS_FAMILY_UNIX 1
98 #define POCO_OS POCO_OS_CYGWIN
99#elif defined(POCO_VXWORKS)
100 #define POCO_OS_FAMILY_UNIX 1
101 #define POCO_OS POCO_OS_VXWORKS
102#elif defined(unix) || defined(__unix) || defined(__unix__)
103 #define POCO_OS_FAMILY_UNIX 1
104 #define POCO_OS POCO_OS_UNKNOWN_UNIX
105#elif defined(_WIN32_WCE)
106 #define POCO_OS_FAMILY_WINDOWS 1
107 #define POCO_OS POCO_OS_WINDOWS_CE
108#elif defined(_WIN32) || defined(_WIN64)
109 #define POCO_OS_FAMILY_WINDOWS 1
110 #define POCO_OS POCO_OS_WINDOWS_NT
111#elif defined(__VMS)
112 #define POCO_OS_FAMILY_VMS 1
113 #define POCO_OS POCO_OS_VMS
114#endif
115
116
117#if !defined(POCO_OS)
118 #error "Unknown Platform."
119#endif
120
121
122//
123// Hardware Architecture and Byte Order
124//
125#define POCO_ARCH_ALPHA 0x01
126#define POCO_ARCH_IA32 0x02
127#define POCO_ARCH_IA64 0x03
128#define POCO_ARCH_MIPS 0x04
129#define POCO_ARCH_HPPA 0x05
130#define POCO_ARCH_PPC 0x06
131#define POCO_ARCH_POWER 0x07
132#define POCO_ARCH_SPARC 0x08
133#define POCO_ARCH_AMD64 0x09
134#define POCO_ARCH_ARM 0x0a
135#define POCO_ARCH_M68K 0x0b
136#define POCO_ARCH_S390 0x0c
137#define POCO_ARCH_SH 0x0d
138#define POCO_ARCH_NIOS2 0x0e
139#define POCO_ARCH_AARCH64 0x0f
140#define POCO_ARCH_ARM64 0x0f
141#define POCO_ARCH_RISCV64 0x10
142
143#if defined(__ALPHA) || defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA)
144 #define POCO_ARCH POCO_ARCH_ALPHA
145 #define POCO_ARCH_LITTLE_ENDIAN 1
146#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(EMSCRIPTEN) || defined(__EMSCRIPTEN__)
147 #define POCO_ARCH POCO_ARCH_IA32
148 #define POCO_ARCH_LITTLE_ENDIAN 1
149#elif defined(_IA64) || defined(__IA64__) || defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
150 #define POCO_ARCH POCO_ARCH_IA64
151 #if defined(hpux) || defined(_hpux)
152 #define POCO_ARCH_BIG_ENDIAN 1
153 #else
154 #define POCO_ARCH_LITTLE_ENDIAN 1
155 #endif
156#elif defined(__x86_64__) || defined(_M_X64)
157 #define POCO_ARCH POCO_ARCH_AMD64
158 #define POCO_ARCH_LITTLE_ENDIAN 1
159#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(_M_MRX000)
160 #define POCO_ARCH POCO_ARCH_MIPS
161 #if defined(POCO_OS_FAMILY_WINDOWS)
162 // Is this OK? Supports windows only little endian??
163 #define POCO_ARCH_LITTLE_ENDIAN 1
164 #elif defined(__MIPSEB__) || defined(_MIPSEB) || defined(__MIPSEB)
165 #define POCO_ARCH_BIG_ENDIAN 1
166 #elif defined(__MIPSEL__) || defined(_MIPSEL) || defined(__MIPSEL)
167 #define POCO_ARCH_LITTLE_ENDIAN 1
168 #else
169 #error "MIPS but neither MIPSEL nor MIPSEB?"
170 #endif
171#elif defined(__hppa) || defined(__hppa__)
172 #define POCO_ARCH POCO_ARCH_HPPA
173 #define POCO_ARCH_BIG_ENDIAN 1
174#elif defined(__PPC) || defined(__POWERPC__) || defined(__powerpc) || defined(__PPC__) || \
175 defined(__powerpc__) || defined(__ppc__) || defined(__ppc) || defined(_ARCH_PPC) || defined(_M_PPC)
176 #define POCO_ARCH POCO_ARCH_PPC
177 #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
178 #define POCO_ARCH_LITTLE_ENDIAN 1
179 #else
180 #define POCO_ARCH_BIG_ENDIAN 1
181 #endif
182#elif defined(_POWER) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_ARCH_PWR3) || \
183 defined(_ARCH_PWR4) || defined(__THW_RS6000)
184 #define POCO_ARCH POCO_ARCH_POWER
185 #define POCO_ARCH_BIG_ENDIAN 1
186#elif defined(__sparc__) || defined(__sparc) || defined(sparc)
187 #define POCO_ARCH POCO_ARCH_SPARC
188 #define POCO_ARCH_BIG_ENDIAN 1
189#elif defined(__arm__) || defined(__arm) || defined(ARM) || defined(_ARM_) || defined(__ARM__) || defined(_M_ARM)
190 #define POCO_ARCH POCO_ARCH_ARM
191 #if defined(__ARMEB__)
192 #define POCO_ARCH_BIG_ENDIAN 1
193 #else
194 #define POCO_ARCH_LITTLE_ENDIAN 1
195 #endif
196#elif defined(__arm64__) || defined(__arm64)
197 #define POCO_ARCH POCO_ARCH_ARM64
198 #if defined(__ARMEB__)
199 #define POCO_ARCH_BIG_ENDIAN 1
200 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
201 #define POCO_ARCH_BIG_ENDIAN 1
202 #else
203 #define POCO_ARCH_LITTLE_ENDIAN 1
204 #endif
205#elif defined(__m68k__)
206 #define POCO_ARCH POCO_ARCH_M68K
207 #define POCO_ARCH_BIG_ENDIAN 1
208#elif defined(__s390__)
209 #define POCO_ARCH POCO_ARCH_S390
210 #define POCO_ARCH_BIG_ENDIAN 1
211#elif defined(__sh__) || defined(__sh) || defined(SHx) || defined(_SHX_)
212 #define POCO_ARCH POCO_ARCH_SH
213 #if defined(__LITTLE_ENDIAN__) || (POCO_OS == POCO_OS_WINDOWS_CE)
214 #define POCO_ARCH_LITTLE_ENDIAN 1
215 #else
216 #define POCO_ARCH_BIG_ENDIAN 1
217 #endif
218#elif defined (nios2) || defined(__nios2) || defined(__nios2__)
219 #define POCO_ARCH POCO_ARCH_NIOS2
220 #if defined(__nios2_little_endian) || defined(nios2_little_endian) || defined(__nios2_little_endian__)
221 #define POCO_ARCH_LITTLE_ENDIAN 1
222 #else
223 #define POCO_ARCH_BIG_ENDIAN 1
224 #endif
225#elif defined(__AARCH64EL__)
226 #define POCO_ARCH POCO_ARCH_AARCH64
227 #define POCO_ARCH_LITTLE_ENDIAN 1
228#elif defined(__AARCH64EB__)
229 #define POCO_ARCH POCO_ARCH_AARCH64
230 #define POCO_ARCH_BIG_ENDIAN 1
231#elif defined(__riscv) && (__riscv_xlen == 64)
232 #define POCO_ARCH POCO_ARCH_RISCV64
233 #define POCO_ARCH_LITTLE_ENDIAN 1
234#endif
235
236
237#if defined(__clang__)
238 #define POCO_COMPILER_CLANG
239 #if defined(__apple_build_version__)
240 #define POCO_COMPILER_APPLECLANG
241 #endif
242#elif defined(_MSC_VER)
243 #define POCO_COMPILER_MSVC
244#elif defined (__GNUC__)
245 #define POCO_COMPILER_GCC
246 #if defined (__MINGW32__) || defined (__MINGW64__)
247 #define POCO_COMPILER_MINGW
248 #endif
249#elif defined (__INTEL_COMPILER) || defined(__ICC) || defined(__ECC) || defined(__ICL)
250 #define POCO_COMPILER_INTEL
251#elif defined (__SUNPRO_CC)
252 #define POCO_COMPILER_SUN
253#elif defined (__MWERKS__) || defined(__CWCC__)
254 #define POCO_COMPILER_CODEWARRIOR
255#elif defined (__sgi) || defined(sgi)
256 #define POCO_COMPILER_SGI
257#elif defined (__HP_aCC)
258 #define POCO_COMPILER_HP_ACC
259#elif defined (__BORLANDC__) || defined(__CODEGEARC__)
260 #define POCO_COMPILER_CBUILDER
261#elif defined (__DMC__)
262 #define POCO_COMPILER_DMARS
263#elif defined (__DECCXX)
264 #define POCO_COMPILER_COMPAC
265#elif (defined (__xlc__) || defined (__xlC__)) && defined(__IBMCPP__)
266 #define POCO_COMPILER_IBM_XLC // IBM XL C++
267#elif defined (__IBMCPP__) && defined(__COMPILER_VER__)
268 #define POCO_COMPILER_IBM_XLC_ZOS // IBM z/OS C++
269#endif
270
271
272#if defined(POCO_COMPILER_GCC) || defined(POCO_COMPILER_CLANG)
273#define POCO_UNUSED __attribute__((unused))
274#else
275#define POCO_UNUSED
276#endif // __GNUC__
277
278
279#if !defined(POCO_ARCH)
280 #error "Unknown Hardware Architecture."
281#endif
282
283
284#if defined(POCO_OS_FAMILY_WINDOWS)
285 #define POCO_DEFAULT_NEWLINE_CHARS "\r\n"
286#else
287 #define POCO_DEFAULT_NEWLINE_CHARS "\n"
288#endif
289
290
291#endif // Foundation_Platform_INCLUDED
292