Pixar Arch
Loading...
Searching...
No Matches
defines.h
Go to the documentation of this file.
1// Copyright 2016 Pixar
2//
3// Licensed under the terms set forth in the LICENSE.txt file available at
4// https://openusd.org/license.
5//
6// Modified by Jeremy Retailleau.
7
8#ifndef PXR_ARCH_DEFINES_H
9#define PXR_ARCH_DEFINES_H
10
11#define PXR_VERSION 2408
12
13//
14// OS
15//
16
17#if defined(__linux__)
18#define ARCH_OS_LINUX
19#elif defined(__APPLE__)
20#include "TargetConditionals.h"
21#define ARCH_OS_DARWIN
22#if TARGET_OS_IPHONE
23// TARGET_OS_IPHONE refers to all iOS derivative platforms
24// TARGET_OS_IOS refers to iPhone/iPad
25// For now, we specialize for the umbrella TARGET_OS_IPHONE group
26#define ARCH_OS_IPHONE
27#else
28#define ARCH_OS_OSX
29#endif
30#elif defined(_WIN32) || defined(_WIN64)
31#define ARCH_OS_WINDOWS
32#endif
33
34//
35// Processor
36//
37
38#if defined(i386) || defined(__i386__) || defined(__x86_64__) || \
39 defined(_M_IX86) || defined(_M_X64)
40#define ARCH_CPU_INTEL
41#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM)
42#define ARCH_CPU_ARM
43#endif
44
45//
46// Bits
47//
48
49#if defined(__x86_64__) || defined(__aarch64__) || defined(_M_X64)
50#define ARCH_BITS_64
51#else
52#error "Unsupported architecture. x86_64 or ARM64 required."
53#endif
54
55//
56// Compiler
57//
58
59#if defined(__clang__)
60#define ARCH_COMPILER_CLANG
61#define ARCH_COMPILER_CLANG_MAJOR __clang_major__
62#define ARCH_COMPILER_CLANG_MINOR __clang_minor__
63#define ARCH_COMPILER_CLANG_PATCHLEVEL __clang_patchlevel__
64#elif defined(__GNUC__)
65#define ARCH_COMPILER_GCC
66#define ARCH_COMPILER_GCC_MAJOR __GNUC__
67#define ARCH_COMPILER_GCC_MINOR __GNUC_MINOR__
68#define ARCH_COMPILER_GCC_PATCHLEVEL __GNUC_PATCHLEVEL__
69#elif defined(__ICC)
70#define ARCH_COMPILER_ICC
71#elif defined(_MSC_VER)
72#define ARCH_COMPILER_MSVC
73#define ARCH_COMPILER_MSVC_VERSION _MSC_VER
74#endif
75
76//
77// Features
78//
79
80// Only use the GNU STL extensions on Linux when using gcc.
81#if defined(ARCH_OS_LINUX) && defined(ARCH_COMPILER_GCC)
82#define ARCH_HAS_GNU_STL_EXTENSIONS
83#endif
84
85// The current version of Apple clang does not support the thread_local
86// keyword.
87#if !(defined(ARCH_OS_DARWIN) && defined(ARCH_COMPILER_CLANG))
88#define ARCH_HAS_THREAD_LOCAL
89#endif
90
91// The MAP_POPULATE flag for mmap calls only exists on Linux platforms.
92#if defined(ARCH_OS_LINUX)
93#define ARCH_HAS_MMAP_MAP_POPULATE
94#endif
95
96// When using MSVC, provide an easy way to detect whether the older
97// "traditional" preprocessor is being used as opposed to the newer, more
98// standards-conforming preprocessor. The traditional preprocessor may require
99// custom versions of macros.
100// See here for more detail about MSVC's preprocessors:
101// https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview
102#if defined(ARCH_COMPILER_MSVC)
103 #if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL
104 #define ARCH_PREPROCESSOR_MSVC_TRADITIONAL
105 #endif
106#endif
107
108#endif // PXR_ARCH_DEFINES_H