diff options
Diffstat (limited to 'uisimulator/common/time-win32.c')
-rw-r--r-- | uisimulator/common/time-win32.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/uisimulator/common/time-win32.c b/uisimulator/common/time-win32.c new file mode 100644 index 0000000000..1de69c35e6 --- /dev/null +++ b/uisimulator/common/time-win32.c @@ -0,0 +1,61 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2014 by Michael Sevakis + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include <time.h> +#include <errno.h> +#include "system.h" +#include "debug.h" + +/* These functions we like but Windows doesn't because it implements the + non-"_r" versions with thread-local storage in its multithreaded libs */ + +struct tm * localtime_r(const time_t *restrict timer, + struct tm *restrict result) +{ + if (!timer || !result) + { + errno = EINVAL; + return NULL; + } + + struct tm *tm = localtime(timer); + if (!tm) + return NULL; + + *result = *tm; + return result; +} + +struct tm * gmtime_r(const time_t *restrict timer, + struct tm *restrict result) +{ + if (!timer || !result) + { + errno = EINVAL; + return NULL; + } + + struct tm *tm = gmtime(timer); + if (!tm) + return NULL; + + *result = *tm; + return result; +} |