Opened 4 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 4 years ago by ryandesign (Ryan Carsten Schmidt)
comment:2 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)
Owner: | set to ryandesign |
---|---|
Status: | new → accepted |
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: | accepted → closed |
Note: See
TracTickets for help on using
tickets.
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
andec_atomic_cas64
at all on macOS and instead definesec_atomic_inc
andec_atomic_inc64
in terms of the built-in macOS functionsOSAtomicIncrement32Barrier
andOSAtomicIncrement64Barrier
respectively.The rest of the patch might not be needed since I believe it is for non-macOS systems.
OSAtomicIncrement32Barrier
andOSAtomicIncrement64Barrier
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.