[Tarantool-patches] [PATCH luajit 07/19] build: fix non-Linux/macOS builds
Maxim Kokryashkin
m.kokryashkin at tarantool.org
Tue Aug 15 14:58:09 MSK 2023
Hi, Sergey!
Thanks for the patch!
LGTM, except for a few typos below.
On Wed, Aug 09, 2023 at 06:35:56PM +0300, Sergey Kaplun via Tarantool-patches wrote:
> This patch is a follow-up for the commit
> a170eb8be9475295f4f67a086e25ed665b95c8ea ("core: separate the profiling
> timer from lj_profile"). It moves the timer machinery to the separate
Typo: s/to the/to a/
> module. Unfortunately, the `profile_{un}lock()` calls for Windows and
> PS3 wasn't updated to access `lj_profile_timer` structure instead of
Typo: s/wasn't/weren't/
> `ProfileState`.
>
> Also, it is a follow-up to the commit
> f8fa8f4bbd103ab07697487ca5cab08d57cdebf5 ("memprof: add profile common
> section"). Since this commit the system-dependent header <unistd.h> and
> `write()`, `open()`, `close()` functions are used. They are undefining
Typo: s/undefining/undefined/
> on Windows, so this leads to error during the build.
Typo: s/error/errors/
>
> This patch fixes the aforementioned misbehaviour. After it our fork may
> be built on Windows at least.
> ---
> src/lib_misc.c | 16 ++++++++++++----
> src/lj_profile_timer.h | 8 ++++----
> 2 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/src/lib_misc.c b/src/lib_misc.c
> index c18d297e..1913a622 100644
> --- a/src/lib_misc.c
> +++ b/src/lib_misc.c
> @@ -8,10 +8,6 @@
> #define lib_misc_c
> #define LUA_LIB
>
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <unistd.h>
> -
> #include "lua.h"
> #include "lmisclib.h"
> #include "lauxlib.h"
> @@ -25,6 +21,12 @@
>
> #include "lj_memprof.h"
>
> +#include <errno.h>
> +#include <fcntl.h>
> +#if !LJ_TARGET_WINDOWS
> +#include <unistd.h>
> +#endif
> +
> /* ------------------------------------------------------------------------ */
>
> static LJ_AINLINE void setnumfield(struct lua_State *L, GCtab *t,
> @@ -78,6 +80,7 @@ LJLIB_CF(misc_getmetrics)
>
> /* --------- profile common section --------------------------------------- */
>
> +#if !LJ_TARGET_WINDOWS
> /*
> ** Yep, 8Mb. Tuned in order not to bother the platform with too often flushes.
> */
> @@ -434,6 +437,7 @@ LJLIB_CF(misc_memprof_stop)
> lua_pushboolean(L, 1);
> return 1;
> }
> +#endif /* !LJ_TARGET_WINDOWS */
>
> #include "lj_libdef.h"
>
> @@ -441,6 +445,7 @@ LJLIB_CF(misc_memprof_stop)
>
> LUALIB_API int luaopen_misc(struct lua_State *L)
> {
> +#if !LJ_TARGET_WINDOWS
> luaM_sysprof_set_writer(buffer_writer_default);
> luaM_sysprof_set_on_stop(on_stop_cb_default);
> /*
> @@ -448,9 +453,12 @@ LUALIB_API int luaopen_misc(struct lua_State *L)
> ** backtracing function.
> */
> luaM_sysprof_set_backtracer(NULL);
> +#endif /* !LJ_TARGET_WINDOWS */
>
> LJ_LIB_REG(L, LUAM_MISCLIBNAME, misc);
> +#if !LJ_TARGET_WINDOWS
> LJ_LIB_REG(L, LUAM_MISCLIBNAME ".memprof", misc_memprof);
> LJ_LIB_REG(L, LUAM_MISCLIBNAME ".sysprof", misc_sysprof);
> +#endif /* !LJ_TARGET_WINDOWS */
> return 1;
> }
> diff --git a/src/lj_profile_timer.h b/src/lj_profile_timer.h
> index 1deeea53..b3e1a6e9 100644
> --- a/src/lj_profile_timer.h
> +++ b/src/lj_profile_timer.h
> @@ -25,8 +25,8 @@
> #if LJ_TARGET_PS3
> #include <sys/timer.h>
> #endif
> -#define profile_lock(ps) pthread_mutex_lock(&ps->lock)
> -#define profile_unlock(ps) pthread_mutex_unlock(&ps->lock)
> +#define profile_lock(ps) pthread_mutex_lock(&ps->timer.lock)
> +#define profile_unlock(ps) pthread_mutex_unlock(&ps->timer.lock)
>
> #elif LJ_PROFILE_WTHREAD
>
> @@ -38,8 +38,8 @@
> #include <windows.h>
> #endif
> typedef unsigned int (WINAPI *WMM_TPFUNC)(unsigned int);
> -#define profile_lock(ps) EnterCriticalSection(&ps->lock)
> -#define profile_unlock(ps) LeaveCriticalSection(&ps->lock)
> +#define profile_lock(ps) EnterCriticalSection(&ps->timer.lock)
> +#define profile_unlock(ps) LeaveCriticalSection(&ps->timer.lock)
>
> #endif
>
> --
> 2.41.0
>
More information about the Tarantool-patches
mailing list