]> git.kaiwu.me - njs.git/commitdiff
QuickJS: using JS_AddIntrinsicBigInt() if detected.
authorVadim Zhestikov <v.zhestikov@f5.com>
Wed, 19 Mar 2025 16:12:45 +0000 (09:12 -0700)
committerVadimZhestikov <108960056+VadimZhestikov@users.noreply.github.com>
Thu, 20 Mar 2025 03:42:01 +0000 (20:42 -0700)
auto/quickjs
src/qjs.c

index 974321424a12a81cfc2b6cb96943d576a8f78aae..e4eecd29e40fd1d29e500d78a4d801897dde535f 100644 (file)
@@ -137,6 +137,29 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         . auto/feature
 
+        njs_feature="QuickJS JS_AddIntrinsicBigInt()"
+        njs_feature_name=NJS_HAVE_QUICKJS_ADD_INTRINSIC_BIG_INT
+        njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
+                          #pragma GCC diagnostic push
+                          #pragma GCC diagnostic ignored \"-Wcast-function-type\"
+                          #endif
+
+                          #include <quickjs.h>
+
+                          int main() {
+                              JSRuntime *rt;
+                              JSContext *ctx;
+
+                              rt = JS_NewRuntime();
+                              ctx = JS_NewContextRaw(rt);
+                              JS_AddIntrinsicBigInt(ctx);
+                              JS_FreeContext(ctx);
+                              JS_FreeRuntime(rt);
+                              return 0;
+                         }"
+
+        . auto/feature
+
         njs_feature="QuickJS version"
         njs_feature_name=NJS_QUICKJS_VERSION
         njs_feature_run=value
index 38015bb9355c9a4527d9347cc0b99a6a24aa91aa..7763c165c8515ad5526d2a044b1e755bc424dcf5 100644 (file)
--- a/src/qjs.c
+++ b/src/qjs.c
@@ -165,7 +165,9 @@ qjs_new_context(JSRuntime *rt, qjs_module_t **addons)
     JS_AddIntrinsicMapSet(ctx);
     JS_AddIntrinsicTypedArrays(ctx);
     JS_AddIntrinsicPromise(ctx);
+#ifdef NJS_HAVE_QUICKJS_ADD_INTRINSIC_BIG_INT
     JS_AddIntrinsicBigInt(ctx);
+#endif
     JS_AddIntrinsicEval(ctx);
 
     for (module = qjs_modules; *module != NULL; module++) {