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