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 Jan 27, 2023
1 parent 65cfe08 commit cd869f5
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 @@ -42193,14 +42193,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 cd869f5

Please sign in to comment.