Use g_once_init_{enter,leave}_pointer where appropriate

This should not result in any functional changes, but will eventually
allow glib to be functional on CHERI-enabled systems such as Morello.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
This commit is contained in:
Alex Richardson 2023-09-11 23:59:52 -07:00 committed by Philip Withnall
parent 726eca7c89
commit a1dfecf11f
25 changed files with 81 additions and 86 deletions

View File

@ -294,10 +294,9 @@ gdbus_shared_thread_func (gpointer user_data)
static SharedThreadData * static SharedThreadData *
_g_dbus_shared_thread_ref (void) _g_dbus_shared_thread_ref (void)
{ {
static gsize shared_thread_data = 0; static SharedThreadData *shared_thread_data = 0;
SharedThreadData *ret;
if (g_once_init_enter (&shared_thread_data)) if (g_once_init_enter_pointer (&shared_thread_data))
{ {
SharedThreadData *data; SharedThreadData *data;
@ -310,12 +309,11 @@ _g_dbus_shared_thread_ref (void)
gdbus_shared_thread_func, gdbus_shared_thread_func,
data); data);
/* We can cast between gsize and gpointer safely */ /* We can cast between gsize and gpointer safely */
g_once_init_leave (&shared_thread_data, (gsize) data); g_once_init_leave_pointer (&shared_thread_data, data);
} }
ret = (SharedThreadData*) shared_thread_data; g_atomic_int_inc (&shared_thread_data->refcount);
g_atomic_int_inc (&ret->refcount); return shared_thread_data;
return ret;
} }
static void static void

View File

@ -365,7 +365,7 @@ get_lowercase_current_desktops (void)
{ {
static gchar **result; static gchar **result;
if (g_once_init_enter (&result)) if (g_once_init_enter_pointer (&result))
{ {
char **tmp = get_valid_current_desktops (NULL); char **tmp = get_valid_current_desktops (NULL);
gsize i, j; gsize i, j;
@ -377,7 +377,7 @@ get_lowercase_current_desktops (void)
tmp[i][j] = g_ascii_tolower (tmp[i][j]); tmp[i][j] = g_ascii_tolower (tmp[i][j]);
} }
g_once_init_leave (&result, tmp); g_once_init_leave_pointer (&result, tmp);
} }
return (const gchar **) result; return (const gchar **) result;
@ -388,11 +388,11 @@ get_current_desktops (const gchar *value)
{ {
static gchar **result; static gchar **result;
if (g_once_init_enter (&result)) if (g_once_init_enter_pointer (&result))
{ {
char **tmp = get_valid_current_desktops (value); char **tmp = get_valid_current_desktops (value);
g_once_init_leave (&result, tmp); g_once_init_leave_pointer (&result, tmp);
} }
return (const gchar **) result; return (const gchar **) result;
@ -3012,7 +3012,7 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo *info,
g_free (program); g_free (program);
} }
if (g_once_init_enter (&gio_launch_desktop_path)) if (g_once_init_enter_pointer (&gio_launch_desktop_path))
{ {
const gchar *tmp = NULL; const gchar *tmp = NULL;
gboolean is_setuid = GLIB_PRIVATE_CALL (g_check_setuid) (); gboolean is_setuid = GLIB_PRIVATE_CALL (g_check_setuid) ();
@ -3028,7 +3028,7 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo *info,
/* Fall back on usual searching in $PATH */ /* Fall back on usual searching in $PATH */
if (tmp == NULL) if (tmp == NULL)
tmp = "gio-launch-desktop"; tmp = "gio-launch-desktop";
g_once_init_leave (&gio_launch_desktop_path, tmp); g_once_init_leave_pointer (&gio_launch_desktop_path, tmp);
} }
wrapped_argv = g_new (char *, argc + 2); wrapped_argv = g_new (char *, argc + 2);

View File

