* configure.ac (AC_CHECK_HEADERS): Added sys/mman.h, sys/resource.h.
authortwisti <none@none>
Mon, 7 May 2007 13:45:19 +0000 (13:45 +0000)
committertwisti <none@none>
Mon, 7 May 2007 13:45:19 +0000 (13:45 +0000)
(AC_CHECK_FUNCS): Added getrusage, mprotect.

* src/vmcore/statistics.c [HAVE_SYS_TIME_H] (sys/time.h): Include
conditionally.
[HAVE_SYS_RESOURCE_H] (sys/resource.h): Likewise.
(getcputime) [!HAVE_GETRUSAGE]: Return 0.

configure.ac
src/vmcore/statistics.c

index eca8403b3d9ba31392f1fd1ea6f854056adda1a8..94dafc260aeba4f16d2c841a3ebd14845d8d5123 100644 (file)
@@ -22,7 +22,7 @@ dnl along with this program; if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 dnl 02110-1301, USA.
 dnl 
-dnl $Id: configure.ac 7799 2007-04-23 23:03:31Z twisti $
+dnl $Id: configure.ac 7879 2007-05-07 13:45:19Z twisti $
 
 dnl Process this file with autoconf to produce a configure script.
 
@@ -212,10 +212,14 @@ AM_PROG_MKDIR_P
 dnl Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
+
+dnl keep them alpha-sorted!
 AC_CHECK_HEADERS([fcntl.h])
-AC_CHECK_HEADERS([sys/time.h])
 AC_CHECK_HEADERS([unistd.h])
 AC_CHECK_HEADERS([sys/ioctl.h])
+AC_CHECK_HEADERS([sys/mman.h])
+AC_CHECK_HEADERS([sys/resource.h])
+AC_CHECK_HEADERS([sys/time.h])
 
 dnl this is for fdlibm
 AC_CHECK_HEADERS([stdint.h])
@@ -241,10 +245,18 @@ AC_PROG_GCC_TRADITIONAL
 AC_TYPE_SIGNAL
 AC_FUNC_MEMCMP
 AC_FUNC_MMAP
-AC_CHECK_FUNCS([calloc mmap getpagesize free])
-AC_CHECK_FUNCS([getcwd gettimeofday])
-AC_CHECK_FUNCS([scandir])
+
+dnl keep them alpha-sorted!
+AC_CHECK_FUNCS([calloc])
+AC_CHECK_FUNCS([getpagesize])
+AC_CHECK_FUNCS([free])
+AC_CHECK_FUNCS([getcwd])
+AC_CHECK_FUNCS([gettimeofday])
+AC_CHECK_FUNCS([getrusage])
 AC_CHECK_FUNCS([isnan])
+AC_CHECK_FUNCS([mmap])
+AC_CHECK_FUNCS([mprotect])
+AC_CHECK_FUNCS([scandir])
 
 dnl Checks for libraries.
 
index 4cf87f3a2974f369f5e8f5f394e7f2d1603aeccd..1f84d2608a35b85776ad686d1330411aadcbafe3 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: statistics.c 7643 2007-04-03 11:35:40Z twisti $
+   $Id: statistics.c 7879 2007-05-07 13:45:19Z twisti $
 
 */
 
 #include "config.h"
 
 #include <string.h> 
-#include <sys/time.h>
-#include <sys/resource.h>
+
+#if defined(HAVE_SYS_TIME_H)
+# include <sys/time.h>
+#endif
+
+#if defined(HAVE_SYS_RESOURCE_H)
+# include <sys/resource.h>
+#endif
 
 #include "vm/types.h"
 
@@ -265,14 +271,21 @@ void jniinvokation(void)
 
 s8 getcputime(void)
 {
+#if defined(HAVE_GETRUSAGE)
        struct rusage ru;
        int sec, usec;
 
        getrusage(RUSAGE_SELF, &ru);
-       sec = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec;
+
+       sec  = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec;
        usec = ru.ru_utime.tv_usec + ru.ru_stime.tv_usec;
 
        return sec * 1000000 + usec;
+#else
+       /* If we don't have getrusage, simply return 0. */
+
+       return 0;
+#endif
 }