From 9502925a798a3af3d40f67a30f30ced94d814f52 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 14 Feb 2011 22:40:12 -0800 Subject: [PATCH] Merge from proposed getloadavg simplifications in gnulib. * configure, lib/Makefile.in, src/config.in: Regenerate. * lib/getloadavg.c, lib/stdlib.in.h, m4/getloadavg.m4: New versions from gnulib. 2011-02-15 Paul Eggert --- ChangeLog | 8 + configure | 500 ++++++++++++++++++++--------------------------- lib/Makefile.in | 2 - lib/getloadavg.c | 46 ----- lib/stdlib.in.h | 10 +- m4/getloadavg.m4 | 137 +++++-------- src/config.in | 14 -- 7 files changed, 282 insertions(+), 435 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52db9f45cd6..c664526fe7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-02-15 Paul Eggert + + Merge from proposed getloadavg simplifications in gnulib. + + * configure, lib/Makefile.in, src/config.in: Regenerate. + * lib/getloadavg.c, lib/stdlib.in.h, m4/getloadavg.m4: New + versions from gnulib. + 2011-02-15 Paul Eggert Merge from gnulib. diff --git a/configure b/configure index 6f7148b0a65..df3d1f72eda 100755 --- a/configure +++ b/configure @@ -816,8 +816,6 @@ GNULIB_DUP2 GNULIB_CLOSE GNULIB_CHOWN GETLOADAVG_LIBS -KMEM_GROUP -NEED_SETGID REPLACE_UNSETENV REPLACE_STRTOD REPLACE_SETENV @@ -1105,6 +1103,9 @@ LDFLAGS LIBS CPPFLAGS CPP +CPPFLAGS +CPP +CPPFLAGS XMKMF' @@ -14468,35 +14469,210 @@ fi # Persuade glibc to declare getloadavg(). -gl_have_func=no # yes means we've found a way to get the load average. - # Make sure getloadavg.c is where it belongs, at configure-time. test -f "$srcdir/$gl_source_base/getloadavg.c" || as_fn_error $? "$srcdir/$gl_source_base/getloadavg.c is missing" "$LINENO" 5 gl_save_LIBS=$LIBS -# Check for getloadavg, but be sure not to touch the cache variable. -(ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg" +ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg" if test "x$ac_cv_func_getloadavg" = xyes; then : - exit 0 + else - exit 1 -fi -) && gl_have_func=yes + gl_have_func=no -# On HPUX9, an unprivileged user can get load averages through this function. -for ac_func in pstat_getdynamic -do : - ac_fn_c_check_func "$LINENO" "pstat_getdynamic" "ac_cv_func_pstat_getdynamic" -if test "x$ac_cv_func_pstat_getdynamic" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PSTAT_GETDYNAMIC 1 + # 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 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_begin in -lelf" >&5 +$as_echo_n "checking for elf_begin in -lelf... " >&6; } +if ${ac_cv_lib_elf_elf_begin+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lelf $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char elf_begin (); +int +main () +{ +return elf_begin (); + ; + return 0; +} _ACEOF - +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_elf_elf_begin=yes +else + ac_cv_lib_elf_elf_begin=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf_begin" >&5 +$as_echo "$ac_cv_lib_elf_elf_begin" >&6; } +if test "x$ac_cv_lib_elf_elf_begin" = xyes; then : + LIBS="-lelf $LIBS" fi -done + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kvm_open in -lkvm" >&5 +$as_echo_n "checking for kvm_open in -lkvm... " >&6; } +if ${ac_cv_lib_kvm_kvm_open+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lkvm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char kvm_open (); +int +main () +{ +return kvm_open (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_kvm_kvm_open=yes +else + ac_cv_lib_kvm_kvm_open=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kvm_kvm_open" >&5 +$as_echo "$ac_cv_lib_kvm_kvm_open" >&6; } +if test "x$ac_cv_lib_kvm_kvm_open" = xyes; then : + LIBS="-lkvm $LIBS" +fi + + # Check for the 4.4BSD definition of getloadavg. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lutil" >&5 +$as_echo_n "checking for getloadavg in -lutil... " >&6; } +if ${ac_cv_lib_util_getloadavg+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lutil $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getloadavg (); +int +main () +{ +return getloadavg (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_util_getloadavg=yes +else + ac_cv_lib_util_getloadavg=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_getloadavg" >&5 +$as_echo "$ac_cv_lib_util_getloadavg" >&6; } +if test "x$ac_cv_lib_util_getloadavg" = xyes; then : + LIBS="-lutil $LIBS" gl_have_func=yes +fi + + fi + + if test $gl_have_func = 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" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lgetloadavg" >&5 +$as_echo_n "checking for getloadavg in -lgetloadavg... " >&6; } +if ${ac_cv_lib_getloadavg_getloadavg+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lgetloadavg $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getloadavg (); +int +main () +{ +return getloadavg (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_getloadavg_getloadavg=yes +else + ac_cv_lib_getloadavg_getloadavg=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_getloadavg_getloadavg" >&5 +$as_echo "$ac_cv_lib_getloadavg_getloadavg" >&6; } +if test "x$ac_cv_lib_getloadavg_getloadavg" = xyes; then : + LIBS="-lgetloadavg $LIBS" gl_have_func=yes +else + LIBS=$gl_getloadavg_LIBS +fi + + fi + + # Set up the replacement function if necessary. + if test $gl_have_func = no; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS getloadavg.$ac_objext" + + +# Figure out what our getloadavg.c needs. # Solaris has libkstat which does not require root. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kstat_open in -lkstat" >&5 @@ -14546,8 +14722,24 @@ fi 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 + for ac_func in pstat_getdynamic +do : + ac_fn_c_check_func "$LINENO" "pstat_getdynamic" "ac_cv_func_pstat_getdynamic" +if test "x$ac_cv_func_pstat_getdynamic" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PSTAT_GETDYNAMIC 1 +_ACEOF + gl_have_func=yes +fi +done + +fi + # AIX has libperfstat which does not require root -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for perfstat_cpu_total in -lperfstat" >&5 +if test $gl_have_func = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perfstat_cpu_total in -lperfstat" >&5 $as_echo_n "checking for perfstat_cpu_total in -lperfstat... " >&6; } if ${ac_cv_lib_perfstat_perfstat_cpu_total+:} false; then : $as_echo_n "(cached) " >&6 @@ -14592,219 +14784,17 @@ _ACEOF fi -test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes - -# 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 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_begin in -lelf" >&5 -$as_echo_n "checking for elf_begin in -lelf... " >&6; } -if ${ac_cv_lib_elf_elf_begin+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lelf $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char elf_begin (); -int -main () -{ -return elf_begin (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_elf_elf_begin=yes -else - ac_cv_lib_elf_elf_begin=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf_begin" >&5 -$as_echo "$ac_cv_lib_elf_elf_begin" >&6; } -if test "x$ac_cv_lib_elf_elf_begin" = xyes; then : - LIBS="-lelf $LIBS" -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kvm_open in -lkvm" >&5 -$as_echo_n "checking for kvm_open in -lkvm... " >&6; } -if ${ac_cv_lib_kvm_kvm_open+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lkvm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char kvm_open (); -int -main () -{ -return kvm_open (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_kvm_kvm_open=yes -else - ac_cv_lib_kvm_kvm_open=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kvm_kvm_open" >&5 -$as_echo "$ac_cv_lib_kvm_kvm_open" >&6; } -if test "x$ac_cv_lib_kvm_kvm_open" = xyes; then : - LIBS="-lkvm $LIBS" -fi - - # Check for the 4.4BSD definition of getloadavg. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lutil" >&5 -$as_echo_n "checking for getloadavg in -lutil... " >&6; } -if ${ac_cv_lib_util_getloadavg+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lutil $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char getloadavg (); -int -main () -{ -return getloadavg (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_util_getloadavg=yes -else - ac_cv_lib_util_getloadavg=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_getloadavg" >&5 -$as_echo "$ac_cv_lib_util_getloadavg" >&6; } -if test "x$ac_cv_lib_util_getloadavg" = xyes; then : - LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes -fi - + test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes fi if test $gl_have_func = 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" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lgetloadavg" >&5 -$as_echo_n "checking for getloadavg in -lgetloadavg... " >&6; } -if ${ac_cv_lib_getloadavg_getloadavg+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgetloadavg $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char getloadavg (); -int -main () -{ -return getloadavg (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_getloadavg_getloadavg=yes -else - ac_cv_lib_getloadavg_getloadavg=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_getloadavg_getloadavg" >&5 -$as_echo "$ac_cv_lib_getloadavg_getloadavg" >&6; } -if test "x$ac_cv_lib_getloadavg_getloadavg" = xyes; then : - LIBS="-lgetloadavg $LIBS" -else - LIBS=$gl_getloadavg_LIBS -fi - -fi - -# Make sure it is really in the library, if we think we found it, -# otherwise set up the replacement function. -for ac_func in getloadavg -do : - ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg" -if test "x$ac_cv_func_getloadavg" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GETLOADAVG 1 -_ACEOF - -else - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS getloadavg.$ac_objext" - - -$as_echo "#define C_GETLOADAVG 1" >>confdefs.h - -# Figure out what our getloadavg.c needs. -gl_have_func=no -ac_fn_c_check_header_mongrel "$LINENO" "sys/dg_sys_info.h" "ac_cv_header_sys_dg_sys_info_h" "$ac_includes_default" + ac_fn_c_check_header_mongrel "$LINENO" "sys/dg_sys_info.h" "ac_cv_header_sys_dg_sys_info_h" "$ac_includes_default" if test "x$ac_cv_header_sys_dg_sys_info_h" = xyes; then : gl_have_func=yes $as_echo "#define DGUX 1" >>confdefs.h - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dg_sys_info in -ldgc" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dg_sys_info in -ldgc" >&5 $as_echo_n "checking for dg_sys_info in -ldgc... " >&6; } if ${ac_cv_lib_dgc_dg_sys_info+:} false; then : $as_echo_n "(cached) " >&6 @@ -14852,6 +14842,7 @@ fi fi +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 @@ -14920,8 +14911,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF -$as_echo "#define NLIST_NAME_UNION 1" >>confdefs.h - fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -14952,65 +14941,10 @@ fi done -fi -done - - -# Some definitions of getloadavg require that the program be installed setgid. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getloadavg requires setgid" >&5 -$as_echo_n "checking whether getloadavg requires setgid... " >&6; } -if ${gl_cv_func_getloadavg_setgid+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define CONFIGURING_GETLOADAVG -#include "$srcdir/$gl_source_base/getloadavg.c" -#ifdef LDAV_PRIVILEGED -Yowza Am I SETGID yet -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "Yowza Am I SETGID yet" >/dev/null 2>&1; then : - gl_cv_func_getloadavg_setgid=yes -else - gl_cv_func_getloadavg_setgid=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getloadavg_setgid" >&5 -$as_echo "$gl_cv_func_getloadavg_setgid" >&6; } -if test $gl_cv_func_getloadavg_setgid = yes; then - NEED_SETGID=true - -$as_echo "#define GETLOADAVG_PRIVILEGED 1" >>confdefs.h - -else - NEED_SETGID=false + fi fi -if test $gl_cv_func_getloadavg_setgid = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking group of /dev/kmem" >&5 -$as_echo_n "checking group of /dev/kmem... " >&6; } -if ${gl_cv_group_kmem+:} false; then : - $as_echo_n "(cached) " >&6 -else - # On Solaris, /dev/kmem is a symlink. Get info on the real file. - ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null` - # If we got an error (system does not support symlinks), try without -L. - test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem` - gl_cv_group_kmem=`echo $ac_ls_output \ - | sed -ne 's/[ ][ ]*/ /g - s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/ - / /s/.* //;p'` -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_group_kmem" >&5 -$as_echo "$gl_cv_group_kmem" >&6; } - KMEM_GROUP=$gl_cv_group_kmem -fi if test "x$gl_save_LIBS" = x; then GETLOADAVG_LIBS=$LIBS else diff --git a/lib/Makefile.in b/lib/Makefile.in index bdc405a505f..82e23967865 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -296,7 +296,6 @@ INSTALL_INFO = @INSTALL_INFO@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -KMEM_GROUP = @KMEM_GROUP@ KRB4LIB = @KRB4LIB@ KRB5LIB = @KRB5LIB@ LDFLAGS = @LDFLAGS@ @@ -349,7 +348,6 @@ MKDEPDIR = @MKDEPDIR@ MKDIR_P = @MKDIR_P@ MOUSE_SUPPORT = @MOUSE_SUPPORT@ M_FILE = @M_FILE@ -NEED_SETGID = @NEED_SETGID@ NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@ diff --git a/lib/getloadavg.c b/lib/getloadavg.c index 96a6aa4d49c..8e917145c5c 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c @@ -94,11 +94,6 @@ #include #include -/* Exclude all the code except the test program at the end - if the system has its own `getloadavg' function. */ - -#ifndef HAVE_GETLOADAVG - # include /* Both the Emacs and non-Emacs sections want this. Some @@ -1032,44 +1027,3 @@ getloadavg (double loadavg[], int nelem) # endif return elem; } - -#endif /* ! HAVE_GETLOADAVG */ - -#ifdef TEST -int -main (int argc, char **argv) -{ - int naptime = 0; - - if (argc > 1) - naptime = atoi (argv[1]); - - while (1) - { - double avg[3]; - int loads; - - errno = 0; /* Don't be misled if it doesn't set errno. */ - loads = getloadavg (avg, 3); - if (loads == -1) - { - perror ("Error getting load average"); - return EXIT_FAILURE; - } - if (loads > 0) - printf ("1-minute: %f ", avg[0]); - if (loads > 1) - printf ("5-minute: %f ", avg[1]); - if (loads > 2) - printf ("15-minute: %f ", avg[2]); - if (loads > 0) - putchar ('\n'); - - if (naptime == 0) - break; - sleep (naptime); - } - - return EXIT_SUCCESS; -} -#endif /* TEST */ diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 6e69a277af0..62d18c62811 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -88,10 +88,10 @@ struct random_data # include #endif -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(Spec) /* empty */ -# endif +#if 3 <= __GNUC__ || __GNUC__ == 2 && 8 <= __GNUC_MINOR__ +# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#else +# define _GL_ATTRIBUTE_NORETURN #endif /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ @@ -119,7 +119,7 @@ struct random_data /* Terminate the current process with the given return code, without running the 'atexit' handlers. */ # if !@HAVE__EXIT@ -_GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__))); +_GL_FUNCDECL_SYS (_Exit, void, (int status) _GL_ATTRIBUTE_NORETURN); # endif _GL_CXXALIAS_SYS (_Exit, void, (int status)); _GL_CXXALIASWARN (_Exit); diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4 index d25ad345b33..4aae158e963 100644 --- a/m4/getloadavg.m4 +++ b/m4/getloadavg.m4 @@ -20,90 +20,44 @@ AC_DEFUN([gl_GETLOADAVG], # Persuade glibc to declare getloadavg(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) -gl_have_func=no # yes means we've found a way to get the load average. - # Make sure getloadavg.c is where it belongs, at configure-time. test -f "$srcdir/$1/getloadavg.c" || AC_MSG_ERROR([$srcdir/$1/getloadavg.c is missing]) gl_save_LIBS=$LIBS -# Check for getloadavg, but be sure not to touch the cache variable. -(AC_CHECK_FUNC([getloadavg], [exit 0], [exit 1])) && gl_have_func=yes +AC_CHECK_FUNC([getloadavg], [], + [gl_have_func=no -# On HPUX9, an unprivileged user can get load averages through this function. -AC_CHECK_FUNCS([pstat_getdynamic]) + # 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 + 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]) + fi -# 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 + if test $gl_have_func = 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=$gl_getloadavg_LIBS]) + fi -# AIX has libperfstat which does not require root -AC_CHECK_LIB([perfstat], [perfstat_cpu_total]) -test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes + # Set up the replacement function if necessary. + if test $gl_have_func = no; then + AC_LIBOBJ([getloadavg]) + gl_PREREQ_GETLOADAVG + fi]) -# 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 - 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 gl_cv_func_getloadavg_setgid=yes]) -fi - -if test $gl_have_func = 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"], [LIBS=$gl_getloadavg_LIBS]) -fi - -# Make sure it is really in the library, if we think we found it, -# otherwise set up the replacement function. -AC_CHECK_FUNCS([getloadavg], [], - [gl_PREREQ_GETLOADAVG]) - -# Some definitions of getloadavg require that the program be installed setgid. -AC_CACHE_CHECK([whether getloadavg requires setgid], - gl_cv_func_getloadavg_setgid, -[AC_EGREP_CPP([Yowza Am I SETGID yet], -[#define CONFIGURING_GETLOADAVG -#include "$srcdir/$1/getloadavg.c" -#ifdef LDAV_PRIVILEGED -Yowza Am I SETGID yet -#endif -], - gl_cv_func_getloadavg_setgid=yes, - gl_cv_func_getloadavg_setgid=no)]) -if test $gl_cv_func_getloadavg_setgid = yes; then - NEED_SETGID=true - AC_DEFINE([GETLOADAVG_PRIVILEGED], [1], - [Define to 1 if the `getloadavg' function needs to be run setuid - or setgid.]) -else - NEED_SETGID=false -fi -AC_SUBST([NEED_SETGID])dnl - -if test $gl_cv_func_getloadavg_setgid = yes; then - AC_CACHE_CHECK([group of /dev/kmem], [gl_cv_group_kmem], -[ # On Solaris, /dev/kmem is a symlink. Get info on the real file. - ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null` - # If we got an error (system does not support symlinks), try without -L. - test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem` - gl_cv_group_kmem=`echo $ac_ls_output \ - | sed -ne ['s/[ ][ ]*/ /g - s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/ - / /s/.* //;p']` -]) - AC_SUBST([KMEM_GROUP], [$gl_cv_group_kmem])dnl -fi if test "x$gl_save_LIBS" = x; then GETLOADAVG_LIBS=$LIBS else @@ -133,14 +87,30 @@ AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0], # -------------------- # Set up the AC_LIBOBJ replacement of `getloadavg'. AC_DEFUN([gl_PREREQ_GETLOADAVG], -[AC_LIBOBJ([getloadavg]) -AC_DEFINE([C_GETLOADAVG], [1], [Define to 1 if using `getloadavg.c'.]) +[ # Figure out what our getloadavg.c needs. -gl_have_func=no -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])]) + +# 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])]) +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 @@ -171,10 +141,7 @@ fi AC_CHECK_HEADERS([nlist.h], [AC_CHECK_MEMBERS([struct nlist.n_un.n_name], - [AC_DEFINE([NLIST_NAME_UNION], [1], - [Define to 1 if your `struct nlist' has an - `n_un' member. Obsolete, depend on - `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [], + [], [], [@%:@include ]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct nlist x; diff --git a/src/config.in b/src/config.in index 68cd4b39ac0..637287a024c 100644 --- a/src/config.in +++ b/src/config.in @@ -42,9 +42,6 @@ along with GNU Emacs. If not, see . */ /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA -/* Define to 1 if using `getloadavg.c'. */ -#undef C_GETLOADAVG - /* Define to 1 for DGUX with . */ #undef DGUX @@ -74,10 +71,6 @@ along with GNU Emacs. If not, see . */ /* Define this to check for short string overrun. */ #undef GC_CHECK_STRING_OVERRUN -/* Define to 1 if the `getloadavg' function needs to be run setuid or setgid. - */ -#undef GETLOADAVG_PRIVILEGED - /* Define to 1 if the `getpgrp' function requires zero arguments. */ #undef GETPGRP_VOID @@ -225,9 +218,6 @@ along with GNU Emacs. If not, see . */ /* Define to 1 if you have the `getline' function. */ #undef HAVE_GETLINE -/* Define to 1 if you have the `getloadavg' function. */ -#undef HAVE_GETLOADAVG - /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H @@ -876,10 +866,6 @@ along with GNU Emacs. If not, see . */ /* Define to support POP mail retrieval. */ #undef MAIL_USE_POP -/* Define to 1 if your `struct nlist' has an `n_un' member. Obsolete, depend - on `HAVE_STRUCT_NLIST_N_UN_N_NAME */ -#undef NLIST_NAME_UNION - /* Define to 1 if you don't have struct exception in math.h. */ #undef NO_MATHERR