(!1685) os: log: use localtime_r() on mingw builds
MingW also provides localtime_r(), but needs _POSIX_THREAD_SAFE_FUNCTIONS symbol before including anything, in order for the prototype being defined. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
e305638cc9
commit
c92d7037db
6
os/log.c
6
os/log.c
|
@ -75,6 +75,8 @@ OR PERFORMANCE OF THIS SOFTWARE.
|
|||
* authorization from the copyright holder(s) and author(s).
|
||||
*/
|
||||
|
||||
#define _POSIX_THREAD_SAFE_FUNCTIONS // for localtime_r on mingw32
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
@ -617,11 +619,7 @@ LogSWrite(int verb, const char *buf, size_t len, Bool end_line)
|
|||
struct tm tm;
|
||||
char fmt_tm[32];
|
||||
|
||||
#ifdef WIN32
|
||||
localtime_s(&tm, &t);
|
||||
#else
|
||||
localtime_r(&t, &tm);
|
||||
#endif
|
||||
strftime(fmt_tm, sizeof(fmt_tm) - 1, "%Y-%m-%d %H:%M:%S", &tm);
|
||||
|
||||
fprintf(logFile, "[%s] ", fmt_tm);
|
||||
|
|
Loading…
Reference in New Issue