mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Extend existing CPU architecture spellings in config header and define platform spellings.
PiperOrigin-RevId: 410474889 Change-Id: I41f870ad49e2203a6bdf833102c0d0a9cafa7af4
This commit is contained in:
parent
e86322db84
commit
dcfd85d74e
|
@ -16,6 +16,7 @@
|
|||
#define SANDBOXED_API_CONFIG_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
|
||||
|
@ -46,7 +47,7 @@ namespace cpu {
|
|||
// CPU architectures known to Sandbox2
|
||||
enum Architecture : uint16_t {
|
||||
// Linux: Use a magic value, so it can be easily spotted in the seccomp-bpf
|
||||
// bytecode decompilation stream. Must be < (1<<15), as/ that's the size of
|
||||
// bytecode decompilation stream. Must be < (1<<15), as that is the size of
|
||||
// data which can be returned by BPF.
|
||||
kUnknown = 0xCAF0,
|
||||
kX8664,
|
||||
|
@ -92,6 +93,37 @@ static_assert(host_cpu::Architecture() != cpu::kUnknown,
|
|||
"Host CPU architecture is not supported: One of x86-64, POWER64 "
|
||||
"(little endian), ARM or AArch64 is required.");
|
||||
|
||||
namespace os {
|
||||
|
||||
// Operating Systems known to Sandbox2
|
||||
enum Platform : uint16_t {
|
||||
kUnknown,
|
||||
kAndroid,
|
||||
kLinux,
|
||||
};
|
||||
|
||||
} // namespace os
|
||||
|
||||
namespace host_os {
|
||||
|
||||
// Returns the current host OS platform if supported. If not supported,
|
||||
// returns platforms::kUnknown.
|
||||
constexpr os::Platform Platform() {
|
||||
#if defined(__ANDROID__)
|
||||
return os::kAndroid;
|
||||
#elif defined(__linux__)
|
||||
return os::kLinux;
|
||||
#else
|
||||
return os::kUnknown;
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr bool IsAndroid() { return Platform() == os::kAndroid; }
|
||||
|
||||
constexpr bool IsLinux() { return Platform() == os::kLinux; }
|
||||
|
||||
} // namespace host_os
|
||||
|
||||
namespace sanitizers {
|
||||
|
||||
constexpr bool IsMSan() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user