aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compat/mingw.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index 74ffc1834f..ab65f77ab9 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -140,12 +140,20 @@ int mingw_open (const char *filename, int oflags, ...)
return fd;
}
-static inline time_t filetime_to_time_t(const FILETIME *ft)
+/*
+ * The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
+ * Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
+ */
+static inline long long filetime_to_hnsec(const FILETIME *ft)
{
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
- winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */
- winTime /= 10000000; /* Nano to seconds resolution */
- return (time_t)winTime;
+ /* Windows to Unix Epoch conversion */
+ return winTime - 116444736000000000LL;
+}
+
+static inline time_t filetime_to_time_t(const FILETIME *ft)
+{
+ return (time_t)(filetime_to_hnsec(ft) / 10000000);
}
/* We keep the do_lstat code in a separate function to avoid recursion.
@@ -281,19 +289,13 @@ int mkstemp(char *template)
int gettimeofday(struct timeval *tv, void *tz)
{
- SYSTEMTIME st;
- struct tm tm;
- GetSystemTime(&st);
- tm.tm_year = st.wYear-1900;
- tm.tm_mon = st.wMonth-1;
- tm.tm_mday = st.wDay;
- tm.tm_hour = st.wHour;
- tm.tm_min = st.wMinute;
- tm.tm_sec = st.wSecond;
- tv->tv_sec = tm_to_time_t(&tm);
- if (tv->tv_sec < 0)
- return -1;
- tv->tv_usec = st.wMilliseconds*1000;
+ FILETIME ft;
+ long long hnsec;
+
+ GetSystemTimeAsFileTime(&ft);
+ hnsec = filetime_to_hnsec(&ft);
+ tv->tv_sec = hnsec / 10000000;
+ tv->tv_usec = (hnsec % 10000000) / 10;
return 0;
}
td>-1/+1 2018-11-03memory_hotplug: cond_resched in __remove_pagesMichal Hocko1-0/+1 2018-11-03bfs: add sanity check at bfs_fill_super()Tetsuo Handa1-3/+6 2018-11-03kernel/sysctl.c: remove duplicated includeMichael Schupikov1-1/+0 2018-11-03kernel/kexec_file.c: remove some duplicated includeszhong jiang1-2/+0 2018-11-03mm, thp: consolidate THP gfp handling into alloc_hugepage_direct_gfpmaskMichal Hocko5-77/+40 2018-11-03ocfs2: fix clusters leak in ocfs2_defrag_extent()Larry Chen1-0/+17 2018-11-03ocfs2: dlmglue: clean up timestamp handlingArnd Bergmann1-17/+9 2018-11-03ocfs2: don't put and assigning null to bh allocated outsideChangwei Ge1-18/+59 2018-11-03ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entryChangwei Ge1-2/+1 2018-11-03ocfs2: don't use iocb when EIOCBQUEUED returnsChangwei Ge1-2/+2 2018-11-03ocfs2: without quota support, avoid calling quota recoveryGuozhonghua1-17/+34 2018-11-03ocfs2: remove ocfs2_is_o2cb_active()Gang He3-10/+1 2018-11-03mm: thp: relax __GFP_THISNODE for MADV_HUGEPAGE mappingsAndrea Arcangeli1-2/+30 2018-11-03include/linux/notifier.h: SRCU: fix ctagsSam Protsenko1-2/+1 2018-11-03mm: handle no memcg case in memcg_kmem_charge() properlyRoman Gushchin1-1/+1 2018-11-02ARM: dts: stm32: update HASH1 dmas property on stm32mp157cAlexandre Torgue1-1/+1 2018-11-02ARM: orion: avoid VLA in orion_mpp_confArnd Bergmann1-1/+6 2018-11-02iov_iter: Fix 9p virtio breakageMarc Zyngier1-1/+1 2018-11-02cifs: fix signed/unsigned mismatch on aio_read patchSteve French1-6/+11 2018-11-02cifs: don't dereference smb_file_target before null checkColin Ian King1-2/+5 2018-11-02CIFS: Add direct I/O functions to file_operationsLong Li1-6/+4 2018-11-02CIFS: Add support for direct I/O writeLong Li2-41/+164 2018-11-02CIFS: Add support for direct I/O readLong Li3-39/+192 2018-11-02smb3: missing defines and structs for reparse point handlingSteve French2-0/+38 2018-11-02smb3: allow more detailed protocol info on open files for debuggingSteve French4-0/+65 2018-11-02smb3: on kerberos mount if server doesn't specify auth type use krb5Steve French1-2/+4 2018-11-02smb3: add trace point for tree connectionSteve French2-1/+44 2018-11-02cifs: fix spelling mistake, EACCESS -> EACCESColin Ian King2-3/+3 2018-11-02cifs: fix return value for cifs_listxattrRonnie Sahlberg1-5/+6