mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-22 05:38:11 +08:00
Add JS_GetVersion()
This commit is contained in:
parent
d378a9f3a5
commit
e4495dbd88
2
Makefile
2
Makefile
@ -136,7 +136,7 @@ CFLAGS+=-fwrapv # ensure that signed overflows behave as expected
|
||||
ifdef CONFIG_WERROR
|
||||
CFLAGS+=-Werror
|
||||
endif
|
||||
DEFINES:=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(shell cat VERSION)\"
|
||||
DEFINES:=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(shell grep JS_VERSION_STR quickjs.h | sed -e 's#.*"\(.*\)".*#\1#')\"
|
||||
ifdef CONFIG_BIGNUM
|
||||
DEFINES+=-DCONFIG_BIGNUM
|
||||
endif
|
||||
|
15
quickjs.c
15
quickjs.c
@ -1286,6 +1286,21 @@ static const JSClassExoticMethods js_proxy_exotic_methods;
|
||||
static const JSClassExoticMethods js_module_ns_exotic_methods;
|
||||
static JSClassID js_class_id_alloc = JS_CLASS_INIT_COUNT;
|
||||
|
||||
const char* JS_GetVersion(void)
|
||||
{
|
||||
#define JS_STRINGIFY_(x) #x
|
||||
#define JS_STRINGIFY(x) JS_STRINGIFY_(x)
|
||||
|
||||
return JS_VERSION_STR
|
||||
#ifdef JS_VERSION_SUFFIX
|
||||
"-" JS_STRINGIFY(JS_VERSION_SUFFIX)
|
||||
#endif
|
||||
;
|
||||
|
||||
#undef JS_STRINGIFY
|
||||
#undef JS_STRINGIFY_
|
||||
}
|
||||
|
||||
static void js_trigger_gc(JSRuntime *rt, size_t size)
|
||||
{
|
||||
BOOL force_gc;
|
||||
|
@ -32,6 +32,15 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define JS_MKVERSION(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
|
||||
#define JS_VERSION JS_MKVERSION(0, 5, 0)
|
||||
#define JS_VERSION_STR "0.5.0"
|
||||
#define JS_VERSION_MAJOR(v) (((v) >> 16))
|
||||
#define JS_VERSION_MINOR(v) (((v) >> 8) & 0xff)
|
||||
#define JS_VERSION_PATCH(v) ((v) & 0xff)
|
||||
|
||||
const char *JS_GetVersion(void);
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define js_likely(x) __builtin_expect(!!(x), 1)
|
||||
#define js_unlikely(x) __builtin_expect(!!(x), 0)
|
||||
|
Loading…
Reference in New Issue
Block a user