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:
@@ -9,7 +9,11 @@ SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
|
||||
#include "cxxopts.hpp"
|
||||
SIMDJSON_POP_DISABLE_WARNINGS
|
||||
|
||||
#if CXXOPTS__VERSION_MAJOR < 3
|
||||
int main(int argc, char *argv[]) {
|
||||
#else
|
||||
int main(int argc, const char *argv[]) {
|
||||
#endif
|
||||
#ifdef __cpp_exceptions
|
||||
try {
|
||||
#endif
|
||||
|
||||
+4
-1
@@ -188,8 +188,11 @@ stat_t simdjson_compute_stats(const simdjson::padded_string &p) {
|
||||
recurse(doc, s, 0);
|
||||
return s;
|
||||
}
|
||||
|
||||
#if CXXOPTS__VERSION_MAJOR < 3
|
||||
int main(int argc, char *argv[]) {
|
||||
#else
|
||||
int main(int argc, const char *argv[]) {
|
||||
#endif
|
||||
#ifdef __cpp_exceptions
|
||||
try {
|
||||
#endif
|
||||
|
||||
+11
-1
@@ -20,7 +20,11 @@ void usage(std::string message) {
|
||||
std::cerr << options.help() << std::endl;
|
||||
}
|
||||
|
||||
#if CXXOPTS__VERSION_MAJOR < 3
|
||||
int main(int argc, char *argv[]) {
|
||||
#else
|
||||
int main(int argc, const char *argv[]) {
|
||||
#endif
|
||||
#ifdef __cpp_exceptions
|
||||
try {
|
||||
#endif
|
||||
@@ -28,7 +32,9 @@ int main(int argc, char *argv[]) {
|
||||
ss << "Parser implementation (by default, detects the most advanced implementation supported on the host machine)." << std::endl;
|
||||
ss << "Available parser implementations:" << std::endl;
|
||||
for (auto impl : simdjson::available_implementations) {
|
||||
ss << "-a " << std::left << std::setw(9) << impl->name() << " - Use the " << impl->description() << " parser implementation." << std::endl;
|
||||
if(impl->supported_by_runtime_system()) {
|
||||
ss << "-a " << std::left << std::setw(9) << impl->name() << " - Use the " << impl->description() << " parser implementation." << std::endl;
|
||||
}
|
||||
}
|
||||
options.add_options()
|
||||
("a,arch", ss.str(), cxxopts::value<std::string>())
|
||||
@@ -54,6 +60,10 @@ int main(int argc, char *argv[]) {
|
||||
usage("Unsupported implementation.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!impl->supported_by_runtime_system()) {
|
||||
usage("The selected implementation does not match your current CPU.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
simdjson::active_implementation = impl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user