Skip to content

Commit dd545c5

Browse files
committed
Merge #20906: contrib: embed C++11 patch in install_db4.sh
9237003 contrib: embed C++11 patch in install_db4.sh (jackielove4u) Pull request description: This is a continuation of bitcoin/bitcoin#20665. Closes #20722. ACKs for top commit: laanwj: ACK 9237003 fanquake: ACK 9237003. Tree-SHA512: ebfd16f5301158de1acc1b8eeca43b3d94f0a6d438832133a30648e5e8a88268b4af983be0bb57f3018e3af8459f32f0de676c1b4e8942e199a4497c776631c5
2 parents 43f3ada + 9237003 commit dd545c5

File tree

1 file changed

+149
-4
lines changed

1 file changed

+149
-4
lines changed

contrib/install_db4.sh

Lines changed: 149 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,155 @@ tar -xzvf ${BDB_VERSION}.tar.gz -C "$BDB_PREFIX"
6868
cd "${BDB_PREFIX}/${BDB_VERSION}/"
6969

7070
# Apply a patch necessary when building with clang and c++11 (see https://community.oracle.com/thread/3952592)
71-
CLANG_CXX11_PATCH_URL='https://gist.githubusercontent.com/LnL7/5153b251fd525fe15de69b67e63a6075/raw/7778e9364679093a32dec2908656738e16b6bdcb/clang.patch'
72-
CLANG_CXX11_PATCH_HASH='7a9a47b03fd5fb93a16ef42235fa9512db9b0829cfc3bdf90edd3ec1f44d637c'
73-
http_get "${CLANG_CXX11_PATCH_URL}" clang.patch "${CLANG_CXX11_PATCH_HASH}"
74-
patch -p2 < clang.patch
71+
patch --ignore-whitespace -p1 << 'EOF'
72+
commit 3311d68f11d1697565401eee6efc85c34f022ea7
73+
Author: fanquake <[email protected]>
74+
Date: Mon Aug 17 20:03:56 2020 +0800
75+
76+
Fix C++11 compatibility
77+
78+
diff --git a/dbinc/atomic.h b/dbinc/atomic.h
79+
index 0034dcc..7c11d4a 100644
80+
--- a/dbinc/atomic.h
81+
+++ b/dbinc/atomic.h
82+
@@ -70,7 +70,7 @@ typedef struct {
83+
* These have no memory barriers; the caller must include them when necessary.
84+
*/
85+
#define atomic_read(p) ((p)->value)
86+
-#define atomic_init(p, val) ((p)->value = (val))
87+
+#define atomic_init_db(p, val) ((p)->value = (val))
88+
89+
#ifdef HAVE_ATOMIC_SUPPORT
90+
91+
@@ -144,7 +144,7 @@ typedef LONG volatile *interlocked_val;
92+
#define atomic_inc(env, p) __atomic_inc(p)
93+
#define atomic_dec(env, p) __atomic_dec(p)
94+
#define atomic_compare_exchange(env, p, o, n) \
95+
- __atomic_compare_exchange((p), (o), (n))
96+
+ __atomic_compare_exchange_db((p), (o), (n))
97+
static inline int __atomic_inc(db_atomic_t *p)
98+
{
99+
int temp;
100+
@@ -176,7 +176,7 @@ static inline int __atomic_dec(db_atomic_t *p)
101+
* http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
102+
* which configure could be changed to use.
103+
*/
104+
-static inline int __atomic_compare_exchange(
105+
+static inline int __atomic_compare_exchange_db(
106+
db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval)
107+
{
108+
atomic_value_t was;
109+
@@ -206,7 +206,7 @@ static inline int __atomic_compare_exchange(
110+
#define atomic_dec(env, p) (--(p)->value)
111+
#define atomic_compare_exchange(env, p, oldval, newval) \
112+
(DB_ASSERT(env, atomic_read(p) == (oldval)), \
113+
- atomic_init(p, (newval)), 1)
114+
+ atomic_init_db(p, (newval)), 1)
115+
#else
116+
#define atomic_inc(env, p) __atomic_inc(env, p)
117+
#define atomic_dec(env, p) __atomic_dec(env, p)
118+
diff --git a/mp/mp_fget.c b/mp/mp_fget.c
119+
index 5fdee5a..0b75f57 100644
120+
--- a/mp/mp_fget.c
121+
+++ b/mp/mp_fget.c
122+
@@ -617,7 +617,7 @@ alloc: /* Allocate a new buffer header and data space. */
123+
124+
/* Initialize enough so we can call __memp_bhfree. */
125+
alloc_bhp->flags = 0;
126+
- atomic_init(&alloc_bhp->ref, 1);
127+
+ atomic_init_db(&alloc_bhp->ref, 1);
128+
#ifdef DIAGNOSTIC
129+
if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) {
130+
__db_errx(env,
131+
@@ -911,7 +911,7 @@ alloc: /* Allocate a new buffer header and data space. */
132+
MVCC_MPROTECT(bhp->buf, mfp->stat.st_pagesize,
133+
PROT_READ);
134+
135+
- atomic_init(&alloc_bhp->ref, 1);
136+
+ atomic_init_db(&alloc_bhp->ref, 1);
137+
MUTEX_LOCK(env, alloc_bhp->mtx_buf);
138+
alloc_bhp->priority = bhp->priority;
139+
alloc_bhp->pgno = bhp->pgno;
140+
diff --git a/mp/mp_mvcc.c b/mp/mp_mvcc.c
141+
index 34467d2..f05aa0c 100644
142+
--- a/mp/mp_mvcc.c
143+
+++ b/mp/mp_mvcc.c
144+
@@ -276,7 +276,7 @@ __memp_bh_freeze(dbmp, infop, hp, bhp, need_frozenp)
145+
#else
146+
memcpy(frozen_bhp, bhp, SSZA(BH, buf));
147+
#endif
148+
- atomic_init(&frozen_bhp->ref, 0);
149+
+ atomic_init_db(&frozen_bhp->ref, 0);
150+
if (mutex != MUTEX_INVALID)
151+
frozen_bhp->mtx_buf = mutex;
152+
else if ((ret = __mutex_alloc(env, MTX_MPOOL_BH,
153+
@@ -428,7 +428,7 @@ __memp_bh_thaw(dbmp, infop, hp, frozen_bhp, alloc_bhp)
154+
#endif
155+
alloc_bhp->mtx_buf = mutex;
156+
MUTEX_LOCK(env, alloc_bhp->mtx_buf);
157+
- atomic_init(&alloc_bhp->ref, 1);
158+
+ atomic_init_db(&alloc_bhp->ref, 1);
159+
F_CLR(alloc_bhp, BH_FROZEN);
160+
}
161+
162+
diff --git a/mp/mp_region.c b/mp/mp_region.c
163+
index e6cece9..ddbe906 100644
164+
--- a/mp/mp_region.c
165+
+++ b/mp/mp_region.c
166+
@@ -224,7 +224,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg)
167+
MTX_MPOOL_FILE_BUCKET, 0, &htab[i].mtx_hash)) != 0)
168+
return (ret);
169+
SH_TAILQ_INIT(&htab[i].hash_bucket);
170+
- atomic_init(&htab[i].hash_page_dirty, 0);
171+
+ atomic_init_db(&htab[i].hash_page_dirty, 0);
172+
}
173+
174+
/*
175+
@@ -269,7 +269,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg)
176+
hp->mtx_hash = (mtx_base == MUTEX_INVALID) ? MUTEX_INVALID :
177+
mtx_base + i;
178+
SH_TAILQ_INIT(&hp->hash_bucket);
179+
- atomic_init(&hp->hash_page_dirty, 0);
180+
+ atomic_init_db(&hp->hash_page_dirty, 0);
181+
#ifdef HAVE_STATISTICS
182+
hp->hash_io_wait = 0;
183+
hp->hash_frozen = hp->hash_thawed = hp->hash_frozen_freed = 0;
184+
diff --git a/mutex/mut_method.c b/mutex/mut_method.c
185+
index 2588763..5c6d516 100644
186+
--- a/mutex/mut_method.c
187+
+++ b/mutex/mut_method.c
188+
@@ -426,7 +426,7 @@ atomic_compare_exchange(env, v, oldval, newval)
189+
MUTEX_LOCK(env, mtx);
190+
ret = atomic_read(v) == oldval;
191+
if (ret)
192+
- atomic_init(v, newval);
193+
+ atomic_init_db(v, newval);
194+
MUTEX_UNLOCK(env, mtx);
195+
196+
return (ret);
197+
diff --git a/mutex/mut_tas.c b/mutex/mut_tas.c
198+
index f3922e0..e40fcdf 100644
199+
--- a/mutex/mut_tas.c
200+
+++ b/mutex/mut_tas.c
201+
@@ -46,7 +46,7 @@ __db_tas_mutex_init(env, mutex, flags)
202+
203+
#ifdef HAVE_SHARED_LATCHES
204+
if (F_ISSET(mutexp, DB_MUTEX_SHARED))
205+
- atomic_init(&mutexp->sharecount, 0);
206+
+ atomic_init_db(&mutexp->sharecount, 0);
207+
else
208+
#endif
209+
if (MUTEX_INIT(&mutexp->tas)) {
210+
@@ -486,7 +486,7 @@ __db_tas_mutex_unlock(env, mutex)
211+
F_CLR(mutexp, DB_MUTEX_LOCKED);
212+
/* Flush flag update before zeroing count */
213+
MEMBAR_EXIT();
214+
- atomic_init(&mutexp->sharecount, 0);
215+
+ atomic_init_db(&mutexp->sharecount, 0);
216+
} else {
217+
DB_ASSERT(env, sharecount > 0);
218+
MEMBAR_EXIT();
219+
EOF
75220

76221
# The packaged config.guess and config.sub are ancient (2009) and can cause build issues.
77222
# Replace them with modern versions.

0 commit comments

Comments
 (0)