develooper Front page | perl.perl5.porters | Postings from May 2003

5.8.0 && Time::HiRes && NCR MP-RAS

Thread Previous
From:
grommel
Date:
May 14, 2003 08:10
Subject:
5.8.0 && Time::HiRes && NCR MP-RAS
Message ID:
OF49058606.37C46CCF-ON86256D26.00509E61-86256D26.0053558C@LocalDomain
Shown below is a patch for the Time::HiRes module in 5.8.0 that works on
our local NCR MP-RAS systems. The problem that made it necessary is
described in the last diff listing. I offer the patch for your
consideration, but I have some misgivings about it. (1) The revised case
expression in hints/svr4.sh is unreliable. On a new system we have
installed, the hardware architecture is no longer "4400" or anything like
it, but "XXXX". Who knows what the future may hold? (2) The new hints file
(last file listed below) will be invoked for every svr4 system, not just
MP-RAS. But maybe MP-RAS is the only svr4 system in wide use nowadays.


$ diff -rc perl-5.8.0/hints/svr4.sh perl-5.8.0MOD/hints/svr4.sh
*** perl-5.8.0/hints/svr4.sh    Sat Jun  1 13:03:13 2002
--- perl-5.8.0MOD/hints/svr4.sh Wed May 14 10:32:12 2003
***************
*** 143,149 ****

  # Configure sets osname=svr4.0, osvers=3.0, archname='3441-svr4.0'
  case "$myuname" in
! *3441*|*4400*isapci)
      # With the NCR High Performance C Compiler R3.0c, miniperl fails
      # t/op/regexp.t test 461 unless we compile with optimizie=-g.
      # The whole O/S is being phased out, so more detailed probing
--- 143,154 ----

  # Configure sets osname=svr4.0, osvers=3.0, archname='3441-svr4.0'
  case "$myuname" in
! *3441*|*4400*|*4400*isapci)
!     # MP-RAS has a version of usleep, but it doesn't work properly.
!     # Tell Configure it is undefined and let Time::HiRes work it out.
!     # See ...ext/Time/HiRes/hints/svr4.pl for more details.
!     # Geoffrey Rommel, 2003-05-09.
!     d_usleep=undef
      # With the NCR High Performance C Compiler R3.0c, miniperl fails
      # t/op/regexp.t test 461 unless we compile with optimizie=-g.
      # The whole O/S is being phased out, so more detailed probing

$ diff...
*** perl-5.8.0/ext/Time/HiRes/HiRes.xs  Wed Jun 12 09:22:01 2002
--- perl-5.8.0MOD/ext/Time/HiRes/HiRes.xs       Tue May 13 16:33:04 2003
***************
*** 292,301 ****
--- 292,318 ----
  #define HAS_USLEEP
  #define usleep hrt_usleep  /* could conflict with ncurses for static
build */

+ #if defined(IS_MP_RAS)
+   /* usleep does not work properly, so we need to use select(),
+   ** but if the value passed to select() is less than 1 second,
+   ** the sleep may actually be shorter than requested (say,
+   ** .2 sec instead of .8 sec).  For this reason, we have to pass
+   ** the full number of seconds to select().
+   ** Geoffrey Rommel, 2003-05-13.  */
  void
  hrt_usleep(unsigned long usec)
  {
      struct timeval tv;
+     tv.tv_sec = (long) usec / 1E6;
+     tv.tv_usec = usec - (tv.tv_sec * 1E6);
+     select(0, (Select_fd_set_t)NULL, (Select_fd_set_t)NULL,
+               (Select_fd_set_t)NULL, &tv);
+ }
+ #else
+ void
+ hrt_usleep(unsigned long usec)
+ {
+     struct timeval tv;
      tv.tv_sec = 0;
      tv.tv_usec = usec;
      select(0, (Select_fd_set_t)NULL, (Select_fd_set_t)NULL,
***************
*** 303,309 ****
--- 320,328 ----
  }
  #endif
  #endif
+ #endif

+
  #if !defined(HAS_USLEEP) && defined(WIN32)
  #define HAS_USLEEP
  #define usleep hrt_usleep  /* could conflict with ncurses for static
build */
***************
*** 585,591 ****
--- 604,621 ----
        struct timeval Ta, Tb;
        CODE:
        gettimeofday(&Ta, NULL);
+ #if defined(IS_MP_RAS)
+         /* MP-RAS: Avoid the contortion below.  WGR, 2003-05-13. */
        if (items > 0) {
+           if (useconds < 0.0) {
+               croak("Time::HiRes::usleep(%"NVgf"): negative time not
invented yet", useconds);
+           } else {
+              usleep((U32)useconds);
+           }
+       } else
+           PerlProc_pause();
+ #else
+       if (items > 0) {
            if (useconds > 1E6) {
                IV seconds = (IV) (useconds / 1E6);
                /* If usleep() has been implemented using setitimer()
***************
*** 600,605 ****
--- 630,636 ----
            usleep((U32)useconds);
        } else
            PerlProc_pause();
+ #endif
        gettimeofday(&Tb, NULL);
  #if 0
        printf("[%ld %ld] [%ld %ld]\n", Tb.tv_sec, Tb.tv_usec, Ta.tv_sec,
Ta.tv_usec);
***************
*** 615,623 ****
--- 646,665 ----
        struct timeval Ta, Tb;
        CODE:
        gettimeofday(&Ta, NULL);
+ #if defined(IS_MP_RAS)
        if (items > 0) {
            NV seconds  = SvNV(ST(0));
            if (seconds >= 0.0) {
+                UV useconds = 1E6 * seconds;
+                usleep(useconds);
+           } else
+               croak("Time::HiRes::sleep(%"NVgf"): negative time not
invented yet", seconds);
+       } else
+           PerlProc_pause();
+ #else
+       if (items > 0) {
+           NV seconds  = SvNV(ST(0));
+           if (seconds >= 0.0) {
                 UV useconds = (UV)(1E6 * (seconds - (UV)seconds));
                 if (seconds >= 1.0)
                     sleep((U32)seconds);
***************
*** 626,631 ****
--- 668,674 ----
                croak("Time::HiRes::sleep(%"NVgf"): negative time not
invented yet", seconds);
        } else
            PerlProc_pause();
+ #endif
        gettimeofday(&Tb, NULL);
  #if 0
        printf("[%ld %ld] [%ld %ld]\n", Tb.tv_sec, Tb.tv_usec, Ta.tv_sec,
Ta.tv_usec);

###########NOTE: The following file is new.

$ diff -rc /dev/null perl-5.8.0MOD/ext/Time/HiRes/hints/svr4.pl
*** /tmp/da0071J        Wed May 14 10:34:45 2003
--- perl-5.8.0MOD/ext/Time/HiRes/hints/svr4.pl  Tue May 13 16:33:32 2003
***************
*** 0 ****
--- 1,14 ----
+ # "svr4" -- actually for NCR MP-RAS 4.0 3.0 and higher
+ #
+ # MP-RAS has a version of usleep in the "c89" library, but it doesn't
+ # work properly.  ualarm, however, is okay.  For some reason, Configure
+ # doesn't find libc89 when building the base perl, but we don't
+ # really need it except for these functions.  Hence, in this hints
+ # file, we (1) turn on a precompiler flag that says this is
+ # MP-RAS -- this will use the true ualarm and build a usleep based
+ # on select() -- and (2) tell make to include libc89.  Whew!...
+ # Geoffrey Rommel, 2003-05-13.
+ #
+ $self->{DEFINE} = ' -DIS_MP_RAS';
+ $self->{LIBS} = ['-lc89'];
+



Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About