16 |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
17 |
|
|
18 |
#include <time.h> |
#include <time.h> |
|
#include <pthread.h> |
|
19 |
|
|
20 |
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
LOCK_DECLARE(lock) |
21 |
|
|
22 |
struct tm * |
struct tm * |
23 |
localtime_r(timep, res) |
localtime_r(timep, res) |
26 |
{ |
{ |
27 |
struct tm *tm; |
struct tm *tm; |
28 |
|
|
29 |
pthread_cleanup_push((void (*)(void*))pthread_mutex_unlock, &mutex); |
LOCK_SET(lock); |
|
pthread_mutex_lock(&mutex); |
|
30 |
tm = localtime(timep); |
tm = localtime(timep); |
31 |
memcpy(res, tm, sizeof(*res)); |
memcpy(res, tm, sizeof(*res)); |
32 |
pthread_cleanup_pop(1); |
LOCK_RELEASE(lock); |
33 |
return res; |
return res; |
34 |
} |
} |