~mmach/netext73/webkit2gtk

« back to all changes in this revision

Viewing changes to Source/WTF/wtf/PlatformOS.h

  • Committer: mmach
  • Date: 2023-06-16 17:21:37 UTC
  • Revision ID: netbit73@gmail.com-20230616172137-2rqx6yr96ga9g3kp
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2006-2019 Apple Inc. All rights reserved.
 
3
 * Copyright (C) 2007-2009 Torch Mobile, Inc.
 
4
 * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
 
5
 *
 
6
 * Redistribution and use in source and binary forms, with or without
 
7
 * modification, are permitted provided that the following conditions
 
8
 * are met:
 
9
 * 1. Redistributions of source code must retain the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer.
 
11
 * 2. Redistributions in binary form must reproduce the above copyright
 
12
 *    notice, this list of conditions and the following disclaimer in the
 
13
 *    documentation and/or other materials provided with the distribution.
 
14
 *
 
15
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 
16
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
18
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
 
19
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
20
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
21
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
22
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 
23
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
25
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
26
 */
 
27
 
 
28
#pragma once
 
29
 
 
30
#ifndef WTF_PLATFORM_GUARD_AGAINST_INDIRECT_INCLUSION
 
31
#error "Please #include <wtf/Platform.h> instead of this file directly."
 
32
#endif
 
33
 
 
34
 
 
35
#if defined(__APPLE__)
 
36
#include <Availability.h>
 
37
#include <AvailabilityMacros.h>
 
38
#include <TargetConditionals.h>
 
39
#endif
 
40
 
 
41
 
 
42
/* OS() - underlying operating system; only to be used for mandated low-level services like
 
43
   virtual memory, not to choose a GUI toolkit */
 
44
#define OS(WTF_FEATURE) (defined WTF_OS_##WTF_FEATURE && WTF_OS_##WTF_FEATURE)
 
45
#define OS_CONSTANT(WTF_FEATURE) (WTF_OS_CONSTANT_##WTF_FEATURE)
 
46
 
 
47
 
 
48
/* ==== OS() - underlying operating system; only to be used for mandated low-level services like
 
49
   virtual memory, not to choose a GUI toolkit ==== */
 
50
 
 
51
/* OS(AIX) - AIX */
 
52
#if defined(_AIX)
 
53
#define WTF_OS_AIX 1
 
54
#endif
 
55
 
 
56
/* OS(DARWIN) - Any Darwin-based OS, including macOS, iOS, macCatalyst, tvOS, and watchOS */
 
57
#if defined(__APPLE__)
 
58
#define WTF_OS_DARWIN 1
 
59
#endif
 
60
 
 
61
/* OS(IOS_FAMILY) - iOS family, including iOS, macCatalyst, tvOS, watchOS */
 
62
#if OS(DARWIN) && TARGET_OS_IPHONE
 
63
#define WTF_OS_IOS_FAMILY 1
 
64
#endif
 
65
 
 
66
/* OS(IOS) - iOS only, not including macCatalyst */
 
67
#if OS(DARWIN) && (TARGET_OS_IOS && !(defined(TARGET_OS_MACCATALYST) && TARGET_OS_MACCATALYST))
 
68
#define WTF_OS_IOS 1
 
69
#endif
 
70
 
 
71
/* OS(TVOS) - tvOS */
 
72
#if OS(DARWIN) && TARGET_OS_TV
 
73
#define WTF_OS_TVOS 1
 
74
#endif
 
75
 
 
76
/* OS(WATCHOS) - watchOS */
 
77
#if OS(DARWIN) && TARGET_OS_WATCH
 
78
#define WTF_OS_WATCHOS 1
 
79
#endif
 
80
 
 
81
/* FIXME: Rename this to drop the X, as that is no longer the name of the operating system. */
 
82
/* OS(MAC_OS_X) - macOS (not including iOS family) */
 
83
#if OS(DARWIN) && TARGET_OS_OSX
 
84
#define WTF_OS_MAC_OS_X 1
 
85
#endif
 
86
 
 
87
/* OS(FREEBSD) - FreeBSD */
 
88
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
 
89
#define WTF_OS_FREEBSD 1
 
90
#endif
 
91
 
 
92
/* OS(FUCHSIA) - Fuchsia */
 
93
#if defined(__Fuchsia__)
 
94
#define WTF_OS_FUCHSIA 1
 
95
#endif
 
96
 
 
97
/* OS(HURD) - GNU/Hurd */
 
98
#if defined(__GNU__)
 
99
#define WTF_OS_HURD 1
 
100
#endif
 
101
 
 
102
/* OS(LINUX) - Linux */
 
103
#if defined(__linux__)
 
104
#define WTF_OS_LINUX 1
 
105
#endif
 
106
 
 
107
/* OS(NETBSD) - NetBSD */
 
108
#if defined(__NetBSD__)
 
109
#define WTF_OS_NETBSD 1
 
110
#endif
 
111
 
 
112
/* OS(OPENBSD) - OpenBSD */
 
113
#if defined(__OpenBSD__)
 
114
#define WTF_OS_OPENBSD 1
 
115
#endif
 
116
 
 
117
/* OS(WINDOWS) - Any version of Windows */
 
118
#if defined(WIN32) || defined(_WIN32)
 
119
#define WTF_OS_WINDOWS 1
 
120
#endif
 
121
 
 
122
 
 
123
/* OS(UNIX) - Any Unix-like system */
 
124
#if    OS(AIX)              \
 
125
    || OS(DARWIN)           \
 
126
    || OS(FREEBSD)          \
 
127
    || OS(FUCHSIA)          \
 
128
    || OS(HURD)             \
 
129
    || OS(LINUX)            \
 
130
    || OS(NETBSD)           \
 
131
    || OS(OPENBSD)          \
 
132
    || defined(unix)        \
 
133
    || defined(__unix)      \
 
134
    || defined(__unix__)
 
135
#define WTF_OS_UNIX 1
 
136
#endif
 
137
 
 
138
 
 
139
#if CPU(ADDRESS64)
 
140
#if (OS(IOS) || OS(TVOS) || OS(WATCHOS)) && CPU(ARM64)
 
141
#define WTF_OS_CONSTANT_EFFECTIVE_ADDRESS_WIDTH 36
 
142
#else
 
143
/* We strongly assume that effective address width is <= 48 in 64bit architectures (e.g. NaN boxing). */
 
144
#define WTF_OS_CONSTANT_EFFECTIVE_ADDRESS_WIDTH 48
 
145
#endif
 
146
#else
 
147
#define WTF_OS_CONSTANT_EFFECTIVE_ADDRESS_WIDTH 32
 
148
#endif
 
149
 
 
150
 
 
151
/* Asserts, invariants for macro definitions */
 
152
 
 
153
#define WTF_OS_WIN ERROR "USE WINDOWS WITH OS NOT WIN"
 
154
#define WTF_OS_MAC ERROR "USE MAC_OS_X WITH OS NOT MAC"