Chromium Code Reviews| 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() { |
| + if (getenv("NACL_DANGEROUS_USE_DFA_VALIDATOR") != NULL) { |
| + return 1; |
| + } |
| + return 0; |
| +} |
| + |
| +const struct NaClValidatorInterface* NaClCreateValidator() { |
|
Nick Bray
2012/05/22 23:46:31
Name: NaClGetValidatorInterface? "Create" seems w
pasko-google - do not use
2012/05/23 14:28:11
I want to emphasize that this needs to be called o
|
| +#if defined(__arm__) |
| + return NaClValidatorCreateArm(); |
| +#elif NACL_ARCH(NACL_TARGET_ARCH) != NACL_x86 |
| +#error("No validator available for this architecture!") |
| +#elif NACL_TARGET_SUBARCH == 32 && defined(NACL_STANDALONE) |
| + if (NaClUseDfaValidator()) { |
| + fprintf(stderr, "DANGER! USING THE EXPERIMENTAL DFA VALIDATOR!\n"); |
| + 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 |
| +} |