0
0
mirror of https://github.com/openwrt/packages.git synced 2025-01-31 03:41:44 +00:00
packages/libs/db/patches/050-Fix-libc-compatibility-by-renaming-atomic_init-API.patch
Rosen Penev e7badaa6cb db47: replace with db
There's no need to maintain an old version.

Removed all patches as they are all upstream.

Import new ones from Arch, Debian, and OpenEmbedded.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2024-08-22 20:41:15 -07:00

133 lines
4.3 KiB
Diff

From a3569f118fd95b7ad41e1a1128e17c0b8928556d Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 20 Jan 2019 18:30:23 -0800
Subject: [PATCH] Fix libc++ compatibility by renaming atomic_init API
db5 does not build because it is redefining a C++11 standard
library identifier, atomic_init(). Therefore prefix all
its internal defines with '__db_', to avoid collisions.
Upstream-Status: Inappropriate [as far as open source community is concerned, upstream is dead]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/dbinc/atomic.h | 4 ++--
src/mp/mp_fget.c | 4 ++--
src/mp/mp_mvcc.c | 4 ++--
src/mp/mp_region.c | 4 ++--
src/mutex/mut_method.c | 2 +-
src/mutex/mut_tas.c | 4 ++--
6 files changed, 11 insertions(+), 11 deletions(-)
--- a/src/dbinc/atomic.h
+++ b/src/dbinc/atomic.h
@@ -70,7 +70,7 @@ typedef struct {
* These have no memory barriers; the caller must include them when necessary.
*/
#define atomic_read(p) ((p)->value)
-#define atomic_init(p, val) ((p)->value = (val))
+#define __db_atomic_init(p, val) ((p)->value = (val))
#ifdef HAVE_ATOMIC_SUPPORT
@@ -206,7 +206,7 @@ static inline int __db_atomic_compare_ex
#define atomic_dec(env, p) (--(p)->value)
#define atomic_compare_exchange(env, p, oldval, newval) \
(DB_ASSERT(env, atomic_read(p) == (oldval)), \
- atomic_init(p, (newval)), 1)
+ __db_atomic_init(p, (newval)), 1)
#else
#define atomic_inc(env, p) __atomic_inc(env, p)
#define atomic_dec(env, p) __atomic_dec(env, p)
--- a/src/mp/mp_fget.c
+++ b/src/mp/mp_fget.c
@@ -649,7 +649,7 @@ alloc: /* Allocate a new buffer header
/* Initialize enough so we can call __memp_bhfree. */
alloc_bhp->flags = 0;
- atomic_init(&alloc_bhp->ref, 1);
+ __db_atomic_init(&alloc_bhp->ref, 1);
#ifdef DIAGNOSTIC
if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) {
__db_errx(env, DB_STR("3025",
@@ -955,7 +955,7 @@ alloc: /* Allocate a new buffer header
MVCC_MPROTECT(bhp->buf, mfp->pagesize,
PROT_READ);
- atomic_init(&alloc_bhp->ref, 1);
+ __db_atomic_init(&alloc_bhp->ref, 1);
MUTEX_LOCK(env, alloc_bhp->mtx_buf);
alloc_bhp->priority = bhp->priority;
alloc_bhp->pgno = bhp->pgno;
--- a/src/mp/mp_mvcc.c
+++ b/src/mp/mp_mvcc.c
@@ -276,7 +276,7 @@ __memp_bh_freeze(dbmp, infop, hp, bhp, n
#else
memcpy(frozen_bhp, bhp, SSZA(BH, buf));
#endif
- atomic_init(&frozen_bhp->ref, 0);
+ __db_atomic_init(&frozen_bhp->ref, 0);
if (mutex != MUTEX_INVALID)
frozen_bhp->mtx_buf = mutex;
else if ((ret = __mutex_alloc(env, MTX_MPOOL_BH,
@@ -428,7 +428,7 @@ __memp_bh_thaw(dbmp, infop, hp, frozen_b
#endif
alloc_bhp->mtx_buf = mutex;
MUTEX_LOCK(env, alloc_bhp->mtx_buf);
- atomic_init(&alloc_bhp->ref, 1);
+ __db_atomic_init(&alloc_bhp->ref, 1);
F_CLR(alloc_bhp, BH_FROZEN);
}
--- a/src/mp/mp_region.c
+++ b/src/mp/mp_region.c
@@ -245,7 +245,7 @@ __memp_init(env, dbmp, reginfo_off, htab
MTX_MPOOL_FILE_BUCKET, 0, &htab[i].mtx_hash)) != 0)
return (ret);
SH_TAILQ_INIT(&htab[i].hash_bucket);
- atomic_init(&htab[i].hash_page_dirty, 0);
+ __db_atomic_init(&htab[i].hash_page_dirty, 0);
}
/*
@@ -302,7 +302,7 @@ no_prealloc:
} else
hp->mtx_hash = mtx_base + (i % dbenv->mp_mtxcount);
SH_TAILQ_INIT(&hp->hash_bucket);
- atomic_init(&hp->hash_page_dirty, 0);
+ __db_atomic_init(&hp->hash_page_dirty, 0);
#ifdef HAVE_STATISTICS
hp->hash_io_wait = 0;
hp->hash_frozen = hp->hash_thawed = hp->hash_frozen_freed = 0;
--- a/src/mutex/mut_method.c
+++ b/src/mutex/mut_method.c
@@ -474,7 +474,7 @@ atomic_compare_exchange(env, v, oldval,
MUTEX_LOCK(env, mtx);
ret = atomic_read(v) == oldval;
if (ret)
- atomic_init(v, newval);
+ __db_atomic_init(v, newval);
MUTEX_UNLOCK(env, mtx);
return (ret);
--- a/src/mutex/mut_tas.c
+++ b/src/mutex/mut_tas.c
@@ -47,7 +47,7 @@ __db_tas_mutex_init(env, mutex, flags)
#ifdef HAVE_SHARED_LATCHES
if (F_ISSET(mutexp, DB_MUTEX_SHARED))
- atomic_init(&mutexp->sharecount, 0);
+ __db_atomic_init(&mutexp->sharecount, 0);
else
#endif
if (MUTEX_INIT(&mutexp->tas)) {
@@ -536,7 +536,7 @@ __db_tas_mutex_unlock(env, mutex)
F_CLR(mutexp, DB_MUTEX_LOCKED);
/* Flush flag update before zeroing count */
MEMBAR_EXIT();
- atomic_init(&mutexp->sharecount, 0);
+ __db_atomic_init(&mutexp->sharecount, 0);
} else {
DB_ASSERT(env, sharecount > 0);
MEMBAR_EXIT();