Loading...
Searching...
No Matches
defines.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_BASE_ARCH_DEFINES_H
25#define PXR_BASE_ARCH_DEFINES_H
26
27//
28// OS
29//
30
31#if defined(__linux__)
32#define ARCH_OS_LINUX
33#elif defined(__APPLE__)
34#include "TargetConditionals.h"
35#define ARCH_OS_DARWIN
36#if TARGET_OS_IPHONE
37// TARGET_OS_IPHONE refers to all iOS derivative platforms
38// TARGET_OS_IOS refers to iPhone/iPad
39// For now, we specialize for the umbrella TARGET_OS_IPHONE group
40#define ARCH_OS_IPHONE
41#else
42#define ARCH_OS_OSX
43#endif
44#elif defined(_WIN32) || defined(_WIN64)
45#define ARCH_OS_WINDOWS
46#endif
47
48//
49// Processor
50//
51
52#if defined(i386) || defined(__i386__) || defined(__x86_64__) || \
53 defined(_M_IX86) || defined(_M_X64)
54#define ARCH_CPU_INTEL
55#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM)
56#define ARCH_CPU_ARM
57#endif
58
59//
60// Bits
61//
62
63#if defined(__x86_64__) || defined(__aarch64__) || defined(_M_X64)
64#define ARCH_BITS_64
65#else
66#error "Unsupported architecture. x86_64 or ARM64 required."
67#endif
68
69//
70// Compiler
71//
72
73#if defined(__clang__)
74#define ARCH_COMPILER_CLANG
75#define ARCH_COMPILER_CLANG_MAJOR __clang_major__
76#define ARCH_COMPILER_CLANG_MINOR __clang_minor__
77#define ARCH_COMPILER_CLANG_PATCHLEVEL __clang_patchlevel__
78#elif defined(__GNUC__)
79#define ARCH_COMPILER_GCC
80#define ARCH_COMPILER_GCC_MAJOR __GNUC__
81#define ARCH_COMPILER_GCC_MINOR __GNUC_MINOR__
82#define ARCH_COMPILER_GCC_PATCHLEVEL __GNUC_PATCHLEVEL__
83#elif defined(__ICC)
84#define ARCH_COMPILER_ICC
85#elif defined(_MSC_VER)
86#define ARCH_COMPILER_MSVC
87#define ARCH_COMPILER_MSVC_VERSION _MSC_VER
88#endif
89
90//
91// Features
92//
93
94// Only use the GNU STL extensions on Linux when using gcc.
95#if defined(ARCH_OS_LINUX) && defined(ARCH_COMPILER_GCC)
96#define ARCH_HAS_GNU_STL_EXTENSIONS
97#endif
98
99// The current version of Apple clang does not support the thread_local
100// keyword.
101#if !(defined(ARCH_OS_DARWIN) && defined(ARCH_COMPILER_CLANG))
102#define ARCH_HAS_THREAD_LOCAL
103#endif
104
105// The MAP_POPULATE flag for mmap calls only exists on Linux platforms.
106#if defined(ARCH_OS_LINUX)
107#define ARCH_HAS_MMAP_MAP_POPULATE
108#endif
109
110#endif // PXR_BASE_ARCH_DEFINES_H