Skip to content

Commit

Permalink
portability: global structs cant be statically initialized with exter…
Browse files Browse the repository at this point in the history
…nal symbols
  • Loading branch information
radare committed Dec 30, 2022
1 parent a3303a2 commit f12f4cc
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -42189,14 +42189,29 @@ static JSValue js_math_random(JSContext *ctx, JSValueConst this_val,
return __JS_NewFloat64(ctx, u.d - 1.0);
}

static double qjs_ceil(double x)
{
return ceil(x);
}

static double qjs_floor(double x)
{
return floor(x);
}

static double qjs_sqrt(double x)
{
return sqrt(x);
}

static const JSCFunctionListEntry js_math_funcs[] = {
JS_CFUNC_MAGIC_DEF("min", 2, js_math_min_max, 0 ),
JS_CFUNC_MAGIC_DEF("max", 2, js_math_min_max, 1 ),
JS_CFUNC_SPECIAL_DEF("abs", 1, f_f, fabs ),
JS_CFUNC_SPECIAL_DEF("floor", 1, f_f, floor ),
JS_CFUNC_SPECIAL_DEF("ceil", 1, f_f, ceil ),
JS_CFUNC_SPECIAL_DEF("floor", 1, f_f, qjs_floor ),
JS_CFUNC_SPECIAL_DEF("ceil", 1, f_f, qjs_ceil ),
JS_CFUNC_SPECIAL_DEF("round", 1, f_f, js_math_round ),
JS_CFUNC_SPECIAL_DEF("sqrt", 1, f_f, sqrt ),
JS_CFUNC_SPECIAL_DEF("sqrt", 1, f_f, qjs_sqrt ),

JS_CFUNC_SPECIAL_DEF("acos", 1, f_f, acos ),
JS_CFUNC_SPECIAL_DEF("asin", 1, f_f, asin ),
Expand Down

0 comments on commit f12f4cc

Please sign in to comment.