1/* -*- mode: c++; c-basic-offset: 4 -*- */
2/*
3 * Copyright (C) 2006-2010 Apple Computer, Inc.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27/* Taken from WebKit: JavaScriptCore/wtf/Platform.h. */
28
29#ifndef PLATFORM_STD_PLATFORM_H
30#define PLATFORM_STD_PLATFORM_H
31
32/*!
33 * @header Platform and configuration macros.
34 */
35
36/* PLATFORM handles OS, operating environment, graphics API, and CPU */
37#define PLATFORM(WTF_FEATURE) \
38    (defined( WTF_PLATFORM_##WTF_FEATURE ) && WTF_PLATFORM_##WTF_FEATURE)
39
40#define COMPILER(WTF_FEATURE) \
41    (defined( WTF_COMPILER_##WTF_FEATURE ) && WTF_COMPILER_##WTF_FEATURE)
42
43#define HAVE(WTF_FEATURE) \
44    (defined( HAVE_##WTF_FEATURE ) && HAVE_##WTF_FEATURE)
45
46#define USE(WTF_FEATURE) \
47    (defined( WTF_USE_##WTF_FEATURE ) && WTF_USE_##WTF_FEATURE)
48
49#define ENABLE(WTF_FEATURE) \
50    (defined( ENABLE_##WTF_FEATURE ) && ENABLE_##WTF_FEATURE)
51
52/* Operating systems - low-level dependencies */
53
54/* PLATFORM(DARWIN) */
55/* Operating system level dependencies for Mac OS X / Darwin that should */
56/* be used regardless of operating environment */
57#ifdef __APPLE__
58#define WTF_PLATFORM_DARWIN 1
59#endif
60
61/* PLATFORM(WIN_OS) */
62/* Operating system level dependencies for Windows that should be used */
63/* regardless of operating environment */
64#if defined(WIN32) || defined(_WIN32)
65#define WTF_PLATFORM_WIN_OS 1
66#endif
67
68/* PLATFORM(FREEBSD) */
69/* Operating system level dependencies for FreeBSD-like systems that */
70/* should be used regardless of operating environment */
71#ifdef __FreeBSD__
72#define WTF_PLATFORM_FREEBSD 1
73#endif
74
75/* PLATFORM(SOLARIS) */
76/* Operating system level dependencies for Solaris that should be used */
77/* regardless of operating environment */
78#if defined(sun) || defined(__sun)
79#define WTF_PLATFORM_SOLARIS 1
80#endif
81
82/* PLATFORM(UNIX) */
83/* Operating system level dependencies for Unix-like systems that */
84/* should be used regardless of operating environment */
85#if   PLATFORM(DARWIN)     \
86   || PLATFORM(FREEBSD)    \
87   || PLATFORM(SOLARIS)    \
88   || defined(unix)        \
89   || defined(__unix)      \
90   || defined(__unix__)    \
91   || defined (__NetBSD__) \
92   || defined(_AIX)
93#define WTF_PLATFORM_UNIX 1
94#endif
95
96/* Operating environments */
97
98/* CPU */
99
100/* PLATFORM(PPC) */
101#if   defined(__ppc__)     \
102   || defined(__PPC__)     \
103   || defined(__powerpc__) \
104   || defined(__powerpc)   \
105   || defined(__POWERPC__) \
106   || defined(_M_PPC)      \
107   || defined(__PPC)
108#define WTF_PLATFORM_PPC 1
109#define WTF_PLATFORM_BIG_ENDIAN 1
110#endif
111
112/* PLATFORM(PPC64) */
113#if   defined(__ppc64__) \
114   || defined(__PPC64__)
115#define WTF_PLATFORM_PPC64 1
116#define WTF_PLATFORM_BIG_ENDIAN 1
117#endif
118
119/* PLATFORM(ARM) */
120#if   defined(arm) \
121   || defined(__arm__)
122#define WTF_PLATFORM_ARM 1
123#if defined(__ARMEB__)
124#define WTF_PLATFORM_BIG_ENDIAN 1
125#elif !defined(__ARM_EABI__) && !defined(__ARMEB__) && !defined(__VFP_FP__)
126#define WTF_PLATFORM_MIDDLE_ENDIAN 1
127#endif
128#if !defined(__ARM_EABI__)
129#define WTF_PLATFORM_FORCE_PACK 1
130#endif
131#endif
132
133/* PLATFORM(X86) */
134#if   defined(__i386__) \
135   || defined(i386)     \
136   || defined(_M_IX86)  \
137   || defined(_X86_)    \
138   || defined(__THW_INTEL)
139#define WTF_PLATFORM_X86 1
140#endif
141
142/* PLATFORM(X86_64) */
143#if   defined(__x86_64__) \
144   || defined(__ia64__) \
145   || defined(_M_X64)
146#define WTF_PLATFORM_X86_64 1
147#endif
148
149/* Some compilers (eg. GCC), have a builtin endianness definition ... */
150#if defined(__LITTLE_ENDIAN__) && !defined(WTF_PLATFORM_LITTLE_ENDIAN)
151#define WTF_PLATFORM_LITTLE_ENDIAN 1
152#endif
153
154#if defined(__BIG_ENDIAN__) && !defined(WTF_PLATFORM_BIG_ENDIAN)
155#define WTF_PLATFORM_BIG_ENDIAN 1
156#endif
157
158#if defined(WTF_PLATFORM_BIG_ENDIAN) && defined(WTF_PLATFORM_LITTLE_ENDIAN)
159#error indeterminate platform endianness
160#endif
161
162/* Compiler */
163
164/* COMPILER(GCC) */
165#if defined(__GNUC__)
166#define WTF_COMPILER_GCC 1
167
168/* Define GCC_VERSION as per
169        http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
170 */
171#define GCC_VERSION (__GNUC__ * 10000 \
172                        + __GNUC_MINOR__ * 100 \
173                        + __GNUC_PATCHLEVEL__)
174
175#endif
176
177/* multiple threads only supported on Darwin for now */
178#if PLATFORM(DARWIN) || PLATFORM(WIN)
179#define WTF_USE_MULTIPLE_THREADS 1
180#define WTF_USE_DTRACE 1
181#endif
182
183#if PLATFORM(DARWIN)
184#include <Availability.h>
185#define WTF_PLATFORM_CF 1
186#define WTF_USE_PTHREADS 1
187#define WTF_USE_LIBPCAP 1
188#define HAVE_READLINE 1
189#define HAVE_LAUNCHD 1
190#define HAVE_LIBDISPATCH 1
191
192/* We have DTrace on 10.5 and later. */
193#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
194#define HAVE_DTRACE 1
195#endif
196
197/* We have the Heimdal framework on 10.6 or later. */
198#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
199#define HAVE_HEIMDAL 1
200#endif
201
202#endif
203
204#if COMPILER(GCC)
205#define HAVE_COMPUTED_GOTO 1
206#endif
207
208#if PLATFORM(DARWIN)
209
210#define HAVE_ERRNO_H 1
211#define HAVE_MMAP 1
212#define HAVE_MERGESORT 1
213#define HAVE_SBRK 1
214#define HAVE_STRINGS_H 1
215#define HAVE_SYS_PARAM_H 1
216#define HAVE_SYS_TIME_H 1
217#define HAVE_SYS_TIMEB_H 1
218
219#endif
220
221#if !defined(errno_t_DEFINED)
222#define errno_t_DEFINED
223typedef int errno_t;
224#endif
225
226#endif /* PLATFORM_STD_PLATFORM_H */
227
228/* vim: set cindent et ts=4 sw=4 tw=79 : */
229