summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorEdwin Groothuis <edwin@FreeBSD.org>2009-10-29 11:00:39 +0000
committerEdwin Groothuis <edwin@FreeBSD.org>2009-10-29 11:00:39 +0000
commitd769d27c9c87877a02a02a6a39b0c014ade2c02e (patch)
tree0976e50dca444a1d71c2ac179aa277b9571a7c0c /lib/libc
parent3739d8e0dc0d6dca96d426ad1abe3d8bfa657dbf (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdtime/localtime.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c
index cbf3b659c437..f933736565cc 100644
--- a/lib/libc/stdtime/localtime.c
+++ b/lib/libc/stdtime/localtime.c
@@ -21,6 +21,7 @@ __FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
+#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include "private.h"
@@ -1413,12 +1414,15 @@ const time_t * const timep;
static pthread_mutex_t localtime_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_key_t localtime_key = -1;
struct tm *p_tm;
+ int r;
if (__isthreaded != 0) {
_pthread_mutex_lock(&localtime_mutex);
if (localtime_key < 0) {
- if (_pthread_key_create(&localtime_key, free) < 0) {
+ if ((r = _pthread_key_create(&localtime_key, free))
+ != 0) {
_pthread_mutex_unlock(&localtime_mutex);
+ errno = r;
return(NULL);
}
}
@@ -1510,12 +1514,14 @@ const time_t * const timep;
static pthread_mutex_t gmtime_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_key_t gmtime_key = -1;
struct tm *p_tm;
+ int r;
if (__isthreaded != 0) {
_pthread_mutex_lock(&gmtime_mutex);
if (gmtime_key < 0) {
- if (_pthread_key_create(&gmtime_key, free) < 0) {
+ if ((r = _pthread_key_create(&gmtime_key, free)) != 0) {
_pthread_mutex_unlock(&gmtime_mutex);
+ errno = r;
return(NULL);
}
}