Platform.h 8.8 KB

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