diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-12-19 09:32:07 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-12-19 09:32:07 +0200 |
commit | c175231e2781abd17eabf412cfb597654a076c7b (patch) | |
tree | 6a41ee39754fb66646b75bcbdcb80a214c897694 /src/gdbmerrno.c | |
parent | 33904b85bae29474da7ed6df3a5c1735c3162d57 (diff) | |
download | gdbm-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.c | 8 |
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. |