[xiph-cvs] cvs commit: icecast/src util.c util.h

Karl Heyes karl at xiph.org
Mon Jan 26 13:49:08 PST 2004



karl        04/01/26 16:49:08

  Modified:    .        configure.in
               src      util.c util.h
  Log:
  add localtime_r checks, useful the threads

Revision  Changes    Path
1.44      +1 -1      icecast/configure.in

Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/icecast/configure.in,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- configure.in	7 Jan 2004 21:53:38 -0000	1.43
+++ configure.in	26 Jan 2004 21:49:07 -0000	1.44
@@ -62,7 +62,7 @@
 dnl Check for types
 
 dnl Checks for library functions.
-AC_CHECK_FUNCS(nanosleep poll)
+AC_CHECK_FUNCS(localtime_r nanosleep poll)
 XIPH_NET
 
 dnl -- configure options --

<p><p>1.27      +20 -0     icecast/src/util.c

Index: util.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/util.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- util.c	15 Jan 2004 01:01:09 -0000	1.26
+++ util.c	26 Jan 2004 21:49:07 -0000	1.27
@@ -24,6 +24,7 @@
 #endif
 
 #include "net/sock.h"
+#include "thread/thread.h"
 
 #include "cfgfile.h"
 #include "util.h"
@@ -587,3 +588,22 @@
     return res;
 }
 
+#ifndef HAVE_LOCALTIME_R
+struct tm *localtime_r (const time_t *timep, struct tm *result)
+{
+     static mutex_t localtime_lock;
+     static int initialised = 0;
+     struct tm *tm;
+
+     if (initialised == 0)
+     {
+         thread_mutex_create (&localtime_lock);
+         initialised = 1;
+     }
+     thread_mutex_lock (&localtime_lock);
+     tm = localtime (timep);
+     memcpy (result, tm, sizeof (*result));
+     thread_mutex_unlock (&localtime_lock);
+     return result;
+}
+#endif

<p><p>1.13      +5 -0      icecast/src/util.h

Index: util.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/util.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- util.h	15 Jan 2004 01:01:09 -0000	1.12
+++ util.h	26 Jan 2004 21:49:07 -0000	1.13
@@ -32,4 +32,9 @@
 int util_dict_set(util_dict *dict, const char *key, const char *val);
 const char *util_dict_get(util_dict *dict, const char *key);
 char *util_dict_urlencode(util_dict *dict, char delim);
+
+#ifndef HAVE_LOCALTIME_R
+struct tm *localtime_r (const time_t *timep, struct tm *result);
+#endif
+
 #endif  /* __UTIL_H__ */

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list