/[radius]/radius/lib/localtime_r.c
ViewVC logotype

Diff of /radius/lib/localtime_r.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by gray, Wed Jul 17 12:36:14 2002 UTC revision 1.3 by gray, Fri Apr 18 05:27:09 2003 UTC
# Line 16  Line 16 
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)
# Line 27  localtime_r(timep, res) Line 26  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  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26