Skip to content

MSGPACK_ENABLE_GCC_CXX_ATOMIC - Failed #905

@wfjm

Description

@wfjm

When running cmake on the cpp_master branch on Ubuntu 18.04 I get a

    -- Performing Test MSGPACK_ENABLE_GCC_CXX_ATOMIC
    -- Performing Test MSGPACK_ENABLE_GCC_CXX_ATOMIC - Failed

The test code in CMakeLists.txt reads

#include <bits/atomicity.h>
int atomic_sub(int i) { return __gnu_cxx::__exchange_and_add(&i, -1) - 1; }
int atomic_add(int i) { return __gnu_cxx::__exchange_and_add(&i, 1) + 1; }
int main(int argc, char * argv[])
{
    atomic_sub(1);
    atomic_add(1);
}

The culprit is that since quite some time the header is under

#include <ext/atomicity.h>

Looking through some old systems is see that

  • up to gcc 4.1.1 I find bits/atomicity.h
  • after gcc 4.6.3 I find ext/atomicity.h

so the transition was somewhere between gcc 4.1.1 and 4.6.3. Ubuntu 18.04 has gcc version 7.5.0

The code compiles and tests without atomicity.h, hard to judge whether there are performance impacts.
In case atomic actions are important, it seems to me that std::atomic is the natural choice these days.

In closing the steps to reproduce (on an Ubuntu 18.04 system, likely on all current Ubuntu/Debian systems):

  git clone https://github.com/msgpack/msgpack-c.git
  cd msgpack-c
  git checkout cpp_master 
  git checkout 70912ff

  mkdir build
  cd build
  cmake -DMSGPACK_CXX17=ON ..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions