Cache the function pointer for g_datalist_id_update_atomic() in a static variable in "gobject.c" to avoid looking it up repeatedly. g_datalist_id_update_atomic() is anyway internal API. Like GData is not a useful data structure in general, this function is only useful for something specific inside GObject. It can be easily seen that _local_g_datalist_id_update_atomic is never read without having a GObject at hand (because we call it on `&object->qdata`). Thus initializing the pointer in g_object_do_class_init() (under lock) is sufficient to ensure thread-safe initialization. Note that we still set the pointer via g_atomic_pointer_set(). This is done in an attempt to pacify thread sanatizer. Note that also with LTO enabled, the GLIB_PRIVATE_CALL() call cannot be inlined. Previously we get: 0000000000011300 <_weak_ref_set>: ... 1131d: e8 ee 03 ff ff call 1710 <glib__private__@plt> 11322: 8b 35 0c b2 05 00 mov 0x5b20c(%rip),%esi # 6c534 <quark_weak_locations.lto_priv.0> 11328: 4c 89 e1 mov %r12,%rcx 1132b: 49 8d 7c 24 10 lea 0x10(%r12),%rdi 11330: 48 8d 15 b9 42 ff ff lea -0xbd47(%rip),%rdx # 55f0 <weak_ref_data_get_or_create_cb.lto_priv.0> 11337: ff 90 80 00 00 00 call *0x80(%rax) afterwards: 0000000000011300 <_weak_ref_set>: ... 1131d: 48 8d 7e 10 lea 0x10(%rsi),%rdi 11321: 48 89 f1 mov %rsi,%rcx 11324: 48 8d 15 c5 42 ff ff lea -0xbd3b(%rip),%rdx # 55f0 <weak_ref_data_get_or_create_cb.lto_priv.0> 1132b: 8b 35 0b b2 05 00 mov 0x5b20b(%rip),%esi # 6c53c <quark_weak_locations.lto_priv.0> 11331: ff 15 f9 b1 05 00 call *0x5b1f9(%rip) # 6c530 <_local_g_datalist_id_update_atomic.lto_priv.0> Also note, that the point here is not to optimize _weak_ref_set() (which is not a hot path). There is work in progress that will use g_datalist_id_update_atomic() for more purposes (and during more relevant code paths of GObject).
GLib
GLib is the low-level core library that forms the basis for projects such as GTK and GNOME. It provides data structure handling for C, portability wrappers, and interfaces for such runtime functionality as an event loop, threads, dynamic loading, and an object system.
The official download locations are: https://download.gnome.org/sources/glib
The official web site is: https://www.gtk.org/
Installation
See the file ‘INSTALL.md’. There is separate and more in-depth documentation for building GLib on Windows.
Supported versions
Upstream GLib only supports the most recent stable release series, the previous stable release series, and the current development release series. All older versions are not supported upstream and may contain bugs, some of which may be exploitable security vulnerabilities.
See SECURITY.md for more details.
Documentation
API documentation is available online for GLib for the:
Discussion
If you have a question about how to use GLib, seek help on GNOME’s Discourse
instance. Alternatively, ask a question
on StackOverflow and tag it glib
.
Reporting bugs
Bugs should be reported to the GNOME issue tracking system. You will need to create an account for yourself. You may also submit bugs by e-mail (without an account) by e-mailing incoming+gnome-glib-658-issue-@gitlab.gnome.org, but this will give you a degraded experience.
Bugs are for reporting problems in GLib itself, not for asking questions about how to use it. To ask questions, use one of our discussion forums.
In bug reports please include:
- Information about your system. For instance:
- What operating system and version
- For Linux, what version of the C library
- And anything else you think is relevant.
- How to reproduce the bug.
- If you can reproduce it with one of the test programs that are built
in the
tests/
subdirectory, that will be most convenient. Otherwise, please include a short test program that exhibits the behavior. As a last resort, you can also provide a pointer to a larger piece of software that can be downloaded.
- If you can reproduce it with one of the test programs that are built
in the
- If the bug was a crash, the exact text that was printed out when the crash occurred.
- Further information such as stack traces may be useful, but is not necessary.
Contributing to GLib
Please follow the contribution guide to know how to start contributing to GLib.
Patches should be submitted as merge requests to gitlab.gnome.org. Note that you will need to be logged in to the site to use this page. If the patch fixes an existing issue, please refer to the issue in your commit message with the following notation (for issue 123):
Closes: #123
Otherwise, create a new merge request that introduces the change. Filing a separate issue is not required.