mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 15:03:34 +00:00
- Remove most __ASSEMBLER__ __LINKER__ ifdefs - Rename libc/intrin/bits.h to libc/serialize.h - Block pthread cancelation in fchmodat() polyfill - Remove `clang-format off` statements in third_party
39 lines
1.5 KiB
C
39 lines
1.5 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
|
|
|
|
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 /* COSMOPOLITAN_LIBC_FMT_WINTIME_H_ */
|