Skip to content

Commit 84a61d5

Browse files
committed
import port/os.h
1 parent adea47e commit 84a61d5

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

ortools/port/os.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,34 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
// Defines macros about target OS and whether it supports threads.
14+
// Defines macros and constexpr about target OS features.
1515
#ifndef ORTOOLS_PORT_OS_H_
1616
#define ORTOOLS_PORT_OS_H_
1717

18+
namespace operations_research {
19+
1820
#if defined(__ANDROID__)
1921
#define ORTOOLS_TARGET_OS_IS_ANDROID
2022
#endif
2123

2224
#if (defined(__apple__) || defined(__APPLE__) || defined(__MACH__))
25+
// Temporarily close the `namespace operations_research` to include a file.
26+
} // namespace operations_research
2327
// From https://stackoverflow.com/a/49560690
2428
#include "TargetConditionals.h"
29+
// Reopen the namespace.
30+
namespace operations_research {
2531
#if TARGET_OS_IPHONE == 1
2632
#define ORTOOLS_TARGET_OS_IS_IOS
2733
#endif
2834
#endif
2935

3036
#if defined(__EMSCRIPTEN__)
3137
#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__
3342

3443
#if defined(ORTOOLS_TARGET_OS_IS_ANDROID) || \
3544
defined(ORTOOLS_TARGET_OS_IS_IOS) || \
@@ -39,4 +48,13 @@
3948
#define ORTOOLS_TARGET_OS_SUPPORTS_THREADS 1
4049
#endif
4150

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+
4260
#endif // ORTOOLS_PORT_OS_H_

0 commit comments

Comments
 (0)