diff options
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 5f0143efbb..8921c0a4c3 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -53,6 +53,8 @@ | |||
53 | * | 53 | * |
54 | * ----------------------------- | 54 | * ----------------------------- |
55 | */ | 55 | */ |
56 | extern size_t rock_get_allocated_bytes(void); /* tlsf_helper.c */ | ||
57 | extern size_t rock_get_unused_bytes(void); | ||
56 | 58 | ||
57 | #define RB_WRAP(func) static int rock_##func(lua_State UNUSED_ATTR *L) | 59 | #define RB_WRAP(func) static int rock_##func(lua_State UNUSED_ATTR *L) |
58 | #define SIMPLE_VOID_WRAPPER(func) RB_WRAP(func) { (void)L; func(); return 0; } | 60 | #define SIMPLE_VOID_WRAPPER(func) RB_WRAP(func) { (void)L; func(); return 0; } |
@@ -931,6 +933,19 @@ RB_WRAP(show_logo) | |||
931 | return 0; | 933 | return 0; |
932 | } | 934 | } |
933 | 935 | ||
936 | RB_WRAP(mem_stats) | ||
937 | { | ||
938 | /* used, allocd, free = rb.mem_stats() */ | ||
939 | /* note free is the high watermark */ | ||
940 | size_t allocd = rock_get_allocated_bytes(); | ||
941 | size_t free = rock_get_unused_bytes(); | ||
942 | |||
943 | lua_pushinteger(L, allocd - free); | ||
944 | lua_pushinteger(L, allocd); | ||
945 | lua_pushinteger(L, free); | ||
946 | return 3; | ||
947 | } | ||
948 | |||
934 | #define RB_FUNC(func) {#func, rock_##func} | 949 | #define RB_FUNC(func) {#func, rock_##func} |
935 | #define RB_ALIAS(name, func) {name, rock_##func} | 950 | #define RB_ALIAS(name, func) {name, rock_##func} |
936 | static const luaL_Reg rocklib[] = | 951 | static const luaL_Reg rocklib[] = |
@@ -1015,6 +1030,7 @@ static const luaL_Reg rocklib[] = | |||
1015 | /* MISC */ | 1030 | /* MISC */ |
1016 | RB_FUNC(restart_lua), | 1031 | RB_FUNC(restart_lua), |
1017 | RB_FUNC(show_logo), | 1032 | RB_FUNC(show_logo), |
1033 | RB_FUNC(mem_stats), | ||
1018 | 1034 | ||
1019 | {NULL, NULL} | 1035 | {NULL, NULL} |
1020 | }; | 1036 | }; |