bug-coreutils
[Top][All Lists]
Advanced

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

Re: FYI: settime.c doesn't compile on OSF1 V5.1 due to stime


From: Paul Eggert
Subject: Re: FYI: settime.c doesn't compile on OSF1 V5.1 due to stime
Date: Thu, 29 Sep 2005 10:35:32 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Jim Meyering <address@hidden> writes:

> +#elif HAVE_STIME
> +  {
> +    /* This fails to compile on OSF1 V5.1, due to stime requiring
> +       a `long int*' and tv_sec is `int'.  But that system does provide
> +       settimeofday.  */
> +    int r = stime (&ts->tv_sec);
> +    if (r == 0 || errno == EPERM)
> +      return r;
>  #endif

That can't work, as it has unbalanced {.  Also, it's probably better
just to return whatever error number stime and/or settimeofday return,
rather than overwriting it with ENOSYS.  I installed the further patch
enclosed below.

However, I'm curious: if settime had this problem, why don't all the
other places that take the address of tv_sec?  For example, date.c
says "localtime (&when.tv_sec)".  So time_t is int but stime takes a
long int *?

Does this have something to do with OSF1 having both 64-bit and 32-bit
times?  And settime is available only in the 64-bit flavor?  If so, is
it possible to cajole OSF1 into using a 64-bit time_t type everywhere,
instead of using it only with settime?  That would be better.


2005-09-29  Paul Eggert  <address@hidden>

        * settime.c (settime): Fix { typo in previous patch.  Also, don't
        bother returning ENOSYS if settimeofday or stime fails; just let
        them return whatever errno they want to return.

--- settime.c   29 Sep 2005 13:13:49 -0000      1.7
+++ settime.c   29 Sep 2005 17:21:44 -0000      1.9
@@ -53,24 +53,18 @@ settime (struct timespec const *ts)
 #if HAVE_SETTIMEOFDAY
   {
     struct timeval tv;
-    int r;
 
     tv.tv_sec = ts->tv_sec;
     tv.tv_usec = ts->tv_nsec / 1000;
-    r = settimeofday (&tv, 0);
-    if (r == 0 || errno == EPERM)
-      return r;
+    return settimeofday (&tv, 0);
   }
 #elif HAVE_STIME
-  {
-    /* This fails to compile on OSF1 V5.1, due to stime requiring
-       a `long int*' and tv_sec is `int'.  But that system does provide
-       settimeofday.  */
-    int r = stime (&ts->tv_sec);
-    if (r == 0 || errno == EPERM)
-      return r;
-#endif
-
+  /* This fails to compile on OSF1 V5.1, due to stime requiring
+     a `long int*' and tv_sec is `int'.  But that system does provide
+     settimeofday.  */
+  return stime (&ts->tv_sec);
+#else
   errno = ENOSYS;
   return -1;
+#endif
 }




reply via email to

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