@ -93,12 +93,12 @@ g_dummy_tls_backend_get_default_database (GTlsBackend *backend)
{ {
GDummyTlsBackend *dummy = G_DUMMY_TLS_BACKEND (backend); GDummyTlsBackend *dummy = G_DUMMY_TLS_BACKEND (backend);
if (g_once_init_enter (&dummy->database)) if (g_once_init_enter_pointer (&dummy->database))
{ {
GTlsDatabase *tlsdb; GTlsDatabase *tlsdb;
tlsdb = g_object_new (_g_dummy_tls_database_get_type (), NULL); tlsdb = g_object_new (_g_dummy_tls_database_get_type (), NULL);
g_once_init_leave (&dummy->database, tlsdb); g_once_init_leave_pointer (&dummy->database, tlsdb);
} }
return g_object_ref (dummy->database); return g_object_ref (dummy->database);

View File

@ -421,13 +421,13 @@ g_inet_socket_address_new_from_string (const char *address,
* it will handle parsing a scope_id as well. * it will handle parsing a scope_id as well.
*/ */
if (G_UNLIKELY (g_once_init_enter (&hints))) if (G_UNLIKELY (g_once_init_enter_pointer (&hints)))
{ {
hints_struct.ai_family = AF_UNSPEC; hints_struct.ai_family = AF_UNSPEC;
hints_struct.ai_socktype = SOCK_STREAM; hints_struct.ai_socktype = SOCK_STREAM;
hints_struct.ai_protocol = 0; hints_struct.ai_protocol = 0;
hints_struct.ai_flags = AI_NUMERICHOST; hints_struct.ai_flags = AI_NUMERICHOST;
g_once_init_leave (&hints, &hints_struct); g_once_init_leave_pointer (&hints, &hints_struct);
} }
status = getaddrinfo (address, NULL, hints, &res); status = getaddrinfo (address, NULL, hints, &res);

View File

@ -105,7 +105,7 @@
static void g_local_file_file_iface_init (GFileIface *iface); static void g_local_file_file_iface_init (GFileIface *iface);
static GFileAttributeInfoList *local_writable_attributes = NULL; static GFileAttributeInfoList *local_writable_attributes = NULL;
static /* GFileAttributeInfoList * */ gsize local_writable_namespaces = 0; static GFileAttributeInfoList *local_writable_namespaces = NULL;
struct _GLocalFile struct _GLocalFile
{ {
@ -1274,7 +1274,7 @@ g_local_file_query_writable_namespaces (GFile *file,
GVfsClass *class; GVfsClass *class;
GVfs *vfs; GVfs *vfs;
if (g_once_init_enter (&local_writable_namespaces)) if (g_once_init_enter_pointer (&local_writable_namespaces))
{ {
/* Writable namespaces: */ /* Writable namespaces: */
@ -1297,7 +1297,7 @@ g_local_file_query_writable_namespaces (GFile *file,
if (class->add_writable_namespaces) if (class->add_writable_namespaces)
class->add_writable_namespaces (vfs, list); class->add_writable_namespaces (vfs, list);
g_once_init_leave (&local_writable_namespaces, (gsize)list); g_once_init_leave_pointer (&local_writable_namespaces, list);
} }
list = (GFileAttributeInfoList *)local_writable_namespaces; list = (GFileAttributeInfoList *)local_writable_namespaces;

View File

@ -94,7 +94,7 @@ static GNetworkMonitor *network_monitor_default_singleton = NULL; /* (owned) (a
GNetworkMonitor * GNetworkMonitor *
g_network_monitor_get_default (void) g_network_monitor_get_default (void)
{ {
if (g_once_init_enter (&network_monitor_default_singleton)) if (g_once_init_enter_pointer (&network_monitor_default_singleton))
{ {
GNetworkMonitor *singleton; GNetworkMonitor *singleton;
@ -102,7 +102,7 @@ g_network_monitor_get_default (void)
"GIO_USE_NETWORK_MONITOR", "GIO_USE_NETWORK_MONITOR",
NULL); NULL);
g_once_init_leave (&network_monitor_default_singleton, singleton); g_once_init_leave_pointer (&network_monitor_default_singleton, singleton);
} }
return network_monitor_default_singleton; return network_monitor_default_singleton;

View File

@ -84,7 +84,7 @@ static GProxyResolver *proxy_resolver_default_singleton = NULL; /* (owned) (ato
GProxyResolver * GProxyResolver *
g_proxy_resolver_get_default (void) g_proxy_resolver_get_default (void)
{ {
if (g_once_init_enter (&proxy_resolver_default_singleton)) if (g_once_init_enter_pointer (&proxy_resolver_default_singleton))
{ {
GProxyResolver *singleton; GProxyResolver *singleton;
@ -92,7 +92,7 @@ g_proxy_resolver_get_default (void)
"GIO_USE_PROXY_RESOLVER", "GIO_USE_PROXY_RESOLVER",
(GIOModuleVerifyFunc) g_proxy_resolver_is_supported); (GIOModuleVerifyFunc) g_proxy_resolver_is_supported);
g_once_init_leave (&proxy_resolver_default_singleton, singleton); g_once_init_leave_pointer (&proxy_resolver_default_singleton, singleton);
} }
return proxy_resolver_default_singleton; return proxy_resolver_default_singleton;

View File

@ -336,7 +336,7 @@ g_resource_find_overlay (const gchar *path,
* we can take a bit more time... * we can take a bit more time...
*/ */
if (g_once_init_enter (&overlay_dirs)) if (g_once_init_enter_pointer (&overlay_dirs))
{ {
gboolean is_setuid = GLIB_PRIVATE_CALL (g_check_setuid) (); gboolean is_setuid = GLIB_PRIVATE_CALL (g_check_setuid) ();
const gchar * const *result; const gchar * const *result;
@ -420,7 +420,7 @@ g_resource_find_overlay (const gchar *path,
result = empty_strv; result = empty_strv;
} }
g_once_init_leave (&overlay_dirs, result); g_once_init_leave_pointer (&overlay_dirs, result);
} }
for (i = 0; overlay_dirs[i]; i++) for (i = 0; overlay_dirs[i]; i++)

View File

@ -1018,7 +1018,7 @@ static GSettingsBackend *settings_backend_default_singleton = NULL; /* (owned)
GSettingsBackend * GSettingsBackend *
g_settings_backend_get_default (void) g_settings_backend_get_default (void)
{ {
if (g_once_init_enter (&settings_backend_default_singleton)) if (g_once_init_enter_pointer (&settings_backend_default_singleton))
{ {
GSettingsBackend *singleton; GSettingsBackend *singleton;
@ -1026,7 +1026,7 @@ g_settings_backend_get_default (void)
"GSETTINGS_BACKEND", "GSETTINGS_BACKEND",
g_settings_backend_verify); g_settings_backend_verify);
g_once_init_leave (&settings_backend_default_singleton, singleton); g_once_init_leave_pointer (&settings_backend_default_singleton, singleton);
} }
return g_object_ref (settings_backend_default_singleton); return g_object_ref (settings_backend_default_singleton);

View File

@ -580,7 +580,7 @@ normalise_whitespace (const gchar *orig)
gchar *result; gchar *result;
gint i; gint i;
if (g_once_init_enter (&splitter)) if (g_once_init_enter_pointer (&splitter))
{ {
GRegex *s; GRegex *s;
@ -593,7 +593,7 @@ normalise_whitespace (const gchar *orig)
s = g_regex_new ("\\n\\s*\\n+", G_REGEX_DEFAULT, s = g_regex_new ("\\n\\s*\\n+", G_REGEX_DEFAULT,
G_REGEX_MATCH_DEFAULT, NULL); G_REGEX_MATCH_DEFAULT, NULL);
g_once_init_leave (&splitter, s); g_once_init_leave_pointer (&splitter, s);
} }
lines = g_regex_split (splitter, orig, 0); lines = g_regex_split (splitter, orig, 0);
@ -744,7 +744,7 @@ parse_into_text_tables (const gchar *directory,
static GHashTable ** static GHashTable **
g_settings_schema_source_get_text_tables (GSettingsSchemaSource *source) g_settings_schema_source_get_text_tables (GSettingsSchemaSource *source)
{ {
if (g_once_init_enter (&source->text_tables)) if (g_once_init_enter_pointer (&source->text_tables))
{ {
GHashTable **text_tables; GHashTable **text_tables;
@ -755,7 +755,7 @@ g_settings_schema_source_get_text_tables (GSettingsSchemaSource *source)
if (source->directory) if (source->directory)
parse_into_text_tables (source->directory, text_tables[0], text_tables[1]); parse_into_text_tables (source->directory, text_tables[0], text_tables[1]);
g_once_init_leave (&source->text_tables, text_tables); g_once_init_leave_pointer (&source->text_tables, text_tables);
} }
return source->text_tables; return source->text_tables;
@ -1496,7 +1496,7 @@ g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key)
if (!key->desktop_overrides) if (!key->desktop_overrides)
return NULL; return NULL;
if (g_once_init_enter (&current_desktops)) if (g_once_init_enter_pointer (&current_desktops))
{ {
const gchar *xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); const gchar *xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
gchar **tmp; gchar **tmp;
@ -1506,7 +1506,7 @@ g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key)
else else
tmp = g_new0 (gchar *, 0 + 1); tmp = g_new0 (gchar *, 0 + 1);
g_once_init_leave (&current_desktops, (const gchar **) tmp); g_once_init_leave_pointer (&current_desktops, (const gchar **) tmp);
} }
for (i = 0; value == NULL && current_desktops[i] != NULL; i++) for (i = 0; value == NULL && current_desktops[i] != NULL; i++)

View File

@ -3179,8 +3179,8 @@ g_socket_get_available_bytes (GSocket *socket)
#else #else
if (socket->priv->type == G_SOCKET_TYPE_DATAGRAM) if (socket->priv->type == G_SOCKET_TYPE_DATAGRAM)
{ {
if (G_UNLIKELY (g_once_init_enter (&buf))) if (G_UNLIKELY (g_once_init_enter_pointer (&buf)))
g_once_init_leave (&buf, g_malloc (bufsize)); g_once_init_leave_pointer (&buf, g_malloc (bufsize));
/* On datagram sockets, FIONREAD ioctl is not reliable because many /* On datagram sockets, FIONREAD ioctl is not reliable because many
* systems add internal header size to the reported size, making it * systems add internal header size to the reported size, making it

View File

@ -121,25 +121,22 @@ _g_object_unref_and_wait_weak_notify (gpointer object)
static void static void
_g_test_watcher_add_pid (GPid pid) _g_test_watcher_add_pid (GPid pid)
{ {
static gsize started = 0; HANDLE job = NULL;
HANDLE job;
if (g_once_init_enter (&started)) if (g_once_init_enter (&job))
{ {
JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
job = CreateJobObjectW (NULL, NULL); HANDLE tmp = CreateJobObjectW (NULL, NULL);
memset (&info, 0, sizeof (info)); memset (&info, 0, sizeof (info));
info.BasicLimitInformation.LimitFlags = 0x2000 /* JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE */; info.BasicLimitInformation.LimitFlags = 0x2000 /* JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE */;
if (!SetInformationJobObject(job, JobObjectExtendedLimitInformation, &info, sizeof (info))) if (!SetInformationJobObject (tmp, JobObjectExtendedLimitInformation, &info, sizeof (info)))
g_warning ("Can't enable JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: %s", g_win32_error_message (GetLastError())); g_warning ("Can't enable JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: %s", g_win32_error_message (GetLastError()));
g_once_init_leave (&started,(gsize)job); g_once_init_leave_pointer (&job, tmp);
} }
job = (HANDLE)started;
if (!AssignProcessToJobObject(job, pid)) if (!AssignProcessToJobObject(job, pid))
g_warning ("Can't assign process to job: %s", g_win32_error_message (GetLastError())); g_warning ("Can't assign process to job: %s", g_win32_error_message (GetLastError()));
} }

View File

@ -110,7 +110,7 @@ static GTlsBackend *tls_backend_default_singleton = NULL; /* (owned) (atomic) *
GTlsBackend * GTlsBackend *
g_tls_backend_get_default (void) g_tls_backend_get_default (void)
{ {
if (g_once_init_enter (&tls_backend_default_singleton)) if (g_once_init_enter_pointer (&tls_backend_default_singleton))
{ {
GTlsBackend *singleton; GTlsBackend *singleton;
@ -118,7 +118,7 @@ g_tls_backend_get_default (void)
"GIO_USE_TLS", "GIO_USE_TLS",
NULL); NULL);
g_once_init_leave (&tls_backend_default_singleton, singleton); g_once_init_leave_pointer (&tls_backend_default_singleton, singleton);
} }
return tls_backend_default_singleton; return tls_backend_default_singleton;

View File

@ -48,7 +48,7 @@ ensure_trash_portal (void)
{ {
static GXdpTrash *trash = NULL; static GXdpTrash *trash = NULL;
if (g_once_init_enter (&trash)) if (g_once_init_enter_pointer (&trash))
{ {
GDBusConnection *connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); GDBusConnection *connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
GXdpTrash *proxy = NULL; GXdpTrash *proxy = NULL;
@ -62,7 +62,7 @@ ensure_trash_portal (void)
g_object_unref (connection); g_object_unref (connection);
} }
g_once_init_leave (&trash, proxy); g_once_init_leave_pointer (&trash, proxy);
} }
return trash; return trash;

View File

@ -355,7 +355,7 @@ g_vfs_get_default (void)
if (GLIB_PRIVATE_CALL (g_check_setuid) ()) if (GLIB_PRIVATE_CALL (g_check_setuid) ())
return g_vfs_get_local (); return g_vfs_get_local ();
if (g_once_init_enter (&vfs_default_singleton)) if (g_once_init_enter_pointer (&vfs_default_singleton))
{ {
GVfs *singleton; GVfs *singleton;
@ -363,7 +363,7 @@ g_vfs_get_default (void)
"GIO_USE_VFS", "GIO_USE_VFS",
(GIOModuleVerifyFunc) g_vfs_is_active); (GIOModuleVerifyFunc) g_vfs_is_active);
g_once_init_leave (&vfs_default_singleton, singleton); g_once_init_leave_pointer (&vfs_default_singleton, singleton);
} }
return vfs_default_singleton; return vfs_default_singleton;
@ -379,12 +379,12 @@ g_vfs_get_default (void)
GVfs * GVfs *
g_vfs_get_local (void) g_vfs_get_local (void)
{ {
static gsize vfs = 0; static GVfs *vfs = 0;
if (g_once_init_enter (&vfs)) if (g_once_init_enter_pointer (&vfs))
g_once_init_leave (&vfs, (gsize)_g_local_vfs_new ()); g_once_init_leave_pointer (&vfs, _g_local_vfs_new ());
return G_VFS (vfs); return vfs;
} }
/** /**

View File

@ -1747,7 +1747,7 @@ static void
_g_win32_registry_key_reread (GWin32RegistryKey *key, _g_win32_registry_key_reread (GWin32RegistryKey *key,
GWin32RegistryKeyPrivate *buf) GWin32RegistryKeyPrivate *buf)
{ {
if (g_once_init_enter (&nt_query_key)) if (g_once_init_enter_pointer (&nt_query_key))
{ {
NtQueryKeyFunc func; NtQueryKeyFunc func;
HMODULE ntdll = GetModuleHandleW (L"ntdll.dll"); HMODULE ntdll = GetModuleHandleW (L"ntdll.dll");
@ -1757,7 +1757,7 @@ _g_win32_registry_key_reread (GWin32RegistryKey *key,
else else
func = NULL; func = NULL;
g_once_init_leave (&nt_query_key, func); g_once_init_leave_pointer (&nt_query_key, func);
} }
/* Assume that predefined keys never get renamed. Also, their handles probably /* Assume that predefined keys never get renamed. Also, their handles probably
@ -1875,7 +1875,7 @@ g_win32_registry_get_os_dirs_w (void)
{ {
static gunichar2 **mui_os_dirs = NULL; static gunichar2 **mui_os_dirs = NULL;
if (g_once_init_enter (&mui_os_dirs)) if (g_once_init_enter_pointer (&mui_os_dirs))
{ {
gunichar2 **new_mui_os_dirs; gunichar2 **new_mui_os_dirs;
gunichar2 *system32 = NULL; gunichar2 *system32 = NULL;
@ -1915,7 +1915,7 @@ g_win32_registry_get_os_dirs_w (void)
new_mui_os_dirs[array_index++] = NULL; new_mui_os_dirs[array_index++] = NULL;
g_once_init_leave (&mui_os_dirs, new_mui_os_dirs); g_once_init_leave_pointer (&mui_os_dirs, new_mui_os_dirs);
} }
return (const gunichar2 * const *) mui_os_dirs; return (const gunichar2 * const *) mui_os_dirs;
@ -1936,7 +1936,7 @@ g_win32_registry_get_os_dirs (void)
{ {
static gchar **mui_os_dirs = NULL; static gchar **mui_os_dirs = NULL;
if (g_once_init_enter (&mui_os_dirs)) if (g_once_init_enter_pointer (&mui_os_dirs))
{ {
gchar **new_mui_os_dirs; gchar **new_mui_os_dirs;
gsize array_index; gsize array_index;
@ -1960,7 +1960,7 @@ g_win32_registry_get_os_dirs (void)
g_critical ("Failed to convert to a system directory #%zu to UTF-8", array_index); g_critical ("Failed to convert to a system directory #%zu to UTF-8", array_index);
} }
g_once_init_leave (&mui_os_dirs, new_mui_os_dirs); g_once_init_leave_pointer (&mui_os_dirs, new_mui_os_dirs);
} }
return (const gchar * const *) mui_os_dirs; return (const gchar * const *) mui_os_dirs;
@ -2504,7 +2504,7 @@ g_win32_registry_key_watch (GWin32RegistryKey *key,
return FALSE; return FALSE;
} }
if (g_once_init_enter (&nt_notify_change_multiple_keys)) if (g_once_init_enter_pointer (&nt_notify_change_multiple_keys))
{ {
NtNotifyChangeMultipleKeysFunc func; NtNotifyChangeMultipleKeysFunc func;
HMODULE ntdll = GetModuleHandleW (L"ntdll.dll"); HMODULE ntdll = GetModuleHandleW (L"ntdll.dll");
@ -2514,7 +2514,7 @@ g_win32_registry_key_watch (GWin32RegistryKey *key,
else else
func = NULL; func = NULL;
g_once_init_leave (&nt_notify_change_multiple_keys, func); g_once_init_leave_pointer (&nt_notify_change_multiple_keys, func);
} }
if (nt_notify_change_multiple_keys== NULL) if (nt_notify_change_multiple_keys== NULL)

View File

@ -416,8 +416,8 @@ ik_source_new (gboolean (* callback) (ik_event_t *event))
gboolean gboolean
_ik_startup (gboolean (*cb)(ik_event_t *event)) _ik_startup (gboolean (*cb)(ik_event_t *event))
{ {
if (g_once_init_enter (&inotify_source)) if (g_once_init_enter_pointer (&inotify_source))
g_once_init_leave (&inotify_source, ik_source_new (cb)); g_once_init_leave_pointer (&inotify_source, ik_source_new (cb));
return inotify_source->fd >= 0; return inotify_source->fd >= 0;
} }

View File

@ -500,11 +500,11 @@ unalias_lang (char *lang)
char *p; char *p;
int i; int i;
if (g_once_init_enter (&alias_table)) if (g_once_init_enter_pointer (&alias_table))
{ {
GHashTable *table = g_hash_table_new (g_str_hash, g_str_equal); GHashTable *table = g_hash_table_new (g_str_hash, g_str_equal);
read_aliases ("/usr/share/locale/locale.alias", table); read_aliases ("/usr/share/locale/locale.alias", table);
g_once_init_leave (&alias_table, table); g_once_init_leave_pointer (&alias_table, table);
} }
i = 0; i = 0;

View File

@ -815,7 +815,7 @@ g_main_context_default (void)
{ {
static GMainContext *default_main_context = NULL; static GMainContext *default_main_context = NULL;
if (g_once_init_enter (&default_main_context)) if (g_once_init_enter_pointer (&default_main_context))
{ {
GMainContext *context; GMainContext *context;
@ -828,7 +828,7 @@ g_main_context_default (void)
g_print ("global-default main context=%p\n", context); g_print ("global-default main context=%p\n", context);
#endif #endif
g_once_init_leave (&default_main_context, context); g_once_init_leave_pointer (&default_main_context, context);
} }
return default_main_context; return default_main_context;

View File

@ -1102,10 +1102,10 @@ g_test_log (GTestLogType lbit,
unsigned subtest_level; unsigned subtest_level;
gdouble timing; gdouble timing;
if (g_once_init_enter (&g_default_print_func)) if (g_once_init_enter_pointer (&g_default_print_func))
{ {
g_once_init_leave (&g_default_print_func, g_once_init_leave_pointer (&g_default_print_func,
g_set_print_handler (g_test_print_handler)); g_set_print_handler (g_test_print_handler));
g_assert_nonnull (g_default_print_func); g_assert_nonnull (g_default_print_func);
} }

View File

@ -663,7 +663,7 @@ g_get_user_database_entry (void)
{ {
static UserDatabaseEntry *entry; static UserDatabaseEntry *entry;
if (g_once_init_enter (&entry)) if (g_once_init_enter_pointer (&entry))
{ {
static UserDatabaseEntry e; static UserDatabaseEntry e;
@ -787,7 +787,7 @@ g_get_user_database_entry (void)
if (!e.real_name) if (!e.real_name)
e.real_name = g_strdup ("Unknown"); e.real_name = g_strdup ("Unknown");
g_once_init_leave (&entry, &e); g_once_init_leave_pointer (&entry, &e);
} }
return entry; return entry;
@ -1065,7 +1065,7 @@ g_get_host_name (void)
{ {
static gchar *hostname; static gchar *hostname;
if (g_once_init_enter (&hostname)) if (g_once_init_enter_pointer (&hostname))
{ {
gboolean failed; gboolean failed;
gchar *utmp = NULL; gchar *utmp = NULL;
@ -1122,7 +1122,7 @@ g_get_host_name (void)
failed = TRUE; failed = TRUE;
#endif #endif
g_once_init_leave (&hostname, failed ? g_strdup ("localhost") : utmp); g_once_init_leave_pointer (&hostname, failed ? g_strdup ("localhost") : utmp);
} }
return hostname; return hostname;

View File

@ -199,8 +199,8 @@ test_once_init_string (void)
g_test_summary ("Test g_once_init_{enter,leave}() usage with a string"); g_test_summary ("Test g_once_init_{enter,leave}() usage with a string");
if (g_once_init_enter (&val)) if (g_once_init_enter_pointer (&val))
g_once_init_leave (&val, "foo"); g_once_init_leave_pointer (&val, "foo");
g_assert_cmpstr (val, ==, "foo"); g_assert_cmpstr (val, ==, "foo");
} }

View File

@ -71,14 +71,14 @@ initializer1 (void)
static gpointer static gpointer
initializer2 (void) initializer2 (void)
{ {
static gsize initialized = 0; static void *initialized = NULL;
if (g_once_init_enter (&initialized)) if (g_once_init_enter_pointer (&initialized))
{ {
void *pointer_value = &dummy_value; void *pointer_value = &dummy_value;
assert_singleton_execution2 (); assert_singleton_execution2 ();
g_once_init_leave (&initialized, (gsize) pointer_value); g_once_init_leave_pointer (&initialized, pointer_value);
} }
return (void*) initialized; return initialized;
} }
static void static void

View File

@ -1719,14 +1719,14 @@ maybe_issue_property_deprecation_warning (const GParamSpec *pspec)
static GMutex already_warned_lock; static GMutex already_warned_lock;
gboolean already; gboolean already;
if (g_once_init_enter (&enable_diagnostic)) if (g_once_init_enter_pointer (&enable_diagnostic))
{ {
const gchar *value = g_getenv ("G_ENABLE_DIAGNOSTIC"); const gchar *value = g_getenv ("G_ENABLE_DIAGNOSTIC");
if (!value) if (!value)
value = "0"; value = "0";
g_once_init_leave (&enable_diagnostic, value); g_once_init_leave_pointer (&enable_diagnostic, value);
} }
if (enable_diagnostic[0] == '0') if (enable_diagnostic[0] == '0')

View File

@ -1867,14 +1867,14 @@ maybe_issue_deprecation_warning (GType type)
gboolean already; gboolean already;
const char *name; const char *name;
if (g_once_init_enter (&enable_diagnostic)) if (g_once_init_enter_pointer (&enable_diagnostic))
{ {
const gchar *value = g_getenv ("G_ENABLE_DIAGNOSTIC"); const gchar *value = g_getenv ("G_ENABLE_DIAGNOSTIC");
if (!value) if (!value)
value = "0"; value = "0";
g_once_init_leave (&enable_diagnostic, value); g_once_init_leave_pointer (&enable_diagnostic, value);
} }
if (enable_diagnostic[0] == '0') if (enable_diagnostic[0] == '0')