aboutsummaryrefslogtreecommitdiff
path: root/src/gdbmerrno.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-12-19 09:32:07 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2017-12-19 09:32:07 +0200
commitc175231e2781abd17eabf412cfb597654a076c7b (patch)
tree6a41ee39754fb66646b75bcbdcb80a214c897694 /src/gdbmerrno.c
parent33904b85bae29474da7ed6df3a5c1735c3162d57 (diff)
downloadgdbm-c175231e2781abd17eabf412cfb597654a076c7b.tar.gz
gdbm-c175231e2781abd17eabf412cfb597654a076c7b.tar.bz2
Make gdbm_error thread-safe
* src/gdbm.h.in (gdbm_errno_location): New extern (gdbm_errno): Change to a define. * src/gdbmerrno.c (gdbm_errno_location): New function. (gdbm_errno_storage): Thread-safe storage for the last errno.
Diffstat (limited to 'src/gdbmerrno.c')
-rw-r--r--src/gdbmerrno.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gdbmerrno.c b/src/gdbmerrno.c
index 87c6401..12748b8 100644
--- a/src/gdbmerrno.c
+++ b/src/gdbmerrno.c
@@ -23,7 +23,13 @@
#include "gdbmdefs.h"
/* The dbm error number is placed in the variable GDBM_ERRNO. */
-gdbm_error gdbm_errno = GDBM_NO_ERROR;
+static __thread gdbm_error gdbm_errno_storage = GDBM_NO_ERROR;
+
+int *
+gdbm_errno_location (void)
+{
+ return &gdbm_errno_storage;
+}
/* Store error code EC in the database structure DBF and in the
global variable gdbm_error.

Return to:

Send suggestions and report system problems to the System administrator.