Index: components/nacl/renderer/sandbox_isa.cc |
diff --git a/components/nacl/renderer/sandbox_isa.cc b/components/nacl/renderer/sandbox_isa.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e0617c38f66ce785027027b0b6baf1a6c322d07e |
--- /dev/null |
+++ b/components/nacl/renderer/sandbox_isa.cc |
@@ -0,0 +1,48 @@ |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// The list of supported ISA strings for x86. See issue: |
Mark Seaborn
2014/03/12 18:24:14
Drop "for x86"?
|
+// http://code.google.com/p/nativeclient/issues/detail?id=1040 for more |
+// information. Note that these string are to be case-insensitive compared. |
+ |
+#include "base/logging.h" |
+#if defined(OS_WIN) |
+#include "base/win/windows_version.h" |
+#endif |
+ |
+const char* const kNexeArchARM = "arm"; |
Mark Seaborn
2014/03/12 18:24:14
Better to write:
static const char kFoo[] = "...";
|
+const char* const kNexeArchMIPS = "mips32"; |
+const char* const kNexeArchX86_32 = "x86-32"; |
+const char* const kNexeArchX86_64 = "x86-64"; |
+ |
+namespace nacl { |
+ |
+const char* GetSandboxISA() { |
+#if defined(ARCH_CPU_ARM_FAMILY) |
+ return kNexeArchArm; |
+#elif defined(ARCH_CPU_MIPS_FAMILY) |
+ return kNexeArchMIPS; |
+#elif defined(ARCH_CPU_X86_FAMILY) |
+ |
+#if defined(OS_WIN) |
+ // We have to check the host architecture on Windows. |
+ // See sandbox_isa.h for an explanation why. |
+ if (base::win::OSInfo::GetInstance()->architecture() == X64_ARCHITECTURE) |
+ return kNexeArchX86_64; |
+ else |
+ return kNexeArchX86_32; |
+#elif ARCH_CPU_64_BITS |
+ return kNexeArchX86_64; |
Mark Seaborn
2014/03/12 18:24:14
Reduce indentation by 2
|
+#else |
+ return kNexeArchX86_32; |
Mark Seaborn
2014/03/12 18:24:14
ditto
|
+#endif // defined(OS_WIN) |
+ |
+#else |
+#error Architecture not supported. |
+ NOTREACHED(); |
Mark Seaborn
2014/03/12 18:24:14
This won't be compiled if you've just #error'd, so
|
+ return NULL; |
+#endif |
+} |
+ |
+} // namespace nacl |