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:
parent
48abfaa93e
commit
fbd92a913e
@ -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 --
|
||||
|
20
src/util.c
20
src/util.c
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user