• Philip Withnall's avatar
    gatomic: Tweak __atomic_load*() calls to work with -Wbad-function-cast · 194df27f
    Philip Withnall authored
    When compiling third-party projects with -Wbad-function-cast, the inline
    g_atomic_pointer_get() implementation which uses C11 __atomic_load*()
    calls on GCC was causing compilation errors like:
    
       error: cast from function call of type ‘long unsigned int’ to non-matching type ‘void *’
    
    While we don’t want to compile all of GLib with -Wbad-function-cast, we
    should support its headers being included in projects which do enable
    that warning.
    
    It doesn’t seem to be possible to cast away the warning (e.g. by casting
    the function’s result through (void)), so we have to assign to an
    intermediate integer of the right size first.
    
    The same has to be done for the bool return value from
    __sync_bool_compare_and_swap(). In that case, casting from bool to
    gboolean raises a -Wbad-function-cast warning, since gboolean is
    secretly int.
    
    The atomic tests have been modified to enable -Wbad-function-cast to
    catch regressions of this in future. The GLib build has conversely been
    modified to set -Wno-bad-function-cast, just in case people have it set
    in their environment CFLAGS.
    Signed-off-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>
    
    GNOME/glib#1041
    194df27f
Name
Last commit
Last update
.gitlab-ci Loading commit data...
build Loading commit data...
docs Loading commit data...
gio Loading commit data...
glib Loading commit data...
gmodule Loading commit data...
gobject Loading commit data...
gthread Loading commit data...
m4macros Loading commit data...
po Loading commit data...
subprojects Loading commit data...
tests Loading commit data...
.dir-locals.el Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gitlab-ci.yml Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
COPYING Loading commit data...
ChangeLog.pre-1-2 Loading commit data...
ChangeLog.pre-2-0 Loading commit data...
ChangeLog.pre-2-10 Loading commit data...
ChangeLog.pre-2-12 Loading commit data...
ChangeLog.pre-2-14 Loading commit data...
ChangeLog.pre-2-16 Loading commit data...
ChangeLog.pre-2-18 Loading commit data...
ChangeLog.pre-2-2 Loading commit data...
ChangeLog.pre-2-20 Loading commit data...
ChangeLog.pre-2-4 Loading commit data...
ChangeLog.pre-2-6 Loading commit data...
ChangeLog.pre-2-8 Loading commit data...
HACKING Loading commit data...
INSTALL.in Loading commit data...
Makefile.am Loading commit data...
NEWS Loading commit data...
NEWS.pre-1-3 Loading commit data...
README Loading commit data...
README.md Loading commit data...
README.rationale Loading commit data...
README.win32 Loading commit data...
acglib.m4 Loading commit data...
acinclude.m4 Loading commit data...
autogen.sh Loading commit data...
check-abis.sh Loading commit data...
configure.ac Loading commit data...
gio-2.0.pc.in Loading commit data...
gio-unix-2.0.pc.in Loading commit data...
gio-windows-2.0.pc.in Loading commit data...
glib-2.0.pc.in Loading commit data...
glib-gettextize.in Loading commit data...
glib-tap.mk Loading commit data...
glib.doap Loading commit data...
glib.mk Loading commit data...
glib.supp Loading commit data...
gmodule-2.0.pc.in Loading commit data...
gmodule-export-2.0.pc.in Loading commit data...
gmodule-no-export-2.0.pc.in Loading commit data...
gobject-2.0.pc.in Loading commit data...
gthread-2.0.pc.in Loading commit data...
meson.build Loading commit data...
meson_options.txt Loading commit data...
msvc_recommended_pragmas.h Loading commit data...
sanity_check Loading commit data...
tap-driver.sh Loading commit data...
tap-test Loading commit data...