mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
Merge branch 'g-once-enter-ptr' into 'main'
gthread: introduce g_once_init_{enter,leave}_pointer See merge request GNOME/glib!3577
This commit is contained in:
commit
57b41b8fec
@ -782,6 +782,8 @@ G_ONCE_INIT
|
||||
g_once
|
||||
g_once_init_enter
|
||||
g_once_init_leave
|
||||
g_once_init_enter_pointer
|
||||
g_once_init_leave_pointer
|
||||
|
||||
<SUBSECTION>
|
||||
g_bit_lock
|
||||
|
@ -294,10 +294,9 @@ gdbus_shared_thread_func (gpointer user_data)
|
||||
static SharedThreadData *
|
||||
_g_dbus_shared_thread_ref (void)
|
||||
{
|
||||
static gsize shared_thread_data = 0;
|
||||
SharedThreadData *ret;
|
||||
static SharedThreadData *shared_thread_data = 0;
|
||||
|
||||
if (g_once_init_enter (&shared_thread_data))
|
||||
if (g_once_init_enter_pointer (&shared_thread_data))
|
||||
{
|
||||
SharedThreadData *data;
|
||||
|
||||
@ -310,12 +309,11 @@ _g_dbus_shared_thread_ref (void)
|
||||
gdbus_shared_thread_func,
|
||||
data);
|
||||
/* 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 (&ret->refcount);
|
||||
return ret;
|
||||
g_atomic_int_inc (&shared_thread_data->refcount);
|
||||
return shared_thread_data;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -365,7 +365,7 @@ get_lowercase_current_desktops (void)
|
||||
{
|
||||
static gchar **result;
|
||||
|
||||
if (g_once_init_enter (&result))
|
||||
if (g_once_init_enter_pointer (&result))
|
||||
{
|
||||
char **tmp = get_valid_current_desktops (NULL);
|
||||
gsize i, j;
|
||||
@ -377,7 +377,7 @@ get_lowercase_current_desktops (void)
|
||||
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;
|
||||
@ -388,11 +388,11 @@ get_current_desktops (const gchar *value)
|
||||
{
|
||||
static gchar **result;
|
||||
|
||||
if (g_once_init_enter (&result))
|
||||
if (g_once_init_enter_pointer (&result))
|
||||
{
|
||||
char **tmp = get_valid_current_desktops (value);
|
||||
|
||||
g_once_init_leave (&result, tmp);
|
||||
g_once_init_leave_pointer (&result, tmp);
|
||||
}
|
||||
|
||||
return (const gchar **) result;
|
||||
@ -3012,7 +3012,7 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo *info,
|
||||
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;
|
||||
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 */
|
||||
if (tmp == NULL)
|
||||
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);
|
||||
|
@ -93,12 +93,12 @@ g_dummy_tls_backend_get_default_database (GTlsBackend *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;
|
||||
|
||||
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);
|
||||
|
@ -421,13 +421,13 @@ g_inet_socket_address_new_from_string (const char *address,
|
||||
* 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_socktype = SOCK_STREAM;
|
||||
hints_struct.ai_protocol = 0;
|
||||
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);
|
||||
|
@ -38,9 +38,9 @@
|
||||
GType
|
||||
@enum_name@_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const G@Type@Value values[] = {
|
||||
/*** END value-header ***/
|
||||
@ -54,7 +54,7 @@ GType
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -105,7 +105,7 @@
|
||||
static void g_local_file_file_iface_init (GFileIface *iface);
|
||||
|
||||
static GFileAttributeInfoList *local_writable_attributes = NULL;
|
||||
static /* GFileAttributeInfoList * */ gsize local_writable_namespaces = 0;
|
||||
static GFileAttributeInfoList *local_writable_namespaces = NULL;
|
||||
|
||||
struct _GLocalFile
|
||||
{
|
||||
@ -1274,7 +1274,7 @@ g_local_file_query_writable_namespaces (GFile *file,
|
||||
GVfsClass *class;
|
||||
GVfs *vfs;
|
||||
|
||||
if (g_once_init_enter (&local_writable_namespaces))
|
||||
if (g_once_init_enter_pointer (&local_writable_namespaces))
|
||||
{
|
||||
/* Writable namespaces: */
|
||||
|
||||
@ -1297,7 +1297,7 @@ g_local_file_query_writable_namespaces (GFile *file,
|
||||
if (class->add_writable_namespaces)
|
||||
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;
|
||||
|
||||
|
@ -94,7 +94,7 @@ static GNetworkMonitor *network_monitor_default_singleton = NULL; /* (owned) (a
|
||||
GNetworkMonitor *
|
||||
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;
|
||||
|
||||
@ -102,7 +102,7 @@ g_network_monitor_get_default (void)
|
||||
"GIO_USE_NETWORK_MONITOR",
|
||||
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;
|
||||
|
@ -84,7 +84,7 @@ static GProxyResolver *proxy_resolver_default_singleton = NULL; /* (owned) (ato
|
||||
GProxyResolver *
|
||||
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;
|
||||
|
||||
@ -92,7 +92,7 @@ g_proxy_resolver_get_default (void)
|
||||
"GIO_USE_PROXY_RESOLVER",
|
||||
(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;
|
||||
|
@ -336,7 +336,7 @@ g_resource_find_overlay (const gchar *path,
|
||||
* 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) ();
|
||||
const gchar * const *result;
|
||||
@ -420,7 +420,7 @@ g_resource_find_overlay (const gchar *path,
|
||||
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++)
|
||||
|
@ -1018,7 +1018,7 @@ static GSettingsBackend *settings_backend_default_singleton = NULL; /* (owned)
|
||||
GSettingsBackend *
|
||||
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;
|
||||
|
||||
@ -1026,7 +1026,7 @@ g_settings_backend_get_default (void)
|
||||
"GSETTINGS_BACKEND",
|
||||
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);
|
||||
|
@ -580,7 +580,7 @@ normalise_whitespace (const gchar *orig)
|
||||
gchar *result;
|
||||
gint i;
|
||||
|
||||
if (g_once_init_enter (&splitter))
|
||||
if (g_once_init_enter_pointer (&splitter))
|
||||
{
|
||||
GRegex *s;
|
||||
|
||||
@ -593,7 +593,7 @@ normalise_whitespace (const gchar *orig)
|
||||
s = g_regex_new ("\\n\\s*\\n+", G_REGEX_DEFAULT,
|
||||
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);
|
||||
@ -744,7 +744,7 @@ parse_into_text_tables (const gchar *directory,
|
||||
static GHashTable **
|
||||
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;
|
||||
|
||||
@ -755,7 +755,7 @@ g_settings_schema_source_get_text_tables (GSettingsSchemaSource *source)
|
||||
if (source->directory)
|
||||
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;
|
||||
@ -1496,7 +1496,7 @@ g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key)
|
||||
if (!key->desktop_overrides)
|
||||
return NULL;
|
||||
|
||||
if (g_once_init_enter (¤t_desktops))
|
||||
if (g_once_init_enter_pointer (¤t_desktops))
|
||||
{
|
||||
const gchar *xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
|
||||
gchar **tmp;
|
||||
@ -1506,7 +1506,7 @@ g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key)
|
||||
else
|
||||
tmp = g_new0 (gchar *, 0 + 1);
|
||||
|
||||
g_once_init_leave (¤t_desktops, (const gchar **) tmp);
|
||||
g_once_init_leave_pointer (¤t_desktops, (const gchar **) tmp);
|
||||
}
|
||||
|
||||
for (i = 0; value == NULL && current_desktops[i] != NULL; i++)
|
||||
|
@ -3179,8 +3179,8 @@ g_socket_get_available_bytes (GSocket *socket)
|
||||
#else
|
||||
if (socket->priv->type == G_SOCKET_TYPE_DATAGRAM)
|
||||
{
|
||||
if (G_UNLIKELY (g_once_init_enter (&buf)))
|
||||
g_once_init_leave (&buf, g_malloc (bufsize));
|
||||
if (G_UNLIKELY (g_once_init_enter_pointer (&buf)))
|
||||
g_once_init_leave_pointer (&buf, g_malloc (bufsize));
|
||||
|
||||
/* On datagram sockets, FIONREAD ioctl is not reliable because many
|
||||
* systems add internal header size to the reported size, making it
|
||||
|
@ -121,25 +121,22 @@ _g_object_unref_and_wait_weak_notify (gpointer object)
|
||||
static void
|
||||
_g_test_watcher_add_pid (GPid pid)
|
||||
{
|
||||
static gsize started = 0;
|
||||
HANDLE job;
|
||||
HANDLE job = NULL;
|
||||
|
||||
if (g_once_init_enter (&started))
|
||||
if (g_once_init_enter (&job))
|
||||
{
|
||||
JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
|
||||
|
||||
job = CreateJobObjectW (NULL, NULL);
|
||||
HANDLE tmp = CreateJobObjectW (NULL, NULL);
|
||||
memset (&info, 0, sizeof (info));
|
||||
info.BasicLimitInformation.LimitFlags = 0x2000 /* JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE */;
|
||||
|
||||
if (!SetInformationJobObject(job, JobObjectExtendedLimitInformation, &info, sizeof (info)))
|
||||
g_warning ("Can't enable JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: %s", g_win32_error_message (GetLastError()));
|
||||
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_once_init_leave (&started,(gsize)job);
|
||||
g_once_init_leave_pointer (&job, tmp);
|
||||
}
|
||||
|
||||
job = (HANDLE)started;
|
||||
|
||||
if (!AssignProcessToJobObject(job, pid))
|
||||
g_warning ("Can't assign process to job: %s", g_win32_error_message (GetLastError()));
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ static GTlsBackend *tls_backend_default_singleton = NULL; /* (owned) (atomic) *
|
||||
GTlsBackend *
|
||||
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;
|
||||
|
||||
@ -118,7 +118,7 @@ g_tls_backend_get_default (void)
|
||||
"GIO_USE_TLS",
|
||||
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;
|
||||
|
@ -48,7 +48,7 @@ ensure_trash_portal (void)
|
||||
{
|
||||
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);
|
||||
GXdpTrash *proxy = NULL;
|
||||
@ -62,7 +62,7 @@ ensure_trash_portal (void)
|
||||
g_object_unref (connection);
|
||||
}
|
||||
|
||||
g_once_init_leave (&trash, proxy);
|
||||
g_once_init_leave_pointer (&trash, proxy);
|
||||
}
|
||||
|
||||
return trash;
|
||||
|
12
gio/gvfs.c
12
gio/gvfs.c
@ -355,7 +355,7 @@ g_vfs_get_default (void)
|
||||
if (GLIB_PRIVATE_CALL (g_check_setuid) ())
|
||||
return g_vfs_get_local ();
|
||||
|
||||
if (g_once_init_enter (&vfs_default_singleton))
|
||||
if (g_once_init_enter_pointer (&vfs_default_singleton))
|
||||
{
|
||||
GVfs *singleton;
|
||||
|
||||
@ -363,7 +363,7 @@ g_vfs_get_default (void)
|
||||
"GIO_USE_VFS",
|
||||
(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;
|
||||
@ -379,12 +379,12 @@ g_vfs_get_default (void)
|
||||
GVfs *
|
||||
g_vfs_get_local (void)
|
||||
{
|
||||
static gsize vfs = 0;
|
||||
static GVfs *vfs = 0;
|
||||
|
||||
if (g_once_init_enter (&vfs))
|
||||
g_once_init_leave (&vfs, (gsize)_g_local_vfs_new ());
|
||||
if (g_once_init_enter_pointer (&vfs))
|
||||
g_once_init_leave_pointer (&vfs, _g_local_vfs_new ());
|
||||
|
||||
return G_VFS (vfs);
|
||||
return vfs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1747,7 +1747,7 @@ static void
|
||||
_g_win32_registry_key_reread (GWin32RegistryKey *key,
|
||||
GWin32RegistryKeyPrivate *buf)
|
||||
{
|
||||
if (g_once_init_enter (&nt_query_key))
|
||||
if (g_once_init_enter_pointer (&nt_query_key))
|
||||
{
|
||||
NtQueryKeyFunc func;
|
||||
HMODULE ntdll = GetModuleHandleW (L"ntdll.dll");
|
||||
@ -1757,7 +1757,7 @@ _g_win32_registry_key_reread (GWin32RegistryKey *key,
|
||||
else
|
||||
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
|
||||
@ -1875,7 +1875,7 @@ g_win32_registry_get_os_dirs_w (void)
|
||||
{
|
||||
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 *system32 = NULL;
|
||||
@ -1915,7 +1915,7 @@ g_win32_registry_get_os_dirs_w (void)
|
||||
|
||||
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;
|
||||
@ -1936,7 +1936,7 @@ g_win32_registry_get_os_dirs (void)
|
||||
{
|
||||
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;
|
||||
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_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;
|
||||
@ -2504,7 +2504,7 @@ g_win32_registry_key_watch (GWin32RegistryKey *key,
|
||||
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;
|
||||
HMODULE ntdll = GetModuleHandleW (L"ntdll.dll");
|
||||
@ -2514,7 +2514,7 @@ g_win32_registry_key_watch (GWin32RegistryKey *key,
|
||||
else
|
||||
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)
|
||||
|
@ -416,8 +416,8 @@ ik_source_new (gboolean (* callback) (ik_event_t *event))
|
||||
gboolean
|
||||
_ik_startup (gboolean (*cb)(ik_event_t *event))
|
||||
{
|
||||
if (g_once_init_enter (&inotify_source))
|
||||
g_once_init_leave (&inotify_source, ik_source_new (cb));
|
||||
if (g_once_init_enter_pointer (&inotify_source))
|
||||
g_once_init_leave_pointer (&inotify_source, ik_source_new (cb));
|
||||
|
||||
return inotify_source->fd >= 0;
|
||||
}
|
||||
|
@ -1163,9 +1163,9 @@ test_object_set_property (GObject *object,
|
||||
static GType
|
||||
test_enum_get_type (void)
|
||||
{
|
||||
static gsize define_type_id = 0;
|
||||
static GType define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&define_type_id))
|
||||
if (g_once_init_enter_pointer (&define_type_id))
|
||||
{
|
||||
static const GEnumValue values[] = {
|
||||
{ TEST_ENUM_FOO, "TEST_ENUM_FOO", "foo" },
|
||||
@ -1176,7 +1176,7 @@ test_enum_get_type (void)
|
||||
};
|
||||
|
||||
GType type_id = g_enum_register_static ("TestEnum", values);
|
||||
g_once_init_leave (&define_type_id, type_id);
|
||||
g_once_init_leave_pointer (&define_type_id, type_id);
|
||||
}
|
||||
|
||||
return define_type_id;
|
||||
@ -1185,9 +1185,9 @@ test_enum_get_type (void)
|
||||
static GType
|
||||
test_flags_get_type (void)
|
||||
{
|
||||
static gsize define_type_id = 0;
|
||||
static GType define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&define_type_id))
|
||||
if (g_once_init_enter_pointer (&define_type_id))
|
||||
{
|
||||
static const GFlagsValue values[] = {
|
||||
{ TEST_FLAGS_NONE, "TEST_FLAGS_NONE", "none" },
|
||||
@ -1198,7 +1198,7 @@ test_flags_get_type (void)
|
||||
};
|
||||
|
||||
GType type_id = g_flags_register_static ("TestFlags", values);
|
||||
g_once_init_leave (&define_type_id, type_id);
|
||||
g_once_init_leave_pointer (&define_type_id, type_id);
|
||||
}
|
||||
|
||||
return define_type_id;
|
||||
|
@ -500,11 +500,11 @@ unalias_lang (char *lang)
|
||||
char *p;
|
||||
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);
|
||||
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;
|
||||
|
@ -815,7 +815,7 @@ g_main_context_default (void)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -828,7 +828,7 @@ g_main_context_default (void)
|
||||
g_print ("global-default main context=%p\n", context);
|
||||
#endif
|
||||
|
||||
g_once_init_leave (&default_main_context, context);
|
||||
g_once_init_leave_pointer (&default_main_context, context);
|
||||
}
|
||||
|
||||
return default_main_context;
|
||||
|
@ -1102,10 +1102,10 @@ g_test_log (GTestLogType lbit,
|
||||
unsigned subtest_level;
|
||||
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_set_print_handler (g_test_print_handler));
|
||||
g_once_init_leave_pointer (&g_default_print_func,
|
||||
g_set_print_handler (g_test_print_handler));
|
||||
g_assert_nonnull (g_default_print_func);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,8 @@
|
||||
* for condition variables to allow synchronization of threads (#GCond).
|
||||
* There are primitives for thread-private data - data that every
|
||||
* thread has a private instance of (#GPrivate). There are facilities
|
||||
* for one-time initialization (#GOnce, g_once_init_enter()). Finally,
|
||||
* for one-time initialization (#GOnce, g_once_init_enter_pointer(),
|
||||
* g_once_init_enter()). Finally,
|
||||
* there are primitives to create and manage threads (#GThread).
|
||||
*
|
||||
* The GLib threading system used to be initialized with g_thread_init().
|
||||
@ -719,6 +720,54 @@ gboolean
|
||||
return need_init;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_once_init_enter_pointer:
|
||||
* @location: (not nullable): location of a static initializable variable
|
||||
* containing `NULL`
|
||||
*
|
||||
* This functions behaves in the same way as g_once_init_enter(), but can
|
||||
* can be used to initialize pointers (or #guintptr) instead of #gsize.
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* static MyStruct *interesting_struct = NULL;
|
||||
*
|
||||
* if (g_once_init_enter_pointer (&interesting_struct))
|
||||
* {
|
||||
* MyStruct *setup_value = allocate_my_struct (); // initialization code here
|
||||
*
|
||||
* g_once_init_leave_pointer (&interesting_struct, g_steal_pointer (&setup_value));
|
||||
* }
|
||||
*
|
||||
* // use interesting_struct here
|
||||
* ]|
|
||||
*
|
||||
* Returns: %TRUE if the initialization section should be entered,
|
||||
* %FALSE and blocks otherwise
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
gboolean
|
||||
(g_once_init_enter_pointer) (gpointer location)
|
||||
{
|
||||
gpointer *value_location = (gpointer *) location;
|
||||
gboolean need_init = FALSE;
|
||||
g_mutex_lock (&g_once_mutex);
|
||||
if (g_atomic_pointer_get (value_location) == 0)
|
||||
{
|
||||
if (!g_slist_find (g_once_init_list, (void *) value_location))
|
||||
{
|
||||
need_init = TRUE;
|
||||
g_once_init_list = g_slist_prepend (g_once_init_list, (void *) value_location);
|
||||
}
|
||||
else
|
||||
do
|
||||
g_cond_wait (&g_once_cond, &g_once_mutex);
|
||||
while (g_slist_find (g_once_init_list, (void *) value_location));
|
||||
}
|
||||
g_mutex_unlock (&g_once_mutex);
|
||||
return need_init;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_once_init_leave:
|
||||
* @location: (not nullable): location of a static initializable variable
|
||||
@ -755,6 +804,42 @@ void
|
||||
g_mutex_unlock (&g_once_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_once_init_leave_pointer:
|
||||
* @location: (not nullable): location of a static initializable variable
|
||||
* containing `NULL`
|
||||
* @result: new non-`NULL` value for `*location`
|
||||
*
|
||||
* Counterpart to g_once_init_enter_pointer(). Expects a location of a static
|
||||
* `NULL`-initialized initialization variable, and an initialization value
|
||||
* other than `NULL`. Sets the variable to the initialization value, and
|
||||
* releases concurrent threads blocking in g_once_init_enter_pointer() on this
|
||||
* initialization variable.
|
||||
*
|
||||
* This functions behaves in the same way as g_once_init_leave(), but
|
||||
* can be used to initialize pointers (or #guintptr) instead of #gsize.
|
||||
*
|
||||
* Since: 2.80
|
||||
*/
|
||||
void
|
||||
(g_once_init_leave_pointer) (gpointer location,
|
||||
gpointer result)
|
||||
{
|
||||
gpointer *value_location = (gpointer *) location;
|
||||
gpointer old_value;
|
||||
|
||||
g_return_if_fail (result != 0);
|
||||
|
||||
old_value = g_atomic_pointer_exchange (value_location, result);
|
||||
g_return_if_fail (old_value == 0);
|
||||
|
||||
g_mutex_lock (&g_once_mutex);
|
||||
g_return_if_fail (g_once_init_list != NULL);
|
||||
g_once_init_list = g_slist_remove (g_once_init_list, (void *) value_location);
|
||||
g_cond_broadcast (&g_once_cond);
|
||||
g_mutex_unlock (&g_once_mutex);
|
||||
}
|
||||
|
||||
/* GThread {{{1 -------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
|
@ -236,6 +236,12 @@ GLIB_AVAILABLE_IN_ALL
|
||||
void g_once_init_leave (volatile void *location,
|
||||
gsize result);
|
||||
|
||||
GLIB_AVAILABLE_IN_2_80
|
||||
gboolean g_once_init_enter_pointer (void *location);
|
||||
GLIB_AVAILABLE_IN_2_80
|
||||
void g_once_init_leave_pointer (void *location,
|
||||
gpointer result);
|
||||
|
||||
/* Use C11-style atomic extensions to check the fast path for status=ready. If
|
||||
* they are not available, fall back to using a mutex and condition variable in
|
||||
* g_once_impl().
|
||||
@ -268,11 +274,30 @@ void g_once_init_leave (volatile void *location,
|
||||
0 ? (void) (*(location) = (result)) : (void) 0; \
|
||||
g_once_init_leave ((location), (gsize) (result)); \
|
||||
}))
|
||||
# define g_once_init_enter_pointer(location) \
|
||||
(G_GNUC_EXTENSION ({ \
|
||||
G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \
|
||||
(void) (0 ? (gpointer) * (location) : NULL); \
|
||||
(!g_atomic_pointer_get (location) && \
|
||||
g_once_init_enter_pointer (location)); \
|
||||
})) GLIB_AVAILABLE_MACRO_IN_2_80
|
||||
# define g_once_init_leave_pointer(location, result) \
|
||||
(G_GNUC_EXTENSION ({ \
|
||||
G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \
|
||||
0 ? (void) (*(location) = (result)) : (void) 0; \
|
||||
g_once_init_leave_pointer ((location), (gpointer) (guintptr) (result)); \
|
||||
})) GLIB_AVAILABLE_MACRO_IN_2_80
|
||||
#else
|
||||
# define g_once_init_enter(location) \
|
||||
(g_once_init_enter((location)))
|
||||
# define g_once_init_leave(location, result) \
|
||||
(g_once_init_leave((location), (gsize) (result)))
|
||||
# define g_once_init_enter_pointer(location) \
|
||||
(g_once_init_enter_pointer((location))) \
|
||||
GLIB_AVAILABLE_MACRO_IN_2_80
|
||||
# define g_once_init_leave_pointer(location, result) \
|
||||
(g_once_init_leave_pointer((location), (gpointer) (guintptr) (result))) \
|
||||
GLIB_AVAILABLE_MACRO_IN_2_80
|
||||
#endif
|
||||
|
||||
GLIB_AVAILABLE_IN_2_36
|
||||
|
@ -663,7 +663,7 @@ g_get_user_database_entry (void)
|
||||
{
|
||||
static UserDatabaseEntry *entry;
|
||||
|
||||
if (g_once_init_enter (&entry))
|
||||
if (g_once_init_enter_pointer (&entry))
|
||||
{
|
||||
static UserDatabaseEntry e;
|
||||
|
||||
@ -787,7 +787,7 @@ g_get_user_database_entry (void)
|
||||
if (!e.real_name)
|
||||
e.real_name = g_strdup ("Unknown");
|
||||
|
||||
g_once_init_leave (&entry, &e);
|
||||
g_once_init_leave_pointer (&entry, &e);
|
||||
}
|
||||
|
||||
return entry;
|
||||
@ -1065,7 +1065,7 @@ g_get_host_name (void)
|
||||
{
|
||||
static gchar *hostname;
|
||||
|
||||
if (g_once_init_enter (&hostname))
|
||||
if (g_once_init_enter_pointer (&hostname))
|
||||
{
|
||||
gboolean failed;
|
||||
gchar *utmp = NULL;
|
||||
@ -1122,7 +1122,7 @@ g_get_host_name (void)
|
||||
failed = TRUE;
|
||||
#endif
|
||||
|
||||
g_once_init_leave (&hostname, failed ? g_strdup ("localhost") : utmp);
|
||||
g_once_init_leave_pointer (&hostname, failed ? g_strdup ("localhost") : utmp);
|
||||
}
|
||||
|
||||
return hostname;
|
||||
|
@ -199,8 +199,8 @@ test_once_init_string (void)
|
||||
|
||||
g_test_summary ("Test g_once_init_{enter,leave}() usage with a string");
|
||||
|
||||
if (g_once_init_enter (&val))
|
||||
g_once_init_leave (&val, "foo");
|
||||
if (g_once_init_enter_pointer (&val))
|
||||
g_once_init_leave_pointer (&val, "foo");
|
||||
|
||||
g_assert_cmpstr (val, ==, "foo");
|
||||
}
|
||||
|
@ -71,14 +71,14 @@ initializer1 (void)
|
||||
static gpointer
|
||||
initializer2 (void)
|
||||
{
|
||||
static gsize initialized = 0;
|
||||
if (g_once_init_enter (&initialized))
|
||||
static void *initialized = NULL;
|
||||
if (g_once_init_enter_pointer (&initialized))
|
||||
{
|
||||
void *pointer_value = &dummy_value;
|
||||
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
|
||||
|
@ -123,9 +123,9 @@
|
||||
GType
|
||||
g_binding_flags_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const GFlagsValue values[] = {
|
||||
{ G_BINDING_DEFAULT, "G_BINDING_DEFAULT", "default" },
|
||||
@ -136,7 +136,7 @@ g_binding_flags_get_type (void)
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_flags_register_static (g_intern_static_string ("GBindingFlags"), values);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -185,16 +185,16 @@ G_DEFINE_BOXED_TYPE (GPatternSpec, g_pattern_spec, g_pattern_spec_copy, g_patter
|
||||
GType
|
||||
g_strv_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
GType g_define_type_id =
|
||||
g_boxed_type_register_static (g_intern_static_string ("GStrv"),
|
||||
(GBoxedCopyFunc) g_strdupv,
|
||||
(GBoxedFreeFunc) g_strfreev);
|
||||
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -22,9 +22,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
GType
|
||||
@enum_name@_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const G@Type@Value values[] = {
|
||||
/*** END value-header ***/
|
||||
@ -38,7 +38,7 @@ GType
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -1719,14 +1719,14 @@ maybe_issue_property_deprecation_warning (const GParamSpec *pspec)
|
||||
static GMutex already_warned_lock;
|
||||
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");
|
||||
|
||||
if (!value)
|
||||
value = "0";
|
||||
|
||||
g_once_init_leave (&enable_diagnostic, value);
|
||||
g_once_init_leave_pointer (&enable_diagnostic, value);
|
||||
}
|
||||
|
||||
if (enable_diagnostic[0] == '0')
|
||||
|
@ -1631,7 +1631,7 @@ g_param_spec_get_default_value (GParamSpec *pspec)
|
||||
* done before a g_once_init_enter() could take the fast path in
|
||||
* another thread.
|
||||
*/
|
||||
if (g_once_init_enter (&priv->default_value.g_type))
|
||||
if (g_once_init_enter_pointer (&priv->default_value.g_type))
|
||||
{
|
||||
GValue default_value = G_VALUE_INIT;
|
||||
|
||||
@ -1641,7 +1641,7 @@ g_param_spec_get_default_value (GParamSpec *pspec)
|
||||
/* store all but the type */
|
||||
memcpy (priv->default_value.data, default_value.data, sizeof (default_value.data));
|
||||
|
||||
g_once_init_leave (&priv->default_value.g_type, pspec->value_type);
|
||||
g_once_init_leave_pointer (&priv->default_value.g_type, pspec->value_type);
|
||||
}
|
||||
|
||||
return &priv->default_value;
|
||||
|
@ -36,7 +36,7 @@ g_io_condition_get_type (void)
|
||||
{
|
||||
static GType etype = 0;
|
||||
|
||||
if (g_once_init_enter (&etype))
|
||||
if (g_once_init_enter_pointer (&etype))
|
||||
{
|
||||
static const GFlagsValue values[] = {
|
||||
{ G_IO_IN, "G_IO_IN", "in" },
|
||||
@ -48,7 +48,7 @@ g_io_condition_get_type (void)
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
GType type_id = g_flags_register_static ("GIOCondition", values);
|
||||
g_once_init_leave (&etype, type_id);
|
||||
g_once_init_leave_pointer (&etype, type_id);
|
||||
}
|
||||
return etype;
|
||||
}
|
||||
|
@ -1867,14 +1867,14 @@ maybe_issue_deprecation_warning (GType type)
|
||||
gboolean already;
|
||||
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");
|
||||
|
||||
if (!value)
|
||||
value = "0";
|
||||
|
||||
g_once_init_leave (&enable_diagnostic, value);
|
||||
g_once_init_leave_pointer (&enable_diagnostic, value);
|
||||
}
|
||||
|
||||
if (enable_diagnostic[0] == '0')
|
||||
|
@ -2009,8 +2009,8 @@ guint g_type_get_type_registration_serial (void);
|
||||
* GType
|
||||
* gtk_gadget_get_type (void)
|
||||
* {
|
||||
* static gsize static_g_define_type_id = 0;
|
||||
* if (g_once_init_enter (&static_g_define_type_id))
|
||||
* static GType static_g_define_type_id = 0;
|
||||
* if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
* {
|
||||
* GType g_define_type_id =
|
||||
* g_type_register_static_simple (GTK_TYPE_WIDGET,
|
||||
@ -2030,7 +2030,7 @@ guint g_type_get_type_registration_serial (void);
|
||||
* };
|
||||
* g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info);
|
||||
* }
|
||||
* g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
* g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
* }
|
||||
* return static_g_define_type_id;
|
||||
* }
|
||||
@ -2265,6 +2265,16 @@ static void type_name##_class_intern_init (gpointer klass) \
|
||||
}
|
||||
#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 */
|
||||
|
||||
#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_80
|
||||
#define _g_type_once_init_type GType
|
||||
#define _g_type_once_init_enter g_once_init_enter_pointer
|
||||
#define _g_type_once_init_leave g_once_init_leave_pointer
|
||||
#else /* if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_80 */
|
||||
#define _g_type_once_init_type gsize
|
||||
#define _g_type_once_init_enter g_once_init_enter
|
||||
#define _g_type_once_init_leave g_once_init_leave
|
||||
#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_80 */
|
||||
|
||||
/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */
|
||||
#define _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \
|
||||
\
|
||||
@ -2286,15 +2296,15 @@ type_name##_get_instance_private (TypeName *self) \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static _g_type_once_init_type static_g_define_type_id = 0;
|
||||
/* Prelude goes here */
|
||||
|
||||
/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */
|
||||
#define _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} /* closes type_name##_get_type() */ \
|
||||
@ -2334,8 +2344,8 @@ static void type_name##_default_init (TypeName##Interface *klass); \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
static _g_type_once_init_type static_g_define_type_id = 0; \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = \
|
||||
g_type_register_static_simple (G_TYPE_INTERFACE, \
|
||||
@ -2351,7 +2361,7 @@ type_name##_get_type (void) \
|
||||
#define _G_DEFINE_INTERFACE_EXTENDED_END() \
|
||||
/* following custom code */ \
|
||||
} \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} /* closes type_name##_get_type() */
|
||||
@ -2460,11 +2470,11 @@ static GType type_name##_get_type_once (void); \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
static _g_type_once_init_type static_g_define_type_id = 0; \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} \
|
||||
@ -2497,11 +2507,11 @@ static GType type_name##_get_type_once (void); \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
static _g_type_once_init_type static_g_define_type_id = 0; \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} \
|
||||
@ -2550,11 +2560,11 @@ static GType type_name##_get_type_once (void); \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
static _g_type_once_init_type static_g_define_type_id = 0; \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} \
|
||||
|
@ -66,9 +66,9 @@ custom_marshal_VOID__INVOCATIONHINT (GClosure *closure,
|
||||
static GType
|
||||
test_enum_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const GEnumValue values[] = {
|
||||
{ TEST_ENUM_NEGATIVE, "TEST_ENUM_NEGATIVE", "negative" },
|
||||
@ -79,7 +79,7 @@ test_enum_get_type (void)
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_enum_register_static (g_intern_static_string ("TestEnum"), values);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
@ -88,9 +88,9 @@ test_enum_get_type (void)
|
||||
static GType
|
||||
test_unsigned_enum_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const GEnumValue values[] = {
|
||||
{ TEST_UNSIGNED_ENUM_FOO, "TEST_UNSIGNED_ENUM_FOO", "foo" },
|
||||
@ -99,7 +99,7 @@ test_unsigned_enum_get_type (void)
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_enum_register_static (g_intern_static_string ("TestUnsignedEnum"), values);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -121,7 +121,7 @@ test_type_flags_final (void)
|
||||
* block within the test_final2_get_type() function
|
||||
*/
|
||||
g_test_expect_message ("GLib", G_LOG_LEVEL_CRITICAL,
|
||||
"*g_once_init_leave: assertion*");
|
||||
"*g_once_init_leave_pointer: assertion*");
|
||||
|
||||
final2_type = TEST_TYPE_FINAL2;
|
||||
g_assert_true (final2_type == G_TYPE_INVALID);
|
||||
|
Loading…
Reference in New Issue
Block a user