Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * vcpuid.c | 8 * vcpuid.c |
| 9 * | 9 * |
| 10 * Verify correctness of CPUID implementation. | 10 * Verify correctness of CPUID implementation. |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 return 0; | 483 return 0; |
| 484 } else { | 484 } else { |
| 485 printf("no %s\n", s); | 485 printf("no %s\n", s); |
| 486 return 1; | 486 return 1; |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 #else | 489 #else |
| 490 # error Please specify platform as NACL_LINUX, NACL_OSX or NACL_WINDOWS | 490 # error Please specify platform as NACL_LINUX, NACL_OSX or NACL_WINDOWS |
| 491 #endif | 491 #endif |
| 492 | 492 |
| 493 #if !(NACL_WINDOWS && (NACL_BUILD_SUBARCH == 64)) | |
|
Roland McGrath
2015/12/05 11:07:46
It would be better to factor out the caller code t
Nico
2015/12/05 15:35:38
Done, but seems somewhat out of scope for this par
| |
| 493 static int DoCPUFeatureTest(NaClCPUFeaturesX86 *features, | 494 static int DoCPUFeatureTest(NaClCPUFeaturesX86 *features, |
| 494 NaClCPUFeatureX86ID id, | 495 NaClCPUFeatureX86ID id, |
| 495 int (*thetest)(void)) { | 496 int (*thetest)(void)) { |
| 496 if (NaClGetCPUFeatureX86(features, id)) | 497 if (NaClGetCPUFeatureX86(features, id)) |
| 497 return DoTest(thetest, NaClGetCPUFeatureX86Name(id)); | 498 return DoTest(thetest, NaClGetCPUFeatureX86Name(id)); |
| 498 else | 499 else |
| 499 return 0; | 500 return 0; |
| 500 } | 501 } |
| 502 #endif /* 64-bit Windows */ | |
| 501 | 503 |
| 502 static void PrintFail(const char *why) { | 504 static void PrintFail(const char *why) { |
| 503 fprintf(stderr, "ERROR: %s.\n", why); | 505 fprintf(stderr, "ERROR: %s.\n", why); |
| 504 fprintf(stderr, "Google Native Client cannot continue.\n"); | 506 fprintf(stderr, "Google Native Client cannot continue.\n"); |
| 505 } | 507 } |
| 506 | 508 |
| 507 #define TEST_NEGATIVE_CASE 0 | 509 #define TEST_NEGATIVE_CASE 0 |
| 508 int CPUIDImplIsValid(void) { | 510 int CPUIDImplIsValid(void) { |
| 509 NaClCPUFeaturesX86 cpuf; | 511 NaClCPUFeaturesX86 cpuf; |
| 510 NaClGetCurrentCPUFeaturesX86((NaClCPUFeatures *) &cpuf); | 512 NaClGetCurrentCPUFeaturesX86((NaClCPUFeatures *) &cpuf); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 if (rcode != 0) { | 557 if (rcode != 0) { |
| 556 PrintFail("CPUID not implemented correctly."); | 558 PrintFail("CPUID not implemented correctly."); |
| 557 return 0; | 559 return 0; |
| 558 } | 560 } |
| 559 } | 561 } |
| 560 #endif /* 64-bit Windows */ | 562 #endif /* 64-bit Windows */ |
| 561 | 563 |
| 562 printf("[CPUID implementation looks okay]\n"); | 564 printf("[CPUID implementation looks okay]\n"); |
| 563 return 1; | 565 return 1; |
| 564 } | 566 } |
| OLD | NEW |