bug-gnu-utils
[Top][All Lists]
Advanced

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

PATCH: bc 1.06: "make timetest" fails with undefined CLOCKS_PER_SEC


From: Perry Hutchison
Subject: PATCH: bc 1.06: "make timetest" fails with undefined CLOCKS_PER_SEC
Date: Sat, 24 Nov 01 23:10:17 PST

> GNU bc 1.06
> ...
> testmul.c:19: `CLOCKS_PER_SEC' undeclared here (not in a function)
> testmul.c:153: `CLOCKS_PER_SEC' undeclared (first use this function)
> ...
> "uname -a" reports "SunOS pluto 4.1.1_U1 8 sun3" and "gcc --version"
> reports "2.7.2"

The following appears to fix it, and also corrects some type punning
between "int" and "clock_t", the latter being equivalent to "long" on
this system.  (Granted "int" and "long" are often the same size, so the
mistyping is considerably less serious in practice than the undefined
symbol.)  I suspect the CLOCKS_PER_SEC fix really ought to be handled
via configure, but I don't know how to go about doing that.

*** lib/testmul.c.orig  Thu Aug 31 08:57:43 2000
--- lib/testmul.c       Sat Nov 24 21:46:17 2001
***************
*** 9,14 ****
--- 9,20 ----
  #include <varargs.h>
  #endif
  
+ #ifndef       CLOCKS_PER_SEC
+ /* These are correct for sun3-sunos4.1.1_U1 */
+ #define       CLOCKS_PER_SEC  1000000L
+ clock_t clock();
+ #endif        /* CLOCKS_PER_SEC */
+ 
  /* from number.c ... */
  extern int mul_base_digits;
  /* extern int mul_small_digits; */
***************
*** 16,22 ****
  
  /* global variables */
  int test_n = 1000;
! int test_time = 30 * CLOCKS_PER_SEC;  /* 30 seconds */ 
  
  /* Other things for number.c. */
  int std_only;
--- 22,28 ----
  
  /* global variables */
  int test_n = 1000;
! clock_t test_time = 30 * CLOCKS_PER_SEC;  /* 30 seconds */ 
  
  /* Other things for number.c. */
  int std_only;
***************
*** 100,110 ****
  
  /* Time stuff !!! */
  
! int
  timeit ( bc_num a, bc_num b, int *n)
  {
!   clock_t first;
!   int i, res;
    bc_num c;
  
    bc_init_num (&c);
--- 106,116 ----
  
  /* Time stuff !!! */
  
! clock_t
  timeit ( bc_num a, bc_num b, int *n)
  {
!   clock_t first, res;
!   int i;
    bc_num c;
  
    bc_init_num (&c);
***************
*** 114,120 ****
      for (i=0; i<test_n; i++)
        bc_multiply(a,b,&c,0);
      *n += test_n;
!      res = (int) (clock() - first);
    } while (res < test_time);
    return res;
  }
--- 120,126 ----
      for (i=0; i<test_n; i++)
        bc_multiply(a,b,&c,0);
      *n += test_n;
!      res = (clock() - first);
    } while (res < test_time);
    return res;
  }




reply via email to

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