Opened 3 years ago

Closed 3 years ago

#61954 closed defect (fixed)

umem: error: implicit declaration of function 'ec_atomic_cas' is invalid in C99

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.6.4
Keywords: arm64 Cc:
Port: umem

Description

umem fails to build on Apple Silicon:

./sol_compat.h:135:12: error: implicit declaration of function 'ec_atomic_cas' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  } while (ec_atomic_cas(mem, last+1, last) != last);
           ^

umem's source code only defines ec_atomic_cas on i386 and x86_64 systems:

# elif (defined(__i386__) || defined(__x86_64__)) && defined(__GNUC__)
static INLINE uint_t ec_atomic_cas(uint_t *mem, uint_t with, uint_t cmp)
{

This is an assembly function, so we need an ARM assembly or generic C version of this function for Apple Silicon.

Change History (3)

comment:1 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

This patch may provide a possible solution:

https://git.triangulation.nl/koenk/libumem-mvx/-/commit/da390045aa0c06d91b9b3224e831a488bcb0d274

It avoids the need to define ec_atomic_cas and ec_atomic_cas64 at all on macOS and instead defines ec_atomic_inc and ec_atomic_inc64 in terms of the built-in macOS functions OSAtomicIncrement32Barrier and OSAtomicIncrement64Barrier respectively.

The rest of the patch might not be needed since I believe it is for non-macOS systems.

OSAtomicIncrement32Barrier and OSAtomicIncrement64Barrier are deprecated according to the OS header in which they're defined, <OSAtomicDeprecated.h>. It says standard C11 functions from <stdatomic.h> or standard C++11 functions from <atomic> should be used instead.

comment:2 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to ryandesign
Status: newaccepted

I was hesitant to apply that patch because it appeared to be from a fork, however I now see that the commit also exists in what appears to be the official upstream repo:

https://github.com/omniti-labs/portableumem/commit/cbaa083431161b8f6cdac780d133f5cb6f7d4b30

I will apply that patch and I will ask upstream if they might release a new version.

comment:3 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: acceptedclosed

In addca2d1a11e7f5233ea3124a13b971987c5722b/macports-ports (master):

umem: Fix build on Apple Silicon

Closes: #61954

Note: See TracTickets for help on using tickets.