bug-bison
[Top][All Lists]
Advanced

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

Re: Bison 1.50: SunOS 4.1.4, Problems and Hack for lib/timevar.c


From: Paul Eggert
Subject: Re: Bison 1.50: SunOS 4.1.4, Problems and Hack for lib/timevar.c
Date: Sat, 12 Oct 2002 23:08:46 -0700 (PDT)

> From: Peter Klein <address@hidden>
> Date: Sun, 13 Oct 2002 00:14:28 +0200
> 
> I have installed the bison 1.50 on my stupid old SunOS 4.1.4 box.
> Unfortunately it won't compile for the very first time.
> I have hacked the file lib/timevar.c a little bit, and now it's working.

Thanks for your bug report.  Your file embodied this patch:

        --- old/timevar.c       2002-08-01 11:12:11.000000000 -0700
        +++ new/timevar.c       2002-10-12 20:58:52.040451764 -0700
        @@ -41,9 +41,11 @@
         # include <sys/times.h>
         #endif
         #ifdef HAVE_SYS_RESOURCE_H
        +#include <sys/time.h>
         #include <sys/resource.h>
         #endif

        +/*
         #ifndef HAVE_CLOCK_T
         typedef int clock_t;
         #endif
        @@ -57,6 +59,7 @@
           clock_t tms_cstime;
         };
         #endif
        +*/

         #if defined HAVE_DECL_GETRUSAGE && !HAVE_DECL_GETRUSAGE
         extern int getrusage PARAMS ((int, struct rusage *));

but this obviously won't work on other kinds of platforms.  I have
installed the following patch in an attempt to fix your bug more
systematically, and also to sync with GCC and to fix the copyright
notices.

Unfortunately you can't use this patch unless you have the latest
versions of Automake and Autoconf to rebuild the patched Bison.
However, the next version of Bison will contain this patch all nicely
Automake/Autoconfed, so you should be able to try it then.  (It will
be helpful if you do try it then, since I don't have a SunOS 4.1.x
host to play with any more.)

2002-10-12  Paul Eggert  <address@hidden>

        * lib/timevar.c [! IN_GCC && HAVE_SYS_TIME_H]: Include <sys/time.h>.
        * m4/timevar.m4 (BISON_PREREQ_TIMEVAR): Check for <sys/time.h>.
        Include <sys/time.h> when checking for clock_t and struct tms.
        Use same include order as source.
        This is for the SunOS 4.1.4 porting bug reported by Peter Klein in
        <http://mail.gnu.org/pipermail/bug-bison/2002-October/001674.html>.
        
        * lib/timevar.c: Update copyright date and clarify comments.
        (get_time) [IN_GCC]: Keep the GCC version for reference.
        
        * lib/timevar.c, lib/timevar.h, lib/timevar.def: Import
        GCC version as of today, then merge Bison's changes.
        Change "GCC" to "Bison" in copyright notice.  timevar.def's
        author is Akim, so change that too.

Index: lib/timevar.c
===================================================================
RCS file: /cvsroot/bison/bison/lib/timevar.c,v
retrieving revision 1.2
diff -p -u -r1.2 timevar.c
--- lib/timevar.c       1 Aug 2002 18:12:11 -0000       1.2
+++ lib/timevar.c       13 Oct 2002 05:51:01 -0000
@@ -1,27 +1,26 @@
 /* Timing variables for measuring compiler performance.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
    Contributed by Alex Samuel <address@hidden>
 
-This file is part of GCC.
+This file is part of Bison, the GNU Compiler Compiler.
 
-GCC is free software; you can redistribute it and/or modify it under
+Bison is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
 Software Foundation; either version 2, or (at your option) any later
 version.
 
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+Bison is distributed in the hope that it will be useful, but WITHOUT ANY
 WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
+along with Bison; see the file COPYING.  If not, write to the Free
 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
 #if IN_GCC
 
-/* These are the original includes --akim.  */
 #include "config.h"
 #include "system.h"
 #include "intl.h"
@@ -29,9 +28,14 @@ Software Foundation, 59 Temple Place - S
 
 #else
 
-/* These are my replacements by hand --akim.
-   There is another change below, flag with IN_GCC.  */
+/* This source file is taken from the GCC source code, with slight
+   modifications that are under control of the IN_GCC preprocessor
+   variable.  The !IN_GCC part of this file is specific to Bison.  */
+   
 # include "../src/system.h"
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# endif
 int time_report = 0;
 
 #endif
@@ -129,7 +133,7 @@ static float clocks_to_msec;
 
 /* See timevar.h for an explanation of timing variables.  */
 
-/* This macro evaluates to non-zero if timing variables are enabled.  */
+/* This macro evaluates to nonzero if timing variables are enabled.  */
 #define TIMEVAR_ENABLE (time_report)
 
 /* A timing variable.  */
@@ -191,7 +195,7 @@ static void timevar_accumulate
 
 /* Fill the current times into TIME.  The definition of this function
    also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
-   HAVA_WALL_TIME macros.  */
+   HAVE_WALL_TIME macros.  */
 
 static void
 get_time (now)
