1/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15
16#ifndef TENSORFLOW_TSL_PLATFORM_PLATFORM_H_
17#define TENSORFLOW_TSL_PLATFORM_PLATFORM_H_
18
19// Set one PLATFORM_* macro and set IS_MOBILE_PLATFORM if the platform is for
20// mobile.
21
22#if !defined(PLATFORM_POSIX) && !defined(PLATFORM_GOOGLE) && \
23 !defined(PLATFORM_POSIX_ANDROID) && !defined(PLATFORM_GOOGLE_ANDROID) && \
24 !defined(PLATFORM_WINDOWS)
25
26// Choose which platform we are on.
27#if defined(ANDROID) || defined(__ANDROID__)
28#define PLATFORM_POSIX_ANDROID
29#define IS_MOBILE_PLATFORM
30
31#elif defined(__APPLE__)
32#include "TargetConditionals.h"
33#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
34#define PLATFORM_POSIX_IOS
35#define IS_MOBILE_PLATFORM
36#else
37// If no platform specified, use:
38#define PLATFORM_POSIX
39#endif
40
41#elif defined(_WIN32)
42#define PLATFORM_WINDOWS
43
44#elif defined(__EMSCRIPTEN__)
45#define PLATFORM_PORTABLE_GOOGLE
46#define PLATFORM_POSIX
47// EMSCRIPTEN builds are considered "mobile" for the sake of portability.
48#define IS_MOBILE_PLATFORM
49
50#elif defined(__TF_CHROMIUMOS__)
51#define PLATFORM_PORTABLE_GOOGLE
52#define PLATFORM_POSIX
53#define PLATFORM_CHROMIUMOS
54
55#else
56// If no platform specified, use:
57#define PLATFORM_POSIX
58
59#endif
60#endif
61
62// Look for both gcc/clang and Visual Studio macros indicating we're compiling
63// for an x86 device.
64#if defined(__x86_64__) || defined(__amd64__) || defined(_M_IX86) || \
65 defined(_M_X64)
66#define PLATFORM_IS_X86
67#endif
68
69// Check if we are compmiling for an arm device.
70#if defined(__arm__) || defined(__aarch64__)
71#define PLATFORM_IS_ARM
72#if defined(__aarch64__)
73#define PLATFORM_IS_ARM64
74#else
75#define PLATFORM_IS_ARM32
76#endif
77#endif
78
79#endif // TENSORFLOW_TSL_PLATFORM_PLATFORM_H_
80