[Tarantool-patches] [PATCH luajit 1/3] misc: fix build with disabled memory profiler

Sergey Kaplun skaplun at tarantool.org
Wed Dec 30 01:22:56 MSK 2020


This patch fixes the regression introduced in scope of
b4e6bf0d82100049d29af1aa3196e781270f39d1 ('misc: add Lua API for memory
profiler'). Build is failed with disabled memory profiler because
related error messages are not defined.

This patch fixes build by making LJ_ERR_PROF_MISUSE visible and avoiding
usage of other profiler-related errors when the profiler is disabled.

Follows up tarantool/tarantool#5442
---
 src/lib_misc.c  | 4 ++++
 src/lj_errmsg.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/lib_misc.c b/src/lib_misc.c
index 958c189..f89827e 100644
--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -187,6 +187,7 @@ LJLIB_CF(misc_memprof_start)
       lua_pushstring(L, err2msg(LJ_ERR_PROF_MISUSE));
       lua_pushinteger(L, EINVAL);
       return 3;
+#if LJ_HASMEMPROF
     case PROFILE_ERRRUN:
       lua_pushnil(L);
       lua_pushstring(L, err2msg(LJ_ERR_PROF_ISRUNNING));
@@ -194,6 +195,7 @@ LJLIB_CF(misc_memprof_start)
       return 3;
     case PROFILE_ERRIO:
       return luaL_fileresult(L, 0, fname);
+#endif
     default:
       lua_assert(0);
       return 0;
@@ -214,6 +216,7 @@ LJLIB_CF(misc_memprof_stop)
       lua_pushstring(L, err2msg(LJ_ERR_PROF_MISUSE));
       lua_pushinteger(L, EINVAL);
       return 3;
+#if LJ_HASMEMPROF
     case PROFILE_ERRRUN:
       lua_pushnil(L);
       lua_pushstring(L, err2msg(LJ_ERR_PROF_NOTRUNNING));
@@ -221,6 +224,7 @@ LJLIB_CF(misc_memprof_stop)
       return 3;
     case PROFILE_ERRIO:
       return luaL_fileresult(L, 0, NULL);
+#endif
     default:
       lua_assert(0);
       return 0;
diff --git a/src/lj_errmsg.h b/src/lj_errmsg.h
index bebe804..ae0a18c 100644
--- a/src/lj_errmsg.h
+++ b/src/lj_errmsg.h
@@ -185,9 +185,9 @@ ERRDEF(FFI_NYIPACKBIT,	"NYI: packed bit fields")
 ERRDEF(FFI_NYICALL,	"NYI: cannot call this C function (yet)")
 #endif
 
-#if LJ_HASMEMPROF
 /* Profiler errors. */
 ERRDEF(PROF_MISUSE,	"profiler misuse")
+#if LJ_HASMEMPROF
 ERRDEF(PROF_ISRUNNING,	"profiler is running already")
 ERRDEF(PROF_NOTRUNNING,	"profiler is not running")
 #endif
-- 
2.28.0



More information about the Tarantool-patches mailing list