]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libiberty/getruntime.c
Change int_range<2> to infinite precision.
[thirdparty/gcc.git] / libiberty / getruntime.c
index 9301deb773e7f8933212c7a719a4fa26cc002874..0ad4244c7483a05bf20bfc47db11db0786d9a7e6 100644 (file)
@@ -1,5 +1,5 @@
 /* Return time used so far, in microseconds.
-   Copyright (C) 1994, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1994-2024 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
@@ -14,14 +14,18 @@ Library General Public License for more details.
 
 You should have received a copy of the GNU Library General Public
 License along with libiberty; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #include "config.h"
 
 #include "ansidecl.h"
 #include "libiberty.h"
 
+/* On some systems (such as WindISS), you must include <sys/types.h>
+   to get the definition of "time_t" before you include <time.h>.  */
+#include <sys/types.h>
+
 /* There are several ways to get elapsed execution time; unfortunately no
    single way is available for all host systems, nor are there reliable
    ways to find out which way is correct for a given host. */
@@ -61,6 +65,10 @@ Boston, MA 02111-1307, USA.  */
 #define CLOCKS_PER_SEC 1
 #endif
 
+#ifndef RUSAGE_SELF
+#define RUSAGE_SELF 0
+#endif
+
 #ifdef _SC_CLK_TCK
 #define GNU_HZ  sysconf(_SC_CLK_TCK)
 #else
@@ -86,12 +94,12 @@ process started.
 */
 
 long
-get_run_time ()
+get_run_time (void)
 {
 #if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
   struct rusage rusage;
 
-  getrusage (0, &rusage);
+  getrusage (RUSAGE_SELF, &rusage);
   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
          + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
 #else /* ! HAVE_GETRUSAGE */