Eli Zaretskii wrote:
the utimens.c file you've brought from Gnulib has 2 problems:
. it defines WIN32_LEAN_AND_MEAN unconditionally, which conflicts
with our own definition in nt/inc/ms-w32.h, which is processed
earlier;
. it includes msvc-nothrow.h, which is absent in the repository, it
should have been imported from Gnulib together with utimens.c
I fixed the first of these temporarily, in a way that at least GCC
lets utimens.c compile, but I think in general utimens.c should do
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
to avoid possible clashes with definitions elsewhere in the sources.
I'd like Bruno's opinion on the macro clash, and on the attached patch for the
msvc-nothrow.h issue, a patch that I installed into Gnulib and into Emacs master
to try to get the Emacs master build working again.
For quite some time Emacs has avoided Gnulib's msvc-nothrow and msvc-inval
modules, the reason for which I do not understand (and don't particularly want
to :-). It's trivial to add the msvc-nothrow and msvc-inval machinery to the
Emacs source code, if this is necessary now for some reason: simply remove them
from the AVOIDED_MODULES list in admin/merge-gnulib and then run
admin/merge-gnulib. I don't know whether this would break other parts of the
build on MS-Windows, though.
From fb26fc4b4ad7db1d12933aefc3d213c6f217092c Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Tue, 2 May 2017 00:40:41 -0700
Subject: [PATCH] utimens: port to Emacs + MS-Windows
Skip the new MS-Windows-specific code if Emacs.
* lib/utimens.c [EMACS_CONFIGUATION]:
Avoid new MS-Windows-specific code.
(USE_SETFILETIME): New macro.
(fdutimens): Use it.
---
ChangeLog | 9 +++++++++
lib/utimens.c | 10 ++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ad44003..8c91b23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-05-02 Paul Eggert <egg...@cs.ucla.edu>
+
+ utimens: port to Emacs + MS-Windows
+ Skip the new MS-Windows-specific code if Emacs.
+ * lib/utimens.c [EMACS_CONFIGUATION]:
+ Avoid new MS-Windows-specific code.
+ (USE_SETFILETIME): New macro.
+ (fdutimens): Use it.
+
2017-05-01 Paul Eggert <egg...@cs.ucla.edu>
tzset: update doc for TZ problems on MS-Windows
diff --git a/lib/utimens.c b/lib/utimens.c
index 0b3b8e2..5f3a846 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -35,7 +35,13 @@
#include "stat-time.h"
#include "timespec.h"
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* On native Windows, use SetFileTime; but avoid this when compiling
+ GNU Emacs, which arranges for this in some other way and which
+ defines WIN32_LEAN_AND_MEAN itself. */
+
+#if ((defined _WIN32 || defined __WIN32__) \
+ && ! defined __CYGWIN__ && ! defined EMACS_CONFIGURATION)
+# define USE_SETFILETIME
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include "msvc-nothrow.h"
@@ -277,7 +283,7 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
lutimensat_works_really = -1;
#endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#ifdef USE_SETFILETIME
/* On native Windows, use SetFileTime(). See
<https://msdn.microsoft.com/en-us/library/ms724933.aspx>
<https://msdn.microsoft.com/en-us/library/ms724284.aspx> */
--
2.7.4