getrusage patch for 2.1.45 (Solaris 2.5.1)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

getrusage patch for 2.1.45 (Solaris 2.5.1)

Albert Chin-69
Solaris 2.5.1 has getrusage but no prototype. This patch adds a
prototype when one is not available. Against 2.1.45.

--
albert chin ([hidden email])

-- snip snip
--- aclocal.m4 2002/11/20 16:56:47 1.75
+++ aclocal.m4 2003/03/21 14:58:50
@@ -696,7 +696,7 @@ fi
 AC_DEFUN([OCTAVE_PROG_SED],
 [AC_MSG_CHECKING([for a sed that does not truncate output])
 if test -z "$SED"; then
-AC_CACHE_VAL(ac_cv_path_sed,
+AC_CACHE_VAL(octave_cv_path_sed,
 [# Loop through the user's path and test for sed and gsed.
 # Then use that list of sed's as ones to test for truncation.
 _AS_PATH_WALK([$PATH],
--- src/DLD-FUNCTIONS/getrusage.cc 2002/12/20 22:43:55 1.6
+++ src/DLD-FUNCTIONS/getrusage.cc 2003/03/21 14:58:54
@@ -34,6 +34,10 @@ Software Foundation, 59 Temple Place - S
 #include <sys/resource.h>
 #endif
 
+#if defined(HAVE_GETRUSAGE) && !defined(HAVE_GETRUSAGE_PROTO)
+extern "C" int getrusage (int, struct rusage *);
+#endif
+
 #if defined (HAVE_TIMES) && defined (HAVE_SYS_TIMES_H)
 
 #if defined (HAVE_SYS_PARAM_H)
--- configure.in.orig Fri Mar 21 09:04:47 2003
+++ configure.in Fri Mar 21 09:05:32 2003
@@ -1154,7 +1154,36 @@
 
 ### A system dependent kluge or two.
 
-AC_CHECK_FUNCS(getrusage times)
+AC_LANG_PUSH(C++)
+AC_MSG_CHECKING([for getrusage])
+AC_TRY_LINK([#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>],[
+struct rusage ru;
+
+getrusage (0, &ru);],[
+  AC_MSG_RESULT([yes])
+  AC_DEFINE(HAVE_GETRUSAGE, 1,
+  [Define to 1 if you have the `getrusage' function.])
+  AC_DEFINE(HAVE_GETRUSAGE_PROTO, 1,
+  [Define to 1 if you have the prototype for the `getrusage' function.])],[
+  AC_MSG_RESULT([no])
+  AC_MSG_CHECKING([for getrusage with custom prototype])
+  AC_TRY_LINK([#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+extern "C" int getrusage (int, struct rusage *);],[
+struct rusage ru;
+
+getrusage (0, &ru);],[
+    AC_MSG_RESULT([yes])
+    AC_DEFINE(HAVE_GETRUSAGE, 1,
+    [Define to 1 if you have the `getrusage' function.])],[
+    AC_MSG_RESULT([no])])])
+AC_LANG_POP(C++)
+
+AC_CHECK_FUNCS(times)
 case "$canonical_host_type" in
   *-*-cygwin*)
     AC_DEFINE(RUSAGE_TIMES_ONLY, 1, [Define if your struct rusage only has time information.])