|
11 | 11 | // See the License for the specific language governing permissions and |
12 | 12 | // limitations under the License. |
13 | 13 |
|
14 | | -// Defines macros about target OS and whether it supports threads. |
| 14 | +// Defines macros and constexpr about target OS features. |
15 | 15 | #ifndef ORTOOLS_PORT_OS_H_ |
16 | 16 | #define ORTOOLS_PORT_OS_H_ |
17 | 17 |
|
| 18 | +namespace operations_research { |
| 19 | + |
18 | 20 | #if defined(__ANDROID__) |
19 | 21 | #define ORTOOLS_TARGET_OS_IS_ANDROID |
20 | 22 | #endif |
21 | 23 |
|
22 | 24 | #if (defined(__apple__) || defined(__APPLE__) || defined(__MACH__)) |
| 25 | +// Temporarily close the `namespace operations_research` to include a file. |
| 26 | +} // namespace operations_research |
23 | 27 | // From https://stackoverflow.com/a/49560690 |
24 | 28 | #include "TargetConditionals.h" |
| 29 | +// Reopen the namespace. |
| 30 | +namespace operations_research { |
25 | 31 | #if TARGET_OS_IPHONE == 1 |
26 | 32 | #define ORTOOLS_TARGET_OS_IS_IOS |
27 | 33 | #endif |
28 | 34 | #endif |
29 | 35 |
|
30 | 36 | #if defined(__EMSCRIPTEN__) |
31 | 37 | #define ORTOOLS_TARGET_OS_IS_EMSCRIPTEN |
32 | | -#endif |
| 38 | +inline constexpr bool kTargetOsIsEmscripten = true; |
| 39 | +#else // __EMSCRIPTEN__ |
| 40 | +inline constexpr bool kTargetOsIsEmscripten = false; |
| 41 | +#endif // __EMSCRIPTEN__ |
33 | 42 |
|
34 | 43 | #if defined(ORTOOLS_TARGET_OS_IS_ANDROID) || \ |
35 | 44 | defined(ORTOOLS_TARGET_OS_IS_IOS) || \ |
|
39 | 48 | #define ORTOOLS_TARGET_OS_SUPPORTS_THREADS 1 |
40 | 49 | #endif |
41 | 50 |
|
| 51 | +#ifdef __PORTABLE_PLATFORM__ |
| 52 | +#define ORTOOLS_TARGET_OS_IS_PORTABLE_PLATFORM |
| 53 | +inline constexpr bool kTargetOsIsPortablePlatform = true; |
| 54 | +#else // __PORTABLE_PLATFORM__ |
| 55 | +inline constexpr bool kTargetOsIsPortablePlatform = false; |
| 56 | +#endif // __PORTABLE_PLATFORM__ |
| 57 | + |
| 58 | +} // namespace operations_research |
| 59 | + |
42 | 60 | #endif // ORTOOLS_PORT_OS_H_ |
0 commit comments