Skip to content

Commit fb8f193

Browse files
kbleesdscho
authored andcommitted
Win32: make FILETIME conversion functions public
We will use them in the upcoming "FSCache" patches (to accelerate sequential lstat() calls). Signed-off-by: Karsten Blees <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 6218340 commit fb8f193

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

compat/mingw.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -868,24 +868,6 @@ int mingw_chmod(const char *filename, int mode)
868868
return _wchmod(wfilename, mode);
869869
}
870870

871-
/*
872-
* The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
873-
* Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
874-
*/
875-
static inline long long filetime_to_hnsec(const FILETIME *ft)
876-
{
877-
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
878-
/* Windows to Unix Epoch conversion */
879-
return winTime - 116444736000000000LL;
880-
}
881-
882-
static inline void filetime_to_timespec(const FILETIME *ft, struct timespec *ts)
883-
{
884-
long long hnsec = filetime_to_hnsec(ft);
885-
ts->tv_sec = (time_t)(hnsec / 10000000);
886-
ts->tv_nsec = (hnsec % 10000000) * 100;
887-
}
888-
889871
/**
890872
* Verifies that safe_create_leading_directories() would succeed.
891873
*/

compat/mingw.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,17 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
361361
return 0;
362362
}
363363

364+
/*
365+
* The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
366+
* Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
367+
*/
368+
static inline long long filetime_to_hnsec(const FILETIME *ft)
369+
{
370+
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
371+
/* Windows to Unix Epoch conversion */
372+
return winTime - 116444736000000000LL;
373+
}
374+
364375
/*
365376
* Use mingw specific stat()/lstat()/fstat() implementations on Windows,
366377
* including our own struct stat with 64 bit st_size and nanosecond-precision
@@ -377,6 +388,13 @@ struct timespec {
377388
#endif
378389
#endif
379390

391+
static inline void filetime_to_timespec(const FILETIME *ft, struct timespec *ts)
392+
{
393+
long long hnsec = filetime_to_hnsec(ft);
394+
ts->tv_sec = (time_t)(hnsec / 10000000);
395+
ts->tv_nsec = (hnsec % 10000000) * 100;
396+
}
397+
380398
struct mingw_stat {
381399
_dev_t st_dev;
382400
_ino_t st_ino;

0 commit comments

Comments
 (0)