ceph/cmake
Kefu Chai 4c726846e4 cmake: do not use GCC extension when detecting 16-bit atomic op
we have following error when trying to compile the C++ source
file on mipsel:

/usr/bin/c++ -DHAVE_CXX11_ATOMIC  -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -g1 -Wdate-time -D_FORTIFY_SOURCE=2  -std=c++11 -fPIE -o CMakeFiles/cmTC_9f34f.dir/src.cxx.o -c /<<PKGBUILDDIR>>/obj-mipsel-linux-gnu/CMakeFiles/CMakeTmp/src.cxx
/<<PKGBUILDDIR>>/obj-mipsel-linux-gnu/CMakeFiles/CMakeTmp/src.cxx:15:44: error: template argument 1 is invalid
   15 | bool atomic16(std::atomic<unsigned __int128> *ptr)
      |                                            ^
/<<PKGBUILDDIR>>/obj-mipsel-linux-gnu/CMakeFiles/CMakeTmp/src.cxx:15:44: error: template argument 1 is invalid
/<<PKGBUILDDIR>>/obj-mipsel-linux-gnu/CMakeFiles/CMakeTmp/src.cxx:15:44: error: template argument 1 is invalid
/<<PKGBUILDDIR>>/obj-mipsel-linux-gnu/CMakeFiles/CMakeTmp/src.cxx:15:44: error: template argument 1 is invalid
/<<PKGBUILDDIR>>/obj-mipsel-linux-gnu/CMakeFiles/CMakeTmp/src.cxx:15:47: error: ‘ptr’ was not declared in this scope
   15 | bool atomic16(std::atomic<unsigned __int128> *ptr)
      |                                               ^~~

the compiler was GCC 11.2.0.

in this change, instead of detecting the architecture, check for
the macro of `__SIZEOF_INT128__`, which is respected by GCC and Clang.
so it's more readable. also, instead of using the `unsigned __int128`
type provided as a GCC extension, use a struct to mimic the use case
of boost::lockfree library.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2022-03-10 22:54:51 +08:00
..
modules cmake: do not use GCC extension when detecting 16-bit atomic op 2022-03-10 22:54:51 +08:00