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