@@ -207,18 +211,24 @@ get_time (now)
   {
 #ifdef USE_TIMES
     struct tms tms;
-    now->wall = times (&tms)   * ticks_to_msec;
+    now->wall = times (&tms)  * ticks_to_msec;
+#if IN_GCC
+    now->user = tms.tms_utime * ticks_to_msec;
+    now->sys  = tms.tms_stime * ticks_to_msec;
+#else
     now->user = (tms.tms_utime + tms.tms_cutime) * ticks_to_msec;
     now->sys  = (tms.tms_stime + tms.tms_cstime) * ticks_to_msec;
 #endif
+#endif
 #ifdef USE_GETRUSAGE
     struct rusage rusage;
+#if IN_GCC
     getrusage (RUSAGE_SELF, &rusage);
+#else
+    getrusage (RUSAGE_CHILDREN, &rusage);
+#endif
     now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
     now->sys  = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
-    getrusage (RUSAGE_CHILDREN, &rusage);
-    now->user += rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
-    now->sys  += rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
 #endif
 #ifdef USE_CLOCK
     now->user = clock () * clocks_to_msec;
@@ -230,9 +240,9 @@ get_time (now)
 
 static void
 timevar_accumulate (timer, start_time, stop_time)
-  struct timevar_time_def *timer;
-  struct timevar_time_def *start_time;
-  struct timevar_time_def *stop_time;
+     struct timevar_time_def *timer;
+     struct timevar_time_def *start_time;
+     struct timevar_time_def *stop_time;
 {
   timer->user += stop_time->user - start_time->user;
   timer->sys += stop_time->sys - start_time->sys;
@@ -551,6 +561,6 @@ print_time (str, total)
   fprintf (stderr,
           _("time in %s: %ld.%06ld (%ld%%)\n"),
           str, total / 1000000, total % 1000000,
-          all_time == 0 ? 0
-          : (long) (((100.0 * (double) total) / (double) all_time) + .5));
+          all_time == 0 ? 0
+          : (long) (((100.0 * (double) total) / (double) all_time) + .5));
 }
Index: lib/timevar.def
===================================================================
RCS file: /cvsroot/bison/bison/lib/timevar.def,v
retrieving revision 1.1
diff -p -u -r1.1 timevar.def
--- lib/timevar.def     31 Jul 2002 19:52:13 -0000      1.1
+++ lib/timevar.def     13 Oct 2002 05:51:01 -0000
@@ -1,22 +1,22 @@
 /* This file contains the definitions for timing variables used to -*- C -*-
    measure run-time performance of the compiler.
-   Copyright (C) 2000 Free Software Foundation, Inc.
-   Contributed by Alex Samuel <address@hidden>
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   Contributed by Akim Demaille <address@hidden>.
 
-   This file is part of GCC.
+   This file is part of Bison, the GNU Compiler Compiler.
 
-   GCC is free software; you can redistribute it and/or modify
+   Bison is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
-   GCC is distributed in the hope that it will be useful,
+   Bison is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with GCC; see the file COPYING.  If not, write to
+   along with Bison; see the file COPYING.  If not, write to
    the Free Software Foundation, 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
Index: lib/timevar.h
===================================================================
RCS file: /cvsroot/bison/bison/lib/timevar.h,v
retrieving revision 1.1
diff -p -u -r1.1 timevar.h
--- lib/timevar.h       31 Jul 2002 19:52:13 -0000      1.1
+++ lib/timevar.h       13 Oct 2002 05:51:01 -0000
@@ -2,20 +2,20 @@
    Copyright (C) 2000 Free Software Foundation, Inc.
    Contributed by Alex Samuel <address@hidden>
 
-   This file is part of GCC.
+   This file is part of Bison, the GNU Compiler Compiler.
 
-   GCC is free software; you can redistribute it and/or modify it
+   Bison is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
-   GCC is distributed in the hope that it will be useful, but WITHOUT
+   Bison is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
    License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with GCC; see the file COPYING.  If not, write to the Free
+   along with Bison; see the file COPYING.  If not, write to the Free
    Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA.  */
 
@@ -41,9 +41,9 @@
 
      - As a standalone timer, using timevar_start and timevar_stop.
        All time elapsed between the two calls is attributed to the
-       variable.  
+       variable.
 */
-   
+
 /* This structure stores the various varieties of time that can be
    measured.  Times are stored in seconds.  The time may be an
    absolute time or a time difference; in the former case, the time
@@ -67,7 +67,7 @@ struct timevar_time_def
    the contents of timevar.def.  */
 
 #define DEFTIMEVAR(identifier__, name__) \
-    identifier__, 
+    identifier__,
 typedef enum
 {
 #include "timevar.def"
Index: m4/timevar.m4
===================================================================
RCS file: /cvsroot/bison/bison/m4/timevar.m4,v
retrieving revision 1.1
diff -p -u -r1.1 timevar.m4
--- m4/timevar.m4       31 Jul 2002 19:52:13 -0000      1.1
+++ m4/timevar.m4       13 Oct 2002 05:51:01 -0000
@@ -1,5 +1,5 @@
 # -*-Autoconf-*-
-# Checks required to run `stage', a nonportable memory/time tracker.
+# Checks required to run `timevar', a nonportable memory/time tracker.
 #
 # Copyright (C) 2002 Free Software Foundation, Inc.
 #
@@ -21,27 +21,33 @@
 # serial 1
 
 AC_DEFUN([BISON_PREREQ_TIMEVAR],
-[AC_CHECK_HEADERS([sys/resource.h sys/times.h])
+[AC_CHECK_HEADERS([sys/resource.h sys/time.h sys/times.h])
 
 AC_CHECK_FUNCS([times])
 
 AC_CHECK_DECLS([getrusage, times, clock, sysconf], [], [],
 [$ac_includes_default
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
 #endif
 #if HAVE_SYS_TIMES_H
 # include <sys/times.h>
 #endif
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
 ])
 
 AC_CHECK_TYPES([clock_t, struct tms], [], [],
 [$ac_includes_default
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
 #endif
 #if HAVE_SYS_TIMES_H
 # include <sys/times.h>
+#endif
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
 #endif
 ])
 ])




reply via email to

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