summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--errno.c2
-rw-r--r--need_errno.h3
-rw-r--r--pthread.h16
-rw-r--r--pthread_key_create.c2
-rw-r--r--pthread_key_delete.c2
-rw-r--r--pthread_setspecific.c14
7 files changed, 37 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index c1bf7a8..6dae638 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2007-11-22 Ivan Pizhenko <ivanp4 at ua dot fm>
+
+ * pthread.h (gmtime_r) gmtime returns 0 if tm represents a time
+ prior to 1/1/1970. Notice this to prevent raising an exception.
+ * pthread.h (localtime_r) Likewise for localtime.
+
+2007-07-14 Marcel Ruff <mr at marcelruff dot info>
+
+ * errno.c (_errno): Fix test for pthread_self() success.
+ * need_errno.h: Remove unintentional line wrap from #if line.
+
+2007-07-14 Mike Romanchuk <mromanchuk at empirix dot com>
+
+ * pthread.h (timespec): Fix tv_sec type.
+
2007-01-07 Sinan Kaya <sinan.kaya at siemens dot com>
* need_errno.h: Fix declaration of _errno - the local version of
diff --git a/errno.c b/errno.c
index 1a7957c..78aa920 100644
--- a/errno.c
+++ b/errno.c
@@ -74,7 +74,7 @@ _errno (void)
pthread_t self;
int *result;
- if ((self = pthread_self ()) == NULL)
+ if ((self = pthread_self ()).p == NULL)
{
/*
* Yikes! unable to allocate a thread!
diff --git a/need_errno.h b/need_errno.h
index f930d6e..a28955a 100644
--- a/need_errno.h
+++ b/need_errno.h
@@ -72,8 +72,7 @@ extern "C" {
/* declare reference to errno */
-#if (defined(_MT) || defined(_MD) || defined(_DLL)) &&
-!defined(_MAC)
+#if (defined(_MT) || defined(_MD) || defined(_DLL)) && !defined(_MAC)
PTW32_DLLPORT int * __cdecl _errno(void);
#define errno (*_errno())
#else /* ndef _MT && ndef _MD && ndef _DLL */
diff --git a/pthread.h b/pthread.h
index 9026111..db05327 100644
--- a/pthread.h
+++ b/pthread.h
@@ -305,7 +305,7 @@ enum {
#ifndef HAVE_STRUCT_TIMESPEC
#define HAVE_STRUCT_TIMESPEC 1
struct timespec {
- long tv_sec;
+ time_t tv_sec;
long tv_nsec;
};
#endif /* HAVE_STRUCT_TIMESPEC */
@@ -1249,13 +1249,19 @@ PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
( strcpy( (_buf), ctime( (_clock) ) ), \
(_buf) )
+/*
+ * gmtime(tm) and localtime(tm) return 0 if tm represents
+ * a time prior to 1/1/1970.
+ */
#define gmtime_r( _clock, _result ) \
- ( *(_result) = *gmtime( (_clock) ), \
- (_result) )
+ ( gmtime( (_clock) ) \
+ ? (*(_result) = *gmtime( (_clock) ), (_result) ) \
+ : (0) )
#define localtime_r( _clock, _result ) \
- ( *(_result) = *localtime( (_clock) ), \
- (_result) )
+ ( localtime( (_clock) ) \
+ ? (*(_result) = *localtime( (_clock) ), (_result) ) \
+ : (0) )
#define rand_r( _seed ) \
( _seed == _seed? rand() : rand() )
diff --git a/pthread_key_create.c b/pthread_key_create.c
index 5e278c2..41f4854 100644
--- a/pthread_key_create.c
+++ b/pthread_key_create.c
@@ -93,7 +93,7 @@ pthread_key_create (pthread_key_t * key, void (*destructor) (void *))
{
/*
* Have to manage associations between thread and key;
- * Therefore, need a lock that allows multiple threads
+ * Therefore, need a lock that allows competing threads
* to gain exclusive access to the key->threads list.
*
* The mutex will only be created when it is first locked.
diff --git a/pthread_key_delete.c b/pthread_key_delete.c
index 7da9b2f..0737e9e 100644
--- a/pthread_key_delete.c
+++ b/pthread_key_delete.c
@@ -119,7 +119,7 @@ pthread_key_delete (pthread_key_t key)
/* A thread could be holding the keyLock */
while (EBUSY == pthread_mutex_destroy (&(key->keyLock)))
{
- Sleep(1); // Ugly.
+ Sleep(0); /* Ugly */
}
}
diff --git a/pthread_setspecific.c b/pthread_setspecific.c
index f06b696..b16270e 100644
--- a/pthread_setspecific.c
+++ b/pthread_setspecific.c
@@ -155,13 +155,13 @@ pthread_setspecific (pthread_key_t key, const void *value)
(void) pthread_mutex_unlock(&(key->keyLock));
}
- if (result == 0)
- {
- if (!TlsSetValue (key->key, (LPVOID) value))
- {
- result = EAGAIN;
- }
- }
+ if (result == 0)
+ {
+ if (!TlsSetValue (key->key, (LPVOID) value))
+ {
+ result = EAGAIN;
+ }
+ }
}
return (result);