From add3f049962534b7d8412517b69d53a3f411c5de Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 19 Jun 2011 11:22:16 -0700 Subject: [PATCH] * lib/unistd.in.h, m4/getloadavg.m4: Merge from gnulib. --- ChangeLog | 4 +++ lib/unistd.in.h | 2 ++ m4/getloadavg.m4 | 64 ++++++++++++++++++++++++------------------------ 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8e48ab2c1c..e4a4754f86f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-06-19 Paul Eggert + + * lib/unistd.in.h, m4/getloadavg.m4: Merge from gnulib. + 2011-06-17 Glenn Morris * configure.in: Restore the behavior of checking crt-dir only diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 261659bc167..fdf0fca54e9 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -1062,6 +1062,7 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " specification . */ # if @REPLACE_PREAD@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pread # define pread rpl_pread # endif _GL_FUNCDECL_RPL (pread, ssize_t, @@ -1096,6 +1097,7 @@ _GL_WARN_ON_USE (pread, "pread is unportable - " . */ # if @REPLACE_PWRITE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef pwrite # define pwrite rpl_pwrite # endif _GL_FUNCDECL_RPL (pwrite, ssize_t, diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4 index 967dfd797fb..b75e05fa056 100644 --- a/m4/getloadavg.m4 +++ b/m4/getloadavg.m4 @@ -26,34 +26,51 @@ gl_save_LIBS=$LIBS # NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7. HAVE_GETLOADAVG=1 AC_CHECK_FUNC([getloadavg], [], - [gl_have_func=no + [gl_func_getloadavg_done=no # Some systems with -lutil have (and need) -lkvm as well, some do not. # On Solaris, -lkvm requires nlist from -lelf, so check that first # to get the right answer into the cache. # For kstat on solaris, we need to test for libelf and libkvm to force the # definition of SVR4 below. - if test $gl_have_func = no; then + if test $gl_func_getloadavg_done = no; then AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"]) AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"]) # Check for the 4.4BSD definition of getloadavg. AC_CHECK_LIB([util], [getloadavg], - [LIBS="-lutil $LIBS" gl_have_func=yes]) + [LIBS="-lutil $LIBS" gl_func_getloadavg_done=yes]) fi - if test $gl_have_func = no; then + if test $gl_func_getloadavg_done = no; then # There is a commonly available library for RS/6000 AIX. # Since it is not a standard part of AIX, it might be installed locally. gl_getloadavg_LIBS=$LIBS LIBS="-L/usr/local/lib $LIBS" AC_CHECK_LIB([getloadavg], [getloadavg], - [LIBS="-lgetloadavg $LIBS" gl_have_func=yes], + [LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes], [LIBS=$gl_getloadavg_LIBS]) fi # Set up the replacement function if necessary. - if test $gl_have_func = no; then + if test $gl_func_getloadavg_done = no; then HAVE_GETLOADAVG=0 + + # Solaris has libkstat which does not require root. + AC_CHECK_LIB([kstat], [kstat_open]) + test $ac_cv_lib_kstat_kstat_open = yes && gl_func_getloadavg_done=yes + + # AIX has libperfstat which does not require root + if test $gl_func_getloadavg_done = no; then + AC_CHECK_LIB([perfstat], [perfstat_cpu_total]) + test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_func_getloadavg_done=yes + fi + + if test $gl_func_getloadavg_done = no; then + AC_CHECK_HEADER([sys/dg_sys_info.h], + [gl_func_getloadavg_done=yes + AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with .]) + AC_CHECK_LIB([dgc], [dg_sys_info])]) + fi fi]) if test "x$gl_save_LIBS" = x; then @@ -88,52 +105,35 @@ AC_DEFUN([gl_PREREQ_GETLOADAVG], [ # Figure out what our getloadavg.c needs. -# Solaris has libkstat which does not require root. -AC_CHECK_LIB([kstat], [kstat_open]) -test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes - # On HPUX9, an unprivileged user can get load averages this way. -if test $gl_have_func = no; then - AC_CHECK_FUNCS([pstat_getdynamic], [gl_have_func=yes]) -fi - -# AIX has libperfstat which does not require root -if test $gl_have_func = no; then - AC_CHECK_LIB([perfstat], [perfstat_cpu_total]) - test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes -fi - -if test $gl_have_func = no; then - AC_CHECK_HEADER([sys/dg_sys_info.h], - [gl_have_func=yes - AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with .]) - AC_CHECK_LIB([dgc], [dg_sys_info])]) +if test $gl_func_getloadavg_done = no; then + AC_CHECK_FUNCS([pstat_getdynamic], [gl_func_getloadavg_done=yes]) fi # We cannot check for , because Solaris 2 does not use dwarf (it # uses stabs), but it is still SVR4. We cannot check for because # Irix 4.0.5F has the header but not the library. -if test $gl_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \ +if test $gl_func_getloadavg_done = no && test "$ac_cv_lib_elf_elf_begin" = yes \ && test "$ac_cv_lib_kvm_kvm_open" = yes; then - gl_have_func=yes + gl_func_getloadavg_done=yes AC_DEFINE([SVR4], [1], [Define to 1 on System V Release 4.]) fi -if test $gl_have_func = no; then +if test $gl_func_getloadavg_done = no; then AC_CHECK_HEADER([inq_stats/cpustats.h], - [gl_have_func=yes + [gl_func_getloadavg_done=yes AC_DEFINE([UMAX], [1], [Define to 1 for Encore UMAX.]) AC_DEFINE([UMAX4_3], [1], [Define to 1 for Encore UMAX 4.3 that has instead of .])]) fi -if test $gl_have_func = no; then +if test $gl_func_getloadavg_done = no; then AC_CHECK_HEADER([sys/cpustats.h], - [gl_have_func=yes; AC_DEFINE([UMAX])]) + [gl_func_getloadavg_done=yes; AC_DEFINE([UMAX])]) fi -if test $gl_have_func = no; then +if test $gl_func_getloadavg_done = no; then AC_CHECK_HEADERS([mach/mach.h]) fi -- 2.39.2