git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 04/18] date.c: mark file-local function static

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Jan 12, 2010, 09:43 UTC
Message-ID
<4B4C4448.9060908@viscovery.net>
In-Reply-To
<7vr5pv3d7w.fsf@alter.siamese.dyndns.org>
Junio C Hamano schrieb:
> Johannes Sixt <j.sixt@viscovery.net> writes:
>> This one is used from compat/mingw.c for the gettimeofday emulation.
>> Please leave it extern.
I'll add this patch to may windows-update series to avoids this hack.
--- 8< ---
From: Johannes Sixt <j6t@kdbg.org>
Subject: [PATCH] compat/mingw.c: do not use tm_to_time_t from date.c

To implement gettimeofday(), a broken-down UTC time was requested from the system using GetSystemTime() and converted using tm_to_time_t() because it does not look at the current timezone, which mktime() would do. But meanwhile we have grown infrastructure in mingw.c, so that we can use a different conversion path. This way we can avoid the ugly back-reference from the compatibility layer to the generic git code.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 compat/mingw.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index faaaade..3c78f39 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -281,19 +281,11 @@ 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;
+	GetSystemTimeAsFileTime(&ft);
+	tv->tv_sec = filetime_to_time_t(&ft);
+	/* the unit is 100-nanoseconds, ie., a 10th of a microsecond */
+	tv->tv_usec = (ft.dwLowDateTime % 10000000) / 10;
 	return 0;
 }
 
-- 
1.6.6.1207.g714a1.dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 24 in “mark file-local symbols static”
  1. 00/18 mark file-local symbols staticJunio C Hamano, Jan 12, 2010
  2. 01/18 bisect.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  3. 02/18 builtin-rev-list.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  4. 03/18 pretty.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  5. 04/18 date.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  6. Johannes SixtJan 12, 2010
  7. Junio C HamanoJan 12, 2010
  8. Johannes SixtJan 12, 2010
  9. 05/18 http.c: mark file-local functions staticJunio C Hamano, Jan 12, 2010
  10. 06/18 entry.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  11. 07/18 parse-options.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  12. 08/18 read-cache.c: mark file-local functions staticJunio C Hamano, Jan 12, 2010
  13. 09/18 remote-curl.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  14. 10/18 quote.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  15. 11/18 submodule.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  16. 12/18 utf8.c: mark file-local function staticJunio C Hamano, Jan 12, 2010
  17. 13/18 mailmap.c: remove unused functionJunio C Hamano, Jan 12, 2010
  18. 14/18 sha1_file.c: remove unused functionJunio C Hamano, Jan 12, 2010
  19. 15/18 strbuf.c: remove unused functionJunio C Hamano, Jan 12, 2010
  20. 16/18 blob.c: remove unused functionJunio C Hamano, Jan 12, 2010
  21. Daniel BarkalowJan 12, 2010
  22. Junio C HamanoJan 13, 2010
  23. 17/18 object.c: remove unused functionsJunio C Hamano, Jan 12, 2010
  24. 18/18 symlinks.c: remove unused functionsJunio C Hamano, Jan 12, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.