Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1diff --git a/dbinc/atomic.h b/dbinc/atomic.h
2index 0034dcc..160c8ea 100644
3--- a/dbinc/atomic.h
4+++ b/dbinc/atomic.h
5@@ -70,7 +70,7 @@ typedef struct {
6 * These have no memory barriers; the caller must include them when necessary.
7 */
8 #define atomic_read(p) ((p)->value)
9-#define atomic_init(p, val) ((p)->value = (val))
10+#define atomic_init_db(p, val) ((p)->value = (val))
11
12 #ifdef HAVE_ATOMIC_SUPPORT
13
14@@ -144,7 +144,7 @@ typedef LONG volatile *interlocked_val;
15 #define atomic_inc(env, p) __atomic_inc(p)
16 #define atomic_dec(env, p) __atomic_dec(p)
17 #define atomic_compare_exchange(env, p, o, n) \
18- __atomic_compare_exchange((p), (o), (n))
19+ __atomic_compare_exchange_int((p), (o), (n))
20 static inline int __atomic_inc(db_atomic_t *p)
21 {
22 int temp;
23@@ -176,7 +176,7 @@ static inline int __atomic_dec(db_atomic_t *p)
24 * http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
25 * which configure could be changed to use.
26 */
27-static inline int __atomic_compare_exchange(
28+static inline int __atomic_compare_exchange_int(
29 db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval)
30 {
31 atomic_value_t was;
32@@ -206,7 +206,7 @@ static inline int __atomic_compare_exchange(
33 #define atomic_dec(env, p) (--(p)->value)
34 #define atomic_compare_exchange(env, p, oldval, newval) \
35 (DB_ASSERT(env, atomic_read(p) == (oldval)), \
36- atomic_init(p, (newval)), 1)
37+ atomic_init_db(p, (newval)), 1)
38 #else
39 #define atomic_inc(env, p) __atomic_inc(env, p)
40 #define atomic_dec(env, p) __atomic_dec(env, p)
41diff --git a/mp/mp_fget.c b/mp/mp_fget.c
42index 5fdee5a..0b75f57 100644
43--- a/mp/mp_fget.c
44+++ b/mp/mp_fget.c
45@@ -617,7 +617,7 @@ alloc: /* Allocate a new buffer header and data space. */
46
47 /* Initialize enough so we can call __memp_bhfree. */
48 alloc_bhp->flags = 0;
49- atomic_init(&alloc_bhp->ref, 1);
50+ atomic_init_db(&alloc_bhp->ref, 1);
51 #ifdef DIAGNOSTIC
52 if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) {
53 __db_errx(env,
54@@ -911,7 +911,7 @@ alloc: /* Allocate a new buffer header and data space. */
55 MVCC_MPROTECT(bhp->buf, mfp->stat.st_pagesize,
56 PROT_READ);
57
58- atomic_init(&alloc_bhp->ref, 1);
59+ atomic_init_db(&alloc_bhp->ref, 1);
60 MUTEX_LOCK(env, alloc_bhp->mtx_buf);
61 alloc_bhp->priority = bhp->priority;
62 alloc_bhp->pgno = bhp->pgno;
63diff --git a/mp/mp_mvcc.c b/mp/mp_mvcc.c
64index 34467d2..f05aa0c 100644
65--- a/mp/mp_mvcc.c
66+++ b/mp/mp_mvcc.c
67@@ -276,7 +276,7 @@ __memp_bh_freeze(dbmp, infop, hp, bhp, need_frozenp)
68 #else
69 memcpy(frozen_bhp, bhp, SSZA(BH, buf));
70 #endif
71- atomic_init(&frozen_bhp->ref, 0);
72+ atomic_init_db(&frozen_bhp->ref, 0);
73 if (mutex != MUTEX_INVALID)
74 frozen_bhp->mtx_buf = mutex;
75 else if ((ret = __mutex_alloc(env, MTX_MPOOL_BH,
76@@ -428,7 +428,7 @@ __memp_bh_thaw(dbmp, infop, hp, frozen_bhp, alloc_bhp)
77 #endif
78 alloc_bhp->mtx_buf = mutex;
79 MUTEX_LOCK(env, alloc_bhp->mtx_buf);
80- atomic_init(&alloc_bhp->ref, 1);
81+ atomic_init_db(&alloc_bhp->ref, 1);
82 F_CLR(alloc_bhp, BH_FROZEN);
83 }
84
85diff --git a/mp/mp_region.c b/mp/mp_region.c
86index e6cece9..ddbe906 100644
87--- a/mp/mp_region.c
88+++ b/mp/mp_region.c
89@@ -224,7 +224,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg)
90 MTX_MPOOL_FILE_BUCKET, 0, &htab[i].mtx_hash)) != 0)
91 return (ret);
92 SH_TAILQ_INIT(&htab[i].hash_bucket);
93- atomic_init(&htab[i].hash_page_dirty, 0);
94+ atomic_init_db(&htab[i].hash_page_dirty, 0);
95 }
96
97 /*
98@@ -269,7 +269,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg)
99 hp->mtx_hash = (mtx_base == MUTEX_INVALID) ? MUTEX_INVALID :
100 mtx_base + i;
101 SH_TAILQ_INIT(&hp->hash_bucket);
102- atomic_init(&hp->hash_page_dirty, 0);
103+ atomic_init_db(&hp->hash_page_dirty, 0);
104 #ifdef HAVE_STATISTICS
105 hp->hash_io_wait = 0;
106 hp->hash_frozen = hp->hash_thawed = hp->hash_frozen_freed = 0;
107diff --git a/mutex/mut_method.c b/mutex/mut_method.c
108index 2588763..5c6d516 100644
109--- a/mutex/mut_method.c
110+++ b/mutex/mut_method.c
111@@ -426,7 +426,7 @@ atomic_compare_exchange(env, v, oldval, newval)
112 MUTEX_LOCK(env, mtx);
113 ret = atomic_read(v) == oldval;
114 if (ret)
115- atomic_init(v, newval);
116+ atomic_init_db(v, newval);
117 MUTEX_UNLOCK(env, mtx);
118
119 return (ret);
120diff --git a/mutex/mut_tas.c b/mutex/mut_tas.c
121index f3922e0..e40fcdf 100644
122--- a/mutex/mut_tas.c
123+++ b/mutex/mut_tas.c
124@@ -46,7 +46,7 @@ __db_tas_mutex_init(env, mutex, flags)
125
126 #ifdef HAVE_SHARED_LATCHES
127 if (F_ISSET(mutexp, DB_MUTEX_SHARED))
128- atomic_init(&mutexp->sharecount, 0);
129+ atomic_init_db(&mutexp->sharecount, 0);
130 else
131 #endif
132 if (MUTEX_INIT(&mutexp->tas)) {
133@@ -486,7 +486,7 @@ __db_tas_mutex_unlock(env, mutex)
134 F_CLR(mutexp, DB_MUTEX_LOCKED);
135 /* Flush flag update before zeroing count */
136 MEMBAR_EXIT();
137- atomic_init(&mutexp->sharecount, 0);
138+ atomic_init_db(&mutexp->sharecount, 0);
139 } else {
140 DB_ASSERT(env, sharecount > 0);
141 MEMBAR_EXIT();