mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
meson: Export HAVE_FREE_SIZED in glibconfig.h for use in g_free()
This allows the `g_free()` wrapper introduced in the previous commit to only be defined if `free_sized()` is actually available to improve performance. This avoids passing an allocation size to every `g_free()` call if it’s not going to be used, saving a register store instruction each time. Suggested by Marco Trevisan in https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3252#note_1660032 Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
c580b5c2f4
commit
c0bdc61879
@ -212,6 +212,8 @@ typedef @g_pid_type@ GPid;
|
||||
#define G_SEARCHPATH_SEPARATOR '@g_searchpath_separator@'
|
||||
#define G_SEARCHPATH_SEPARATOR_S "@g_searchpath_separator@"
|
||||
|
||||
#mesondefine G_HAVE_FREE_SIZED
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GLIBCONFIG_H__ */
|
||||
|
@ -166,13 +166,13 @@ void g_aligned_free_sized (gpointer mem,
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
|
||||
#if G_GNUC_CHECK_VERSION (4, 1) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78
|
||||
#if G_GNUC_CHECK_VERSION (4, 1) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED)
|
||||
|
||||
#define g_free(mem) \
|
||||
(__builtin_object_size ((mem), 0) != ((size_t) - 1)) ? \
|
||||
g_free_sized (mem, __builtin_object_size ((mem), 0)) : (g_free) (mem)
|
||||
|
||||
#endif /* G_GNUC_CHECK_VERSION (4, 1) && && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 */
|
||||
#endif /* G_GNUC_CHECK_VERSION (4, 1) && && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED) */
|
||||
|
||||
/**
|
||||
* g_steal_pointer:
|
||||
|
@ -729,6 +729,10 @@ foreach f : functions
|
||||
endif
|
||||
endforeach
|
||||
|
||||
# Export the information about free_sized() so we can correctly define a macro
|
||||
# wrapper around g_free()/g_free_sized() depending on whether it’s available
|
||||
glibconfig_conf.set('G_HAVE_FREE_SIZED', have_func_free_sized)
|
||||
|
||||
# Check that stpcpy() is usable; must use header.
|
||||
# See:
|
||||
# https://github.com/mesonbuild/meson/issues/5628.
|
||||
|
Loading…
Reference in New Issue
Block a user