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__)) && defined(__LP64__)
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_RISCV64
98#elif defined(__riscv)
99# define OF_RISCV
100#elif defined(__s390x__)
101# define OF_S390X
102#elif defined(__s390__)
103# define OF_S390
104#elif defined(__sh__)
105# define OF_SUPERH
106#elif defined(__e2k__)
107# define OF_ELBRUS_2000
108#elif defined(__loongarch64)
109# define OF_LOONGARCH64
110#endif
111
112#if defined(__APPLE__)
113# include <TargetConditionals.h>
114# if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
115 (defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR)
116# define OF_IOS
117# else
118# define OF_MACOS
119# endif
120#elif defined(__linux__)
121# define OF_LINUX
122#elif defined(_WIN32)
123# define OF_WINDOWS
124#elif defined(__FreeBSD__)
125# define OF_FREEBSD
126#elif defined(__NetBSD__)
127# define OF_NETBSD
128#elif defined(__OpenBSD__)
129# define OF_OPENBSD
130#elif defined(__DragonFly__)
131# define OF_DRAGONFLYBSD
132#elif defined(__ANDROID__)
133# define OF_ANDROID
134#elif defined(__HAIKU__)
135# define OF_HAIKU
136#elif defined(_AIX)
137# define OF_AIX
138#elif defined(__MORPHOS__)
139# define OF_MORPHOS
140# define OF_AMIGAOS
141#elif defined(__amigaos4__)
142# define OF_AMIGAOS4
143# define OF_AMIGAOS
144#elif defined(__amigaos__)
145# define OF_AMIGAOS_M68K
146# define OF_AMIGAOS
147#elif defined(__sun__)
148# define OF_SOLARIS
149#elif defined(__QNX__)
150# define OF_QNX
151#elif defined(__hpux__)
152# define OF_HPUX
153#elif defined(_PSP)
154# define OF_PSP
155#elif defined(__DJGPP__)
156# define OF_DJGPP
157# define OF_MSDOS
158#elif defined(__riscos__)
159# define OF_ACORN_RISC_OS
160#elif defined(__MINT__)
161# define OF_MINT
162#elif defined(__gnu_hurd__)
163# define OF_HURD
164#elif defined(__serenity__)
165# define OF_SERENITYOS
166#endif
167
168#ifdef __GLIBC__
169# define OF_GLIBC
170#endif
171
172#if defined(__ELF__)
173# define OF_ELF
174#elif defined(__MACH__)
175# define OF_MACH_O
176#endif
177
178#if defined(__PIC__) || defined(__pic__)
179# define OF_PIC
180#endif