Commit fbd92a91 authored by Karl Heyes's avatar Karl Heyes

add localtime_r checks, useful the threads

svn path=/trunk/icecast/; revision=5785
parent 48abfaa9
......@@ -62,7 +62,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
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 --
......
......@@ -24,6 +24,7 @@
#endif
#include "net/sock.h"
#include "thread/thread.h"
#include "cfgfile.h"
#include "util.h"
......@@ -587,3 +588,22 @@ char *util_dict_urlencode(util_dict *dict, char delim)
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
......@@ -32,4 +32,9 @@ void util_dict_free(util_dict *dict);
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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment