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