Skip to content

Instantly share code, notes, and snippets.

@danieldk
Created June 3, 2013 19:12
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save danieldk/5700533 to your computer and use it in GitHub Desktop.
Save danieldk/5700533 to your computer and use it in GitHub Desktop.
Berkeley DB 4.8 patch for compilers that have __atomic_compare_exchange.
Binary files dbxml-2.5.16.orig/db-4.8.26/dbinc/.atomic.h.un~ and dbxml-2.5.16/db-4.8.26/dbinc/.atomic.h.un~ differ
diff -ruN dbxml-2.5.16.orig/db-4.8.26/dbinc/atomic.h dbxml-2.5.16/db-4.8.26/dbinc/atomic.h
--- dbxml-2.5.16.orig/db-4.8.26/dbinc/atomic.h 2013-06-03 21:04:07.000000000 +0200
+++ dbxml-2.5.16/db-4.8.26/dbinc/atomic.h 2013-06-03 21:10:53.000000000 +0200
@@ -144,7 +144,7 @@
#define atomic_inc(env, p) __atomic_inc(p)
#define atomic_dec(env, p) __atomic_dec(p)
#define atomic_compare_exchange(env, p, o, n) \
- __atomic_compare_exchange((p), (o), (n))
+ __atomic_compare_exchange_db((p), (o), (n))
static inline int __atomic_inc(db_atomic_t *p)
{
int temp;
@@ -176,7 +176,7 @@
* http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
* which configure could be changed to use.
*/
-static inline int __atomic_compare_exchange(
+static inline int __atomic_compare_exchange_db(
db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval)
{
atomic_value_t was;
@jmjatlanta
Copy link

How do I apply this patch?

Navigate to the file atomic.h that is in the dbinc directory. Somewhere around line 147, you will see _atomic_compare_exchange((p), (o), (n)) (as in line 9 above). Change that line to be __atomic_compare_exchange_db((p), (o), (n)). You are just adding a _db at the end of the function name.

You will also do something simolar around line 179. After that, re-run make to build Berkeley DB 4.8.

@Koff
Copy link

Koff commented Jan 24, 2020

You can just run sed -i 's/__atomic_compare_exchange/__atomic_compare_exchange_db/g' db-4.8.30.NC/dbinc/atomic.h

@danieldk
Copy link
Author

...or just use patch. From the main dbxml directory:

patch -p1 < gistfile1.txt 

@nerdlabs001
Copy link

I had to change lines 9 AND 18 from the commit above but now im good to go , Thanks all =)

@DavidDevGit
Copy link

How do I apply this patch?

Navigate to the file atomic.h that is in the dbinc directory. Somewhere around line 147, you will see _atomic_compare_exchange((p), (o), (n)) (as in line 9 above). Change that line to be __atomic_compare_exchange_db((p), (o), (n)). You are just adding a _db at the end of the function name.

You will also do something simolar around line 179. After that, re-run make to build Berkeley DB 4.8.

clear, concise instructions. This worked for me. Thank you

@Edison4mobile
Copy link

You can just run sed -i 's/__atomic_compare_exchange/__atomic_compare_exchange_db/g' db-4.8.30.NC/dbinc/atomic.h

great thanks

@Hongdeshuai
Copy link

Yeah, it works perfect

@younicoin
Copy link

younicoin commented Nov 21, 2023

yes that works! line 179 in dbinc/atomic.h, add suffix _db here :
//static inline int __atomic_compare_exchange(
static inline int __atomic_compare_exchange_db(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment