mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 23:13:34 +00:00
42 lines
1.6 KiB
C
42 lines
1.6 KiB
C
|
#ifndef COSMOPOLITAN_LIBC_FMT_WINTIME_H_
|
||
|
#define COSMOPOLITAN_LIBC_FMT_WINTIME_H_
|
||
|
#include "libc/calls/struct/timespec.h"
|
||
|
#include "libc/calls/struct/timeval.h"
|
||
|
#include "libc/nt/struct/filetime.h"
|
||
|
|
||
|
#define MODERNITYSECONDS 11644473600ull
|
||
|
#define HECTONANOSECONDS 10000000ull
|
||
|
|
||
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||
|
COSMOPOLITAN_C_START_
|
||
|
|
||
|
int64_t DosDateTimeToUnix(uint32_t, uint32_t) pureconst;
|
||
|
int64_t TimeSpecToWindowsTime(struct timespec) pureconst;
|
||
|
int64_t TimeValToWindowsTime(struct timeval) pureconst;
|
||
|
struct timespec WindowsDurationToTimeSpec(int64_t) pureconst;
|
||
|
struct timespec WindowsTimeToTimeSpec(int64_t) pureconst;
|
||
|
struct timeval WindowsDurationToTimeVal(int64_t) pureconst;
|
||
|
struct timeval WindowsTimeToTimeVal(int64_t) pureconst;
|
||
|
|
||
|
#define MakeFileTime(x) \
|
||
|
({ \
|
||
|
int64_t __x = x; \
|
||
|
(struct NtFileTime){(uint32_t)__x, (uint32_t)(__x >> 32)}; \
|
||
|
})
|
||
|
|
||
|
#define ReadFileTime(t) \
|
||
|
({ \
|
||
|
struct NtFileTime __t = t; \
|
||
|
uint64_t x = __t.dwHighDateTime; \
|
||
|
(int64_t)(x << 32 | __t.dwLowDateTime); \
|
||
|
})
|
||
|
|
||
|
#define FileTimeToTimeSpec(x) WindowsTimeToTimeSpec(ReadFileTime(x))
|
||
|
#define FileTimeToTimeVal(x) WindowsTimeToTimeVal(ReadFileTime(x))
|
||
|
#define TimeSpecToFileTime(x) MakeFileTime(TimeSpecToWindowsTime(x))
|
||
|
#define TimeValToFileTime(x) MakeFileTime(TimeValToWindowsTime(x))
|
||
|
|
||
|
COSMOPOLITAN_C_END_
|
||
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||
|
#endif /* COSMOPOLITAN_LIBC_FMT_WINTIME_H_ */
|