[gnu.g++.lib.bug] additional USG support for libg++-1.35.0

ronald@UCDAVIS.EDU (06/01/89)

Here is an additional patch to go along with the patches I posted
previously that allows the use of the timer functions in libg++
on a USG (System V) machine.

--
Ronald Cole               | uucp:     cvms!ronald       voice: +1 916 895 8321
Senior Software Engineer  | internet: csusac!cvms!ronald@ucdavis.edu
CVM Systems               +----------------------------------------------------
	"No sex, please, we're software engineers." - Michael Swaine

------------------------- starts here -----------------------------
diff -rc2 libg++-1.35.0/src/builtin.cc libg++/src/builtin.cc
*** libg++-1.35.0/src/builtin.cc	Sun May  7 05:19:36 1989
--- libg++/src/builtin.cc	Wed May 31 13:36:40 1989
***************
*** 321,334 ****
  // surely OK for these machines...
  
! #if defined(BSD) || defined(vax) || defined(sun)
  
  extern "C" {
  #include <sys/time.h>
  #include <sys/resource.h>
  int   getrusage(int, struct rusage*);
  }
  
  static struct rusage Old_Time;
  static struct rusage New_Time;
  static int    Timer_Set = 0;
  
--- 321,345 ----
  // surely OK for these machines...
  
! #if defined(BSD) || defined(USG) || defined(vax) || defined(sun)
  
  extern "C" {
+ #ifdef USG
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/times.h>
+ #else
  #include <sys/time.h>
  #include <sys/resource.h>
  int   getrusage(int, struct rusage*);
+ #endif
  }
  
+ #ifdef USG
+ static struct tms Old_Time;
+ static struct tms New_Time;
+ #else
  static struct rusage Old_Time;
  static struct rusage New_Time;
+ #endif
  static int    Timer_Set = 0;
  
***************
*** 336,341 ****
--- 347,357 ----
  {
     Timer_Set = 1;
+ #ifdef USG
+    times(&Old_Time);
+    return((double) Old_Time.tms_utime / HZ);
+ #else
     getrusage(RUSAGE_SELF,&Old_Time);        /* set starting process time */
     return(Old_Time.ru_utime.tv_sec + (Old_Time.ru_utime.tv_usec / 1000000.0));
+ #endif
  }
  
***************
*** 353,365 ****
--- 369,393 ----
     else {
      /* get process time */
+ #ifdef USG
+       times(&New_Time);
+ #else
        getrusage(RUSAGE_SELF,&New_Time);
+ #endif
        if (Last_Time == 0.0) {
+ #ifdef USG
+ 	 return((double) (New_Time.tms_utime - Old_Time.tms_utime) / HZ);
+ #else
           return((New_Time.ru_utime.tv_sec - Old_Time.ru_utime.tv_sec) + 
                 ((New_Time.ru_utime.tv_usec - Old_Time.ru_utime.tv_usec) 
                  / 1000000.0));
+ #endif
        }
        else {
+ #ifdef USG
+ 	 return((double) New_Time.tms_utime / HZ - Last_Time);
+ #else
           return((New_Time.ru_utime.tv_sec + 
                  (New_Time.ru_utime.tv_usec / 1000000.0)) - Last_Time);
+ #endif
        }
     }
-------------------------- ends here ------------------------------