1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-01-03 14:56:34 -05:00

add localtime_r checks, useful the threads

svn path=/trunk/icecast/; revision=5785
This commit is contained in:
Karl Heyes 2004-01-26 21:49:07 +00:00
parent 48abfaa93e
commit fbd92a913e
3 changed files with 26 additions and 1 deletions

View File

@ -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 --

View File

@ -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

View File

@ -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__ */