From: Paul Eggert Date: Mon, 8 May 2017 17:46:21 +0000 (-0700) Subject: Merge from gnulib X-Git-Tag: emacs-26.0.90~521^2~432 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7ff7624a7aa62f30cabf14744e182e9ea6156290;p=emacs.git Merge from gnulib This incorporates: 2017-05-08 intprops: don’t depend on ‘verify’ 2017-05-07 utimens: on native Windows, improve resolution if fd < 0 2017-05-07 utimens: Improve error code on native Windows * lib/intprops.h, lib/utimens.c: Copy from gnulib. --- diff --git a/lib/intprops.h b/lib/intprops.h index 1ea9647e16e..8f5ad545154 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -21,7 +21,6 @@ #define _GL_INTPROPS_H #include -#include /* Return a value with the common real type of E and V and the value of V. */ #define _GL_INT_CONVERT(e, v) (0 * (e) + (v)) @@ -80,24 +79,7 @@ /* This include file assumes that signed types are two's complement without padding bits; the above macros have undefined behavior otherwise. If this is a problem for you, please let us know how to fix it for your host. - As a sanity check, test the assumption for some signed types that - bounds. */ -verify (TYPE_MINIMUM (signed char) == SCHAR_MIN); -verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX); -verify (TYPE_MINIMUM (short int) == SHRT_MIN); -verify (TYPE_MAXIMUM (short int) == SHRT_MAX); -verify (TYPE_MINIMUM (int) == INT_MIN); -verify (TYPE_MAXIMUM (int) == INT_MAX); -verify (TYPE_MINIMUM (long int) == LONG_MIN); -verify (TYPE_MAXIMUM (long int) == LONG_MAX); -#ifdef LLONG_MAX -verify (TYPE_MINIMUM (long long int) == LLONG_MIN); -verify (TYPE_MAXIMUM (long long int) == LLONG_MAX); -#endif -/* Similarly, sanity-check one ISO/IEC TS 18661-1:2014 macro if defined. */ -#ifdef UINT_WIDTH -verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH); -#endif + This assumption is tested by the intprops-tests module. */ /* Does the __typeof__ keyword work? This could be done by 'configure', but for now it's easier to do it by hand. */ diff --git a/lib/utimens.c b/lib/utimens.c index 5f3a846ea2f..b4bfa8e3222 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -349,11 +349,19 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) return 0; else { - #if 0 DWORD sft_error = GetLastError (); - fprintf (stderr, "utime SetFileTime error 0x%x\n", (unsigned int) sft_error); + #if 0 + fprintf (stderr, "fdutimens SetFileTime error 0x%x\n", (unsigned int) sft_error); #endif - errno = EINVAL; + switch (sft_error) + { + case ERROR_ACCESS_DENIED: /* fd was opened without O_RDWR */ + errno = EACCES; /* not specified by POSIX */ + break; + default: + errno = EINVAL; + break; + } return -1; } } @@ -465,7 +473,9 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) return -1; } -#if HAVE_WORKING_UTIMES +#ifdef USE_SETFILETIME + return _gl_utimens_windows (file, ts); +#elif HAVE_WORKING_UTIMES return utimes (file, t); #else {