mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 00:49:04 +02:00
util: Add os_localtime
MSVC does not have localtime_r, so add abstraction. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7829>
This commit is contained in:
parent
531843cf2e
commit
116b6d135d
1 changed files with 12 additions and 0 deletions
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -62,6 +63,17 @@ os_time_get(void)
|
|||
}
|
||||
|
||||
|
||||
static inline struct tm *
|
||||
os_localtime(const time_t *timer, struct tm *buf)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return localtime_s(buf, timer) ? NULL : buf;
|
||||
#else
|
||||
return localtime_r(timer, buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sleep.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue