]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
ggml : fix static_assert with older compilers #2024 (#2218)
authorEvan Miller <redacted>
Fri, 14 Jul 2023 18:55:56 +0000 (14:55 -0400)
committerGitHub <redacted>
Fri, 14 Jul 2023 18:55:56 +0000 (21:55 +0300)
ggml.c
k_quants.h

diff --git a/ggml.c b/ggml.c
index f5821f1f1aa042d3c04eabc36b9aca9678ea4e87..3ea8ba6ec92f65c098bd6f2ec65c43713ad17edd 100644 (file)
--- a/ggml.c
+++ b/ggml.c
 #include <unistd.h>
 #endif
 
+// static_assert should be a #define, but if it's not,
+// fall back to the _Static_assert C11 keyword.
 // if C99 - static_assert is noop
 // ref: https://stackoverflow.com/a/53923785/4039976
 #ifndef static_assert
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201100L)
+#define static_assert(cond, msg) _Static_assert(cond, msg)
+#else
 #define static_assert(cond, msg) struct global_scope_noop_trick
 #endif
+#endif
 
 #if defined(_MSC_VER)
 // disable "possible loss of data" to avoid hundreds of casts
@@ -112,10 +118,6 @@ typedef void * thread_ret_t;
 #endif
 #endif
 
-#ifdef __HAIKU__
-#define static_assert(cond, msg) _Static_assert(cond, msg)
-#endif
-
 /*#define GGML_PERF*/
 #define GGML_DEBUG 0
 #define GGML_GELU_FP16
index 6abe3d7b8f42201f655388c29360cf721619746e..adc6a391376d45126e4f5eb0f0d688bf77d1755b 100644 (file)
 #define K_SCALE_SIZE 12
 #endif
 
+#ifndef static_assert
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201100L)
+#define static_assert(cond, msg) _Static_assert(cond, msg)
+#else
+#define static_assert(cond, msg) struct global_scope_noop_trick
+#endif
+#endif
+
 //
 // Super-block quantization structures
 //