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#define ARCH_OS_IOS
38#else
39#define ARCH_OS_OSX
40#endif
41#elif defined(_WIN32) || defined(_WIN64)
42#define ARCH_OS_WINDOWS
43#endif
44
45//
46// Processor
47//
48
49#if defined(i386) || defined(__i386__) || defined(__x86_64__) || \
50 defined(_M_IX86) || defined(_M_X64)
51#define ARCH_CPU_INTEL
52#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM)
53#define ARCH_CPU_ARM
54#endif
55
56//
57// Bits
58//
59
60#if defined(__x86_64__) || defined(__aarch64__) || defined(_M_X64)
61#define ARCH_BITS_64
62#else
63#error "Unsupported architecture. x86_64 or ARM64 required."
64#endif
65
66//
67// Compiler
68//
69
70#if defined(__clang__)
71#define ARCH_COMPILER_CLANG
72#define ARCH_COMPILER_CLANG_MAJOR __clang_major__
73#define ARCH_COMPILER_CLANG_MINOR __clang_minor__
74#define ARCH_COMPILER_CLANG_PATCHLEVEL __clang_patchlevel__
75#elif defined(__GNUC__)
76#define ARCH_COMPILER_GCC
77#define ARCH_COMPILER_GCC_MAJOR __GNUC__
78#define ARCH_COMPILER_GCC_MINOR __GNUC_MINOR__
79#define ARCH_COMPILER_GCC_PATCHLEVEL __GNUC_PATCHLEVEL__
80#elif defined(__ICC)
81#define ARCH_COMPILER_ICC
82#elif defined(_MSC_VER)
83#define ARCH_COMPILER_MSVC
84#define ARCH_COMPILER_MSVC_VERSION _MSC_VER
85#endif
86
87//
88// Features
89//
90
91// Only use the GNU STL extensions on Linux when using gcc.
92#if defined(ARCH_OS_LINUX) && defined(ARCH_COMPILER_GCC)
93#define ARCH_HAS_GNU_STL_EXTENSIONS
94#endif
95
96// The current version of Apple clang does not support the thread_local
97// keyword.
98#if !(defined(ARCH_OS_DARWIN) && defined(ARCH_COMPILER_CLANG))
99#define ARCH_HAS_THREAD_LOCAL
100#endif
101
102// The MAP_POPULATE flag for mmap calls only exists on Linux platforms.
103#if defined(ARCH_OS_LINUX)
104#define ARCH_HAS_MMAP_MAP_POPULATE
105#endif
106
107#endif // PXR_BASE_ARCH_DEFINES_H