summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdtime/strptime.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdtime/strptime.c')
-rw-r--r--lib/libc/stdtime/strptime.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c
index ca4dcef..88d04ce 100644
--- a/lib/libc/stdtime/strptime.c
+++ b/lib/libc/stdtime/strptime.c
@@ -64,21 +64,18 @@ static char sccsid[] = "@(#)strptime.c 0.1 (Powerdog) 94/03/27";
#endif /* !defined NOID */
#endif /* not lint */
+#include "namespace.h"
#include <time.h>
#include <ctype.h>
#include <string.h>
-#ifdef _THREAD_SAFE
#include <pthread.h>
-#include "pthread_private.h"
-#endif
+#include "un-namespace.h"
+#include "libc_private.h"
#include "timelocal.h"
static char * _strptime(const char *, const char *, struct tm *);
-#ifdef _THREAD_SAFE
-static struct pthread_mutex _gotgmt_mutexd = PTHREAD_MUTEX_STATIC_INITIALIZER;
-static pthread_mutex_t gotgmt_mutex = &_gotgmt_mutexd;
-#endif
+static pthread_mutex_t gotgmt_mutex = PTHREAD_MUTEX_INITIALIZER;
static int got_GMT;
#define asizeof(a) (sizeof (a) / sizeof ((a)[0]))
@@ -524,21 +521,19 @@ strptime(const char *buf, const char *fmt, struct tm *tm)
{
char *ret;
-#ifdef _THREAD_SAFE
- pthread_mutex_lock(&gotgmt_mutex);
-#endif
+ if (__isthreaded)
+ _pthread_mutex_lock(&gotgmt_mutex);
got_GMT = 0;
ret = _strptime(buf, fmt, tm);
if (ret && got_GMT) {
time_t t = timegm(tm);
- localtime_r(&t, tm);
+ localtime_r(&t, tm);
got_GMT = 0;
}
-#ifdef _THREAD_SAFE
- pthread_mutex_unlock(&gotgmt_mutex);
-#endif
+ if (__isthreaded)
+ _pthread_mutex_unlock(&gotgmt_mutex);
return ret;
}
OpenPOWER on IntegriCloud