This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Avoid "enum conversion when passing argument 1 of 'getrusage' is invalid in C++" warning
- From: Pedro Alves <palves at sourceware dot org>
- To: bfd-cvs at sourceware dot org, gdb-cvs at sourceware dot org
- Date: 28 Nov 2015 16:41:59 -0000
- Subject: [binutils-gdb] Avoid "enum conversion when passing argument 1 of 'getrusage' is invalid in C++" warning
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6a8796db3691b9a53dc5475eaec5388bc1af115d
commit 6a8796db3691b9a53dc5475eaec5388bc1af115d
Author: Uros Bizjak <ubizjak@gmail.com>
Date: Sat Nov 28 16:39:29 2015 +0000
Avoid "enum conversion when passing argument 1 of 'getrusage' is invalid in C++" warning
* getruntime.c (RUSAGE_SELF): Define if not already defined.
(get_runtime): Use RUSAGE_SELF as argument 1 of getrusage call.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225614 138bc75d-0d04-0410-961f-82ee72b054a4
Diff:
---
libiberty/ChangeLog | 6 +++---
libiberty/getruntime.c | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 1341206..65abd11 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -52,10 +52,10 @@
* configure: Regenerated.
-2015-07-08 Uros Bizjak <ubizjak@gmail.com>
+2015-07-09 Uros Bizjak <ubizjak@gmail.com>
- * getruntime.c (get_run_time) [__USE_GNU]: Use RUSAGE_SELF as
- argument 1 of getrusage call.
+ * getruntime.c (RUSAGE_SELF): Define if not already defined.
+ (get_runtime): Use RUSAGE_SELF as argument 1 of getrusage call.
2015-06-01 Jason Merrill <jason@redhat.com>
diff --git a/libiberty/getruntime.c b/libiberty/getruntime.c
index 9d5eed1..1e0daad 100644
--- a/libiberty/getruntime.c
+++ b/libiberty/getruntime.c
@@ -65,6 +65,10 @@ Boston, MA 02110-1301, 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
@@ -95,11 +99,7 @@ get_run_time (void)
#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
struct rusage rusage;
-#if defined __USE_GNU && !defined __cplusplus
getrusage (RUSAGE_SELF, &rusage);
-#else
- getrusage (0, &rusage);
-#endif
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 */