projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git]
/
libiberty
/
getruntime.c
diff --git
a/libiberty/getruntime.c
b/libiberty/getruntime.c
index 6e70773bd94bae14cc931c9f223f9a88046ae151..f9f7841a743909405dcc00aaa906f963f4e98cba 100644
(file)
--- a/
libiberty/getruntime.c
+++ b/
libiberty/getruntime.c
@@
-1,5
+1,5
@@
/* Return time used so far, in microseconds.
/* Return time used so far, in microseconds.
- Copyright (C) 1994
, 1999
Free Software Foundation, Inc.
+ Copyright (C) 1994
-2020
Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
@@
-14,22
+14,36
@@
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
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., 5
9 Temple Place - Suite 330
,
-Boston, MA 0211
1-1307
, USA. */
+not, write to the Free Software Foundation, Inc., 5
1 Franklin Street - Fifth Floor
,
+Boston, MA 0211
0-1301
, USA. */
#include "config.h"
#include "ansidecl.h"
#include "libiberty.h"
#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. */
/* 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. */
-#include <time.h>
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# ifdef HAVE_TIME_H
+# include <time.h>
+# endif
+# endif
+#endif
-#ifdef HAVE_GETRUSAGE
-#include <sys/time.h>
+#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
#include <sys/resource.h>
#endif
#include <sys/resource.h>
#endif
@@
-51,6
+65,10
@@
Boston, MA 02111-1307, USA. */
#define CLOCKS_PER_SEC 1
#endif
#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
#ifdef _SC_CLK_TCK
#define GNU_HZ sysconf(_SC_CLK_TCK)
#else
@@
-63,13
+81,25
@@
Boston, MA 02111-1307, USA. */
#endif
#endif
#endif
#endif
+/*
+
+@deftypefn Replacement long get_run_time (void)
+
+Returns the time used so far, in microseconds. If possible, this is
+the time used by this process, else it is the elapsed time since the
+process started.
+
+@end deftypefn
+
+*/
+
long
long
-get_run_time ()
+get_run_time (
void
)
{
{
-#if
def HAVE_GETRUSAGE
+#if
defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
struct rusage rusage;
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 */
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 */
This page took
0.034531 seconds
and
4
git commands to generate.