Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 858
    • Issues 858
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 57
    • Merge requests 57
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Merge requests
  • !1949

gatomic: Make fallback g_atomic_pointer_get type-safe

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Simon McVittie requested to merge wip/smcv/armel-atomic-pointer-get into master Feb 14, 2021
  • Overview 7
  • Commits 1
  • Pipelines 1
  • Changes 1

Since !1715 (merged), g_atomic_pointer_get (&x) has usually returned the type of x, rather than a generic pointer, in C++ code (where x is any pointer, or any pointer-sized integer such as guintptr). glib/tests/cxx.cpp asserts that this is the case.

However, this was only implemented for the lock-free fast-path, not for the slow path used in platforms with an ARMv5 baseline (and therefore no atomic instructions) such as Debian armel.


This is a fix for the issue described below.

I tried uploading a snapshot of recent GLib git master to Debian experimental, and got this build failure on the armel (ARMv5, EABI, software floating point) architecture used for older ARM CPUs such as Marvell Kirkwood:

[127/1241] c++ -Iglib/tests/cxx.p -Iglib/tests -I../../../glib/tests -I. -I../../.. -Iglib -I../../../glib -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -pthread -MD -MQ glib/tests/cxx.p/cxx.cpp.o -MF glib/tests/cxx.p/cxx.cpp.o.d -o glib/tests/cxx.p/cxx.cpp.o -c ../../../glib/tests/cxx.cpp
FAILED: glib/tests/cxx.p/cxx.cpp.o 
c++ -Iglib/tests/cxx.p -Iglib/tests -I../../../glib/tests -I. -I../../.. -Iglib -I../../../glib -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -pthread -MD -MQ glib/tests/cxx.p/cxx.cpp.o -MF glib/tests/cxx.p/cxx.cpp.o.d -o glib/tests/cxx.p/cxx.cpp.o -c ../../../glib/tests/cxx.cpp
In file included from ../../../glib/gthread.h:32,
                 from ../../../glib/gasyncqueue.h:32,
                 from ../../../glib/glib.h:32,
                 from ../../../glib/tests/cxx.cpp:18:
../../../glib/tests/cxx.cpp: In function ‘void test_typeof()’:
../../../glib/gatomic.h:427:25: error: invalid conversion from ‘gpointer’ {aka ‘void*’} to ‘MyObject*’ [-fpermissive]
  427 |   (g_atomic_pointer_get (atomic))
      |   ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
      |                         |
      |                         gpointer {aka void*}
../../../glib/tests/cxx.cpp:35:20: note: in expansion of macro ‘g_atomic_pointer_get’
   35 |   MyObject *obj3 = g_atomic_pointer_get (&obj2);
      |                    ^~~~~~~~~~~~~~~~~~~~
Edited Feb 14, 2021 by Simon McVittie
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: wip/smcv/armel-atomic-pointer-get