mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-23 01:18:53 +02:00
gutils: clean up bit funcs inlining mess
gutils.h and gutils.c define three utility functions as inlines that are also exported via the ABI. This is done via complicated G_INLINE_FUNC and G_IMPLEMENT_INLINES logic. In order to be able to remove this mess, we create a another convoluted but slightly cleaner approach: write straight-up inline versions of the functions named _impl() in the header. Define macros with the "public" function names that call these inlines. From the .c file, export the ABI versions of these functions, implemented using the _impl() version. https://bugzilla.gnome.org/show_bug.cgi?id=757374
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "glibconfig.h"
|
||||
|
||||
#include "gutils.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
@@ -50,12 +51,6 @@
|
||||
#include <crt_externs.h> /* for _NSGetEnviron */
|
||||
#endif
|
||||
|
||||
/* implement gutils's inline functions
|
||||
*/
|
||||
#define G_IMPLEMENT_INLINES 1
|
||||
#define __G_UTILS_C__
|
||||
#include "gutils.h"
|
||||
|
||||
#include "glib-init.h"
|
||||
#include "glib-private.h"
|
||||
#include "genviron.h"
|
||||
@@ -483,6 +478,10 @@ g_find_program_in_path (const gchar *program)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The functions below are defined this way for compatibility reasons.
|
||||
* See the note in gutils.h.
|
||||
*/
|
||||
|
||||
/**
|
||||
* g_bit_nth_lsf:
|
||||
* @mask: a #gulong containing flags
|
||||
@@ -496,6 +495,12 @@ g_find_program_in_path (const gchar *program)
|
||||
* Returns: the index of the first bit set which is higher than @nth_bit, or -1
|
||||
* if no higher bits are set
|
||||
*/
|
||||
gint
|
||||
(g_bit_nth_lsf) (gulong mask,
|
||||
gint nth_bit)
|
||||
{
|
||||
return g_bit_nth_lsf_impl (mask, nth_bit);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_bit_nth_msf:
|
||||
@@ -511,6 +516,13 @@ g_find_program_in_path (const gchar *program)
|
||||
* Returns: the index of the first bit set which is lower than @nth_bit, or -1
|
||||
* if no lower bits are set
|
||||
*/
|
||||
gint
|
||||
(g_bit_nth_msf) (gulong mask,
|
||||
gint nth_bit)
|
||||
{
|
||||
return g_bit_nth_msf_impl (mask, nth_bit);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* g_bit_storage:
|
||||
@@ -521,6 +533,11 @@ g_find_program_in_path (const gchar *program)
|
||||
*
|
||||
* Returns: the number of bits used to hold @number
|
||||
*/
|
||||
guint
|
||||
(g_bit_storage) (gulong number)
|
||||
{
|
||||
return g_bit_storage_impl (number);
|
||||
}
|
||||
|
||||
G_LOCK_DEFINE_STATIC (g_utils_global);
|
||||
|
||||
|
Reference in New Issue
Block a user