bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/4] Avoid an utimes(2) warning


From: Bruno Haible
Subject: Re: [PATCH 2/4] Avoid an utimes(2) warning
Date: Wed, 28 Apr 2010 02:35:58 +0200
User-agent: KMail/1.9.9

Andreas Gruenbacher wrote:
> > > * lib/utimens.c: On some systems, the timestamp parameter of
> > > utimens(2) is not declared as a const *; avoid warnings in that case.
> > 
> > You mean the parameter of futimesat(), futimes(), lutimes()?
> 
> I know that utimes() is affected.

Aha! Now we're at the root of the problem: There is a portability problem
with utimes(), which causes a warning in utimens.c.

The gnulib philosophy / principle to deal with this situation is that we
fix the problem with utimes(), instead of having to modify all possible
code that calls utimes(). One change instead of an unbounded number of
changes.

> > And which platform is affected?
> Tru64.

The declaration in <sys/time.h> on OSF/1 5.1 looks like this:

#ifdef _XOPEN_SOURCE_EXTENDED
extern int utimes __((const char *, const struct timeval *));
#else /* _XOPEN_SOURCE_EXTENDED */
extern int utimes __((const char *, struct timeval *));
#endif

I would not want to define _XOPEN_SOURCE_EXTENDED in AC_USE_SYSTEM_EXTENSIONS,
because it not only has the effect of bringing more POSIX declarations but
also hides some Tru64 specific function declarations (NSIG, sigsend etc.).
See also [1]:
  "Defining _XOPEN_SOURCE_EXTENDED globally is definitely not a good 
   workaround as it, amoungst others, will start using the XTI socket 
   API rather than the BSD socket API that cURL relies on."

So what we should do, according to gnulib philosophy, is to provide a
utimes() replacement.

But since utimes() already has so many other problems, we are recommending
to use utimens() instead. utimens() is quasi the utimes() replacement.
So your patch is fine. And I'm updating the doc as below.

[1] http://curl.haxx.se/mail/archive-2000-03/0057.html


2010-04-27  Bruno Haible  <address@hidden>

        Update doc about utimes().
        * doc/posix-functions/utimes.texi: Mention the OSF/1 problem and the
        'utimens' module.
        Reported by Andreas Gruenbacher <address@hidden>.

--- doc/posix-functions/utimes.texi.orig        Wed Apr 28 02:33:43 2010
+++ doc/posix-functions/utimes.texi     Wed Apr 28 02:32:45 2010
@@ -16,6 +16,10 @@
 This function is missing on some platforms:
 mingw, Interix 3.5, BeOS.
 @item
+The declaration of this function lacks @code{const} in the second argument
+on some platforms:
+OSF/1 5.1.
address@hidden
 On some platforms, this function mis-handles trailing slash:
 FreeBSD 7.2, Solaris 9.
 @item
@@ -32,3 +36,7 @@
 @code{utime} worked fine.
 glibc 2.2.5.
 @end itemize
+
+Extension: Gnulib provides a module @samp{utimens} that works around these
+problems and allows to set the time with nanosecond resolution (as far as
+supported by the file system).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]