File: mips-atomic.diff

package info (click to toggle)
erlang-p1-cache-tab 1.0.31-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 376 kB
  • sloc: erlang: 1,365; ansic: 123; makefile: 32
file content (33 lines) | stat: -rw-r--r-- 1,462 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Description: fix FTBFS on mips, mipsel and powerpc
 mips, mipsel and powerpc do not implement 64-bit atomics
 natively. The fix is to use libatomic (part of GCC) which provides
 helper routines for these missing atomics, implemented using locks.
Author: James Cowgill <jcowgill@debian.org>

Index: erlang-p1-cache-tab/c_src/ets_cache.c
===================================================================
--- erlang-p1-cache-tab.orig/c_src/ets_cache.c
+++ erlang-p1-cache-tab/c_src/ets_cache.c
@@ -137,7 +137,7 @@ static ERL_NIF_TERM incr_counter(ErlNifE
   if (enif_get_uint(env, argv[0], &counter))
     if (counter < state->max_counters) {
       if (state->counters[counter] != MAX_UINT64)
-        return enif_make_uint64(env, __sync_add_and_fetch(state->counters + counter, 1));
+        return enif_make_uint64(env, __atomic_add_fetch(state->counters + counter, 1, __ATOMIC_SEQ_CST));
     }
 
   return enif_make_badarg(env);
Index: erlang-p1-cache-tab/rebar.config
===================================================================
--- erlang-p1-cache-tab.orig/rebar.config
+++ erlang-p1-cache-tab/rebar.config
@@ -27,7 +27,8 @@
 
 {port_specs, [{"priv/lib/ets_cache.so", ["c_src/ets_cache.c"]}]}.
 {port_env, [{"ERL_LDFLAGS", " -L$ERL_EI_LIBDIR -lei"},
-            {"CFLAGS", "$CFLAGS -g -O2 -Wall"}]}.
+            {"CFLAGS", "$CFLAGS -g -O2 -Wall"},
+	    {"LDFLAGS", "$LDFLAGS -latomic"}]}.
 
 {cover_enabled, true}.
 {cover_export_enabled, true}.