Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: src/trusted/validator/validator_init.c

Issue 10134056: Refactor the process of choosing validators. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: small fixes towards Mark's comments Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/trusted/validator/validator_init.c
diff --git a/src/trusted/validator/validator_init.c b/src/trusted/validator/validator_init.c
new file mode 100644
index 0000000000000000000000000000000000000000..7ab1eba4a59b9f12aef83b886c56e35ab18bbb70
--- /dev/null
+++ b/src/trusted/validator/validator_init.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "native_client/src/trusted/validator/ncvalidate.h"
+
+int NaClUseDfaValidator() {
Mark Seaborn 2012/06/20 20:02:26 This function can be declared static
pasko-google - do not use 2012/06/21 15:24:18 That produces an error on ARM: defined but not use
+ if (getenv("NACL_DANGEROUS_USE_DFA_VALIDATOR") != NULL) {
+ return 1;
+ }
+ return 0;
+}
+
+const struct NaClValidatorInterface* NaClCreateValidator() {
+#if defined(__arm__)
Mark Seaborn 2012/06/20 20:02:26 Use NACL_ARCH() again instead of __arm__
pasko-google - do not use 2012/06/21 15:24:18 Done.
+ return NaClValidatorCreateArm();
+#elif NACL_ARCH(NACL_TARGET_ARCH) != NACL_x86
+#error("No validator available for this architecture!")
Mark Seaborn 2012/06/20 20:02:26 No brackets are needed here
pasko-google - do not use 2012/06/21 15:24:18 Done.
+#elif NACL_TARGET_SUBARCH == 32 && defined(NACL_STANDALONE)
+ if (NaClUseDfaValidator()) {
+ fprintf(stderr, "DANGER! USING THE EXPERIMENTAL DFA VALIDATOR!\n");
Mark Seaborn 2012/06/20 20:02:26 Please use NaClLog with LOG_WARNING instead of fpr
pasko-google - do not use 2012/06/21 15:24:18 Done.
+ return NaClDfaValidatorCreate_x86_32();
+ } else {
+ return NaClValidatorCreate_x86_32();
+ }
+#elif NACL_TARGET_SUBARCH == 32
+ return NaClValidatorCreate_x86_32();
+#elif NACL_TARGET_SUBARCH == 64 && defined(NACL_STANDALONE)
+ if (NaClUseDfaValidator()) {
+ fprintf(stderr, "DANGER! USING THE EXPERIMENTAL DFA VALIDATOR!\n");
+ return NaClDfaValidatorCreate_x86_64();
+ } else {
+ return NaClValidatorCreate_x86_64();
+ }
+#elif NACL_TARGET_SUBARCH == 64
+ return NaClValidatorCreate_x86_64();
+#endif
+}

Powered by Google App Engine
This is Rietveld 408576698