ObjFW
Loading...
Searching...
No Matches
platform.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#include "objfw-defs.h"
21
22/* Required to build universal binaries on OS X */
23#ifdef OF_UNIVERSAL
24# if __BIG_ENDIAN__
25# define OF_BIG_ENDIAN
26# define OF_FLOAT_BIG_ENDIAN
27# elif !__LITTLE_ENDIAN__
28# error OF_UNIVERSAL defined, but neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__!
29# endif
30#endif
31
32#if defined(__x86_64__) || defined(__amd64__)
33# define OF_AMD64
34#elif defined(__i386__)
35# define OF_X86
36#elif defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__)
37# define OF_POWERPC64
38#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__)
39# define OF_POWERPC
40#elif defined(__arm64__) || defined(__aarch64__) || defined(__ARM64_ARCH_8__)
41# define OF_ARM64
42#elif defined(__arm__) || defined(__ARM__)
43# define OF_ARM
44# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
45 defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || \
46 defined(__ARM_ARCH_7EM__)
47# define OF_ARMV7
48# endif
49# if defined(OF_ARMV7) || defined(__ARM_ARCH_6__) || \
50 defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || \
51 defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || \
52 defined(__ARM_ARCH_6T2__)
53# define OF_ARMV6
54# endif
55#elif defined(_MIPS_SIM)
56# if _MIPS_SIM == _ABI64
57# define OF_MIPS64
58# define OF_MIPS64_N64
59# elif _MIPS_SIM == _ABIN32
60# define OF_MIPS64
61# define OF_MIPS64_N32
62# elif _MIPS_SIM == _ABIO32
63# define OF_MIPS
64# define OF_MIPS_O32
65# endif
66#elif defined(__mips_eabi) && _MIPS_SZPTR == 32
67# define OF_MIPS
68# define OF_MIPS_EABI
69#elif defined(__sparc64__) || (defined(__sparc__) && defined(__arch64__))
70# define OF_SPARC64
71#elif defined(__sparc__) && !defined(__arch64__)
72# define OF_SPARC
73#elif defined(__hppa64__) || defined(_PA_RISC2_0)
74# define OF_PA_RISC_2_0
75#elif defined(__hppa__) || defined(_PA_RISC1_0) || defined(_PA_RISC1_1)
76# define OF_PA_RISC
77#elif defined(__ia64__) || defined(__IA64__)
78# define OF_ITANIUM
79#elif defined(__m68k__)
80# define OF_M68K
81# ifdef __mc68060__
82# define OF_M68060
83# endif
84# if defined(__mc68040__) || defined(OF_M68060)
85# define OF_M68040
86# endif
87# if defined(__mc68030__) || defined(OF_M68040)
88# define OF_M68030
89# endif
90# if defined(__mc68020__) || defined(OF_M68030)
91# define OF_M68020
92# endif
93# if defined(__mc68010__) || defined(OF_M68020)
94# define OF_M68010
95# endif
96#elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
97# define OF_RISC_V_64
98#elif defined(__riscv)
99# define OF_RISC_V
100#elif defined(__s390x__)
101# define OF_S390X
102#elif defined(__s390__)
103# define OF_S390
104#elif defined(__e2k__)
105# define OF_ELBRUS_2000
106#endif
107
108#if defined(__APPLE__)
109# include <TargetConditionals.h>
110# if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
111 (defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR)
112# define OF_IOS
113# else
114# define OF_MACOS
115# endif
116#elif defined(__linux__)
117# define OF_LINUX
118#elif defined(_WIN32)
119# define OF_WINDOWS
120#elif defined(__FreeBSD__)
121# define OF_FREEBSD
122#elif defined(__NetBSD__)
123# define OF_NETBSD
124#elif defined(__OpenBSD__)
125# define OF_OPENBSD
126#elif defined(__DragonFly__)
127# define OF_DRAGONFLYBSD
128#elif defined(__ANDROID__)
129# define OF_ANDROID
130#elif defined(__HAIKU__)
131# define OF_HAIKU
132#elif defined(_AIX)
133# define OF_AIX
134#elif defined(__MORPHOS__)
135# define OF_MORPHOS
136# define OF_AMIGAOS
137#elif defined(__amigaos4__)
138# define OF_AMIGAOS4
139# define OF_AMIGAOS
140#elif defined(__amigaos__)
141# define OF_AMIGAOS_M68K
142# define OF_AMIGAOS
143#elif defined(__sun__)
144# define OF_SOLARIS
145#elif defined(__QNX__)
146# define OF_QNX
147#elif defined(__hpux__)
148# define OF_HPUX
149#elif defined(_PSP)
150# define OF_PSP
151#elif defined(__DJGPP__)
152# define OF_DJGPP
153# define OF_MSDOS
154#elif defined(__riscos__)
155# define OF_ACORN_RISC_OS
156#elif defined(__MINT__)
157# define OF_MINT
158#elif defined(__gnu_hurd__)
159# define OF_HURD
160#endif
161
162#ifdef __GLIBC__
163# define OF_GLIBC
164#endif
165
166#if defined(__ELF__)
167# define OF_ELF
168#elif defined(__MACH__)
169# define OF_MACH_O
170#endif
171
172#if defined(__PIC__) || defined(__pic__)
173# define OF_PIC
174#endif