diff --git a/include/simdjson.h b/include/simdjson.h index f09c9f46c..0e2a08e0d 100644 --- a/include/simdjson.h +++ b/include/simdjson.h @@ -34,8 +34,8 @@ } */ -#include "simdjson/base.h" #include "simdjson/dom.h" #include "simdjson/implementations.h" +#include "simdjson/builtin.h" #endif // SIMDJSON_H diff --git a/include/simdjson/arm64.h b/include/simdjson/arm64.h index 907dd972f..72deb2a63 100644 --- a/include/simdjson/arm64.h +++ b/include/simdjson/arm64.h @@ -1,23 +1,17 @@ #ifndef SIMDJSON_ARM64_H #define SIMDJSON_ARM64_H +#include "simdjson/implementation-base.h" + #ifdef SIMDJSON_FALLBACK_H #error "arm64.h must be included before fallback.h" #endif -#include "simdjson/portability.h" - #ifndef SIMDJSON_IMPLEMENTATION_ARM64 #define SIMDJSON_IMPLEMENTATION_ARM64 (SIMDJSON_IS_ARM64) #endif #define SIMDJSON_CAN_ALWAYS_RUN_ARM64 SIMDJSON_IMPLEMENTATION_ARM64 && SIMDJSON_IS_ARM64 - -#include "simdjson/internal/isadetection.h" -#include "simdjson/internal/jsoncharutils_tables.h" -#include "simdjson/internal/numberparsing_tables.h" -#include "simdjson/internal/simdprune_tables.h" - #if SIMDJSON_IMPLEMENTATION_ARM64 namespace simdjson { diff --git a/include/simdjson/base.h b/include/simdjson/base.h index 00ce6851b..c142f4a36 100644 --- a/include/simdjson/base.h +++ b/include/simdjson/base.h @@ -3,6 +3,7 @@ #include "simdjson/compiler_check.h" #include "simdjson/common_defs.h" +#include "simdjson/portability.h" SIMDJSON_PUSH_DISABLE_WARNINGS SIMDJSON_DISABLE_UNDESIRED_WARNINGS diff --git a/include/simdjson/builtin.h b/include/simdjson/builtin.h index 594a73a83..730c9939b 100644 --- a/include/simdjson/builtin.h +++ b/include/simdjson/builtin.h @@ -6,14 +6,19 @@ #ifndef SIMDJSON_BUILTIN_IMPLEMENTATION #if SIMDJSON_CAN_ALWAYS_RUN_HASWELL #define SIMDJSON_BUILTIN_IMPLEMENTATION haswell +#include "simdjson/haswell.h" #elif SIMDJSON_CAN_ALWAYS_RUN_WESTMERE #define SIMDJSON_BUILTIN_IMPLEMENTATION westmere +#include "simdjson/westmere.h" #elif SIMDJSON_CAN_ALWAYS_RUN_ARM64 #define SIMDJSON_BUILTIN_IMPLEMENTATION arm64 +#include "simdjson/arm64.h" #elif SIMDJSON_CAN_ALWAYS_RUN_PPC64 #define SIMDJSON_BUILTIN_IMPLEMENTATION ppc64 +#include "simdjson/ppc64.h" #elif SIMDJSON_CAN_ALWAYS_RUN_FALLBACK #define SIMDJSON_BUILTIN_IMPLEMENTATION fallback +#include "simdjson/fallback.h" #else #error "All possible implementations (including fallback) have been disabled! simdjson will not run." #endif diff --git a/include/simdjson/dom.h b/include/simdjson/dom.h index 5629b2b1a..b23745c58 100644 --- a/include/simdjson/dom.h +++ b/include/simdjson/dom.h @@ -1,6 +1,8 @@ #ifndef SIMDJSON_DOM_H #define SIMDJSON_DOM_H +#include "simdjson/base.h" + SIMDJSON_PUSH_DISABLE_WARNINGS SIMDJSON_DISABLE_UNDESIRED_WARNINGS diff --git a/include/simdjson/fallback.h b/include/simdjson/fallback.h index bea921547..0c85b433a 100644 --- a/include/simdjson/fallback.h +++ b/include/simdjson/fallback.h @@ -1,7 +1,7 @@ #ifndef SIMDJSON_FALLBACK_H #define SIMDJSON_FALLBACK_H -#include "simdjson/portability.h" +#include "simdjson/implementation-base.h" // Default Fallback to on unless a builtin implementation has already been selected. #ifndef SIMDJSON_IMPLEMENTATION_FALLBACK diff --git a/include/simdjson/haswell.h b/include/simdjson/haswell.h index cc93482dd..0195d423c 100644 --- a/include/simdjson/haswell.h +++ b/include/simdjson/haswell.h @@ -1,6 +1,8 @@ #ifndef SIMDJSON_HASWELL_H #define SIMDJSON_HASWELL_H +#include "simdjson/implementation-base.h" + #ifdef SIMDJSON_WESTMERE_H #error "haswell.h must be included before westmere.h" #endif @@ -8,8 +10,6 @@ #error "haswell.h must be included before fallback.h" #endif -#include "simdjson/portability.h" - // Default Haswell to on if this is x86-64. Even if we're not compiled for it, it could be selected // at runtime. #ifndef SIMDJSON_IMPLEMENTATION_HASWELL diff --git a/include/simdjson/implementation-base.h b/include/simdjson/implementation-base.h new file mode 100644 index 000000000..7b95fa3d4 --- /dev/null +++ b/include/simdjson/implementation-base.h @@ -0,0 +1,23 @@ +#ifndef SIMDJSON_IMPLEMENTATION_BASE_H +#define SIMDJSON_IMPLEMENTATION_BASE_H + +/** + * @file + * @private + * + * Includes common stuff needed for implementations. + */ + +#include "simdjson/base.h" +#include "simdjson/implementation.h" + +// Implementation-internal files (must be included before the implementations themselves, to keep +// amalgamation working--otherwise, the first time a file is included, it might be put inside the +// #ifdef SIMDJSON_IMPLEMENTATION_ARM64/FALLBACK/etc., which means the other implementations can't +// compile unless that implementation is turned on). +#include "simdjson/internal/isadetection.h" +#include "simdjson/internal/jsoncharutils_tables.h" +#include "simdjson/internal/numberparsing_tables.h" +#include "simdjson/internal/simdprune_tables.h" + +#endif // SIMDJSON_IMPLEMENTATION_BASE_H \ No newline at end of file diff --git a/include/simdjson/implementations.h b/include/simdjson/implementations.h index 8e89efc6f..2815d1ea4 100644 --- a/include/simdjson/implementations.h +++ b/include/simdjson/implementations.h @@ -4,22 +4,12 @@ SIMDJSON_PUSH_DISABLE_WARNINGS SIMDJSON_DISABLE_UNDESIRED_WARNINGS -// Implementation-internal files (must be included before the implementations themselves, to keep -// amalgamation working--otherwise, the first time a file is included, it might be put inside the -// #ifdef SIMDJSON_IMPLEMENTATION_ARM64/FALLBACK/etc., which means the other implementations can't -// compile unless that implementation is turned on). -#include "simdjson/internal/isadetection.h" -#include "simdjson/internal/jsoncharutils_tables.h" -#include "simdjson/internal/numberparsing_tables.h" -#include "simdjson/internal/simdprune_tables.h" - // Implementations #include "simdjson/arm64.h" #include "simdjson/haswell.h" #include "simdjson/westmere.h" #include "simdjson/ppc64.h" #include "simdjson/fallback.h" -#include "simdjson/builtin.h" SIMDJSON_POP_DISABLE_WARNINGS diff --git a/include/simdjson/ppc64.h b/include/simdjson/ppc64.h index 181cad213..315869be7 100644 --- a/include/simdjson/ppc64.h +++ b/include/simdjson/ppc64.h @@ -1,23 +1,17 @@ #ifndef SIMDJSON_PPC64_H #define SIMDJSON_PPC64_H +#include "simdjson/implementation-base.h" + #ifdef SIMDJSON_FALLBACK_H #error "ppc64.h must be included before fallback.h" #endif -#include "simdjson/portability.h" - #ifndef SIMDJSON_IMPLEMENTATION_PPC64 #define SIMDJSON_IMPLEMENTATION_PPC64 (SIMDJSON_IS_PPC64) #endif #define SIMDJSON_CAN_ALWAYS_RUN_PPC64 SIMDJSON_IMPLEMENTATION_PPC64 && SIMDJSON_IS_PPC64 - -#include "simdjson/internal/isadetection.h" -#include "simdjson/internal/jsoncharutils_tables.h" -#include "simdjson/internal/numberparsing_tables.h" -#include "simdjson/internal/simdprune_tables.h" - #if SIMDJSON_IMPLEMENTATION_PPC64 namespace simdjson { diff --git a/include/simdjson/westmere.h b/include/simdjson/westmere.h index 2f202c71a..917031e2b 100644 --- a/include/simdjson/westmere.h +++ b/include/simdjson/westmere.h @@ -1,12 +1,12 @@ #ifndef SIMDJSON_WESTMERE_H #define SIMDJSON_WESTMERE_H +#include "simdjson/implementation-base.h" + #ifdef SIMDJSON_FALLBACK_H #error "westmere.h must be included before fallback.h" #endif -#include "simdjson/portability.h" - // Default Westmere to on if this is x86-64, unless we'll always select Haswell. #ifndef SIMDJSON_IMPLEMENTATION_WESTMERE #define SIMDJSON_IMPLEMENTATION_WESTMERE (SIMDJSON_IS_X86_64 && !SIMDJSON_REQUIRES_HASWELL)