mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Make it possible to check that an implementation is supported at runtime (#1197)
* Make it possible to check that an implementation is supported at runtime. * add CI fuzzing on arm 64 bit This adds fuzzing on drone.io arm64 For some reason, leak detection had to be disabled. If it is enabled, the fuzzer falsely reports a crash at the end of fuzzing. Closes: #1188 * Guarding the implementation accesses. * Better doc. * Updating cxxopts. * Make it possible to check that an implementation is supported at runtime. * Guarding the implementation accesses. * Better doc. * Updating cxxopts. * We need to accomodate cxxopts Co-authored-by: Paul Dreik <github@pauldreik.se>
This commit is contained in:
@@ -1868,6 +1868,10 @@ int main(int argc, char *argv[]) {
|
||||
fprintf(stderr, "Unsupported architecture value -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!impl->supported_by_runtime_system()) {
|
||||
fprintf(stderr, "The selected implementation does not match your current CPU: -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
simdjson::active_implementation = impl;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -340,6 +340,10 @@ int main(int argc, char *argv[]) {
|
||||
fprintf(stderr, "Unsupported architecture value -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!impl->supported_by_runtime_system()) {
|
||||
fprintf(stderr, "The selected implementation does not match your current CPU: -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
simdjson::active_implementation = impl;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -202,6 +202,10 @@ int main(int argc, char *argv[]) {
|
||||
fprintf(stderr, "Unsupported architecture value -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!impl->supported_by_runtime_system()) {
|
||||
fprintf(stderr, "The selected implementation does not match your current CPU: -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
simdjson::active_implementation = impl;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -119,6 +119,10 @@ int main(int argc, char *argv[]) {
|
||||
fprintf(stderr, "Unsupported architecture value -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!impl->supported_by_runtime_system()) {
|
||||
fprintf(stderr, "The selected implementation does not match your current CPU: -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
simdjson::active_implementation = impl;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -117,6 +117,10 @@ int main(int argc, char *argv[]) {
|
||||
fprintf(stderr, "Unsupported architecture value -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!impl->supported_by_runtime_system()) {
|
||||
fprintf(stderr, "The selected implementation does not match your current CPU: -a %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
simdjson::active_implementation = impl;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -201,10 +201,24 @@ void implementation_selection_2() {
|
||||
}
|
||||
}
|
||||
|
||||
void implementation_selection_2_safe() {
|
||||
for (auto implementation : simdjson::available_implementations) {
|
||||
if(implementation->supported_by_runtime_system()) {
|
||||
cout << implementation->name() << ": " << implementation->description() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
void implementation_selection_3() {
|
||||
cout << simdjson::available_implementations["fallback"]->description() << endl;
|
||||
}
|
||||
|
||||
void implementation_selection_safe() {
|
||||
auto my_implementation = simdjson::available_implementations["haswell"];
|
||||
if(! my_implementation) { exit(1); }
|
||||
if(! my_implementation->supported_by_runtime_system()) { exit(1); }
|
||||
simdjson::active_implementation = my_implementation;
|
||||
}
|
||||
|
||||
void implementation_selection_4() {
|
||||
// Use the fallback implementation, even though my machine is fast enough for anything
|
||||
simdjson::active_implementation = simdjson::available_implementations["fallback"];
|
||||
|
||||
Reference in New Issue
Block a user