Greetings,

Recall that on:

 $ cc/ver nl:
 DEC C V5.3-006 on OpenVMS VAX V6.2

I find that perl@11238 will fail Time/HiRes.t test #14 by an offset that
corresponds to my GMT offset.  I knew that there'd be plenty of code in
[.vms]vms.c to handle this but unfortunately I have not yet found a
clever way to get the static utc_offest_sec from [.vms]vms.obj to be
recognized by the compiler of HiRes.c in [.ext.time.hires].  What I ahve
managed to do is get things to run and pass even test #14 with the
following:

--- perl_11238/ext/Time/HiRes/HiRes.xs.orig     Mon Jul  9 07:10:16 2001
+++ perl_11238/ext/Time/HiRes/HiRes.xs  Wed Jul 11 15:08:02 2001
@@ -94,7 +94,13 @@
 #include <descrip.h>
 #ifdef __VAX
 #include <lib$routines.h> /* lib$ediv() */
-#endif
+/* borrowed from vms.c: */
+#if defined(__VMS_VER) && defined(__DECC_VER)
+#  if __VMS_VER >= 70000000 && __DECC_VER >= 50200000
+#    define RTL_USES_UTC 1
+#  endif
+#endif /* defined(__VMS_VER) && defined(__DECC_VER) */
+#endif /* __VAX */
 
 /*
         VMS binary time is expressed in 100 nano-seconds since
@@ -127,6 +133,10 @@
  long div_100ns_to_usecs;
  long quo,rem;
  long quo1,rem1;
+#  ifndef RTL_USES_UTC
+ char *tz_diff;
+ long utc_offset_secs;
+#  endif  /* RTL_USES_UTC */
 #else
  __int64 quad;
  __qdiv_t ans1,ans2;
@@ -162,7 +172,18 @@
         quad1[0] = rem;
         quad1[1] = 0L;
         lib$ediv(&div_100ns_to_usecs,&quad1,&quo1,&rem1);
+#  ifndef RTL_USES_UTC
+        tz_diff = getenv("SYS$TIMEZONE_DIFFERENTIAL");
+        if (!tz_diff) {
+            utc_offset_secs = 0L;
+        }
+        else { 
+            utc_offset_secs = atol(tz_diff);
+        }
+        tp->tv_sec = quo - utc_offset_secs; /* Whole seconds */
+#  else
         tp->tv_sec = quo; /* Whole seconds */
+#  endif  /* RTL_USES_UTC */
         tp->tv_usec = quo1; /* Micro-seconds */
 #else
         quad -= base_adjust; /* convert to epoch offset */
End of "VAX-hack"

However, I am not pleased with the overhead of calling getenv() on a high
resolution timer and would rather work things around a bit to either make
use of [.vms]vms.obj or perhaps make the utc_offset_secs in HiRes.xs
static (with a rename).  Until I figure that stuff out I won't attempt to
patch the upcoming 5.7.2 release candidates, but I thought having this
patch in the archive might be helpful to someone out there.

Peter Prymmer


Reply via email to