aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-02-07 23:05:03 -0800
committerPaul Eggert2011-02-07 23:05:03 -0800
commit79ab4b7f0e69ac1d76186346c33187b1fb02ff02 (patch)
tree38948150fa2119df0765c9004a27011caa9f3f50
parent226590f8d1247314abf913cc1bc77621f8a5bca9 (diff)
downloademacs-79ab4b7f0e69ac1d76186346c33187b1fb02ff02.tar.gz
emacs-79ab4b7f0e69ac1d76186346c33187b1fb02ff02.zip
Import getloadavg module from gnulib.
-rw-r--r--ChangeLog21
-rw-r--r--Makefile.in2
-rw-r--r--aclocal.m42
-rw-r--r--admin/notes/copyright1
-rwxr-xr-xconfigure1306
-rw-r--r--configure.in8
-rw-r--r--lib/Makefile.in173
-rw-r--r--lib/getloadavg.c (renamed from src/getloadavg.c)488
-rw-r--r--lib/gnulib.mk96
-rw-r--r--lib/stdlib.in.h725
-rw-r--r--m4/getloadavg.m4189
-rw-r--r--m4/gl-comp.m411
-rw-r--r--m4/stdlib_h.m4107
-rw-r--r--src/ChangeLog10
-rw-r--r--src/config.in12
-rw-r--r--src/deps.mk1
-rw-r--r--src/lisp.h5
-rw-r--r--src/s/freebsd.h2
-rw-r--r--src/s/netbsd.h3
19 files changed, 2398 insertions, 764 deletions
diff --git a/ChangeLog b/ChangeLog
index 07f01d6207e..649fe4b2ba6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
12011-02-08 Paul Eggert <eggert@cs.ucla.edu>
2
3 Import getloadavg module from gnulib.
4 * .bzrignore: Add lib/stdlib.h.
5 * Makefile.in (GNULIB_MODULES): Add getloadavg.
6 * admin/notes/copyright: Remove src/getloadavg.c as a special case.
7 * configure.in (LIBS_SYSTEM): Omit -lkstat on sol2*; gnulib does this.
8 (AC_CONFIG_LIBOBJ_DIR, AC_FUNC_GETLOADAVG, GETLOADAVG_FILES):
9 Remove; gnulib does this now.
10 * lib/getloadavg.c: Rename from src/getloadavg.c, and sync
11 from gnulib. This adds support for several other systems, such
12 as Tru64 4.0D, QNX, AIX perfstat, etc. It also fixes a potential
13 buffer overrun on Linux hosts under very high load, and on hosts
14 that maintain a channel to the load average file it makes sure
15 the file descriptor is close-on-exec (on hosts that support this)
16 and is not stdin, stdout, or stderr.
17 * lib/stdlib.in.h, m4/getloadavg.m4, m4/stdlib_h.m4: New files,
18 from gnulib.
19 * aclocal.m4, configure, lib/Makefile.in, lib/gnulib.mk, m4/gl-comp.m4:
20 * src/config.in: Regenerate.
21
12011-02-06 Paul Eggert <eggert@cs.ucla.edu> 222011-02-06 Paul Eggert <eggert@cs.ucla.edu>
2 23
3 gnulib: allow multiple gnulib generated replacements to coexist 24 gnulib: allow multiple gnulib generated replacements to coexist
diff --git a/Makefile.in b/Makefile.in
index e8206a6f012..126304cc4e5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -330,7 +330,7 @@ DOS_gnulib_comp.m4 = gl-comp.m4
330# Update modules from gnulib, for maintainers, who should have it in 330# Update modules from gnulib, for maintainers, who should have it in
331# $(gnulib_srcdir) (relative to $(srcdir) and should have build tools 331# $(gnulib_srcdir) (relative to $(srcdir) and should have build tools
332# as per $(gnulib_srcdir)/DEPENDENCIES. 332# as per $(gnulib_srcdir)/DEPENDENCIES.
333GNULIB_MODULES = dtoastr getopt-gnu ignore-value mktime strftime 333GNULIB_MODULES = dtoastr getloadavg getopt-gnu ignore-value mktime strftime
334GNULIB_TOOL_FLAGS = \ 334GNULIB_TOOL_FLAGS = \
335 --import --no-changelog --no-vc-files --makefile-name=gnulib.mk 335 --import --no-changelog --no-vc-files --makefile-name=gnulib.mk
336sync-from-gnulib: $(gnulib_srcdir) 336sync-from-gnulib: $(gnulib_srcdir)
diff --git a/aclocal.m4 b/aclocal.m4
index 62d57bb59fd..f299e4ab11e 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -987,6 +987,7 @@ AC_SUBST([am__untar])
987m4_include([m4/00gnulib.m4]) 987m4_include([m4/00gnulib.m4])
988m4_include([m4/c-strtod.m4]) 988m4_include([m4/c-strtod.m4])
989m4_include([m4/extensions.m4]) 989m4_include([m4/extensions.m4])
990m4_include([m4/getloadavg.m4])
990m4_include([m4/getopt.m4]) 991m4_include([m4/getopt.m4])
991m4_include([m4/gl-comp.m4]) 992m4_include([m4/gl-comp.m4])
992m4_include([m4/gnulib-common.m4]) 993m4_include([m4/gnulib-common.m4])
@@ -995,6 +996,7 @@ m4_include([m4/mktime.m4])
995m4_include([m4/multiarch.m4]) 996m4_include([m4/multiarch.m4])
996m4_include([m4/stdbool.m4]) 997m4_include([m4/stdbool.m4])
997m4_include([m4/stddef_h.m4]) 998m4_include([m4/stddef_h.m4])
999m4_include([m4/stdlib_h.m4])
998m4_include([m4/strftime.m4]) 1000m4_include([m4/strftime.m4])
999m4_include([m4/time_h.m4]) 1001m4_include([m4/time_h.m4])
1000m4_include([m4/time_r.m4]) 1002m4_include([m4/time_r.m4])
diff --git a/admin/notes/copyright b/admin/notes/copyright
index e4077caf77b..32a096c928d 100644
--- a/admin/notes/copyright
+++ b/admin/notes/copyright
@@ -631,7 +631,6 @@ alone (may import them from Gnulib again). These are:
631 warn-on-use.h 631 warn-on-use.h
632 lib/*.[ch] 632 lib/*.[ch]
633 lib/gnulib.mk 633 lib/gnulib.mk
634 src/getloadavg.c
635 src/gmalloc.c 634 src/gmalloc.c
636 src/md5.c 635 src/md5.c
637 src/md5.h 636 src/md5.h
diff --git a/configure b/configure
index f2369751060..40e191eb9ab 100755
--- a/configure
+++ b/configure
@@ -599,7 +599,6 @@ ac_includes_default="\
599# include <unistd.h> 599# include <unistd.h>
600#endif" 600#endif"
601 601
602ac_config_libobj_dir=src
603ac_header_list= 602ac_header_list=
604gl_getopt_required=POSIX 603gl_getopt_required=POSIX
605gl_getopt_required=POSIX 604gl_getopt_required=POSIX
@@ -611,6 +610,7 @@ gl_LIBOBJS
611am__EXEEXT_FALSE 610am__EXEEXT_FALSE
612am__EXEEXT_TRUE 611am__EXEEXT_TRUE
613LTLIBOBJS 612LTLIBOBJS
613LIBOBJS
614WINDOW_SUPPORT 614WINDOW_SUPPORT
615TOOLTIP_SUPPORT 615TOOLTIP_SUPPORT
616MOUSE_SUPPORT 616MOUSE_SUPPORT
@@ -677,6 +677,9 @@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC
677TIME_H_DEFINES_STRUCT_TIMESPEC 677TIME_H_DEFINES_STRUCT_TIMESPEC
678NEXT_AS_FIRST_DIRECTIVE_TIME_H 678NEXT_AS_FIRST_DIRECTIVE_TIME_H
679NEXT_TIME_H 679NEXT_TIME_H
680HAVE_RANDOM_H
681NEXT_AS_FIRST_DIRECTIVE_STDLIB_H
682NEXT_STDLIB_H
680NEXT_AS_FIRST_DIRECTIVE_STDDEF_H 683NEXT_AS_FIRST_DIRECTIVE_STDDEF_H
681NEXT_STDDEF_H 684NEXT_STDDEF_H
682STDDEF_H 685STDDEF_H
@@ -813,12 +816,71 @@ GNULIB_DUP3
813GNULIB_DUP2 816GNULIB_DUP2
814GNULIB_CLOSE 817GNULIB_CLOSE
815GNULIB_CHOWN 818GNULIB_CHOWN
816GL_COND_LIBTOOL_FALSE
817GL_COND_LIBTOOL_TRUE
818GETLOADAVG_LIBS 819GETLOADAVG_LIBS
819KMEM_GROUP 820KMEM_GROUP
820NEED_SETGID 821NEED_SETGID
821LIBOBJS 822REPLACE_UNSETENV
823REPLACE_STRTOD
824REPLACE_SETENV
825REPLACE_REALPATH
826REPLACE_REALLOC
827REPLACE_PUTENV
828REPLACE_MKSTEMP
829REPLACE_MALLOC
830REPLACE_CANONICALIZE_FILE_NAME
831REPLACE_CALLOC
832HAVE_DECL_UNSETENV
833HAVE_UNLOCKPT
834HAVE_SYS_LOADAVG_H
835HAVE_STRUCT_RANDOM_DATA
836HAVE_STRTOULL
837HAVE_STRTOLL
838HAVE_STRTOD
839HAVE_DECL_SETENV
840HAVE_SETENV
841HAVE_RPMATCH
842HAVE_REALPATH
843HAVE_RANDOM_R
844HAVE_PTSNAME
845HAVE_MKSTEMPS
846HAVE_MKSTEMP
847HAVE_MKOSTEMPS
848HAVE_MKOSTEMP
849HAVE_MKDTEMP
850HAVE_GRANTPT
851HAVE_GETSUBOPT
852HAVE_DECL_GETLOADAVG
853HAVE_CANONICALIZE_FILE_NAME
854HAVE_ATOLL
855HAVE__EXIT
856GNULIB_UNSETENV
857GNULIB_UNLOCKPT
858GNULIB_SYSTEM_POSIX
859GNULIB_STRTOULL
860GNULIB_STRTOLL
861GNULIB_STRTOD
862GNULIB_SETENV
863GNULIB_RPMATCH
864GNULIB_REALPATH
865GNULIB_REALLOC_POSIX
866GNULIB_RANDOM_R
867GNULIB_PUTENV
868GNULIB_PTSNAME
869GNULIB_MKSTEMPS
870GNULIB_MKSTEMP
871GNULIB_MKOSTEMPS
872GNULIB_MKOSTEMP
873GNULIB_MKDTEMP
874GNULIB_MALLOC_POSIX
875GNULIB_GRANTPT
876GNULIB_GETSUBOPT
877GNULIB_GETLOADAVG
878GNULIB_CANONICALIZE_FILE_NAME
879GNULIB_CALLOC_POSIX
880GNULIB_ATOLL
881GNULIB__EXIT
882GL_COND_LIBTOOL_FALSE
883GL_COND_LIBTOOL_TRUE
822BLESSMAIL_TARGET 884BLESSMAIL_TARGET
823LIBS_MAIL 885LIBS_MAIL
824liblockfile 886liblockfile
@@ -5823,6 +5885,7 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
5823 # Code from module dtoastr: 5885 # Code from module dtoastr:
5824 # Code from module extensions: 5886 # Code from module extensions:
5825 5887
5888 # Code from module getloadavg:
5826 # Code from module getopt-gnu: 5889 # Code from module getopt-gnu:
5827 # Code from module getopt-posix: 5890 # Code from module getopt-posix:
5828 # Code from module gettext-h: 5891 # Code from module gettext-h:
@@ -5833,6 +5896,7 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
5833 # Code from module multiarch: 5896 # Code from module multiarch:
5834 # Code from module stdbool: 5897 # Code from module stdbool:
5835 # Code from module stddef: 5898 # Code from module stddef:
5899 # Code from module stdlib:
5836 # Code from module strftime: 5900 # Code from module strftime:
5837 # Code from module time: 5901 # Code from module time:
5838 # Code from module time_r: 5902 # Code from module time_r:
@@ -6705,7 +6769,7 @@ case "$opsys" in
6705 6769
6706 hpux*) LIBS_SYSTEM="-l:libdld.sl" ;; 6770 hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
6707 6771
6708 sol2*) LIBS_SYSTEM="-lsocket -lnsl -lkstat" ;; 6772 sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
6709 6773
6710 ## Motif needs -lgen. 6774 ## Motif needs -lgen.
6711 unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;; 6775 unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
@@ -6721,8 +6785,6 @@ else
6721 CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS" 6785 CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
6722fi 6786fi
6723 6787
6724
6725
6726# Check whether --enable-largefile was given. 6788# Check whether --enable-largefile was given.
6727if test "${enable_largefile+set}" = set; then : 6789if test "${enable_largefile+set}" = set; then :
6728 enableval=$enable_largefile; 6790 enableval=$enable_largefile;
@@ -13019,500 +13081,6 @@ fi
13019done 13081done
13020 13082
13021 13083
13022ac_have_func=no # yes means we've found a way to get the load average.
13023
13024# Make sure getloadavg.c is where it belongs, at configure-time.
13025test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
13026 as_fn_error $? "$srcdir/$ac_config_libobj_dir/getloadavg.c is missing" "$LINENO" 5
13027
13028ac_save_LIBS=$LIBS
13029
13030# Check for getloadavg, but be sure not to touch the cache variable.
13031(ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg"
13032if test "x$ac_cv_func_getloadavg" = xyes; then :
13033 exit 0
13034else
13035 exit 1
13036fi
13037) && ac_have_func=yes
13038
13039# On HPUX9, an unprivileged user can get load averages through this function.
13040for ac_func in pstat_getdynamic
13041do :
13042 ac_fn_c_check_func "$LINENO" "pstat_getdynamic" "ac_cv_func_pstat_getdynamic"
13043if test "x$ac_cv_func_pstat_getdynamic" = xyes; then :
13044 cat >>confdefs.h <<_ACEOF
13045#define HAVE_PSTAT_GETDYNAMIC 1
13046_ACEOF
13047
13048fi
13049done
13050
13051
13052# Solaris has libkstat which does not require root.
13053{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for kstat_open in -lkstat" >&5
13054$as_echo_n "checking for kstat_open in -lkstat... " >&6; }
13055if ${ac_cv_lib_kstat_kstat_open+:} false; then :
13056 $as_echo_n "(cached) " >&6
13057else
13058 ac_check_lib_save_LIBS=$LIBS
13059LIBS="-lkstat $LIBS"
13060cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13061/* end confdefs.h. */
13062
13063/* Override any GCC internal prototype to avoid an error.
13064 Use char because int might match the return type of a GCC
13065 builtin and then its argument prototype would still apply. */
13066#ifdef __cplusplus
13067extern "C"
13068#endif
13069char kstat_open ();
13070int
13071main ()
13072{
13073return kstat_open ();
13074 ;
13075 return 0;
13076}
13077_ACEOF
13078if ac_fn_c_try_link "$LINENO"; then :
13079 ac_cv_lib_kstat_kstat_open=yes
13080else
13081 ac_cv_lib_kstat_kstat_open=no
13082fi
13083rm -f core conftest.err conftest.$ac_objext \
13084 conftest$ac_exeext conftest.$ac_ext
13085LIBS=$ac_check_lib_save_LIBS
13086fi
13087{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kstat_kstat_open" >&5
13088$as_echo "$ac_cv_lib_kstat_kstat_open" >&6; }
13089if test "x$ac_cv_lib_kstat_kstat_open" = xyes; then :
13090 cat >>confdefs.h <<_ACEOF
13091#define HAVE_LIBKSTAT 1
13092_ACEOF
13093
13094 LIBS="-lkstat $LIBS"
13095
13096fi
13097
13098test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
13099
13100# Some systems with -lutil have (and need) -lkvm as well, some do not.
13101# On Solaris, -lkvm requires nlist from -lelf, so check that first
13102# to get the right answer into the cache.
13103# For kstat on solaris, we need libelf to force the definition of SVR4 below.
13104if test $ac_have_func = no; then
13105 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_begin in -lelf" >&5
13106$as_echo_n "checking for elf_begin in -lelf... " >&6; }
13107if ${ac_cv_lib_elf_elf_begin+:} false; then :
13108 $as_echo_n "(cached) " >&6
13109else
13110 ac_check_lib_save_LIBS=$LIBS
13111LIBS="-lelf $LIBS"
13112cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13113/* end confdefs.h. */
13114
13115/* Override any GCC internal prototype to avoid an error.
13116 Use char because int might match the return type of a GCC
13117 builtin and then its argument prototype would still apply. */
13118#ifdef __cplusplus
13119extern "C"
13120#endif
13121char elf_begin ();
13122int
13123main ()
13124{
13125return elf_begin ();
13126 ;
13127 return 0;
13128}
13129_ACEOF
13130if ac_fn_c_try_link "$LINENO"; then :
13131 ac_cv_lib_elf_elf_begin=yes
13132else
13133 ac_cv_lib_elf_elf_begin=no
13134fi
13135rm -f core conftest.err conftest.$ac_objext \
13136 conftest$ac_exeext conftest.$ac_ext
13137LIBS=$ac_check_lib_save_LIBS
13138fi
13139{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf_begin" >&5
13140$as_echo "$ac_cv_lib_elf_elf_begin" >&6; }
13141if test "x$ac_cv_lib_elf_elf_begin" = xyes; then :
13142 LIBS="-lelf $LIBS"
13143fi
13144
13145fi
13146if test $ac_have_func = no; then
13147 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kvm_open in -lkvm" >&5
13148$as_echo_n "checking for kvm_open in -lkvm... " >&6; }
13149if ${ac_cv_lib_kvm_kvm_open+:} false; then :
13150 $as_echo_n "(cached) " >&6
13151else
13152 ac_check_lib_save_LIBS=$LIBS
13153LIBS="-lkvm $LIBS"
13154cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13155/* end confdefs.h. */
13156
13157/* Override any GCC internal prototype to avoid an error.
13158 Use char because int might match the return type of a GCC
13159 builtin and then its argument prototype would still apply. */
13160#ifdef __cplusplus
13161extern "C"
13162#endif
13163char kvm_open ();
13164int
13165main ()
13166{
13167return kvm_open ();
13168 ;
13169 return 0;
13170}
13171_ACEOF
13172if ac_fn_c_try_link "$LINENO"; then :
13173 ac_cv_lib_kvm_kvm_open=yes
13174else
13175 ac_cv_lib_kvm_kvm_open=no
13176fi
13177rm -f core conftest.err conftest.$ac_objext \
13178 conftest$ac_exeext conftest.$ac_ext
13179LIBS=$ac_check_lib_save_LIBS
13180fi
13181{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kvm_kvm_open" >&5
13182$as_echo "$ac_cv_lib_kvm_kvm_open" >&6; }
13183if test "x$ac_cv_lib_kvm_kvm_open" = xyes; then :
13184 LIBS="-lkvm $LIBS"
13185fi
13186
13187 # Check for the 4.4BSD definition of getloadavg.
13188 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lutil" >&5
13189$as_echo_n "checking for getloadavg in -lutil... " >&6; }
13190if ${ac_cv_lib_util_getloadavg+:} false; then :
13191 $as_echo_n "(cached) " >&6
13192else
13193 ac_check_lib_save_LIBS=$LIBS
13194LIBS="-lutil $LIBS"
13195cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13196/* end confdefs.h. */
13197
13198/* Override any GCC internal prototype to avoid an error.
13199 Use char because int might match the return type of a GCC
13200 builtin and then its argument prototype would still apply. */
13201#ifdef __cplusplus
13202extern "C"
13203#endif
13204char getloadavg ();
13205int
13206main ()
13207{
13208return getloadavg ();
13209 ;
13210 return 0;
13211}
13212_ACEOF
13213if ac_fn_c_try_link "$LINENO"; then :
13214 ac_cv_lib_util_getloadavg=yes
13215else
13216 ac_cv_lib_util_getloadavg=no
13217fi
13218rm -f core conftest.err conftest.$ac_objext \
13219 conftest$ac_exeext conftest.$ac_ext
13220LIBS=$ac_check_lib_save_LIBS
13221fi
13222{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_getloadavg" >&5
13223$as_echo "$ac_cv_lib_util_getloadavg" >&6; }
13224if test "x$ac_cv_lib_util_getloadavg" = xyes; then :
13225 LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes
13226fi
13227
13228fi
13229
13230if test $ac_have_func = no; then
13231 # There is a commonly available library for RS/6000 AIX.
13232 # Since it is not a standard part of AIX, it might be installed locally.
13233 ac_getloadavg_LIBS=$LIBS
13234 LIBS="-L/usr/local/lib $LIBS"
13235 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lgetloadavg" >&5
13236$as_echo_n "checking for getloadavg in -lgetloadavg... " >&6; }
13237if ${ac_cv_lib_getloadavg_getloadavg+:} false; then :
13238 $as_echo_n "(cached) " >&6
13239else
13240 ac_check_lib_save_LIBS=$LIBS
13241LIBS="-lgetloadavg $LIBS"
13242cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13243/* end confdefs.h. */
13244
13245/* Override any GCC internal prototype to avoid an error.
13246 Use char because int might match the return type of a GCC
13247 builtin and then its argument prototype would still apply. */
13248#ifdef __cplusplus
13249extern "C"
13250#endif
13251char getloadavg ();
13252int
13253main ()
13254{
13255return getloadavg ();
13256 ;
13257 return 0;
13258}
13259_ACEOF
13260if ac_fn_c_try_link "$LINENO"; then :
13261 ac_cv_lib_getloadavg_getloadavg=yes
13262else
13263 ac_cv_lib_getloadavg_getloadavg=no
13264fi
13265rm -f core conftest.err conftest.$ac_objext \
13266 conftest$ac_exeext conftest.$ac_ext
13267LIBS=$ac_check_lib_save_LIBS
13268fi
13269{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_getloadavg_getloadavg" >&5
13270$as_echo "$ac_cv_lib_getloadavg_getloadavg" >&6; }
13271if test "x$ac_cv_lib_getloadavg_getloadavg" = xyes; then :
13272 LIBS="-lgetloadavg $LIBS"
13273else
13274 LIBS=$ac_getloadavg_LIBS
13275fi
13276
13277fi
13278
13279# Make sure it is really in the library, if we think we found it,
13280# otherwise set up the replacement function.
13281for ac_func in getloadavg
13282do :
13283 ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg"
13284if test "x$ac_cv_func_getloadavg" = xyes; then :
13285 cat >>confdefs.h <<_ACEOF
13286#define HAVE_GETLOADAVG 1
13287_ACEOF
13288
13289else
13290 case " $LIBOBJS " in
13291 *" getloadavg.$ac_objext "* ) ;;
13292 *) LIBOBJS="$LIBOBJS getloadavg.$ac_objext"
13293 ;;
13294esac
13295
13296
13297$as_echo "#define C_GETLOADAVG 1" >>confdefs.h
13298
13299# Figure out what our getloadavg.c needs.
13300ac_have_func=no
13301ac_fn_c_check_header_mongrel "$LINENO" "sys/dg_sys_info.h" "ac_cv_header_sys_dg_sys_info_h" "$ac_includes_default"
13302if test "x$ac_cv_header_sys_dg_sys_info_h" = xyes; then :
13303 ac_have_func=yes
13304
13305$as_echo "#define DGUX 1" >>confdefs.h
13306
13307 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dg_sys_info in -ldgc" >&5
13308$as_echo_n "checking for dg_sys_info in -ldgc... " >&6; }
13309if ${ac_cv_lib_dgc_dg_sys_info+:} false; then :
13310 $as_echo_n "(cached) " >&6
13311else
13312 ac_check_lib_save_LIBS=$LIBS
13313LIBS="-ldgc $LIBS"
13314cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13315/* end confdefs.h. */
13316
13317/* Override any GCC internal prototype to avoid an error.
13318 Use char because int might match the return type of a GCC
13319 builtin and then its argument prototype would still apply. */
13320#ifdef __cplusplus
13321extern "C"
13322#endif
13323char dg_sys_info ();
13324int
13325main ()
13326{
13327return dg_sys_info ();
13328 ;
13329 return 0;
13330}
13331_ACEOF
13332if ac_fn_c_try_link "$LINENO"; then :
13333 ac_cv_lib_dgc_dg_sys_info=yes
13334else
13335 ac_cv_lib_dgc_dg_sys_info=no
13336fi
13337rm -f core conftest.err conftest.$ac_objext \
13338 conftest$ac_exeext conftest.$ac_ext
13339LIBS=$ac_check_lib_save_LIBS
13340fi
13341{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dgc_dg_sys_info" >&5
13342$as_echo "$ac_cv_lib_dgc_dg_sys_info" >&6; }
13343if test "x$ac_cv_lib_dgc_dg_sys_info" = xyes; then :
13344 cat >>confdefs.h <<_ACEOF
13345#define HAVE_LIBDGC 1
13346_ACEOF
13347
13348 LIBS="-ldgc $LIBS"
13349
13350fi
13351
13352fi
13353
13354
13355
13356ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default"
13357if test "x$ac_cv_header_locale_h" = xyes; then :
13358
13359fi
13360
13361
13362for ac_func in setlocale
13363do :
13364 ac_fn_c_check_func "$LINENO" "setlocale" "ac_cv_func_setlocale"
13365if test "x$ac_cv_func_setlocale" = xyes; then :
13366 cat >>confdefs.h <<_ACEOF
13367#define HAVE_SETLOCALE 1
13368_ACEOF
13369
13370fi
13371done
13372
13373
13374# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
13375# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
13376# Irix 4.0.5F has the header but not the library.
13377if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \
13378 && test "$ac_cv_lib_kvm_kvm_open" = yes; then
13379 ac_have_func=yes
13380
13381$as_echo "#define SVR4 1" >>confdefs.h
13382
13383fi
13384
13385if test $ac_have_func = no; then
13386 ac_fn_c_check_header_mongrel "$LINENO" "inq_stats/cpustats.h" "ac_cv_header_inq_stats_cpustats_h" "$ac_includes_default"
13387if test "x$ac_cv_header_inq_stats_cpustats_h" = xyes; then :
13388 ac_have_func=yes
13389
13390$as_echo "#define UMAX 1" >>confdefs.h
13391
13392
13393$as_echo "#define UMAX4_3 1" >>confdefs.h
13394
13395fi
13396
13397
13398fi
13399
13400if test $ac_have_func = no; then
13401 ac_fn_c_check_header_mongrel "$LINENO" "sys/cpustats.h" "ac_cv_header_sys_cpustats_h" "$ac_includes_default"
13402if test "x$ac_cv_header_sys_cpustats_h" = xyes; then :
13403 ac_have_func=yes; $as_echo "#define UMAX 1" >>confdefs.h
13404
13405fi
13406
13407
13408fi
13409
13410if test $ac_have_func = no; then
13411 for ac_header in mach/mach.h
13412do :
13413 ac_fn_c_check_header_mongrel "$LINENO" "mach/mach.h" "ac_cv_header_mach_mach_h" "$ac_includes_default"
13414if test "x$ac_cv_header_mach_mach_h" = xyes; then :
13415 cat >>confdefs.h <<_ACEOF
13416#define HAVE_MACH_MACH_H 1
13417_ACEOF
13418
13419fi
13420
13421done
13422
13423fi
13424
13425for ac_header in nlist.h
13426do :
13427 ac_fn_c_check_header_mongrel "$LINENO" "nlist.h" "ac_cv_header_nlist_h" "$ac_includes_default"
13428if test "x$ac_cv_header_nlist_h" = xyes; then :
13429 cat >>confdefs.h <<_ACEOF
13430#define HAVE_NLIST_H 1
13431_ACEOF
13432 ac_fn_c_check_member "$LINENO" "struct nlist" "n_un.n_name" "ac_cv_member_struct_nlist_n_un_n_name" "#include <nlist.h>
13433"
13434if test "x$ac_cv_member_struct_nlist_n_un_n_name" = xyes; then :
13435
13436cat >>confdefs.h <<_ACEOF
13437#define HAVE_STRUCT_NLIST_N_UN_N_NAME 1
13438_ACEOF
13439
13440
13441$as_echo "#define NLIST_NAME_UNION 1" >>confdefs.h
13442
13443fi
13444
13445
13446fi
13447
13448done
13449
13450fi
13451done
13452
13453
13454# Some definitions of getloadavg require that the program be installed setgid.
13455{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getloadavg requires setgid" >&5
13456$as_echo_n "checking whether getloadavg requires setgid... " >&6; }
13457if ${ac_cv_func_getloadavg_setgid+:} false; then :
13458 $as_echo_n "(cached) " >&6
13459else
13460 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13461/* end confdefs.h. */
13462#include "$srcdir/$ac_config_libobj_dir/getloadavg.c"
13463#ifdef LDAV_PRIVILEGED
13464Yowza Am I SETGID yet
13465#endif
13466_ACEOF
13467if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
13468 $EGREP "Yowza Am I SETGID yet" >/dev/null 2>&1; then :
13469 ac_cv_func_getloadavg_setgid=yes
13470else
13471 ac_cv_func_getloadavg_setgid=no
13472fi
13473rm -f conftest*
13474
13475fi
13476{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getloadavg_setgid" >&5
13477$as_echo "$ac_cv_func_getloadavg_setgid" >&6; }
13478if test $ac_cv_func_getloadavg_setgid = yes; then
13479 NEED_SETGID=true
13480
13481$as_echo "#define GETLOADAVG_PRIVILEGED 1" >>confdefs.h
13482
13483else
13484 NEED_SETGID=false
13485fi
13486
13487if test $ac_cv_func_getloadavg_setgid = yes; then
13488 { $as_echo "$as_me:${as_lineno-$LINENO}: checking group of /dev/kmem" >&5
13489$as_echo_n "checking group of /dev/kmem... " >&6; }
13490if ${ac_cv_group_kmem+:} false; then :
13491 $as_echo_n "(cached) " >&6
13492else
13493 # On Solaris, /dev/kmem is a symlink. Get info on the real file.
13494 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
13495 # If we got an error (system does not support symlinks), try without -L.
13496 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
13497 ac_cv_group_kmem=`$as_echo "$ac_ls_output" \
13498 | sed -ne 's/[ ][ ]*/ /g;
13499 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
13500 / /s/.* //;p;'`
13501
13502fi
13503{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_group_kmem" >&5
13504$as_echo "$ac_cv_group_kmem" >&6; }
13505 KMEM_GROUP=$ac_cv_group_kmem
13506fi
13507if test "x$ac_save_LIBS" = x; then
13508 GETLOADAVG_LIBS=$LIBS
13509else
13510 GETLOADAVG_LIBS=`$as_echo "$LIBS" | sed "s|$ac_save_LIBS||"`
13511fi
13512LIBS=$ac_save_LIBS
13513
13514
13515
13516{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5 13084{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5
13517$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } 13085$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; }
13518if ${ac_cv_sys_largefile_source+:} false; then : 13086if ${ac_cv_sys_largefile_source+:} false; then :
@@ -13675,6 +13243,68 @@ $as_echo "#define HAVE_C99_STRTOLD 1" >>confdefs.h
13675 fi 13243 fi
13676 13244
13677 13245
13246 GNULIB__EXIT=0;
13247 GNULIB_ATOLL=0;
13248 GNULIB_CALLOC_POSIX=0;
13249 GNULIB_CANONICALIZE_FILE_NAME=0;
13250 GNULIB_GETLOADAVG=0;
13251 GNULIB_GETSUBOPT=0;
13252 GNULIB_GRANTPT=0;
13253 GNULIB_MALLOC_POSIX=0;
13254 GNULIB_MKDTEMP=0;
13255 GNULIB_MKOSTEMP=0;
13256 GNULIB_MKOSTEMPS=0;
13257 GNULIB_MKSTEMP=0;
13258 GNULIB_MKSTEMPS=0;
13259 GNULIB_PTSNAME=0;
13260 GNULIB_PUTENV=0;
13261 GNULIB_RANDOM_R=0;
13262 GNULIB_REALLOC_POSIX=0;
13263 GNULIB_REALPATH=0;
13264 GNULIB_RPMATCH=0;
13265 GNULIB_SETENV=0;
13266 GNULIB_STRTOD=0;
13267 GNULIB_STRTOLL=0;
13268 GNULIB_STRTOULL=0;
13269 GNULIB_SYSTEM_POSIX=0;
13270 GNULIB_UNLOCKPT=0;
13271 GNULIB_UNSETENV=0;
13272 HAVE__EXIT=1;
13273 HAVE_ATOLL=1;
13274 HAVE_CANONICALIZE_FILE_NAME=1;
13275 HAVE_DECL_GETLOADAVG=1;
13276 HAVE_GETSUBOPT=1;
13277 HAVE_GRANTPT=1;
13278 HAVE_MKDTEMP=1;
13279 HAVE_MKOSTEMP=1;
13280 HAVE_MKOSTEMPS=1;
13281 HAVE_MKSTEMP=1;
13282 HAVE_MKSTEMPS=1;
13283 HAVE_PTSNAME=1;
13284 HAVE_RANDOM_R=1;
13285 HAVE_REALPATH=1;
13286 HAVE_RPMATCH=1;
13287 HAVE_SETENV=1;
13288 HAVE_DECL_SETENV=1;
13289 HAVE_STRTOD=1;
13290 HAVE_STRTOLL=1;
13291 HAVE_STRTOULL=1;
13292 HAVE_STRUCT_RANDOM_DATA=1;
13293 HAVE_SYS_LOADAVG_H=0;
13294 HAVE_UNLOCKPT=1;
13295 HAVE_DECL_UNSETENV=1;
13296 REPLACE_CALLOC=0;
13297 REPLACE_CANONICALIZE_FILE_NAME=0;
13298 REPLACE_MALLOC=0;
13299 REPLACE_MKSTEMP=0;
13300 REPLACE_PUTENV=0;
13301 REPLACE_REALLOC=0;
13302 REPLACE_REALPATH=0;
13303 REPLACE_SETENV=0;
13304 REPLACE_STRTOD=0;
13305 REPLACE_UNSETENV=0;
13306
13307
13678 GNULIB_CHOWN=0; 13308 GNULIB_CHOWN=0;
13679 GNULIB_CLOSE=0; 13309 GNULIB_CLOSE=0;
13680 GNULIB_DUP2=0; 13310 GNULIB_DUP2=0;
@@ -14830,6 +14460,601 @@ fi
14830 # Code from module dtoastr: 14460 # Code from module dtoastr:
14831 14461
14832 # Code from module extensions: 14462 # Code from module extensions:
14463 # Code from module getloadavg:
14464
14465
14466# Persuade glibc <stdlib.h> to declare getloadavg().
14467
14468
14469gl_have_func=no # yes means we've found a way to get the load average.
14470
14471# Make sure getloadavg.c is where it belongs, at configure-time.
14472test -f "$srcdir/$gl_source_base/getloadavg.c" ||
14473 as_fn_error $? "$srcdir/$gl_source_base/getloadavg.c is missing" "$LINENO" 5
14474
14475gl_save_LIBS=$LIBS
14476
14477# Check for getloadavg, but be sure not to touch the cache variable.
14478(ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg"
14479if test "x$ac_cv_func_getloadavg" = xyes; then :
14480 exit 0
14481else
14482 exit 1
14483fi
14484) && gl_have_func=yes
14485
14486# On HPUX9, an unprivileged user can get load averages through this function.
14487for ac_func in pstat_getdynamic
14488do :
14489 ac_fn_c_check_func "$LINENO" "pstat_getdynamic" "ac_cv_func_pstat_getdynamic"
14490if test "x$ac_cv_func_pstat_getdynamic" = xyes; then :
14491 cat >>confdefs.h <<_ACEOF
14492#define HAVE_PSTAT_GETDYNAMIC 1
14493_ACEOF
14494
14495fi
14496done
14497
14498
14499# Solaris has libkstat which does not require root.
14500{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for kstat_open in -lkstat" >&5
14501$as_echo_n "checking for kstat_open in -lkstat... " >&6; }
14502if ${ac_cv_lib_kstat_kstat_open+:} false; then :
14503 $as_echo_n "(cached) " >&6
14504else
14505 ac_check_lib_save_LIBS=$LIBS
14506LIBS="-lkstat $LIBS"
14507cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14508/* end confdefs.h. */
14509
14510/* Override any GCC internal prototype to avoid an error.
14511 Use char because int might match the return type of a GCC
14512 builtin and then its argument prototype would still apply. */
14513#ifdef __cplusplus
14514extern "C"
14515#endif
14516char kstat_open ();
14517int
14518main ()
14519{
14520return kstat_open ();
14521 ;
14522 return 0;
14523}
14524_ACEOF
14525if ac_fn_c_try_link "$LINENO"; then :
14526 ac_cv_lib_kstat_kstat_open=yes
14527else
14528 ac_cv_lib_kstat_kstat_open=no
14529fi
14530rm -f core conftest.err conftest.$ac_objext \
14531 conftest$ac_exeext conftest.$ac_ext
14532LIBS=$ac_check_lib_save_LIBS
14533fi
14534{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kstat_kstat_open" >&5
14535$as_echo "$ac_cv_lib_kstat_kstat_open" >&6; }
14536if test "x$ac_cv_lib_kstat_kstat_open" = xyes; then :
14537 cat >>confdefs.h <<_ACEOF
14538#define HAVE_LIBKSTAT 1
14539_ACEOF
14540
14541 LIBS="-lkstat $LIBS"
14542
14543fi
14544
14545test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes
14546
14547# AIX has libperfstat which does not require root
14548{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for perfstat_cpu_total in -lperfstat" >&5
14549$as_echo_n "checking for perfstat_cpu_total in -lperfstat... " >&6; }
14550if ${ac_cv_lib_perfstat_perfstat_cpu_total+:} false; then :
14551 $as_echo_n "(cached) " >&6
14552else
14553 ac_check_lib_save_LIBS=$LIBS
14554LIBS="-lperfstat $LIBS"
14555cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14556/* end confdefs.h. */
14557
14558/* Override any GCC internal prototype to avoid an error.
14559 Use char because int might match the return type of a GCC
14560 builtin and then its argument prototype would still apply. */
14561#ifdef __cplusplus
14562extern "C"
14563#endif
14564char perfstat_cpu_total ();
14565int
14566main ()
14567{
14568return perfstat_cpu_total ();
14569 ;
14570 return 0;
14571}
14572_ACEOF
14573if ac_fn_c_try_link "$LINENO"; then :
14574 ac_cv_lib_perfstat_perfstat_cpu_total=yes
14575else
14576 ac_cv_lib_perfstat_perfstat_cpu_total=no
14577fi
14578rm -f core conftest.err conftest.$ac_objext \
14579 conftest$ac_exeext conftest.$ac_ext
14580LIBS=$ac_check_lib_save_LIBS
14581fi
14582{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_perfstat_perfstat_cpu_total" >&5
14583$as_echo "$ac_cv_lib_perfstat_perfstat_cpu_total" >&6; }
14584if test "x$ac_cv_lib_perfstat_perfstat_cpu_total" = xyes; then :
14585 cat >>confdefs.h <<_ACEOF
14586#define HAVE_LIBPERFSTAT 1
14587_ACEOF
14588
14589 LIBS="-lperfstat $LIBS"
14590
14591fi
14592
14593test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes
14594
14595# Some systems with -lutil have (and need) -lkvm as well, some do not.
14596# On Solaris, -lkvm requires nlist from -lelf, so check that first
14597# to get the right answer into the cache.
14598# For kstat on solaris, we need to test for libelf and libkvm to force the
14599# definition of SVR4 below.
14600if test $gl_have_func = no; then
14601 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_begin in -lelf" >&5
14602$as_echo_n "checking for elf_begin in -lelf... " >&6; }
14603if ${ac_cv_lib_elf_elf_begin+:} false; then :
14604 $as_echo_n "(cached) " >&6
14605else
14606 ac_check_lib_save_LIBS=$LIBS
14607LIBS="-lelf $LIBS"
14608cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14609/* end confdefs.h. */
14610
14611/* Override any GCC internal prototype to avoid an error.
14612 Use char because int might match the return type of a GCC
14613 builtin and then its argument prototype would still apply. */
14614#ifdef __cplusplus
14615extern "C"
14616#endif
14617char elf_begin ();
14618int
14619main ()
14620{
14621return elf_begin ();
14622 ;
14623 return 0;
14624}
14625_ACEOF
14626if ac_fn_c_try_link "$LINENO"; then :
14627 ac_cv_lib_elf_elf_begin=yes
14628else
14629 ac_cv_lib_elf_elf_begin=no
14630fi
14631rm -f core conftest.err conftest.$ac_objext \
14632 conftest$ac_exeext conftest.$ac_ext
14633LIBS=$ac_check_lib_save_LIBS
14634fi
14635{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf_begin" >&5
14636$as_echo "$ac_cv_lib_elf_elf_begin" >&6; }
14637if test "x$ac_cv_lib_elf_elf_begin" = xyes; then :
14638 LIBS="-lelf $LIBS"
14639fi
14640
14641 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kvm_open in -lkvm" >&5
14642$as_echo_n "checking for kvm_open in -lkvm... " >&6; }
14643if ${ac_cv_lib_kvm_kvm_open+:} false; then :
14644 $as_echo_n "(cached) " >&6
14645else
14646 ac_check_lib_save_LIBS=$LIBS
14647LIBS="-lkvm $LIBS"
14648cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14649/* end confdefs.h. */
14650
14651/* Override any GCC internal prototype to avoid an error.
14652 Use char because int might match the return type of a GCC
14653 builtin and then its argument prototype would still apply. */
14654#ifdef __cplusplus
14655extern "C"
14656#endif
14657char kvm_open ();
14658int
14659main ()
14660{
14661return kvm_open ();
14662 ;
14663 return 0;
14664}
14665_ACEOF
14666if ac_fn_c_try_link "$LINENO"; then :
14667 ac_cv_lib_kvm_kvm_open=yes
14668else
14669 ac_cv_lib_kvm_kvm_open=no
14670fi
14671rm -f core conftest.err conftest.$ac_objext \
14672 conftest$ac_exeext conftest.$ac_ext
14673LIBS=$ac_check_lib_save_LIBS
14674fi
14675{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kvm_kvm_open" >&5
14676$as_echo "$ac_cv_lib_kvm_kvm_open" >&6; }
14677if test "x$ac_cv_lib_kvm_kvm_open" = xyes; then :
14678 LIBS="-lkvm $LIBS"
14679fi
14680
14681 # Check for the 4.4BSD definition of getloadavg.
14682 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lutil" >&5
14683$as_echo_n "checking for getloadavg in -lutil... " >&6; }
14684if ${ac_cv_lib_util_getloadavg+:} false; then :
14685 $as_echo_n "(cached) " >&6
14686else
14687 ac_check_lib_save_LIBS=$LIBS
14688LIBS="-lutil $LIBS"
14689cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14690/* end confdefs.h. */
14691
14692/* Override any GCC internal prototype to avoid an error.
14693 Use char because int might match the return type of a GCC
14694 builtin and then its argument prototype would still apply. */
14695#ifdef __cplusplus
14696extern "C"
14697#endif
14698char getloadavg ();
14699int
14700main ()
14701{
14702return getloadavg ();
14703 ;
14704 return 0;
14705}
14706_ACEOF
14707if ac_fn_c_try_link "$LINENO"; then :
14708 ac_cv_lib_util_getloadavg=yes
14709else
14710 ac_cv_lib_util_getloadavg=no
14711fi
14712rm -f core conftest.err conftest.$ac_objext \
14713 conftest$ac_exeext conftest.$ac_ext
14714LIBS=$ac_check_lib_save_LIBS
14715fi
14716{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_getloadavg" >&5
14717$as_echo "$ac_cv_lib_util_getloadavg" >&6; }
14718if test "x$ac_cv_lib_util_getloadavg" = xyes; then :
14719 LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes
14720fi
14721
14722fi
14723
14724if test $gl_have_func = no; then
14725 # There is a commonly available library for RS/6000 AIX.
14726 # Since it is not a standard part of AIX, it might be installed locally.
14727 gl_getloadavg_LIBS=$LIBS
14728 LIBS="-L/usr/local/lib $LIBS"
14729 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lgetloadavg" >&5
14730$as_echo_n "checking for getloadavg in -lgetloadavg... " >&6; }
14731if ${ac_cv_lib_getloadavg_getloadavg+:} false; then :
14732 $as_echo_n "(cached) " >&6
14733else
14734 ac_check_lib_save_LIBS=$LIBS
14735LIBS="-lgetloadavg $LIBS"
14736cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14737/* end confdefs.h. */
14738
14739/* Override any GCC internal prototype to avoid an error.
14740 Use char because int might match the return type of a GCC
14741 builtin and then its argument prototype would still apply. */
14742#ifdef __cplusplus
14743extern "C"
14744#endif
14745char getloadavg ();
14746int
14747main ()
14748{
14749return getloadavg ();
14750 ;
14751 return 0;
14752}
14753_ACEOF
14754if ac_fn_c_try_link "$LINENO"; then :
14755 ac_cv_lib_getloadavg_getloadavg=yes
14756else
14757 ac_cv_lib_getloadavg_getloadavg=no
14758fi
14759rm -f core conftest.err conftest.$ac_objext \
14760 conftest$ac_exeext conftest.$ac_ext
14761LIBS=$ac_check_lib_save_LIBS
14762fi
14763{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_getloadavg_getloadavg" >&5
14764$as_echo "$ac_cv_lib_getloadavg_getloadavg" >&6; }
14765if test "x$ac_cv_lib_getloadavg_getloadavg" = xyes; then :
14766 LIBS="-lgetloadavg $LIBS"
14767else
14768 LIBS=$gl_getloadavg_LIBS
14769fi
14770
14771fi
14772
14773# Make sure it is really in the library, if we think we found it,
14774# otherwise set up the replacement function.
14775for ac_func in getloadavg
14776do :
14777 ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg"
14778if test "x$ac_cv_func_getloadavg" = xyes; then :
14779 cat >>confdefs.h <<_ACEOF
14780#define HAVE_GETLOADAVG 1
14781_ACEOF
14782
14783else
14784
14785
14786
14787
14788
14789
14790
14791
14792 gl_LIBOBJS="$gl_LIBOBJS getloadavg.$ac_objext"
14793
14794
14795$as_echo "#define C_GETLOADAVG 1" >>confdefs.h
14796
14797# Figure out what our getloadavg.c needs.
14798gl_have_func=no
14799ac_fn_c_check_header_mongrel "$LINENO" "sys/dg_sys_info.h" "ac_cv_header_sys_dg_sys_info_h" "$ac_includes_default"
14800if test "x$ac_cv_header_sys_dg_sys_info_h" = xyes; then :
14801 gl_have_func=yes
14802
14803$as_echo "#define DGUX 1" >>confdefs.h
14804
14805 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dg_sys_info in -ldgc" >&5
14806$as_echo_n "checking for dg_sys_info in -ldgc... " >&6; }
14807if ${ac_cv_lib_dgc_dg_sys_info+:} false; then :
14808 $as_echo_n "(cached) " >&6
14809else
14810 ac_check_lib_save_LIBS=$LIBS
14811LIBS="-ldgc $LIBS"
14812cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14813/* end confdefs.h. */
14814
14815/* Override any GCC internal prototype to avoid an error.
14816 Use char because int might match the return type of a GCC
14817 builtin and then its argument prototype would still apply. */
14818#ifdef __cplusplus
14819extern "C"
14820#endif
14821char dg_sys_info ();
14822int
14823main ()
14824{
14825return dg_sys_info ();
14826 ;
14827 return 0;
14828}
14829_ACEOF
14830if ac_fn_c_try_link "$LINENO"; then :
14831 ac_cv_lib_dgc_dg_sys_info=yes
14832else
14833 ac_cv_lib_dgc_dg_sys_info=no
14834fi
14835rm -f core conftest.err conftest.$ac_objext \
14836 conftest$ac_exeext conftest.$ac_ext
14837LIBS=$ac_check_lib_save_LIBS
14838fi
14839{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dgc_dg_sys_info" >&5
14840$as_echo "$ac_cv_lib_dgc_dg_sys_info" >&6; }
14841if test "x$ac_cv_lib_dgc_dg_sys_info" = xyes; then :
14842 cat >>confdefs.h <<_ACEOF
14843#define HAVE_LIBDGC 1
14844_ACEOF
14845
14846 LIBS="-ldgc $LIBS"
14847
14848fi
14849
14850fi
14851
14852
14853
14854# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
14855# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
14856# Irix 4.0.5F has the header but not the library.
14857if test $gl_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \
14858 && test "$ac_cv_lib_kvm_kvm_open" = yes; then
14859 gl_have_func=yes
14860
14861$as_echo "#define SVR4 1" >>confdefs.h
14862
14863fi
14864
14865if test $gl_have_func = no; then
14866 ac_fn_c_check_header_mongrel "$LINENO" "inq_stats/cpustats.h" "ac_cv_header_inq_stats_cpustats_h" "$ac_includes_default"
14867if test "x$ac_cv_header_inq_stats_cpustats_h" = xyes; then :
14868 gl_have_func=yes
14869
14870$as_echo "#define UMAX 1" >>confdefs.h
14871
14872
14873$as_echo "#define UMAX4_3 1" >>confdefs.h
14874
14875fi
14876
14877
14878fi
14879
14880if test $gl_have_func = no; then
14881 ac_fn_c_check_header_mongrel "$LINENO" "sys/cpustats.h" "ac_cv_header_sys_cpustats_h" "$ac_includes_default"
14882if test "x$ac_cv_header_sys_cpustats_h" = xyes; then :
14883 gl_have_func=yes; $as_echo "#define UMAX 1" >>confdefs.h
14884
14885fi
14886
14887
14888fi
14889
14890if test $gl_have_func = no; then
14891 for ac_header in mach/mach.h
14892do :
14893 ac_fn_c_check_header_mongrel "$LINENO" "mach/mach.h" "ac_cv_header_mach_mach_h" "$ac_includes_default"
14894if test "x$ac_cv_header_mach_mach_h" = xyes; then :
14895 cat >>confdefs.h <<_ACEOF
14896#define HAVE_MACH_MACH_H 1
14897_ACEOF
14898
14899fi
14900
14901done
14902
14903fi
14904
14905for ac_header in nlist.h
14906do :
14907 ac_fn_c_check_header_mongrel "$LINENO" "nlist.h" "ac_cv_header_nlist_h" "$ac_includes_default"
14908if test "x$ac_cv_header_nlist_h" = xyes; then :
14909 cat >>confdefs.h <<_ACEOF
14910#define HAVE_NLIST_H 1
14911_ACEOF
14912 ac_fn_c_check_member "$LINENO" "struct nlist" "n_un.n_name" "ac_cv_member_struct_nlist_n_un_n_name" "#include <nlist.h>
14913"
14914if test "x$ac_cv_member_struct_nlist_n_un_n_name" = xyes; then :
14915
14916cat >>confdefs.h <<_ACEOF
14917#define HAVE_STRUCT_NLIST_N_UN_N_NAME 1
14918_ACEOF
14919
14920
14921$as_echo "#define NLIST_NAME_UNION 1" >>confdefs.h
14922
14923fi
14924
14925 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14926/* end confdefs.h. */
14927#include <nlist.h>
14928int
14929main ()
14930{
14931struct nlist x;
14932 #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
14933 x.n_un.n_name = "";
14934 #else
14935 x.n_name = "";
14936 #endif
14937 ;
14938 return 0;
14939}
14940_ACEOF
14941if ac_fn_c_try_link "$LINENO"; then :
14942
14943$as_echo "#define N_NAME_POINTER 1" >>confdefs.h
14944
14945fi
14946rm -f core conftest.err conftest.$ac_objext \
14947 conftest$ac_exeext conftest.$ac_ext
14948
14949fi
14950
14951done
14952
14953fi
14954done
14955
14956
14957# Some definitions of getloadavg require that the program be installed setgid.
14958{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getloadavg requires setgid" >&5
14959$as_echo_n "checking whether getloadavg requires setgid... " >&6; }
14960if ${gl_cv_func_getloadavg_setgid+:} false; then :
14961 $as_echo_n "(cached) " >&6
14962else
14963 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14964/* end confdefs.h. */
14965#define CONFIGURING_GETLOADAVG
14966#include "$srcdir/$gl_source_base/getloadavg.c"
14967#ifdef LDAV_PRIVILEGED
14968Yowza Am I SETGID yet
14969#endif
14970
14971_ACEOF
14972if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
14973 $EGREP "Yowza Am I SETGID yet" >/dev/null 2>&1; then :
14974 gl_cv_func_getloadavg_setgid=yes
14975else
14976 gl_cv_func_getloadavg_setgid=no
14977fi
14978rm -f conftest*
14979
14980fi
14981{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getloadavg_setgid" >&5
14982$as_echo "$gl_cv_func_getloadavg_setgid" >&6; }
14983if test $gl_cv_func_getloadavg_setgid = yes; then
14984 NEED_SETGID=true
14985
14986$as_echo "#define GETLOADAVG_PRIVILEGED 1" >>confdefs.h
14987
14988else
14989 NEED_SETGID=false
14990fi
14991
14992if test $gl_cv_func_getloadavg_setgid = yes; then
14993 { $as_echo "$as_me:${as_lineno-$LINENO}: checking group of /dev/kmem" >&5
14994$as_echo_n "checking group of /dev/kmem... " >&6; }
14995if ${gl_cv_group_kmem+:} false; then :
14996 $as_echo_n "(cached) " >&6
14997else
14998 # On Solaris, /dev/kmem is a symlink. Get info on the real file.
14999 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
15000 # If we got an error (system does not support symlinks), try without -L.
15001 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
15002 gl_cv_group_kmem=`echo $ac_ls_output \
15003 | sed -ne 's/[ ][ ]*/ /g
15004 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/
15005 / /s/.* //;p'`
15006
15007fi
15008{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_group_kmem" >&5
15009$as_echo "$gl_cv_group_kmem" >&6; }
15010 KMEM_GROUP=$gl_cv_group_kmem
15011fi
15012if test "x$gl_save_LIBS" = x; then
15013 GETLOADAVG_LIBS=$LIBS
15014else
15015 GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$gl_save_LIBS!!"`
15016fi
15017LIBS=$gl_save_LIBS
15018
15019
15020# Test whether the system declares getloadavg. Solaris has the function
15021# but declares it in <sys/loadavg.h>, not <stdlib.h>.
15022for ac_header in sys/loadavg.h
15023do :
15024 ac_fn_c_check_header_mongrel "$LINENO" "sys/loadavg.h" "ac_cv_header_sys_loadavg_h" "$ac_includes_default"
15025if test "x$ac_cv_header_sys_loadavg_h" = xyes; then :
15026 cat >>confdefs.h <<_ACEOF
15027#define HAVE_SYS_LOADAVG_H 1
15028_ACEOF
15029
15030fi
15031
15032done
15033
15034if test $ac_cv_header_sys_loadavg_h = yes; then
15035 HAVE_SYS_LOADAVG_H=1
15036else
15037 HAVE_SYS_LOADAVG_H=0
15038fi
15039ac_fn_c_check_decl "$LINENO" "getloadavg" "ac_cv_have_decl_getloadavg" "#if HAVE_SYS_LOADAVG_H
15040 # include <sys/loadavg.h>
15041 #endif
15042 #include <stdlib.h>
15043"
15044if test "x$ac_cv_have_decl_getloadavg" = xyes; then :
15045
15046else
15047 HAVE_DECL_GETLOADAVG=0
15048fi
15049
15050
15051
15052
15053
15054 GNULIB_GETLOADAVG=1
15055
15056
15057
14833 # Code from module getopt-gnu: 15058 # Code from module getopt-gnu:
14834 15059
14835 15060
@@ -15261,6 +15486,84 @@ $as_echo "$gl_cv_next_stddef_h" >&6; }
15261 15486
15262 fi 15487 fi
15263 15488
15489 # Code from module stdlib:
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500 if test $gl_cv_have_include_next = yes; then
15501 gl_cv_next_stdlib_h='<'stdlib.h'>'
15502 else
15503 { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stdlib.h>" >&5
15504$as_echo_n "checking absolute name of <stdlib.h>... " >&6; }
15505if ${gl_cv_next_stdlib_h+:} false; then :
15506 $as_echo_n "(cached) " >&6
15507else
15508
15509 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15510/* end confdefs.h. */
15511#include <stdlib.h>
15512
15513_ACEOF
15514 case "$host_os" in
15515 aix*) gl_absname_cpp="$ac_cpp -C" ;;
15516 *) gl_absname_cpp="$ac_cpp" ;;
15517 esac
15518 gl_cv_next_stdlib_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
15519 sed -n '\#/stdlib.h#{
15520 s#.*"\(.*/stdlib.h\)".*#\1#
15521 s#^/[^/]#//&#
15522 p
15523 q
15524 }'`'"'
15525
15526
15527fi
15528{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdlib_h" >&5
15529$as_echo "$gl_cv_next_stdlib_h" >&6; }
15530 fi
15531 NEXT_STDLIB_H=$gl_cv_next_stdlib_h
15532
15533 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
15534 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
15535 gl_next_as_first_directive='<'stdlib.h'>'
15536 else
15537 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
15538 gl_next_as_first_directive=$gl_cv_next_stdlib_h
15539 fi
15540 NEXT_AS_FIRST_DIRECTIVE_STDLIB_H=$gl_next_as_first_directive
15541
15542
15543
15544
15545 for ac_header in random.h
15546do :
15547 ac_fn_c_check_header_compile "$LINENO" "random.h" "ac_cv_header_random_h" "$ac_includes_default
15548"
15549if test "x$ac_cv_header_random_h" = xyes; then :
15550 cat >>confdefs.h <<_ACEOF
15551#define HAVE_RANDOM_H 1
15552_ACEOF
15553
15554fi
15555
15556done
15557
15558 if test $ac_cv_header_random_h = yes; then
15559 HAVE_RANDOM_H=1
15560 else
15561 HAVE_RANDOM_H=0
15562 fi
15563
15564
15565
15566
15264 # Code from module strftime: 15567 # Code from module strftime:
15265 15568
15266 15569
@@ -17078,7 +17381,6 @@ S_FILE="\$(srcdir)/${opsysfile}"
17078 17381
17079 17382
17080 17383
17081
17082cat >>confdefs.h <<_ACEOF 17384cat >>confdefs.h <<_ACEOF
17083#define EMACS_CONFIGURATION "${canonical}" 17385#define EMACS_CONFIGURATION "${canonical}"
17084_ACEOF 17386_ACEOF
diff --git a/configure.in b/configure.in
index 58e445b98a6..d095e08fb23 100644
--- a/configure.in
+++ b/configure.in
@@ -984,7 +984,7 @@ case "$opsys" in
984 984
985 hpux*) LIBS_SYSTEM="-l:libdld.sl" ;; 985 hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
986 986
987 sol2*) LIBS_SYSTEM="-lsocket -lnsl -lkstat" ;; 987 sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
988 988
989 ## Motif needs -lgen. 989 ## Motif needs -lgen.
990 unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;; 990 unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
@@ -1000,9 +1000,6 @@ else
1000 CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS" 1000 CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
1001fi 1001fi
1002 1002
1003dnl For AC_FUNC_GETLOADAVG, at least:
1004AC_CONFIG_LIBOBJ_DIR(src)
1005
1006dnl Do this early because it can frob feature test macros for Unix-98 &c. 1003dnl Do this early because it can frob feature test macros for Unix-98 &c.
1007AC_SYS_LARGEFILE 1004AC_SYS_LARGEFILE
1008 1005
@@ -2665,8 +2662,6 @@ fi
2665 2662
2666AC_CHECK_HEADERS(sys/un.h) 2663AC_CHECK_HEADERS(sys/un.h)
2667 2664
2668AC_FUNC_GETLOADAVG
2669
2670AC_FUNC_FSEEKO 2665AC_FUNC_FSEEKO
2671 2666
2672AC_FUNC_GETPGRP 2667AC_FUNC_GETPGRP
@@ -3115,7 +3110,6 @@ fi
3115S_FILE="\$(srcdir)/${opsysfile}" 3110S_FILE="\$(srcdir)/${opsysfile}"
3116AC_SUBST(M_FILE) 3111AC_SUBST(M_FILE)
3117AC_SUBST(S_FILE) 3112AC_SUBST(S_FILE)
3118AC_SUBST(GETLOADAVG_LIBS)
3119AC_SUBST(ns_appdir) 3113AC_SUBST(ns_appdir)
3120AC_SUBST(ns_appbindir) 3114AC_SUBST(ns_appbindir)
3121AC_SUBST(ns_appresdir) 3115AC_SUBST(ns_appresdir)
diff --git a/lib/Makefile.in b/lib/Makefile.in
index e50f9b31ef3..5e170d155e8 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -24,7 +24,7 @@
24# the same distribution terms as the rest of that program. 24# the same distribution terms as the rest of that program.
25# 25#
26# Generated by gnulib-tool. 26# Generated by gnulib-tool.
27# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dtoastr getopt-gnu ignore-value mktime strftime 27# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dtoastr getloadavg getopt-gnu ignore-value mktime strftime
28 28
29VPATH = @srcdir@ 29VPATH = @srcdir@
30pkgdatadir = $(datadir)/@PACKAGE@ 30pkgdatadir = $(datadir)/@PACKAGE@
@@ -51,14 +51,15 @@ subdir = lib
51ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 51ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
52am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ 52am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
53 $(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/extensions.m4 \ 53 $(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/extensions.m4 \
54 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gl-comp.m4 \ 54 $(top_srcdir)/m4/getloadavg.m4 $(top_srcdir)/m4/getopt.m4 \
55 $(top_srcdir)/m4/gnulib-common.m4 \ 55 $(top_srcdir)/m4/gl-comp.m4 $(top_srcdir)/m4/gnulib-common.m4 \
56 $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/mktime.m4 \ 56 $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/mktime.m4 \
57 $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/stdbool.m4 \ 57 $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/stdbool.m4 \
58 $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/strftime.m4 \ 58 $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \
59 $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ 59 $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/time_h.m4 \
60 $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/unistd_h.m4 \ 60 $(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \
61 $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/configure.in 61 $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/wchar_t.m4 \
62 $(top_srcdir)/configure.in
62am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 63am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
63 $(ACLOCAL_M4) 64 $(ACLOCAL_M4)
64mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs 65mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -134,6 +135,9 @@ GCONF_LIBS = @GCONF_LIBS@
134GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ 135GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
135GETOPT_H = @GETOPT_H@ 136GETOPT_H = @GETOPT_H@
136GMALLOC_OBJ = @GMALLOC_OBJ@ 137GMALLOC_OBJ = @GMALLOC_OBJ@
138GNULIB_ATOLL = @GNULIB_ATOLL@
139GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
140GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
137GNULIB_CHOWN = @GNULIB_CHOWN@ 141GNULIB_CHOWN = @GNULIB_CHOWN@
138GNULIB_CLOSE = @GNULIB_CLOSE@ 142GNULIB_CLOSE = @GNULIB_CLOSE@
139GNULIB_DUP2 = @GNULIB_DUP2@ 143GNULIB_DUP2 = @GNULIB_DUP2@
@@ -150,27 +154,47 @@ GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
150GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ 154GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
151GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ 155GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
152GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ 156GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
157GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
153GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ 158GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
154GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ 159GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
155GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ 160GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
161GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
156GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@ 162GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
163GNULIB_GRANTPT = @GNULIB_GRANTPT@
157GNULIB_LCHOWN = @GNULIB_LCHOWN@ 164GNULIB_LCHOWN = @GNULIB_LCHOWN@
158GNULIB_LINK = @GNULIB_LINK@ 165GNULIB_LINK = @GNULIB_LINK@
159GNULIB_LINKAT = @GNULIB_LINKAT@ 166GNULIB_LINKAT = @GNULIB_LINKAT@
160GNULIB_LSEEK = @GNULIB_LSEEK@ 167GNULIB_LSEEK = @GNULIB_LSEEK@
168GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
169GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
170GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
171GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
172GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
173GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
161GNULIB_MKTIME = @GNULIB_MKTIME@ 174GNULIB_MKTIME = @GNULIB_MKTIME@
162GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@ 175GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
163GNULIB_PIPE = @GNULIB_PIPE@ 176GNULIB_PIPE = @GNULIB_PIPE@
164GNULIB_PIPE2 = @GNULIB_PIPE2@ 177GNULIB_PIPE2 = @GNULIB_PIPE2@
165GNULIB_PREAD = @GNULIB_PREAD@ 178GNULIB_PREAD = @GNULIB_PREAD@
179GNULIB_PTSNAME = @GNULIB_PTSNAME@
180GNULIB_PUTENV = @GNULIB_PUTENV@
166GNULIB_PWRITE = @GNULIB_PWRITE@ 181GNULIB_PWRITE = @GNULIB_PWRITE@
182GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
167GNULIB_READLINK = @GNULIB_READLINK@ 183GNULIB_READLINK = @GNULIB_READLINK@
168GNULIB_READLINKAT = @GNULIB_READLINKAT@ 184GNULIB_READLINKAT = @GNULIB_READLINKAT@
185GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
186GNULIB_REALPATH = @GNULIB_REALPATH@
169GNULIB_RMDIR = @GNULIB_RMDIR@ 187GNULIB_RMDIR = @GNULIB_RMDIR@
188GNULIB_RPMATCH = @GNULIB_RPMATCH@
189GNULIB_SETENV = @GNULIB_SETENV@
170GNULIB_SLEEP = @GNULIB_SLEEP@ 190GNULIB_SLEEP = @GNULIB_SLEEP@
171GNULIB_STRPTIME = @GNULIB_STRPTIME@ 191GNULIB_STRPTIME = @GNULIB_STRPTIME@
192GNULIB_STRTOD = @GNULIB_STRTOD@
193GNULIB_STRTOLL = @GNULIB_STRTOLL@
194GNULIB_STRTOULL = @GNULIB_STRTOULL@
172GNULIB_SYMLINK = @GNULIB_SYMLINK@ 195GNULIB_SYMLINK = @GNULIB_SYMLINK@
173GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ 196GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
197GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
174GNULIB_TIMEGM = @GNULIB_TIMEGM@ 198GNULIB_TIMEGM = @GNULIB_TIMEGM@
175GNULIB_TIME_R = @GNULIB_TIME_R@ 199GNULIB_TIME_R = @GNULIB_TIME_R@
176GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@ 200GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
@@ -178,8 +202,11 @@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
178GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ 202GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
179GNULIB_UNLINK = @GNULIB_UNLINK@ 203GNULIB_UNLINK = @GNULIB_UNLINK@
180GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ 204GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
205GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
206GNULIB_UNSETENV = @GNULIB_UNSETENV@
181GNULIB_USLEEP = @GNULIB_USLEEP@ 207GNULIB_USLEEP = @GNULIB_USLEEP@
182GNULIB_WRITE = @GNULIB_WRITE@ 208GNULIB_WRITE = @GNULIB_WRITE@
209GNULIB__EXIT = @GNULIB__EXIT@
183GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@ 210GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@
184GREP = @GREP@ 211GREP = @GREP@
185GTK_CFLAGS = @GTK_CFLAGS@ 212GTK_CFLAGS = @GTK_CFLAGS@
@@ -187,15 +214,20 @@ GTK_LIBS = @GTK_LIBS@
187GTK_OBJ = @GTK_OBJ@ 214GTK_OBJ = @GTK_OBJ@
188GZIP_INFO = @GZIP_INFO@ 215GZIP_INFO = @GZIP_INFO@
189GZIP_PROG = @GZIP_PROG@ 216GZIP_PROG = @GZIP_PROG@
217HAVE_ATOLL = @HAVE_ATOLL@
218HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
190HAVE_CHOWN = @HAVE_CHOWN@ 219HAVE_CHOWN = @HAVE_CHOWN@
191HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@ 220HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
192HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@ 221HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
193HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@ 222HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
223HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
194HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@ 224HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
195HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@ 225HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
196HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@ 226HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
197HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@ 227HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
228HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
198HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@ 229HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
230HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
199HAVE_DUP2 = @HAVE_DUP2@ 231HAVE_DUP2 = @HAVE_DUP2@
200HAVE_DUP3 = @HAVE_DUP3@ 232HAVE_DUP3 = @HAVE_DUP3@
201HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ 233HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
@@ -210,30 +242,50 @@ HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
210HAVE_GETLOGIN = @HAVE_GETLOGIN@ 242HAVE_GETLOGIN = @HAVE_GETLOGIN@
211HAVE_GETOPT_H = @HAVE_GETOPT_H@ 243HAVE_GETOPT_H = @HAVE_GETOPT_H@
212HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ 244HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
245HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
246HAVE_GRANTPT = @HAVE_GRANTPT@
213HAVE_LCHOWN = @HAVE_LCHOWN@ 247HAVE_LCHOWN = @HAVE_LCHOWN@
214HAVE_LINK = @HAVE_LINK@ 248HAVE_LINK = @HAVE_LINK@
215HAVE_LINKAT = @HAVE_LINKAT@ 249HAVE_LINKAT = @HAVE_LINKAT@
216HAVE_MAKEINFO = @HAVE_MAKEINFO@ 250HAVE_MAKEINFO = @HAVE_MAKEINFO@
251HAVE_MKDTEMP = @HAVE_MKDTEMP@
252HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
253HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
254HAVE_MKSTEMP = @HAVE_MKSTEMP@
255HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
217HAVE_NANOSLEEP = @HAVE_NANOSLEEP@ 256HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
218HAVE_OS_H = @HAVE_OS_H@ 257HAVE_OS_H = @HAVE_OS_H@
219HAVE_PIPE = @HAVE_PIPE@ 258HAVE_PIPE = @HAVE_PIPE@
220HAVE_PIPE2 = @HAVE_PIPE2@ 259HAVE_PIPE2 = @HAVE_PIPE2@
221HAVE_PREAD = @HAVE_PREAD@ 260HAVE_PREAD = @HAVE_PREAD@
261HAVE_PTSNAME = @HAVE_PTSNAME@
222HAVE_PWRITE = @HAVE_PWRITE@ 262HAVE_PWRITE = @HAVE_PWRITE@
263HAVE_RANDOM_H = @HAVE_RANDOM_H@
264HAVE_RANDOM_R = @HAVE_RANDOM_R@
223HAVE_READLINK = @HAVE_READLINK@ 265HAVE_READLINK = @HAVE_READLINK@
224HAVE_READLINKAT = @HAVE_READLINKAT@ 266HAVE_READLINKAT = @HAVE_READLINKAT@
267HAVE_REALPATH = @HAVE_REALPATH@
268HAVE_RPMATCH = @HAVE_RPMATCH@
269HAVE_SETENV = @HAVE_SETENV@
225HAVE_SLEEP = @HAVE_SLEEP@ 270HAVE_SLEEP = @HAVE_SLEEP@
226HAVE_STRPTIME = @HAVE_STRPTIME@ 271HAVE_STRPTIME = @HAVE_STRPTIME@
272HAVE_STRTOD = @HAVE_STRTOD@
273HAVE_STRTOLL = @HAVE_STRTOLL@
274HAVE_STRTOULL = @HAVE_STRTOULL@
275HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
227HAVE_SYMLINK = @HAVE_SYMLINK@ 276HAVE_SYMLINK = @HAVE_SYMLINK@
228HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ 277HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
278HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
229HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@ 279HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
230HAVE_TIMEGM = @HAVE_TIMEGM@ 280HAVE_TIMEGM = @HAVE_TIMEGM@
231HAVE_UNISTD_H = @HAVE_UNISTD_H@ 281HAVE_UNISTD_H = @HAVE_UNISTD_H@
232HAVE_UNLINKAT = @HAVE_UNLINKAT@ 282HAVE_UNLINKAT = @HAVE_UNLINKAT@
283HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
233HAVE_USLEEP = @HAVE_USLEEP@ 284HAVE_USLEEP = @HAVE_USLEEP@
234HAVE_WCHAR_T = @HAVE_WCHAR_T@ 285HAVE_WCHAR_T = @HAVE_WCHAR_T@
235HAVE_XSERVER = @HAVE_XSERVER@ 286HAVE_XSERVER = @HAVE_XSERVER@
236HAVE__BOOL = @HAVE__BOOL@ 287HAVE__BOOL = @HAVE__BOOL@
288HAVE__EXIT = @HAVE__EXIT@
237IMAGEMAGICK_CFLAGS = @IMAGEMAGICK_CFLAGS@ 289IMAGEMAGICK_CFLAGS = @IMAGEMAGICK_CFLAGS@
238IMAGEMAGICK_LIBS = @IMAGEMAGICK_LIBS@ 290IMAGEMAGICK_LIBS = @IMAGEMAGICK_LIBS@
239INCLUDE_NEXT = @INCLUDE_NEXT@ 291INCLUDE_NEXT = @INCLUDE_NEXT@
@@ -300,10 +352,12 @@ M_FILE = @M_FILE@
300NEED_SETGID = @NEED_SETGID@ 352NEED_SETGID = @NEED_SETGID@
301NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ 353NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
302NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ 354NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
355NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
303NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ 356NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
304NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ 357NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
305NEXT_GETOPT_H = @NEXT_GETOPT_H@ 358NEXT_GETOPT_H = @NEXT_GETOPT_H@
306NEXT_STDDEF_H = @NEXT_STDDEF_H@ 359NEXT_STDDEF_H = @NEXT_STDDEF_H@
360NEXT_STDLIB_H = @NEXT_STDLIB_H@
307NEXT_TIME_H = @NEXT_TIME_H@ 361NEXT_TIME_H = @NEXT_TIME_H@
308NEXT_UNISTD_H = @NEXT_UNISTD_H@ 362NEXT_UNISTD_H = @NEXT_UNISTD_H@
309NS_OBJ = @NS_OBJ@ 363NS_OBJ = @NS_OBJ@
@@ -330,6 +384,8 @@ PROFILING_CFLAGS = @PROFILING_CFLAGS@
330PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ 384PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
331RALLOC_OBJ = @RALLOC_OBJ@ 385RALLOC_OBJ = @RALLOC_OBJ@
332RANLIB = @RANLIB@ 386RANLIB = @RANLIB@
387REPLACE_CALLOC = @REPLACE_CALLOC@
388REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
333REPLACE_CHOWN = @REPLACE_CHOWN@ 389REPLACE_CHOWN = @REPLACE_CHOWN@
334REPLACE_CLOSE = @REPLACE_CLOSE@ 390REPLACE_CLOSE = @REPLACE_CLOSE@
335REPLACE_DUP = @REPLACE_DUP@ 391REPLACE_DUP = @REPLACE_DUP@
@@ -345,19 +401,27 @@ REPLACE_LINK = @REPLACE_LINK@
345REPLACE_LINKAT = @REPLACE_LINKAT@ 401REPLACE_LINKAT = @REPLACE_LINKAT@
346REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ 402REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
347REPLACE_LSEEK = @REPLACE_LSEEK@ 403REPLACE_LSEEK = @REPLACE_LSEEK@
404REPLACE_MALLOC = @REPLACE_MALLOC@
405REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
348REPLACE_MKTIME = @REPLACE_MKTIME@ 406REPLACE_MKTIME = @REPLACE_MKTIME@
349REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ 407REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
350REPLACE_NULL = @REPLACE_NULL@ 408REPLACE_NULL = @REPLACE_NULL@
351REPLACE_PREAD = @REPLACE_PREAD@ 409REPLACE_PREAD = @REPLACE_PREAD@
410REPLACE_PUTENV = @REPLACE_PUTENV@
352REPLACE_PWRITE = @REPLACE_PWRITE@ 411REPLACE_PWRITE = @REPLACE_PWRITE@
353REPLACE_READLINK = @REPLACE_READLINK@ 412REPLACE_READLINK = @REPLACE_READLINK@
413REPLACE_REALLOC = @REPLACE_REALLOC@
414REPLACE_REALPATH = @REPLACE_REALPATH@
354REPLACE_RMDIR = @REPLACE_RMDIR@ 415REPLACE_RMDIR = @REPLACE_RMDIR@
416REPLACE_SETENV = @REPLACE_SETENV@
355REPLACE_SLEEP = @REPLACE_SLEEP@ 417REPLACE_SLEEP = @REPLACE_SLEEP@
418REPLACE_STRTOD = @REPLACE_STRTOD@
356REPLACE_SYMLINK = @REPLACE_SYMLINK@ 419REPLACE_SYMLINK = @REPLACE_SYMLINK@
357REPLACE_TIMEGM = @REPLACE_TIMEGM@ 420REPLACE_TIMEGM = @REPLACE_TIMEGM@
358REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@ 421REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
359REPLACE_UNLINK = @REPLACE_UNLINK@ 422REPLACE_UNLINK = @REPLACE_UNLINK@
360REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ 423REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
424REPLACE_UNSETENV = @REPLACE_UNSETENV@
361REPLACE_USLEEP = @REPLACE_USLEEP@ 425REPLACE_USLEEP = @REPLACE_USLEEP@
362REPLACE_WRITE = @REPLACE_WRITE@ 426REPLACE_WRITE = @REPLACE_WRITE@
363RSVG_CFLAGS = @RSVG_CFLAGS@ 427RSVG_CFLAGS = @RSVG_CFLAGS@
@@ -471,23 +535,23 @@ x_default_search_path = @x_default_search_path@
471# present in all Makefile.am that need it. This is ensured by the applicability 535# present in all Makefile.am that need it. This is ensured by the applicability
472# 'all' defined above. 536# 'all' defined above.
473BUILT_SOURCES = arg-nonnull.h c++defs.h $(GETOPT_H) $(STDBOOL_H) \ 537BUILT_SOURCES = arg-nonnull.h c++defs.h $(GETOPT_H) $(STDBOOL_H) \
474 $(STDDEF_H) time.h unistd.h warn-on-use.h 538 $(STDDEF_H) stdlib.h time.h unistd.h warn-on-use.h
475EXTRA_DIST = $(top_srcdir)/./arg-nonnull.h $(top_srcdir)/./c++defs.h \ 539EXTRA_DIST = $(top_srcdir)/./arg-nonnull.h $(top_srcdir)/./c++defs.h \
476 ftoastr.c ftoastr.h getopt.c getopt.in.h getopt1.c \ 540 ftoastr.c ftoastr.h getloadavg.c getopt.c getopt.in.h \
477 getopt_int.h intprops.h mktime-internal.h mktime.c \ 541 getopt1.c getopt_int.h intprops.h mktime-internal.h mktime.c \
478 stdbool.in.h stddef.in.h strftime.c strftime.h time.in.h \ 542 stdbool.in.h stddef.in.h stdlib.in.h strftime.c strftime.h \
479 time_r.c unistd.in.h $(top_srcdir)/./warn-on-use.h 543 time.in.h time_r.c unistd.in.h $(top_srcdir)/./warn-on-use.h
480MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \ 544MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \
481 c++defs.h c++defs.h-t getopt.h getopt.h-t stdbool.h \ 545 c++defs.h c++defs.h-t getopt.h getopt.h-t stdbool.h \
482 stdbool.h-t stddef.h stddef.h-t time.h time.h-t unistd.h \ 546 stdbool.h-t stddef.h stddef.h-t stdlib.h stdlib.h-t time.h \
483 unistd.h-t warn-on-use.h warn-on-use.h-t 547 time.h-t unistd.h unistd.h-t warn-on-use.h warn-on-use.h-t
484noinst_LIBRARIES = libgnu.a 548noinst_LIBRARIES = libgnu.a
485DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src 549DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src
486libgnu_a_SOURCES = dtoastr.c gettext.h ignore-value.h 550libgnu_a_SOURCES = dtoastr.c gettext.h ignore-value.h
487libgnu_a_LIBADD = $(gl_LIBOBJS) 551libgnu_a_LIBADD = $(gl_LIBOBJS)
488libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 552libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
489EXTRA_libgnu_a_SOURCES = ftoastr.c getopt.c getopt1.c mktime.c \ 553EXTRA_libgnu_a_SOURCES = ftoastr.c getloadavg.c getopt.c getopt1.c \
490 strftime.c time_r.c 554 mktime.c strftime.c time_r.c
491ARG_NONNULL_H = arg-nonnull.h 555ARG_NONNULL_H = arg-nonnull.h
492CXXDEFS_H = c++defs.h 556CXXDEFS_H = c++defs.h
493WARN_ON_USE_H = warn-on-use.h 557WARN_ON_USE_H = warn-on-use.h
@@ -542,6 +606,7 @@ distclean-compile:
542 606
543@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtoastr.Po@am__quote@ 607@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtoastr.Po@am__quote@
544@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@ 608@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@
609@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getloadavg.Po@am__quote@
545@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ 610@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
546@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@ 611@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@
547@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@ 612@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@
@@ -818,6 +883,82 @@ stddef.h: stddef.in.h
818 } > $@-t && \ 883 } > $@-t && \
819 mv $@-t $@ 884 mv $@-t $@
820 885
886# We need the following in order to create <stdlib.h> when the system
887# doesn't have one that works with the given compiler.
888stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
889 $(AM_V_GEN)rm -f $@-t $@ && \
890 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
891 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
892 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
893 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
894 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
895 -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \
896 -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
897 -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
898 -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \
899 -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
900 -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
901 -e 's|@''GNULIB_GRANTPT''@|$(GNULIB_GRANTPT)|g' \
902 -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
903 -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
904 -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \
905 -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \
906 -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
907 -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
908 -e 's|@''GNULIB_PTSNAME''@|$(GNULIB_PTSNAME)|g' \
909 -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
910 -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
911 -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
912 -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \
913 -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
914 -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
915 -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
916 -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
917 -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
918 -e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \
919 -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \
920 -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
921 -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
922 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
923 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
924 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
925 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
926 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
927 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
928 -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
929 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
930 -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
931 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
932 -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
933 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
934 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
935 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
936 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
937 -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
938 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
939 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
940 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
941 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
942 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
943 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
944 -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
945 -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
946 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
947 -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
948 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
949 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
950 -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
951 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
952 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
953 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
954 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
955 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
956 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
957 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
958 < $(srcdir)/stdlib.in.h; \
959 } > $@-t && \
960 mv $@-t $@
961
821# We need the following in order to create <time.h> when the system 962# We need the following in order to create <time.h> when the system
822# doesn't have one that works with the given compiler. 963# doesn't have one that works with the given compiler.
823time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 964time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
diff --git a/src/getloadavg.c b/lib/getloadavg.c
index d9c24717b79..96a6aa4d49c 100644
--- a/src/getloadavg.c
+++ b/lib/getloadavg.c
@@ -1,15 +1,15 @@
1/* Get the system load averages. 1/* Get the system load averages.
2 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 2
3 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2011 Free Software
4 Free Software Foundation, Inc. 4 Foundation, Inc.
5 5
6 NOTE: The canonical source of this file is maintained with gnulib. 6 NOTE: The canonical source of this file is maintained with gnulib.
7 Bugs can be reported to bug-gnulib@gnu.org. 7 Bugs can be reported to bug-gnulib@gnu.org.
8 8
9 This program is free software; you can redistribute it and/or modify 9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option) 11 the Free Software Foundation; either version 3 of the License, or
12 any later version. 12 (at your option) any later version.
13 13
14 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,62 +17,62 @@
17 GNU General Public License for more details. 17 GNU General Public License for more details.
18 18
19 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 USA. */
23 21
24/* Compile-time symbols that this file uses: 22/* Compile-time symbols that this file uses:
25 23
26 HAVE_PSTAT_GETDYNAMIC Define this if your system has the 24 HAVE_PSTAT_GETDYNAMIC Define this if your system has the
27 pstat_getdynamic function. I think it 25 pstat_getdynamic function. I think it
28 is unique to HPUX9. The best way to get the 26 is unique to HPUX9. The best way to get the
29 definition is through the AC_FUNC_GETLOADAVG 27 definition is through the AC_FUNC_GETLOADAVG
30 macro that comes with autoconf 2.13 or newer. 28 macro that comes with autoconf 2.13 or newer.
31 If that isn't an option, then just put 29 If that isn't an option, then just put
32 AC_CHECK_FUNCS(pstat_getdynamic) in your 30 AC_CHECK_FUNCS(pstat_getdynamic) in your
33 configure.in file. 31 configure.in file.
34 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. 32 HAVE_LIBPERFSTAT Define this if your system has the
35 KERNEL_FILE Pathname of the kernel to nlist. 33 perfstat_cpu_total function in libperfstat (AIX).
36 LDAV_CVT() Scale the load average from the kernel. 34 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
37 Returns a double. 35 KERNEL_FILE Name of the kernel file to nlist.
38 LDAV_SYMBOL Name of kernel symbol giving load average. 36 LDAV_CVT() Scale the load average from the kernel.
39 LOAD_AVE_TYPE Type of the load average array in the kernel. 37 Returns a double.
40 Must be defined unless one of 38 LDAV_SYMBOL Name of kernel symbol giving load average.
41 apollo, DGUX, NeXT, or UMAX is defined; 39 LOAD_AVE_TYPE Type of the load average array in the kernel.
40 Must be defined unless one of
41 apollo, DGUX, NeXT, or UMAX is defined;
42 or we have libkstat; 42 or we have libkstat;
43 otherwise, no load average is available. 43 otherwise, no load average is available.
44 HAVE_NLIST_H nlist.h is available. NLIST_STRUCT defaults 44 HAVE_NLIST_H nlist.h is available. NLIST_STRUCT defaults
45 to this. 45 to this.
46 NLIST_STRUCT Include nlist.h, not a.out.h, and 46 NLIST_STRUCT Include nlist.h, not a.out.h.
47 the nlist n_name element is a pointer, 47 N_NAME_POINTER The nlist n_name element is a pointer,
48 not an array. 48 not an array.
49 HAVE_STRUCT_NLIST_N_UN_N_NAME `n_un.n_name' is member of `struct nlist'. 49 HAVE_STRUCT_NLIST_N_UN_N_NAME `n_un.n_name' is member of `struct nlist'.
50 LINUX_LDAV_FILE [__linux__]: File containing load averages. 50 LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing
51 HAVE_LOCALE_H locale.h is available. 51 load averages.
52 HAVE_SETLOCALE The `setlocale' function is available.
53 52
54 Specific system predefines this file uses, aside from setting 53 Specific system predefines this file uses, aside from setting
55 default values if not emacs: 54 default values if not emacs:
56 55
57 apollo 56 apollo
58 BSD Real BSD, not just BSD-like. 57 BSD Real BSD, not just BSD-like.
59 convex 58 convex
60 DGUX 59 DGUX
61 eunice UNIX emulator under VMS. 60 eunice UNIX emulator under VMS.
62 hpux 61 hpux
63 __MSDOS__ No-op for MSDOS. 62 __MSDOS__ No-op for MSDOS.
64 NeXT 63 NeXT
65 sgi 64 sgi
66 sequent Sequent Dynix 3.x.x (BSD) 65 sequent Sequent Dynix 3.x.x (BSD)
67 _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV) 66 _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV)
68 sony_news NEWS-OS (works at least for 4.1C) 67 sony_news NEWS-OS (works at least for 4.1C)
69 UMAX 68 UMAX
70 UMAX4_3 69 UMAX4_3
71 VMS 70 VMS
72 WINDOWS32 No-op for Windows95/NT. 71 WINDOWS32 No-op for Windows95/NT.
73 __linux__ Linux: assumes /proc filesystem mounted. 72 __linux__ Linux: assumes /proc file system mounted.
74 Support from Michael K. Johnson. 73 Support from Michael K. Johnson.
75 __NetBSD__ NetBSD: assumes /kern filesystem mounted. 74 __CYGWIN__ Cygwin emulates linux /proc/loadavg.
75 __NetBSD__ NetBSD: assumes /kern file system mounted.
76 76
77 In addition, to avoid nesting many #ifdefs, we internally set 77 In addition, to avoid nesting many #ifdefs, we internally set
78 LDAV_DONE to indicate that the load average has been computed. 78 LDAV_DONE to indicate that the load average has been computed.
@@ -80,41 +80,35 @@
80 We also #define LDAV_PRIVILEGED if a program will require 80 We also #define LDAV_PRIVILEGED if a program will require
81 special installation to be able to call getloadavg. */ 81 special installation to be able to call getloadavg. */
82 82
83/* This should always be first. */ 83/* "configure" defines CONFIGURING_GETLOADAVG to sidestep problems
84#ifdef HAVE_CONFIG_H 84 with partially-configured source directories. */
85
86#ifndef CONFIGURING_GETLOADAVG
85# include <config.h> 87# include <config.h>
88# include <stdbool.h>
86#endif 89#endif
87 90
88#include <sys/types.h> 91/* Specification. */
89 92#include <stdlib.h>
90/* Both the Emacs and non-Emacs sections want this. Some
91 configuration files' definitions for the LOAD_AVE_CVT macro (like
92 sparc.h's) use macros like FSCALE, defined here. */
93#if defined (unix) || defined (__unix)
94# include <sys/param.h>
95#endif
96 93
94#include <errno.h>
95#include <stdio.h>
97 96
98/* Exclude all the code except the test program at the end 97/* Exclude all the code except the test program at the end
99 if the system has its own `getloadavg' function. 98 if the system has its own `getloadavg' function. */
100
101 The declaration of `errno' is needed by the test program
102 as well as the function itself, so it comes first. */
103 99
104#include <errno.h> 100#ifndef HAVE_GETLOADAVG
105 101
106#ifndef errno 102# include <sys/types.h>
107extern int errno;
108#endif
109 103
110#ifdef HAVE_LOCALE_H 104/* Both the Emacs and non-Emacs sections want this. Some
111# include <locale.h> 105 configuration files' definitions for the LOAD_AVE_CVT macro (like
112#endif 106 sparc.h's) use macros like FSCALE, defined here. */
113#ifndef HAVE_SETLOCALE 107# if defined (unix) || defined (__unix)
114# define setlocale(Category, Locale) /* empty */ 108# include <sys/param.h>
115#endif 109# endif
116 110
117#ifndef HAVE_GETLOADAVG 111# include "intprops.h"
118 112
119/* The existing Emacs configuration files define a macro called 113/* The existing Emacs configuration files define a macro called
120 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and 114 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and
@@ -126,7 +120,7 @@ extern int errno;
126 LOAD_AVE_CVT, but future machine config files should just define 120 LOAD_AVE_CVT, but future machine config files should just define
127 LDAV_CVT directly. */ 121 LDAV_CVT directly. */
128 122
129# if !defined(LDAV_CVT) && defined(LOAD_AVE_CVT) 123# if !defined (LDAV_CVT) && defined (LOAD_AVE_CVT)
130# define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0) 124# define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0)
131# endif 125# endif
132 126
@@ -170,11 +164,11 @@ extern int errno;
170# define sun 164# define sun
171# endif 165# endif
172 166
173# if defined(hp300) && !defined(hpux) 167# if defined (hp300) && !defined (hpux)
174# define MORE_BSD 168# define MORE_BSD
175# endif 169# endif
176 170
177# if defined(ultrix) && defined(mips) 171# if defined (ultrix) && defined (mips)
178# define decstation 172# define decstation
179# endif 173# endif
180 174
@@ -182,7 +176,7 @@ extern int errno;
182# define SVR4 176# define SVR4
183# endif 177# endif
184 178
185# if (defined(sun) && defined(SVR4)) || defined (SOLARIS2) 179# if (defined (sun) && defined (SVR4)) || defined (SOLARIS2)
186# define SUNOS_5 180# define SUNOS_5
187# endif 181# endif
188 182
@@ -192,6 +186,8 @@ extern int errno;
192# include <sys/socket.h> 186# include <sys/socket.h>
193# include <net/route.h> 187# include <net/route.h>
194# include <sys/table.h> 188# include <sys/table.h>
189/* Tru64 4.0D's table.h redefines sys */
190# undef sys
195# endif 191# endif
196 192
197# if defined (__osf__) && (defined (mips) || defined (__mips__)) 193# if defined (__osf__) && (defined (mips) || defined (__mips__))
@@ -203,7 +199,7 @@ extern int errno;
203 default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>. Combine 199 default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>. Combine
204 that with a couple of other things and we'll have a unique match. */ 200 that with a couple of other things and we'll have a unique match. */
205# if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES) 201# if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES)
206# define tek4300 /* Define by emacs, but not by other users. */ 202# define tek4300 /* Define by emacs, but not by other users. */
207# endif 203# endif
208 204
209 205
@@ -254,11 +250,11 @@ extern int errno;
254# define LOAD_AVE_TYPE long 250# define LOAD_AVE_TYPE long
255# endif 251# endif
256 252
257# if defined(alliant) && defined(i860) /* Alliant FX/2800 */ 253# if defined (alliant) && defined (i860) /* Alliant FX/2800 */
258# define LOAD_AVE_TYPE long 254# define LOAD_AVE_TYPE long
259# endif 255# endif
260 256
261# ifdef _AIX 257# if defined _AIX && ! defined HAVE_LIBPERFSTAT
262# define LOAD_AVE_TYPE long 258# define LOAD_AVE_TYPE long
263# endif 259# endif
264 260
@@ -278,7 +274,7 @@ extern int errno;
278# define FSCALE 1024.0 274# define FSCALE 1024.0
279# endif 275# endif
280 276
281# if defined(alliant) && defined(i860) /* Alliant FX/2800 */ 277# if defined (alliant) && defined (i860) /* Alliant FX/2800 */
282/* <sys/param.h> defines an incorrect value for FSCALE on an 278/* <sys/param.h> defines an incorrect value for FSCALE on an
283 Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */ 279 Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */
284# undef FSCALE 280# undef FSCALE
@@ -286,7 +282,7 @@ extern int errno;
286# endif 282# endif
287 283
288 284
289# ifndef FSCALE 285# ifndef FSCALE
290 286
291/* SunOS and some others define FSCALE in sys/param.h. */ 287/* SunOS and some others define FSCALE in sys/param.h. */
292 288
@@ -294,7 +290,7 @@ extern int errno;
294# define FSCALE 2048.0 290# define FSCALE 2048.0
295# endif 291# endif
296 292
297# if defined(MIPS) || defined(SVR4) || defined(decstation) 293# if defined (MIPS) || defined (SVR4) || defined (decstation)
298# define FSCALE 256 294# define FSCALE 256
299# endif 295# endif
300 296
@@ -313,11 +309,11 @@ extern int errno;
313# define FSCALE 100.0 309# define FSCALE 100.0
314# endif 310# endif
315 311
316# ifdef _AIX 312# if defined _AIX && !defined HAVE_LIBPERFSTAT
317# define FSCALE 65536.0 313# define FSCALE 65536.0
318# endif 314# endif
319 315
320# endif /* Not FSCALE. */ 316# endif /* Not FSCALE. */
321 317
322# if !defined (LDAV_CVT) && defined (FSCALE) 318# if !defined (LDAV_CVT) && defined (FSCALE)
323# define LDAV_CVT(n) (((double) (n)) / FSCALE) 319# define LDAV_CVT(n) (((double) (n)) / FSCALE)
@@ -329,7 +325,7 @@ extern int errno;
329# endif 325# endif
330# endif 326# endif
331 327
332# if defined(sgi) || (defined(mips) && !defined(BSD)) 328# if defined (sgi) || (defined (mips) && !defined (BSD))
333# define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31)) 329# define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31))
334# endif 330# endif
335 331
@@ -342,7 +338,7 @@ extern int errno;
342# define KERNEL_FILE "/hp-ux" 338# define KERNEL_FILE "/hp-ux"
343# endif 339# endif
344 340
345# if !defined(KERNEL_FILE) && (defined(_SEQUENT_) || defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || (defined (ardent) && defined (titan))) 341# if !defined (KERNEL_FILE) && (defined (_SEQUENT_) || defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan)))
346# define KERNEL_FILE "/unix" 342# define KERNEL_FILE "/unix"
347# endif 343# endif
348 344
@@ -351,22 +347,21 @@ extern int errno;
351# define LDAV_SYMBOL "_Loadavg" 347# define LDAV_SYMBOL "_Loadavg"
352# endif 348# endif
353 349
354# if !defined(LDAV_SYMBOL) && ((defined(hpux) && !defined(hp9000s300)) || defined(_SEQUENT_) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX)) 350# if !defined (LDAV_SYMBOL) && ((defined (hpux) && !defined (hp9000s300)) || defined (_SEQUENT_) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan)) || (defined (_AIX) && !defined(HAVE_LIBPERFSTAT)))
355# define LDAV_SYMBOL "avenrun" 351# define LDAV_SYMBOL "avenrun"
356# endif 352# endif
357 353
358# include <unistd.h> 354# include <unistd.h>
359# include <stdio.h>
360 355
361/* LOAD_AVE_TYPE should only get defined if we're going to use the 356/* LOAD_AVE_TYPE should only get defined if we're going to use the
362 nlist method. */ 357 nlist method. */
363# if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL)) 358# if !defined (LOAD_AVE_TYPE) && (defined (BSD) || defined (LDAV_CVT) || defined (KERNEL_FILE) || defined (LDAV_SYMBOL))
364# define LOAD_AVE_TYPE double 359# define LOAD_AVE_TYPE double
365# endif 360# endif
366 361
367# ifdef LOAD_AVE_TYPE 362# ifdef LOAD_AVE_TYPE
368 363
369# ifndef VMS 364# ifndef __VMS
370# ifndef __linux__ 365# ifndef __linux__
371# ifndef NLIST_STRUCT 366# ifndef NLIST_STRUCT
372# include <a.out.h> 367# include <a.out.h>
@@ -375,7 +370,6 @@ extern int errno;
375# endif /* NLIST_STRUCT */ 370# endif /* NLIST_STRUCT */
376 371
377# ifdef SUNOS_5 372# ifdef SUNOS_5
378# include <fcntl.h>
379# include <kvm.h> 373# include <kvm.h>
380# include <kstat.h> 374# include <kstat.h>
381# endif 375# endif
@@ -393,7 +387,7 @@ extern int errno;
393# endif /* LDAV_SYMBOL */ 387# endif /* LDAV_SYMBOL */
394# endif /* __linux__ */ 388# endif /* __linux__ */
395 389
396# else /* VMS */ 390# else /* __VMS */
397 391
398# ifndef eunice 392# ifndef eunice
399# include <iodef.h> 393# include <iodef.h>
@@ -401,7 +395,7 @@ extern int errno;
401# else /* eunice */ 395# else /* eunice */
402# include <vms/iodef.h> 396# include <vms/iodef.h>
403# endif /* eunice */ 397# endif /* eunice */
404# endif /* VMS */ 398# endif /* __VMS */
405 399
406# ifndef LDAV_CVT 400# ifndef LDAV_CVT
407# define LDAV_CVT(n) ((double) (n)) 401# define LDAV_CVT(n) ((double) (n))
@@ -409,7 +403,16 @@ extern int errno;
409 403
410# endif /* LOAD_AVE_TYPE */ 404# endif /* LOAD_AVE_TYPE */
411 405
412# if defined(__GNU__) && !defined (NeXT) 406# if defined HAVE_LIBPERFSTAT
407# include <sys/protosw.h>
408# include <libperfstat.h>
409# include <sys/proc.h>
410# ifndef SBITS
411# define SBITS 16
412# endif
413# endif
414
415# if defined (__GNU__) && !defined (NeXT)
413/* Note that NeXT Openstep defines __GNU__ even though it should not. */ 416/* Note that NeXT Openstep defines __GNU__ even though it should not. */
414/* GNU system acts much like NeXT, for load average purposes, 417/* GNU system acts much like NeXT, for load average purposes,
415 but not exactly. */ 418 but not exactly. */
@@ -430,7 +433,6 @@ extern int errno;
430# endif /* sgi */ 433# endif /* sgi */
431 434
432# ifdef UMAX 435# ifdef UMAX
433# include <stdio.h>
434# include <signal.h> 436# include <signal.h>
435# include <sys/time.h> 437# include <sys/time.h>
436# include <sys/wait.h> 438# include <sys/wait.h>
@@ -456,17 +458,16 @@ extern int errno;
456# include <sys/dg_sys_info.h> 458# include <sys/dg_sys_info.h>
457# endif 459# endif
458 460
459# if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION) 461# if (defined __linux__ || defined __CYGWIN__ || defined SUNOS_5 \
462 || (defined LOAD_AVE_TYPE && ! defined __VMS))
460# include <fcntl.h> 463# include <fcntl.h>
461# else
462# include <sys/file.h>
463# endif 464# endif
464 465
465/* Avoid static vars inside a function since in HPUX they dump as pure. */ 466/* Avoid static vars inside a function since in HPUX they dump as pure. */
466 467
467# ifdef NeXT 468# ifdef NeXT
468static processor_set_t default_set; 469static processor_set_t default_set;
469static int getloadavg_initialized; 470static bool getloadavg_initialized;
470# endif /* NeXT */ 471# endif /* NeXT */
471 472
472# ifdef UMAX 473# ifdef UMAX
@@ -475,26 +476,26 @@ static unsigned int samples;
475# endif /* UMAX */ 476# endif /* UMAX */
476 477
477# ifdef DGUX 478# ifdef DGUX
478static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */ 479static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
479# endif /* DGUX */ 480# endif /* DGUX */
480 481
481#if !defined(HAVE_LIBKSTAT) && defined(LOAD_AVE_TYPE) 482# if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE)
482/* File descriptor open to /dev/kmem or VMS load ave driver. */ 483/* File descriptor open to /dev/kmem or VMS load ave driver. */
483static int channel; 484static int channel;
484/* Nonzero if channel is valid. */ 485/* True if channel is valid. */
485static int getloadavg_initialized; 486static bool getloadavg_initialized;
486/* Offset in kmem to seek to read load average, or 0 means invalid. */ 487/* Offset in kmem to seek to read load average, or 0 means invalid. */
487static long offset; 488static long offset;
488 489
489# if !defined(VMS) && !defined(sgi) && !defined(__linux__) 490# if ! defined __VMS && ! defined sgi && ! defined __linux__
490static struct nlist name_list[2]; 491static struct nlist name_list[2];
491# endif /* Not VMS or sgi */ 492# endif
492 493
493# ifdef SUNOS_5 494# ifdef SUNOS_5
494static kvm_t *kd; 495static kvm_t *kd;
495# endif /* SUNOS_5 */ 496# endif /* SUNOS_5 */
496 497
497#endif /* LOAD_AVE_TYPE && !HAVE_LIBKSTAT */ 498# endif /* LOAD_AVE_TYPE && !HAVE_LIBKSTAT */
498 499
499/* Put the 1 minute, 5 minute and 15 minute load averages 500/* Put the 1 minute, 5 minute and 15 minute load averages
500 into the first NELEM elements of LOADAVG. 501 into the first NELEM elements of LOADAVG.
@@ -502,11 +503,9 @@ static kvm_t *kd;
502 or -1 if an error occurred. */ 503 or -1 if an error occurred. */
503 504
504int 505int
505getloadavg (loadavg, nelem) 506getloadavg (double loadavg[], int nelem)
506 double loadavg[];
507 int nelem;
508{ 507{
509 int elem = 0; /* Return value. */ 508 int elem = 0; /* Return value. */
510 509
511# ifdef NO_GET_LOAD_AVG 510# ifdef NO_GET_LOAD_AVG
512# define LDAV_DONE 511# define LDAV_DONE
@@ -527,7 +526,7 @@ getloadavg (loadavg, nelem)
527 if (kc == 0) 526 if (kc == 0)
528 return -1; 527 return -1;
529 ksp = kstat_lookup (kc, "unix", 0, "system_misc"); 528 ksp = kstat_lookup (kc, "unix", 0, "system_misc");
530 if (ksp == 0 ) 529 if (ksp == 0)
531 return -1; 530 return -1;
532 if (kstat_read (kc, ksp, 0) == -1) 531 if (kstat_read (kc, ksp, 0) == -1)
533 return -1; 532 return -1;
@@ -542,22 +541,22 @@ getloadavg (loadavg, nelem)
542 } 541 }
543 542
544 if (nelem >= 1) 543 if (nelem >= 1)
545 loadavg[elem++] = (double) kn->value.ul/FSCALE; 544 loadavg[elem++] = (double) kn->value.ul / FSCALE;
546 545
547 if (nelem >= 2) 546 if (nelem >= 2)
548 { 547 {
549 kn = kstat_data_lookup (ksp, "avenrun_5min"); 548 kn = kstat_data_lookup (ksp, "avenrun_5min");
550 if (kn != 0) 549 if (kn != 0)
551 { 550 {
552 loadavg[elem++] = (double) kn->value.ul/FSCALE; 551 loadavg[elem++] = (double) kn->value.ul / FSCALE;
553 552
554 if (nelem >= 3) 553 if (nelem >= 3)
555 { 554 {
556 kn = kstat_data_lookup (ksp, "avenrun_15min"); 555 kn = kstat_data_lookup (ksp, "avenrun_15min");
557 if (kn != 0) 556 if (kn != 0)
558 loadavg[elem++] = (double) kn->value.ul/FSCALE; 557 loadavg[elem++] = (double) kn->value.ul / FSCALE;
559 } 558 }
560 } 559 }
561 } 560 }
562 561
563 kstat_close (kc); 562 kstat_close (kc);
@@ -580,7 +579,23 @@ getloadavg (loadavg, nelem)
580 579
581# endif /* hpux && HAVE_PSTAT_GETDYNAMIC */ 580# endif /* hpux && HAVE_PSTAT_GETDYNAMIC */
582 581
583# if !defined (LDAV_DONE) && defined (__linux__) 582# if ! defined LDAV_DONE && defined HAVE_LIBPERFSTAT
583# define LDAV_DONE
584# undef LOAD_AVE_TYPE
585/* Use perfstat_cpu_total because we don't have to be root. */
586 {
587 perfstat_cpu_total_t cpu_stats;
588 int result = perfstat_cpu_total (NULL, &cpu_stats, sizeof cpu_stats, 1);
589 if (result == -1)
590 return result;
591 loadavg[0] = cpu_stats.loadavg[0] / (double)(1 << SBITS);
592 loadavg[1] = cpu_stats.loadavg[1] / (double)(1 << SBITS);
593 loadavg[2] = cpu_stats.loadavg[2] / (double)(1 << SBITS);
594 elem = 3;
595 }
596# endif
597
598# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__))
584# define LDAV_DONE 599# define LDAV_DONE
585# undef LOAD_AVE_TYPE 600# undef LOAD_AVE_TYPE
586 601
@@ -588,32 +603,50 @@ getloadavg (loadavg, nelem)
588# define LINUX_LDAV_FILE "/proc/loadavg" 603# define LINUX_LDAV_FILE "/proc/loadavg"
589# endif 604# endif
590 605
591 char ldavgbuf[40]; 606 char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
592 double load_ave[3]; 607 char const *ptr = ldavgbuf;
593 int fd, count; 608 int fd, count;
594 609
595 fd = open (LINUX_LDAV_FILE, O_RDONLY); 610 fd = open (LINUX_LDAV_FILE, O_RDONLY);
596 if (fd == -1) 611 if (fd == -1)
597 return -1; 612 return -1;
598 count = read (fd, ldavgbuf, 40); 613 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
599 (void) close (fd); 614 (void) close (fd);
600 if (count <= 0) 615 if (count <= 0)
601 return -1; 616 return -1;
617 ldavgbuf[count] = '\0';
602 618
603 /* The following sscanf must use the C locale. */ 619 for (elem = 0; elem < nelem; elem++)
604 setlocale (LC_NUMERIC, "C"); 620 {
605 count = sscanf (ldavgbuf, "%lf %lf %lf", 621 double numerator = 0;
606 &load_ave[0], &load_ave[1], &load_ave[2]); 622 double denominator = 1;
607 setlocale (LC_NUMERIC, ""); 623 bool have_digit = false;
608 if (count < 1)
609 return -1;
610 624
611 for (elem = 0; elem < nelem && elem < count; elem++) 625 while (*ptr == ' ')
612 loadavg[elem] = load_ave[elem]; 626 ptr++;
627
628 /* Finish if this number is missing, and report an error if all
629 were missing. */
630 if (! ('0' <= *ptr && *ptr <= '9'))
631 {
632 if (elem == 0)
633 return -1;
634 break;
635 }
636
637 while ('0' <= *ptr && *ptr <= '9')
638 numerator = 10 * numerator + (*ptr++ - '0');
639
640 if (*ptr == '.')
641 for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
642 numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
643
644 loadavg[elem++] = numerator / denominator;
645 }
613 646
614 return elem; 647 return elem;
615 648
616# endif /* __linux__ */ 649# endif /* __linux__ || __CYGWIN__ */
617 650
618# if !defined (LDAV_DONE) && defined (__NetBSD__) 651# if !defined (LDAV_DONE) && defined (__NetBSD__)
619# define LDAV_DONE 652# define LDAV_DONE
@@ -631,8 +664,8 @@ getloadavg (loadavg, nelem)
631 if (fp == NULL) 664 if (fp == NULL)
632 return -1; 665 return -1;
633 count = fscanf (fp, "%lu %lu %lu %lu\n", 666 count = fscanf (fp, "%lu %lu %lu %lu\n",
634 &load_ave[0], &load_ave[1], &load_ave[2], 667 &load_ave[0], &load_ave[1], &load_ave[2],
635 &scale); 668 &scale);
636 (void) fclose (fp); 669 (void) fclose (fp);
637 if (count != 4) 670 if (count != 4)
638 return -1; 671 return -1;
@@ -650,7 +683,7 @@ getloadavg (loadavg, nelem)
650 683
651 host_t host; 684 host_t host;
652 struct processor_set_basic_info info; 685 struct processor_set_basic_info info;
653 unsigned info_count; 686 unsigned int info_count;
654 687
655 /* We only know how to get the 1-minute average for this system, 688 /* We only know how to get the 1-minute average for this system,
656 so even if the caller asks for more than 1, we only return 1. */ 689 so even if the caller asks for more than 1, we only return 1. */
@@ -658,21 +691,21 @@ getloadavg (loadavg, nelem)
658 if (!getloadavg_initialized) 691 if (!getloadavg_initialized)
659 { 692 {
660 if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS) 693 if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS)
661 getloadavg_initialized = 1; 694 getloadavg_initialized = true;
662 } 695 }
663 696
664 if (getloadavg_initialized) 697 if (getloadavg_initialized)
665 { 698 {
666 info_count = PROCESSOR_SET_BASIC_INFO_COUNT; 699 info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
667 if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host, 700 if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
668 (processor_set_info_t) &info, &info_count) 701 (processor_set_info_t) &info, &info_count)
669 != KERN_SUCCESS) 702 != KERN_SUCCESS)
670 getloadavg_initialized = 0; 703 getloadavg_initialized = false;
671 else 704 else
672 { 705 {
673 if (nelem > 0) 706 if (nelem > 0)
674 loadavg[elem++] = (double) info.load_average / LOAD_SCALE; 707 loadavg[elem++] = (double) info.load_average / LOAD_SCALE;
675 } 708 }
676 } 709 }
677 710
678 if (!getloadavg_initialized) 711 if (!getloadavg_initialized)
@@ -704,24 +737,24 @@ getloadavg (loadavg, nelem)
704 desc.sd_size = sizeof conf; 737 desc.sd_size = sizeof conf;
705 738
706 if (inq_stats (1, &desc)) 739 if (inq_stats (1, &desc))
707 return -1; 740 return -1;
708 741
709 c = 0; 742 c = 0;
710 for (i = 0; i < conf.config_maxclass; ++i) 743 for (i = 0; i < conf.config_maxclass; ++i)
711 { 744 {
712 struct class_stats stats; 745 struct class_stats stats;
713 memset (&stats, 0, sizeof stats); 746 memset (&stats, 0, sizeof stats);
714 747
715 desc.sd_type = CPUTYPE_CLASS; 748 desc.sd_type = CPUTYPE_CLASS;
716 desc.sd_objid = i; 749 desc.sd_objid = i;
717 desc.sd_addr = (char *) &stats; 750 desc.sd_addr = (char *) &stats;
718 desc.sd_size = sizeof stats; 751 desc.sd_size = sizeof stats;
719 752
720 if (inq_stats (1, &desc)) 753 if (inq_stats (1, &desc))
721 return -1; 754 return -1;
722 755
723 c += stats.class_numcpus; 756 c += stats.class_numcpus;
724 } 757 }
725 cpus = c; 758 cpus = c;
726 samples = cpus < 2 ? 3 : (2 * cpus / 3); 759 samples = cpus < 2 ? 3 : (2 * cpus / 3);
727 } 760 }
@@ -742,7 +775,7 @@ getloadavg (loadavg, nelem)
742 { 775 {
743 load += proc_sum_data.ps_nrun[j]; 776 load += proc_sum_data.ps_nrun[j];
744 if (j++ == PS_NRUNSIZE) 777 if (j++ == PS_NRUNSIZE)
745 j = 0; 778 j = 0;
746 } 779 }
747 780
748 if (nelem > 0) 781 if (nelem > 0)
@@ -755,8 +788,8 @@ getloadavg (loadavg, nelem)
755 it's not supposed to fail. The first argument is for no 788 it's not supposed to fail. The first argument is for no
756 apparent reason of type `long int *'. */ 789 apparent reason of type `long int *'. */
757 dg_sys_info ((long int *) &load_info, 790 dg_sys_info ((long int *) &load_info,
758 DG_SYS_INFO_LOAD_INFO_TYPE, 791 DG_SYS_INFO_LOAD_INFO_TYPE,
759 DG_SYS_INFO_LOAD_VERSION_0); 792 DG_SYS_INFO_LOAD_VERSION_0);
760 793
761 if (nelem > 0) 794 if (nelem > 0)
762 loadavg[elem++] = load_info.one_minute; 795 loadavg[elem++] = load_info.one_minute;
@@ -800,7 +833,7 @@ getloadavg (loadavg, nelem)
800 = (load_ave.tl_lscale == 0 833 = (load_ave.tl_lscale == 0
801 ? load_ave.tl_avenrun.d[0] 834 ? load_ave.tl_avenrun.d[0]
802 : (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale)); 835 : (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale));
803# endif /* OSF_MIPS */ 836# endif /* OSF_MIPS */
804 837
805# if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32)) 838# if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32))
806# define LDAV_DONE 839# define LDAV_DONE
@@ -820,15 +853,15 @@ getloadavg (loadavg, nelem)
820 for (elem = 0; elem < nelem; elem++) 853 for (elem = 0; elem < nelem; elem++)
821 loadavg[elem] 854 loadavg[elem]
822 = (load_ave.tl_lscale == 0 855 = (load_ave.tl_lscale == 0
823 ? load_ave.tl_avenrun.d[elem] 856 ? load_ave.tl_avenrun.d[elem]
824 : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale)); 857 : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
825# endif /* OSF_ALPHA */ 858# endif /* OSF_ALPHA */
826 859
827# if !defined (LDAV_DONE) && defined (VMS) 860# if ! defined LDAV_DONE && defined __VMS
828 /* VMS specific code -- read from the Load Ave driver. */ 861 /* VMS specific code -- read from the Load Ave driver. */
829 862
830 LOAD_AVE_TYPE load_ave[3]; 863 LOAD_AVE_TYPE load_ave[3];
831 static int getloadavg_initialized = 0; 864 static bool getloadavg_initialized;
832# ifdef eunice 865# ifdef eunice
833 struct 866 struct
834 { 867 {
@@ -848,27 +881,27 @@ getloadavg (loadavg, nelem)
848 $DESCRIPTOR (descriptor, "LAV0:"); 881 $DESCRIPTOR (descriptor, "LAV0:");
849# endif 882# endif
850 if (sys$assign (&descriptor, &channel, 0, 0) & 1) 883 if (sys$assign (&descriptor, &channel, 0, 0) & 1)
851 getloadavg_initialized = 1; 884 getloadavg_initialized = true;
852 } 885 }
853 886
854 /* Read the load average vector. */ 887 /* Read the load average vector. */
855 if (getloadavg_initialized 888 if (getloadavg_initialized
856 && !(sys$qiow (0, channel, IO$_READVBLK, 0, 0, 0, 889 && !(sys$qiow (0, channel, IO$_READVBLK, 0, 0, 0,
857 load_ave, 12, 0, 0, 0, 0) & 1)) 890 load_ave, 12, 0, 0, 0, 0) & 1))
858 { 891 {
859 sys$dassgn (channel); 892 sys$dassgn (channel);
860 getloadavg_initialized = 0; 893 getloadavg_initialized = false;
861 } 894 }
862 895
863 if (!getloadavg_initialized) 896 if (!getloadavg_initialized)
864 return -1; 897 return -1;
865# endif /* VMS */ 898# endif /* ! defined LDAV_DONE && defined __VMS */
866 899
867# if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE) && !defined(VMS) 900# if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS
868 901
869 /* UNIX-specific code -- read the average from /dev/kmem. */ 902 /* UNIX-specific code -- read the average from /dev/kmem. */
870 903
871# define LDAV_PRIVILEGED /* This code requires special installation. */ 904# define LDAV_PRIVILEGED /* This code requires special installation. */
872 905
873 LOAD_AVE_TYPE load_ave[3]; 906 LOAD_AVE_TYPE load_ave[3];
874 907
@@ -876,7 +909,7 @@ getloadavg (loadavg, nelem)
876 if (offset == 0) 909 if (offset == 0)
877 { 910 {
878# ifndef sgi 911# ifndef sgi
879# ifndef NLIST_STRUCT 912# if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
880 strcpy (name_list[0].n_name, LDAV_SYMBOL); 913 strcpy (name_list[0].n_name, LDAV_SYMBOL);
881 strcpy (name_list[1].n_name, ""); 914 strcpy (name_list[1].n_name, "");
882# else /* NLIST_STRUCT */ 915# else /* NLIST_STRUCT */
@@ -892,25 +925,25 @@ getloadavg (loadavg, nelem)
892# ifndef SUNOS_5 925# ifndef SUNOS_5
893 if ( 926 if (
894# if !(defined (_AIX) && !defined (ps2)) 927# if !(defined (_AIX) && !defined (ps2))
895 nlist (KERNEL_FILE, name_list) 928 nlist (KERNEL_FILE, name_list)
896# else /* _AIX */ 929# else /* _AIX */
897 knlist (name_list, 1, sizeof (name_list[0])) 930 knlist (name_list, 1, sizeof (name_list[0]))
898# endif 931# endif
899 >= 0) 932 >= 0)
900 /* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i. */ 933 /* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i. */
901 { 934 {
902# ifdef FIXUP_KERNEL_SYMBOL_ADDR 935# ifdef FIXUP_KERNEL_SYMBOL_ADDR
903 FIXUP_KERNEL_SYMBOL_ADDR (name_list); 936 FIXUP_KERNEL_SYMBOL_ADDR (name_list);
904# endif 937# endif
905 offset = name_list[0].n_value; 938 offset = name_list[0].n_value;
906 } 939 }
907# endif /* !SUNOS_5 */ 940# endif /* !SUNOS_5 */
908# else /* sgi */ 941# else /* sgi */
909 int ldav_off; 942 int ldav_off;
910 943
911 ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN); 944 ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
912 if (ldav_off != -1) 945 if (ldav_off != -1)
913 offset = (long) ldav_off & 0x7fffffff; 946 offset = (long int) ldav_off & 0x7fffffff;
914# endif /* sgi */ 947# endif /* sgi */
915 } 948 }
916 949
@@ -918,30 +951,39 @@ getloadavg (loadavg, nelem)
918 if (!getloadavg_initialized) 951 if (!getloadavg_initialized)
919 { 952 {
920# ifndef SUNOS_5 953# ifndef SUNOS_5
921 channel = open ("/dev/kmem", 0); 954 /* Set the channel to close on exec, so it does not
922 if (channel >= 0) 955 litter any child's descriptor table. */
923 { 956# ifndef O_CLOEXEC
924 /* Set the channel to close on exec, so it does not 957# define O_CLOEXEC 0
925 litter any child's descriptor table. */ 958# endif
926# ifdef F_SETFD 959 int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
927# ifndef FD_CLOEXEC 960 if (0 <= fd)
928# define FD_CLOEXEC 1 961 {
929# endif 962# if F_DUPFD_CLOEXEC
930 (void) fcntl (channel, F_SETFD, FD_CLOEXEC); 963 if (fd <= STDERR_FILENO)
964 {
965 int fd1 = fcntl (fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
966 close (fd);
967 fd = fd1;
968 }
931# endif 969# endif
932 getloadavg_initialized = 1; 970 if (0 <= fd)
933 } 971 {
972 channel = fd;
973 getloadavg_initialized = true;
974 }
975 }
934# else /* SUNOS_5 */ 976# else /* SUNOS_5 */
935 /* We pass 0 for the kernel, corefile, and swapfile names 977 /* We pass 0 for the kernel, corefile, and swapfile names
936 to use the currently running kernel. */ 978 to use the currently running kernel. */
937 kd = kvm_open (0, 0, 0, O_RDONLY, 0); 979 kd = kvm_open (0, 0, 0, O_RDONLY, 0);
938 if (kd != 0) 980 if (kd != 0)
939 { 981 {
940 /* nlist the currently running kernel. */ 982 /* nlist the currently running kernel. */
941 kvm_nlist (kd, name_list); 983 kvm_nlist (kd, name_list);
942 offset = name_list[0].n_value; 984 offset = name_list[0].n_value;
943 getloadavg_initialized = 1; 985 getloadavg_initialized = true;
944 } 986 }
945# endif /* SUNOS_5 */ 987# endif /* SUNOS_5 */
946 } 988 }
947 989
@@ -951,25 +993,25 @@ getloadavg (loadavg, nelem)
951 /* Try to read the load. */ 993 /* Try to read the load. */
952# ifndef SUNOS_5 994# ifndef SUNOS_5
953 if (lseek (channel, offset, 0) == -1L 995 if (lseek (channel, offset, 0) == -1L
954 || read (channel, (char *) load_ave, sizeof (load_ave)) 996 || read (channel, (char *) load_ave, sizeof (load_ave))
955 != sizeof (load_ave)) 997 != sizeof (load_ave))
956 { 998 {
957 close (channel); 999 close (channel);
958 getloadavg_initialized = 0; 1000 getloadavg_initialized = false;
959 } 1001 }
960# else /* SUNOS_5 */ 1002# else /* SUNOS_5 */
961 if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave)) 1003 if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
962 != sizeof (load_ave)) 1004 != sizeof (load_ave))
963 { 1005 {
964 kvm_close (kd); 1006 kvm_close (kd);
965 getloadavg_initialized = 0; 1007 getloadavg_initialized = false;
966 } 1008 }
967# endif /* SUNOS_5 */ 1009# endif /* SUNOS_5 */
968 } 1010 }
969 1011
970 if (offset == 0 || !getloadavg_initialized) 1012 if (offset == 0 || !getloadavg_initialized)
971 return -1; 1013 return -1;
972# endif /* LOAD_AVE_TYPE and not VMS */ 1014# endif /* ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS */
973 1015
974# if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS. */ 1016# if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS. */
975 if (nelem > 0) 1017 if (nelem > 0)
@@ -982,23 +1024,20 @@ getloadavg (loadavg, nelem)
982# define LDAV_DONE 1024# define LDAV_DONE
983# endif /* !LDAV_DONE && LOAD_AVE_TYPE */ 1025# endif /* !LDAV_DONE && LOAD_AVE_TYPE */
984 1026
985# ifdef LDAV_DONE 1027# if !defined LDAV_DONE
986 return elem;
987# else
988 /* Set errno to zero to indicate that there was no particular error; 1028 /* Set errno to zero to indicate that there was no particular error;
989 this function just can't work at all on this system. */ 1029 this function just can't work at all on this system. */
990 errno = 0; 1030 errno = 0;
991 return -1; 1031 elem = -1;
992# endif 1032# endif
1033 return elem;
993} 1034}
994 1035
995#endif /* ! HAVE_GETLOADAVG */ 1036#endif /* ! HAVE_GETLOADAVG */
996 1037
997#ifdef TEST 1038#ifdef TEST
998void 1039int
999main (argc, argv) 1040main (int argc, char **argv)
1000 int argc;
1001 char **argv;
1002{ 1041{
1003 int naptime = 0; 1042 int naptime = 0;
1004 1043
@@ -1010,28 +1049,27 @@ main (argc, argv)
1010 double avg[3]; 1049 double avg[3];
1011 int loads; 1050 int loads;
1012 1051
1013 errno = 0; /* Don't be misled if it doesn't set errno. */ 1052 errno = 0; /* Don't be misled if it doesn't set errno. */
1014 loads = getloadavg (avg, 3); 1053 loads = getloadavg (avg, 3);
1015 if (loads == -1) 1054 if (loads == -1)
1016 { 1055 {
1017 perror ("Error getting load average"); 1056 perror ("Error getting load average");
1018 exit (1); 1057 return EXIT_FAILURE;
1019 } 1058 }
1020 if (loads > 0) 1059 if (loads > 0)
1021 printf ("1-minute: %f ", avg[0]); 1060 printf ("1-minute: %f ", avg[0]);
1022 if (loads > 1) 1061 if (loads > 1)
1023 printf ("5-minute: %f ", avg[1]); 1062 printf ("5-minute: %f ", avg[1]);
1024 if (loads > 2) 1063 if (loads > 2)
1025 printf ("15-minute: %f ", avg[2]); 1064 printf ("15-minute: %f ", avg[2]);
1026 if (loads > 0) 1065 if (loads > 0)
1027 putchar ('\n'); 1066 putchar ('\n');
1028 1067
1029 if (naptime == 0) 1068 if (naptime == 0)
1030 break; 1069 break;
1031 sleep (naptime); 1070 sleep (naptime);
1032 } 1071 }
1033 1072
1034 exit (0); 1073 return EXIT_SUCCESS;
1035} 1074}
1036#endif /* TEST */ 1075#endif /* TEST */
1037
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index af628c8d300..ffd175d58c8 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -9,7 +9,7 @@
9# the same distribution terms as the rest of that program. 9# the same distribution terms as the rest of that program.
10# 10#
11# Generated by gnulib-tool. 11# Generated by gnulib-tool.
12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dtoastr getopt-gnu ignore-value mktime strftime 12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dtoastr getloadavg getopt-gnu ignore-value mktime strftime
13 13
14 14
15MOSTLYCLEANFILES += core *.stackdump 15MOSTLYCLEANFILES += core *.stackdump
@@ -79,6 +79,15 @@ EXTRA_libgnu_a_SOURCES += ftoastr.c
79 79
80## end gnulib module dtoastr 80## end gnulib module dtoastr
81 81
82## begin gnulib module getloadavg
83
84
85EXTRA_DIST += getloadavg.c
86
87EXTRA_libgnu_a_SOURCES += getloadavg.c
88
89## end gnulib module getloadavg
90
82## begin gnulib module getopt-posix 91## begin gnulib module getopt-posix
83 92
84BUILT_SOURCES += $(GETOPT_H) 93BUILT_SOURCES += $(GETOPT_H)
@@ -175,6 +184,91 @@ EXTRA_DIST += stddef.in.h
175 184
176## end gnulib module stddef 185## end gnulib module stddef
177 186
187## begin gnulib module stdlib
188
189BUILT_SOURCES += stdlib.h
190
191# We need the following in order to create <stdlib.h> when the system
192# doesn't have one that works with the given compiler.
193stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
194 $(AM_V_GEN)rm -f $@-t $@ && \
195 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
196 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
197 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
198 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
199 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
200 -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \
201 -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
202 -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
203 -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \
204 -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
205 -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
206 -e 's|@''GNULIB_GRANTPT''@|$(GNULIB_GRANTPT)|g' \
207 -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
208 -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
209 -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \
210 -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \
211 -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
212 -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
213 -e 's|@''GNULIB_PTSNAME''@|$(GNULIB_PTSNAME)|g' \
214 -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
215 -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
216 -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
217 -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \
218 -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
219 -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
220 -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
221 -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
222 -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
223 -e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \
224 -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \
225 -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
226 -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
227 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
228 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
229 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
230 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
231 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
232 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
233 -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
234 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
235 -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
236 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
237 -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
238 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
239 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
240 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
241 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
242 -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
243 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
244 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
245 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
246 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
247 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
248 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
249 -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
250 -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
251 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
252 -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
253 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
254 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
255 -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
256 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
257 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
258 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
259 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
260 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
261 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
262 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
263 < $(srcdir)/stdlib.in.h; \
264 } > $@-t && \
265 mv $@-t $@
266MOSTLYCLEANFILES += stdlib.h stdlib.h-t
267
268EXTRA_DIST += stdlib.in.h
269
270## end gnulib module stdlib
271
178## begin gnulib module strftime 272## begin gnulib module strftime
179 273
180 274
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
new file mode 100644
index 00000000000..b3bb9d4e5de
--- /dev/null
+++ b/lib/stdlib.in.h
@@ -0,0 +1,725 @@
1/* A GNU-like <stdlib.h>.
2
3 Copyright (C) 1995, 2001-2004, 2006-2011 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@
20#endif
21@PRAGMA_COLUMNS@
22
23#if defined __need_malloc_and_calloc
24/* Special invocation convention inside glibc header files. */
25
26#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
27
28#else
29/* Normal invocation convention. */
30
31#ifndef _GL_STDLIB_H
32
33/* The include_next requires a split double-inclusion guard. */
34#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
35
36#ifndef _GL_STDLIB_H
37#define _GL_STDLIB_H
38
39/* NetBSD 5.0 mis-defines NULL. */
40#include <stddef.h>
41
42/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
43#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
44# include <sys/wait.h>
45#endif
46
47/* Solaris declares getloadavg() in <sys/loadavg.h>. */
48#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
49# include <sys/loadavg.h>
50#endif
51
52/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
53 from <stdlib.h> if _REENTRANT is defined. Include it always. */
54#if @HAVE_RANDOM_H@
55# include <random.h>
56#endif
57
58#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@)
59# include <stdint.h>
60#endif
61
62#if !@HAVE_STRUCT_RANDOM_DATA@
63/* Define 'struct random_data'.
64 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
65# if !GNULIB_defined_struct_random_data
66struct random_data
67{
68 int32_t *fptr; /* Front pointer. */
69 int32_t *rptr; /* Rear pointer. */
70 int32_t *state; /* Array of state values. */
71 int rand_type; /* Type of random number generator. */
72 int rand_deg; /* Degree of random number generator. */
73 int rand_sep; /* Distance between front and rear. */
74 int32_t *end_ptr; /* Pointer behind state table. */
75};
76# define GNULIB_defined_struct_random_data 1
77# endif
78#endif
79
80#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
81/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
82/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
83/* But avoid namespace pollution on glibc systems and native Windows. */
84# include <unistd.h>
85#endif
86
87#ifndef __attribute__
88# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
89# define __attribute__(Spec) /* empty */
90# endif
91#endif
92
93/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
94
95/* The definition of _GL_ARG_NONNULL is copied here. */
96
97/* The definition of _GL_WARN_ON_USE is copied here. */
98
99
100/* Some systems do not define EXIT_*, despite otherwise supporting C89. */
101#ifndef EXIT_SUCCESS
102# define EXIT_SUCCESS 0
103#endif
104/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
105 with proper operation of xargs. */
106#ifndef EXIT_FAILURE
107# define EXIT_FAILURE 1
108#elif EXIT_FAILURE != 1
109# undef EXIT_FAILURE
110# define EXIT_FAILURE 1
111#endif
112
113
114#if @GNULIB__EXIT@
115/* Terminate the current process with the given return code, without running
116 the 'atexit' handlers. */
117# if !@HAVE__EXIT@
118_GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__)));
119# endif
120_GL_CXXALIAS_SYS (_Exit, void, (int status));
121_GL_CXXALIASWARN (_Exit);
122#elif defined GNULIB_POSIXCHECK
123# undef _Exit
124# if HAVE_RAW_DECL__EXIT
125_GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
126 "use gnulib module _Exit for portability");
127# endif
128#endif
129
130
131#if @GNULIB_ATOLL@
132/* Parse a signed decimal integer.
133 Returns the value of the integer. Errors are not detected. */
134# if !@HAVE_ATOLL@
135_GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1)));
136# endif
137_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
138_GL_CXXALIASWARN (atoll);
139#elif defined GNULIB_POSIXCHECK
140# undef atoll
141# if HAVE_RAW_DECL_ATOLL
142_GL_WARN_ON_USE (atoll, "atoll is unportable - "
143 "use gnulib module atoll for portability");
144# endif
145#endif
146
147#if @GNULIB_CALLOC_POSIX@
148# if @REPLACE_CALLOC@
149# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
150# undef calloc
151# define calloc rpl_calloc
152# endif
153_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
154_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
155# else
156_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
157# endif
158_GL_CXXALIASWARN (calloc);
159#elif defined GNULIB_POSIXCHECK
160# undef calloc
161/* Assume calloc is always declared. */
162_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
163 "use gnulib module calloc-posix for portability");
164#endif
165
166#if @GNULIB_CANONICALIZE_FILE_NAME@
167# if @REPLACE_CANONICALIZE_FILE_NAME@
168# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
169# define canonicalize_file_name rpl_canonicalize_file_name
170# endif
171_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
172 _GL_ARG_NONNULL ((1)));
173_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
174# else
175# if !@HAVE_CANONICALIZE_FILE_NAME@
176_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
177 _GL_ARG_NONNULL ((1)));
178# endif
179_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
180# endif
181_GL_CXXALIASWARN (canonicalize_file_name);
182#elif defined GNULIB_POSIXCHECK
183# undef canonicalize_file_name
184# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
185_GL_WARN_ON_USE (canonicalize_file_name,
186 "canonicalize_file_name is unportable - "
187 "use gnulib module canonicalize-lgpl for portability");
188# endif
189#endif
190
191#if @GNULIB_GETLOADAVG@
192/* Store max(NELEM,3) load average numbers in LOADAVG[].
193 The three numbers are the load average of the last 1 minute, the last 5
194 minutes, and the last 15 minutes, respectively.
195 LOADAVG is an array of NELEM numbers. */
196# if !@HAVE_DECL_GETLOADAVG@
197_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
198 _GL_ARG_NONNULL ((1)));
199# endif
200_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
201_GL_CXXALIASWARN (getloadavg);
202#elif defined GNULIB_POSIXCHECK
203# undef getloadavg
204# if HAVE_RAW_DECL_GETLOADAVG
205_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
206 "use gnulib module getloadavg for portability");
207# endif
208#endif
209
210#if @GNULIB_GETSUBOPT@
211/* Assuming *OPTIONP is a comma separated list of elements of the form
212 "token" or "token=value", getsubopt parses the first of these elements.
213 If the first element refers to a "token" that is member of the given
214 NULL-terminated array of tokens:
215 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
216 the first option and the comma, sets *VALUEP to the value of the
217 element (or NULL if it doesn't contain an "=" sign),
218 - It returns the index of the "token" in the given array of tokens.
219 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
220 For more details see the POSIX:2001 specification.
221 http://www.opengroup.org/susv3xsh/getsubopt.html */
222# if !@HAVE_GETSUBOPT@
223_GL_FUNCDECL_SYS (getsubopt, int,
224 (char **optionp, char *const *tokens, char **valuep)
225 _GL_ARG_NONNULL ((1, 2, 3)));
226# endif
227_GL_CXXALIAS_SYS (getsubopt, int,
228 (char **optionp, char *const *tokens, char **valuep));
229_GL_CXXALIASWARN (getsubopt);
230#elif defined GNULIB_POSIXCHECK
231# undef getsubopt
232# if HAVE_RAW_DECL_GETSUBOPT
233_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
234 "use gnulib module getsubopt for portability");
235# endif
236#endif
237
238#if @GNULIB_GRANTPT@
239/* Change the ownership and access permission of the slave side of the
240 pseudo-terminal whose master side is specified by FD. */
241# if !@HAVE_GRANTPT@
242_GL_FUNCDECL_SYS (grantpt, int, (int fd));
243# endif
244_GL_CXXALIAS_SYS (grantpt, int, (int fd));
245_GL_CXXALIASWARN (grantpt);
246#elif defined GNULIB_POSIXCHECK
247# undef grantpt
248# if HAVE_RAW_DECL_GRANTPT
249_GL_WARN_ON_USE (ptsname, "grantpt is not portable - "
250 "use gnulib module grantpt for portability");
251# endif
252#endif
253
254#if @GNULIB_MALLOC_POSIX@
255# if @REPLACE_MALLOC@
256# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257# undef malloc
258# define malloc rpl_malloc
259# endif
260_GL_FUNCDECL_RPL (malloc, void *, (size_t size));
261_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
262# else
263_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
264# endif
265_GL_CXXALIASWARN (malloc);
266#elif defined GNULIB_POSIXCHECK
267# undef malloc
268/* Assume malloc is always declared. */
269_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
270 "use gnulib module malloc-posix for portability");
271#endif
272
273#if @GNULIB_MKDTEMP@
274/* Create a unique temporary directory from TEMPLATE.
275 The last six characters of TEMPLATE must be "XXXXXX";
276 they are replaced with a string that makes the directory name unique.
277 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
278 The directory is created mode 700. */
279# if !@HAVE_MKDTEMP@
280_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
281# endif
282_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
283_GL_CXXALIASWARN (mkdtemp);
284#elif defined GNULIB_POSIXCHECK
285# undef mkdtemp
286# if HAVE_RAW_DECL_MKDTEMP
287_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
288 "use gnulib module mkdtemp for portability");
289# endif
290#endif
291
292#if @GNULIB_MKOSTEMP@
293/* Create a unique temporary file from TEMPLATE.
294 The last six characters of TEMPLATE must be "XXXXXX";
295 they are replaced with a string that makes the file name unique.
296 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
297 and O_TEXT, O_BINARY (defined in "binary-io.h").
298 The file is then created, with the specified flags, ensuring it didn't exist
299 before.
300 The file is created read-write (mask at least 0600 & ~umask), but it may be
301 world-readable and world-writable (mask 0666 & ~umask), depending on the
302 implementation.
303 Returns the open file descriptor if successful, otherwise -1 and errno
304 set. */
305# if !@HAVE_MKOSTEMP@
306_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
307 _GL_ARG_NONNULL ((1)));
308# endif
309_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
310_GL_CXXALIASWARN (mkostemp);
311#elif defined GNULIB_POSIXCHECK
312# undef mkostemp
313# if HAVE_RAW_DECL_MKOSTEMP
314_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
315 "use gnulib module mkostemp for portability");
316# endif
317#endif
318
319#if @GNULIB_MKOSTEMPS@
320/* Create a unique temporary file from TEMPLATE.
321 The last six characters of TEMPLATE before a suffix of length
322 SUFFIXLEN must be "XXXXXX";
323 they are replaced with a string that makes the file name unique.
324 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
325 and O_TEXT, O_BINARY (defined in "binary-io.h").
326 The file is then created, with the specified flags, ensuring it didn't exist
327 before.
328 The file is created read-write (mask at least 0600 & ~umask), but it may be
329 world-readable and world-writable (mask 0666 & ~umask), depending on the
330 implementation.
331 Returns the open file descriptor if successful, otherwise -1 and errno
332 set. */
333# if !@HAVE_MKOSTEMPS@
334_GL_FUNCDECL_SYS (mkostemps, int,
335 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
336 _GL_ARG_NONNULL ((1)));
337# endif
338_GL_CXXALIAS_SYS (mkostemps, int,
339 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
340_GL_CXXALIASWARN (mkostemps);
341#elif defined GNULIB_POSIXCHECK
342# undef mkostemps
343# if HAVE_RAW_DECL_MKOSTEMPS
344_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
345 "use gnulib module mkostemps for portability");
346# endif
347#endif
348
349#if @GNULIB_MKSTEMP@
350/* Create a unique temporary file from TEMPLATE.
351 The last six characters of TEMPLATE must be "XXXXXX";
352 they are replaced with a string that makes the file name unique.
353 The file is then created, ensuring it didn't exist before.
354 The file is created read-write (mask at least 0600 & ~umask), but it may be
355 world-readable and world-writable (mask 0666 & ~umask), depending on the
356 implementation.
357 Returns the open file descriptor if successful, otherwise -1 and errno
358 set. */
359# if @REPLACE_MKSTEMP@
360# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
361# define mkstemp rpl_mkstemp
362# endif
363_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
364_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
365# else
366# if ! @HAVE_MKSTEMP@
367_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
368# endif
369_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
370# endif
371_GL_CXXALIASWARN (mkstemp);
372#elif defined GNULIB_POSIXCHECK
373# undef mkstemp
374# if HAVE_RAW_DECL_MKSTEMP
375_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
376 "use gnulib module mkstemp for portability");
377# endif
378#endif
379
380#if @GNULIB_MKSTEMPS@
381/* Create a unique temporary file from TEMPLATE.
382 The last six characters of TEMPLATE prior to a suffix of length
383 SUFFIXLEN must be "XXXXXX";
384 they are replaced with a string that makes the file name unique.
385 The file is then created, ensuring it didn't exist before.
386 The file is created read-write (mask at least 0600 & ~umask), but it may be
387 world-readable and world-writable (mask 0666 & ~umask), depending on the
388 implementation.
389 Returns the open file descriptor if successful, otherwise -1 and errno
390 set. */
391# if !@HAVE_MKSTEMPS@
392_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
393 _GL_ARG_NONNULL ((1)));
394# endif
395_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
396_GL_CXXALIASWARN (mkstemps);
397#elif defined GNULIB_POSIXCHECK
398# undef mkstemps
399# if HAVE_RAW_DECL_MKSTEMPS
400_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
401 "use gnulib module mkstemps for portability");
402# endif
403#endif
404
405#if @GNULIB_PTSNAME@
406/* Return the pathname of the pseudo-terminal slave associated with
407 the master FD is open on, or NULL on errors. */
408# if !@HAVE_PTSNAME@
409_GL_FUNCDECL_SYS (ptsname, char *, (int fd));
410# endif
411_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
412_GL_CXXALIASWARN (ptsname);
413#elif defined GNULIB_POSIXCHECK
414# undef ptsname
415# if HAVE_RAW_DECL_PTSNAME
416_GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
417 "use gnulib module ptsname for portability");
418# endif
419#endif
420
421#if @GNULIB_PUTENV@
422# if @REPLACE_PUTENV@
423# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
424# undef putenv
425# define putenv rpl_putenv
426# endif
427_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
428_GL_CXXALIAS_RPL (putenv, int, (char *string));
429# else
430_GL_CXXALIAS_SYS (putenv, int, (char *string));
431# endif
432_GL_CXXALIASWARN (putenv);
433#endif
434
435
436#if @GNULIB_RANDOM_R@
437# if !@HAVE_RANDOM_R@
438# ifndef RAND_MAX
439# define RAND_MAX 2147483647
440# endif
441# endif
442#endif
443
444#if @GNULIB_RANDOM_R@
445# if !@HAVE_RANDOM_R@
446_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
447 _GL_ARG_NONNULL ((1, 2)));
448# endif
449_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
450_GL_CXXALIASWARN (random_r);
451#elif defined GNULIB_POSIXCHECK
452# undef random_r
453# if HAVE_RAW_DECL_RANDOM_R
454_GL_WARN_ON_USE (random_r, "random_r is unportable - "
455 "use gnulib module random_r for portability");
456# endif
457#endif
458
459#if @GNULIB_RANDOM_R@
460# if !@HAVE_RANDOM_R@
461_GL_FUNCDECL_SYS (srandom_r, int,
462 (unsigned int seed, struct random_data *rand_state)
463 _GL_ARG_NONNULL ((2)));
464# endif
465_GL_CXXALIAS_SYS (srandom_r, int,
466 (unsigned int seed, struct random_data *rand_state));
467_GL_CXXALIASWARN (srandom_r);
468#elif defined GNULIB_POSIXCHECK
469# undef srandom_r
470# if HAVE_RAW_DECL_SRANDOM_R
471_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
472 "use gnulib module random_r for portability");
473# endif
474#endif
475
476#if @GNULIB_RANDOM_R@
477# if !@HAVE_RANDOM_R@
478_GL_FUNCDECL_SYS (initstate_r, int,
479 (unsigned int seed, char *buf, size_t buf_size,
480 struct random_data *rand_state)
481 _GL_ARG_NONNULL ((2, 4)));
482# endif
483_GL_CXXALIAS_SYS (initstate_r, int,
484 (unsigned int seed, char *buf, size_t buf_size,
485 struct random_data *rand_state));
486_GL_CXXALIASWARN (initstate_r);
487#elif defined GNULIB_POSIXCHECK
488# undef initstate_r
489# if HAVE_RAW_DECL_INITSTATE_R
490_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
491 "use gnulib module random_r for portability");
492# endif
493#endif
494
495#if @GNULIB_RANDOM_R@
496# if !@HAVE_RANDOM_R@
497_GL_FUNCDECL_SYS (setstate_r, int,
498 (char *arg_state, struct random_data *rand_state)
499 _GL_ARG_NONNULL ((1, 2)));
500# endif
501_GL_CXXALIAS_SYS (setstate_r, int,
502 (char *arg_state, struct random_data *rand_state));
503_GL_CXXALIASWARN (setstate_r);
504#elif defined GNULIB_POSIXCHECK
505# undef setstate_r
506# if HAVE_RAW_DECL_SETSTATE_R
507_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
508 "use gnulib module random_r for portability");
509# endif
510#endif
511
512
513#if @GNULIB_REALLOC_POSIX@
514# if @REPLACE_REALLOC@
515# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
516# undef realloc
517# define realloc rpl_realloc
518# endif
519_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
520_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
521# else
522_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
523# endif
524_GL_CXXALIASWARN (realloc);
525#elif defined GNULIB_POSIXCHECK
526# undef realloc
527/* Assume realloc is always declared. */
528_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
529 "use gnulib module realloc-posix for portability");
530#endif
531
532#if @GNULIB_REALPATH@
533# if @REPLACE_REALPATH@
534# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
535# define realpath rpl_realpath
536# endif
537_GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
538 _GL_ARG_NONNULL ((1)));
539_GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
540# else
541# if !@HAVE_REALPATH@
542_GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
543 _GL_ARG_NONNULL ((1)));
544# endif
545_GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
546# endif
547_GL_CXXALIASWARN (realpath);
548#elif defined GNULIB_POSIXCHECK
549# undef realpath
550# if HAVE_RAW_DECL_REALPATH
551_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
552 "canonicalize or canonicalize-lgpl for portability");
553# endif
554#endif
555
556#if @GNULIB_RPMATCH@
557/* Test a user response to a question.
558 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
559# if !@HAVE_RPMATCH@
560_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
561# endif
562_GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
563_GL_CXXALIASWARN (rpmatch);
564#elif defined GNULIB_POSIXCHECK
565# undef rpmatch
566# if HAVE_RAW_DECL_RPMATCH
567_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
568 "use gnulib module rpmatch for portability");
569# endif
570#endif
571
572#if @GNULIB_SETENV@
573/* Set NAME to VALUE in the environment.
574 If REPLACE is nonzero, overwrite an existing value. */
575# if @REPLACE_SETENV@
576# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
577# undef setenv
578# define setenv rpl_setenv
579# endif
580_GL_FUNCDECL_RPL (setenv, int,
581 (const char *name, const char *value, int replace)
582 _GL_ARG_NONNULL ((1)));
583_GL_CXXALIAS_RPL (setenv, int,
584 (const char *name, const char *value, int replace));
585# else
586# if !@HAVE_DECL_SETENV@
587_GL_FUNCDECL_SYS (setenv, int,
588 (const char *name, const char *value, int replace)
589 _GL_ARG_NONNULL ((1)));
590# endif
591_GL_CXXALIAS_SYS (setenv, int,
592 (const char *name, const char *value, int replace));
593# endif
594# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
595_GL_CXXALIASWARN (setenv);
596# endif
597#elif defined GNULIB_POSIXCHECK
598# undef setenv
599# if HAVE_RAW_DECL_SETENV
600_GL_WARN_ON_USE (setenv, "setenv is unportable - "
601 "use gnulib module setenv for portability");
602# endif
603#endif
604
605#if @GNULIB_STRTOD@
606 /* Parse a double from STRING, updating ENDP if appropriate. */
607# if @REPLACE_STRTOD@
608# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
609# define strtod rpl_strtod
610# endif
611_GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
612 _GL_ARG_NONNULL ((1)));
613_GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
614# else
615# if !@HAVE_STRTOD@
616_GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
617 _GL_ARG_NONNULL ((1)));
618# endif
619_GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
620# endif
621_GL_CXXALIASWARN (strtod);
622#elif defined GNULIB_POSIXCHECK
623# undef strtod
624# if HAVE_RAW_DECL_STRTOD
625_GL_WARN_ON_USE (strtod, "strtod is unportable - "
626 "use gnulib module strtod for portability");
627# endif
628#endif
629
630#if @GNULIB_STRTOLL@
631/* Parse a signed integer whose textual representation starts at STRING.
632 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
633 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
634 "0x").
635 If ENDPTR is not NULL, the address of the first byte after the integer is
636 stored in *ENDPTR.
637 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
638 to ERANGE. */
639# if !@HAVE_STRTOLL@
640_GL_FUNCDECL_SYS (strtoll, long long,
641 (const char *string, char **endptr, int base)
642 _GL_ARG_NONNULL ((1)));
643# endif
644_GL_CXXALIAS_SYS (strtoll, long long,
645 (const char *string, char **endptr, int base));
646_GL_CXXALIASWARN (strtoll);
647#elif defined GNULIB_POSIXCHECK
648# undef strtoll
649# if HAVE_RAW_DECL_STRTOLL
650_GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
651 "use gnulib module strtoll for portability");
652# endif
653#endif
654
655#if @GNULIB_STRTOULL@
656/* Parse an unsigned integer whose textual representation starts at STRING.
657 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
658 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
659 "0x").
660 If ENDPTR is not NULL, the address of the first byte after the integer is
661 stored in *ENDPTR.
662 Upon overflow, the return value is ULLONG_MAX, and errno is set to
663 ERANGE. */
664# if !@HAVE_STRTOULL@
665_GL_FUNCDECL_SYS (strtoull, unsigned long long,
666 (const char *string, char **endptr, int base)
667 _GL_ARG_NONNULL ((1)));
668# endif
669_GL_CXXALIAS_SYS (strtoull, unsigned long long,
670 (const char *string, char **endptr, int base));
671_GL_CXXALIASWARN (strtoull);
672#elif defined GNULIB_POSIXCHECK
673# undef strtoull
674# if HAVE_RAW_DECL_STRTOULL
675_GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
676 "use gnulib module strtoull for portability");
677# endif
678#endif
679
680#if @GNULIB_UNLOCKPT@
681/* Unlock the slave side of the pseudo-terminal whose master side is specified
682 by FD, so that it can be opened. */
683# if !@HAVE_UNLOCKPT@
684_GL_FUNCDECL_SYS (unlockpt, int, (int fd));
685# endif
686_GL_CXXALIAS_SYS (unlockpt, int, (int fd));
687_GL_CXXALIASWARN (unlockpt);
688#elif defined GNULIB_POSIXCHECK
689# undef unlockpt
690# if HAVE_RAW_DECL_UNLOCKPT
691_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
692 "use gnulib module unlockpt for portability");
693# endif
694#endif
695
696#if @GNULIB_UNSETENV@
697/* Remove the variable NAME from the environment. */
698# if @REPLACE_UNSETENV@
699# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
700# undef unsetenv
701# define unsetenv rpl_unsetenv
702# endif
703_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
704_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
705# else
706# if !@HAVE_DECL_UNSETENV@
707_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
708# endif
709_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
710# endif
711# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
712_GL_CXXALIASWARN (unsetenv);
713# endif
714#elif defined GNULIB_POSIXCHECK
715# undef unsetenv
716# if HAVE_RAW_DECL_UNSETENV
717_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
718 "use gnulib module unsetenv for portability");
719# endif
720#endif
721
722
723#endif /* _GL_STDLIB_H */
724#endif /* _GL_STDLIB_H */
725#endif
diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4
new file mode 100644
index 00000000000..d25ad345b33
--- /dev/null
+++ b/m4/getloadavg.m4
@@ -0,0 +1,189 @@
1# Check for getloadavg.
2
3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2011 Free Software
4# Foundation, Inc.
5
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10#serial 2
11
12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
13# New applications should use gl_GETLOADAVG instead.
14
15# gl_GETLOADAVG(LIBOBJDIR)
16# ------------------------
17AC_DEFUN([gl_GETLOADAVG],
18[AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
19
20# Persuade glibc <stdlib.h> to declare getloadavg().
21AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
22
23gl_have_func=no # yes means we've found a way to get the load average.
24
25# Make sure getloadavg.c is where it belongs, at configure-time.
26test -f "$srcdir/$1/getloadavg.c" ||
27 AC_MSG_ERROR([$srcdir/$1/getloadavg.c is missing])
28
29gl_save_LIBS=$LIBS
30
31# Check for getloadavg, but be sure not to touch the cache variable.
32(AC_CHECK_FUNC([getloadavg], [exit 0], [exit 1])) && gl_have_func=yes
33
34# On HPUX9, an unprivileged user can get load averages through this function.
35AC_CHECK_FUNCS([pstat_getdynamic])
36
37# Solaris has libkstat which does not require root.
38AC_CHECK_LIB([kstat], [kstat_open])
39test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes
40
41# AIX has libperfstat which does not require root
42AC_CHECK_LIB([perfstat], [perfstat_cpu_total])
43test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes
44
45# Some systems with -lutil have (and need) -lkvm as well, some do not.
46# On Solaris, -lkvm requires nlist from -lelf, so check that first
47# to get the right answer into the cache.
48# For kstat on solaris, we need to test for libelf and libkvm to force the
49# definition of SVR4 below.
50if test $gl_have_func = no; then
51 AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"])
52 AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"])
53 # Check for the 4.4BSD definition of getloadavg.
54 AC_CHECK_LIB([util], [getloadavg],
55 [LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes])
56fi
57
58if test $gl_have_func = no; then
59 # There is a commonly available library for RS/6000 AIX.
60 # Since it is not a standard part of AIX, it might be installed locally.
61 gl_getloadavg_LIBS=$LIBS
62 LIBS="-L/usr/local/lib $LIBS"
63 AC_CHECK_LIB([getloadavg], [getloadavg],
64 [LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS])
65fi
66
67# Make sure it is really in the library, if we think we found it,
68# otherwise set up the replacement function.
69AC_CHECK_FUNCS([getloadavg], [],
70 [gl_PREREQ_GETLOADAVG])
71
72# Some definitions of getloadavg require that the program be installed setgid.
73AC_CACHE_CHECK([whether getloadavg requires setgid],
74 gl_cv_func_getloadavg_setgid,
75[AC_EGREP_CPP([Yowza Am I SETGID yet],
76[#define CONFIGURING_GETLOADAVG
77#include "$srcdir/$1/getloadavg.c"
78#ifdef LDAV_PRIVILEGED
79Yowza Am I SETGID yet
80#endif
81],
82 gl_cv_func_getloadavg_setgid=yes,
83 gl_cv_func_getloadavg_setgid=no)])
84if test $gl_cv_func_getloadavg_setgid = yes; then
85 NEED_SETGID=true
86 AC_DEFINE([GETLOADAVG_PRIVILEGED], [1],
87 [Define to 1 if the `getloadavg' function needs to be run setuid
88 or setgid.])
89else
90 NEED_SETGID=false
91fi
92AC_SUBST([NEED_SETGID])dnl
93
94if test $gl_cv_func_getloadavg_setgid = yes; then
95 AC_CACHE_CHECK([group of /dev/kmem], [gl_cv_group_kmem],
96[ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
97 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
98 # If we got an error (system does not support symlinks), try without -L.
99 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
100 gl_cv_group_kmem=`echo $ac_ls_output \
101 | sed -ne ['s/[ ][ ]*/ /g
102 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/
103 / /s/.* //;p']`
104])
105 AC_SUBST([KMEM_GROUP], [$gl_cv_group_kmem])dnl
106fi
107if test "x$gl_save_LIBS" = x; then
108 GETLOADAVG_LIBS=$LIBS
109else
110 GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$gl_save_LIBS!!"`
111fi
112LIBS=$gl_save_LIBS
113
114AC_SUBST([GETLOADAVG_LIBS])dnl
115
116# Test whether the system declares getloadavg. Solaris has the function
117# but declares it in <sys/loadavg.h>, not <stdlib.h>.
118AC_CHECK_HEADERS([sys/loadavg.h])
119if test $ac_cv_header_sys_loadavg_h = yes; then
120 HAVE_SYS_LOADAVG_H=1
121else
122 HAVE_SYS_LOADAVG_H=0
123fi
124AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0],
125 [#if HAVE_SYS_LOADAVG_H
126 # include <sys/loadavg.h>
127 #endif
128 #include <stdlib.h>])
129])# gl_GETLOADAVG
130
131
132# gl_PREREQ_GETLOADAVG
133# --------------------
134# Set up the AC_LIBOBJ replacement of `getloadavg'.
135AC_DEFUN([gl_PREREQ_GETLOADAVG],
136[AC_LIBOBJ([getloadavg])
137AC_DEFINE([C_GETLOADAVG], [1], [Define to 1 if using `getloadavg.c'.])
138# Figure out what our getloadavg.c needs.
139gl_have_func=no
140AC_CHECK_HEADER([sys/dg_sys_info.h],
141[gl_have_func=yes
142 AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
143 AC_CHECK_LIB([dgc], [dg_sys_info])])
144
145# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
146# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
147# Irix 4.0.5F has the header but not the library.
148if test $gl_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \
149 && test "$ac_cv_lib_kvm_kvm_open" = yes; then
150 gl_have_func=yes
151 AC_DEFINE([SVR4], [1], [Define to 1 on System V Release 4.])
152fi
153
154if test $gl_have_func = no; then
155 AC_CHECK_HEADER([inq_stats/cpustats.h],
156 [gl_have_func=yes
157 AC_DEFINE([UMAX], [1], [Define to 1 for Encore UMAX.])
158 AC_DEFINE([UMAX4_3], [1],
159 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
160 instead of <sys/cpustats.h>.])])
161fi
162
163if test $gl_have_func = no; then
164 AC_CHECK_HEADER([sys/cpustats.h],
165 [gl_have_func=yes; AC_DEFINE([UMAX])])
166fi
167
168if test $gl_have_func = no; then
169 AC_CHECK_HEADERS([mach/mach.h])
170fi
171
172AC_CHECK_HEADERS([nlist.h],
173[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
174 [AC_DEFINE([NLIST_NAME_UNION], [1],
175 [Define to 1 if your `struct nlist' has an
176 `n_un' member. Obsolete, depend on
177 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
178 [@%:@include <nlist.h>])
179 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
180 [[struct nlist x;
181 #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
182 x.n_un.n_name = "";
183 #else
184 x.n_name = "";
185 #endif]])],
186 [AC_DEFINE([N_NAME_POINTER], [1],
187 [Define to 1 if the nlist n_name member is a pointer])])
188])dnl
189])# gl_PREREQ_GETLOADAVG
diff --git a/m4/gl-comp.m4 b/m4/gl-comp.m4
index 4bd213cdbd5..036b67452c8 100644
--- a/m4/gl-comp.m4
+++ b/m4/gl-comp.m4
@@ -31,6 +31,7 @@ AC_DEFUN([gl_EARLY],
31 # Code from module dtoastr: 31 # Code from module dtoastr:
32 # Code from module extensions: 32 # Code from module extensions:
33 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 33 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
34 # Code from module getloadavg:
34 # Code from module getopt-gnu: 35 # Code from module getopt-gnu:
35 # Code from module getopt-posix: 36 # Code from module getopt-posix:
36 # Code from module gettext-h: 37 # Code from module gettext-h:
@@ -41,6 +42,7 @@ AC_DEFUN([gl_EARLY],
41 # Code from module multiarch: 42 # Code from module multiarch:
42 # Code from module stdbool: 43 # Code from module stdbool:
43 # Code from module stddef: 44 # Code from module stddef:
45 # Code from module stdlib:
44 # Code from module strftime: 46 # Code from module strftime:
45 # Code from module time: 47 # Code from module time:
46 # Code from module time_r: 48 # Code from module time_r:
@@ -69,6 +71,9 @@ AC_DEFUN([gl_INIT],
69 # Code from module dtoastr: 71 # Code from module dtoastr:
70 AC_REQUIRE([gl_C99_STRTOLD]) 72 AC_REQUIRE([gl_C99_STRTOLD])
71 # Code from module extensions: 73 # Code from module extensions:
74 # Code from module getloadavg:
75 gl_GETLOADAVG([$gl_source_base])
76 gl_STDLIB_MODULE_INDICATOR([getloadavg])
72 # Code from module getopt-gnu: 77 # Code from module getopt-gnu:
73 gl_FUNC_GETOPT_GNU 78 gl_FUNC_GETOPT_GNU
74 gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu]) 79 gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
@@ -90,6 +95,8 @@ AC_DEFUN([gl_INIT],
90 AM_STDBOOL_H 95 AM_STDBOOL_H
91 # Code from module stddef: 96 # Code from module stddef:
92 gl_STDDEF_H 97 gl_STDDEF_H
98 # Code from module stdlib:
99 gl_STDLIB_H
93 # Code from module strftime: 100 # Code from module strftime:
94 gl_FUNC_GNU_STRFTIME 101 gl_FUNC_GNU_STRFTIME
95 # Code from module time: 102 # Code from module time:
@@ -246,6 +253,7 @@ AC_DEFUN([gl_FILE_LIST], [
246 lib/dtoastr.c 253 lib/dtoastr.c
247 lib/ftoastr.c 254 lib/ftoastr.c
248 lib/ftoastr.h 255 lib/ftoastr.h
256 lib/getloadavg.c
249 lib/getopt.c 257 lib/getopt.c
250 lib/getopt.in.h 258 lib/getopt.in.h
251 lib/getopt1.c 259 lib/getopt1.c
@@ -257,6 +265,7 @@ AC_DEFUN([gl_FILE_LIST], [
257 lib/mktime.c 265 lib/mktime.c
258 lib/stdbool.in.h 266 lib/stdbool.in.h
259 lib/stddef.in.h 267 lib/stddef.in.h
268 lib/stdlib.in.h
260 lib/strftime.c 269 lib/strftime.c
261 lib/strftime.h 270 lib/strftime.h
262 lib/time.in.h 271 lib/time.in.h
@@ -265,6 +274,7 @@ AC_DEFUN([gl_FILE_LIST], [
265 m4/00gnulib.m4 274 m4/00gnulib.m4
266 m4/c-strtod.m4 275 m4/c-strtod.m4
267 m4/extensions.m4 276 m4/extensions.m4
277 m4/getloadavg.m4
268 m4/getopt.m4 278 m4/getopt.m4
269 m4/gnulib-common.m4 279 m4/gnulib-common.m4
270 m4/include_next.m4 280 m4/include_next.m4
@@ -272,6 +282,7 @@ AC_DEFUN([gl_FILE_LIST], [
272 m4/multiarch.m4 282 m4/multiarch.m4
273 m4/stdbool.m4 283 m4/stdbool.m4
274 m4/stddef_h.m4 284 m4/stddef_h.m4
285 m4/stdlib_h.m4
275 m4/strftime.m4 286 m4/strftime.m4
276 m4/time_h.m4 287 m4/time_h.m4
277 m4/time_r.m4 288 m4/time_r.m4
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
new file mode 100644
index 00000000000..28eb1a0e537
--- /dev/null
+++ b/m4/stdlib_h.m4
@@ -0,0 +1,107 @@
1# stdlib_h.m4 serial 35
2dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_STDLIB_H],
8[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 gl_NEXT_HEADERS([stdlib.h])
11 AC_CHECK_HEADERS([random.h], [], [], [AC_INCLUDES_DEFAULT])
12 if test $ac_cv_header_random_h = yes; then
13 HAVE_RANDOM_H=1
14 else
15 HAVE_RANDOM_H=0
16 fi
17 AC_SUBST([HAVE_RANDOM_H])
18
19 dnl Check for declarations of anything we want to poison if the
20 dnl corresponding gnulib module is not in use, and which is not
21 dnl guaranteed by C89.
22 gl_WARN_ON_USE_PREPARE([[#include <stdlib.h>
23#if HAVE_SYS_LOADAVG_H
24# include <sys/loadavg.h>
25#endif
26#if HAVE_RANDOM_H
27# include <random.h>
28#endif
29 ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp
30 mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r
31 setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt
32 unsetenv])
33])
34
35AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
36[
37 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
38 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
39 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
40 dnl Define it also as a C macro, for the benefit of the unit tests.
41 gl_MODULE_INDICATOR_FOR_TESTS([$1])
42])
43
44AC_DEFUN([gl_STDLIB_H_DEFAULTS],
45[
46 GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT])
47 GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL])
48 GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
49 GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME])
50 GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG])
51 GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
52 GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT])
53 GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
54 GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
55 GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP])
56 GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS])
57 GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
58 GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS])
59 GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME])
60 GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
61 GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
62 GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
63 GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH])
64 GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
65 GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
66 GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
67 GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL])
68 GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
69 GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX])
70 GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT])
71 GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
72 dnl Assume proper GNU behavior unless another module says otherwise.
73 HAVE__EXIT=1; AC_SUBST([HAVE__EXIT])
74 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
75 HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
76 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
77 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
78 HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT])
79 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
80 HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
81 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
82 HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
83 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
84 HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
85 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
86 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
87 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
88 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
89 HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV])
90 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
91 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
92 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
93 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
94 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
95 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT])
96 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV])
97 REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC])
98 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
99 REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC])
100 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
101 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
102 REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC])
103 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
104 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
105 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
106 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
107])
diff --git a/src/ChangeLog b/src/ChangeLog
index 24ec9ce43cd..72d6c49592a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12011-02-08 Paul Eggert <eggert@cs.ucla.edu>
2
3 Import getloadavg module from gnulib.
4 * deps.mk (getloadavg.o): Remove; gnulib now does this.
5 * lisp.h (getloadavg) [!defined HAVE_GETLOADAVG]: Remove; gnulib
6 now does this.
7 * src/s/freebsd.h (HAVE_GETLOADAVG): Remove; gnulib now does this.
8 * src/s/netbsd.h (HAVE_GETLOADAVG): Likewise.
9 * config.in: Regenerate.
10
12011-02-07 Paul Eggert <eggert@cs.ucla.edu> 112011-02-07 Paul Eggert <eggert@cs.ucla.edu>
2 12
3 conform to C89 pointer rules 13 conform to C89 pointer rules
diff --git a/src/config.in b/src/config.in
index 729c598a445..20d5d165d7b 100644
--- a/src/config.in
+++ b/src/config.in
@@ -408,6 +408,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
408/* Define to 1 if using libotf. */ 408/* Define to 1 if using libotf. */
409#undef HAVE_LIBOTF 409#undef HAVE_LIBOTF
410 410
411/* Define to 1 if you have the `perfstat' library (-lperfstat). */
412#undef HAVE_LIBPERFSTAT
413
411/* Define to 1 if you have the <libpng/png.h> header file. */ 414/* Define to 1 if you have the <libpng/png.h> header file. */
412#undef HAVE_LIBPNG_PNG_H 415#undef HAVE_LIBPNG_PNG_H
413 416
@@ -558,6 +561,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
558/* Define to 1 if you have the `random' function. */ 561/* Define to 1 if you have the `random' function. */
559#undef HAVE_RANDOM 562#undef HAVE_RANDOM
560 563
564/* Define to 1 if you have the <random.h> header file. */
565#undef HAVE_RANDOM_H
566
561/* Define to 1 if you have the `recvfrom' function. */ 567/* Define to 1 if you have the `recvfrom' function. */
562#undef HAVE_RECVFROM 568#undef HAVE_RECVFROM
563 569
@@ -672,6 +678,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
672/* Define to 1 if you have the `sysinfo' function. */ 678/* Define to 1 if you have the `sysinfo' function. */
673#undef HAVE_SYSINFO 679#undef HAVE_SYSINFO
674 680
681/* Define to 1 if you have the <sys/loadavg.h> header file. */
682#undef HAVE_SYS_LOADAVG_H
683
675/* Define to 1 if you have the <sys/mman.h> header file. */ 684/* Define to 1 if you have the <sys/mman.h> header file. */
676#undef HAVE_SYS_MMAN_H 685#undef HAVE_SYS_MMAN_H
677 686
@@ -889,6 +898,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
889/* Define to 1 if you are using NS windowing under GNUstep. */ 898/* Define to 1 if you are using NS windowing under GNUstep. */
890#undef NS_IMPL_GNUSTEP 899#undef NS_IMPL_GNUSTEP
891 900
901/* Define to 1 if the nlist n_name member is a pointer */
902#undef N_NAME_POINTER
903
892/* Define if the C compiler is the linker. */ 904/* Define if the C compiler is the linker. */
893#undef ORDINARY_LINK 905#undef ORDINARY_LINK
894 906
diff --git a/src/deps.mk b/src/deps.mk
index e8ff3dd592e..3cb69bab2d8 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -115,7 +115,6 @@ fringe.o: fringe.c dispextern.h nsgui.h frame.h window.h buffer.h termhooks.h \
115ftfont.o: ftfont.c dispextern.h frame.h character.h charset.h composite.h \ 115ftfont.o: ftfont.c dispextern.h frame.h character.h charset.h composite.h \
116 font.h lisp.h $(config_h) blockinput.h atimer.h systime.h coding.h \ 116 font.h lisp.h $(config_h) blockinput.h atimer.h systime.h coding.h \
117 fontset.h ccl.h ftfont.h globals.h 117 fontset.h ccl.h ftfont.h globals.h
118getloadavg.o: getloadavg.c $(config_h)
119gnutls.o: gnutls.c gnutls.h process.h ../lib/unistd.h \ 118gnutls.o: gnutls.c gnutls.h process.h ../lib/unistd.h \
120 lisp.h globals.h $(config_h) 119 lisp.h globals.h $(config_h)
121gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h lisp.h $(config_h) \ 120gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h lisp.h $(config_h) \
diff --git a/src/lisp.h b/src/lisp.h
index 4afc73195fd..2b2f61bbda4 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3407,11 +3407,6 @@ EXFUN (Fclear_face_cache, 1);
3407EXFUN (Fx_load_color_file, 1); 3407EXFUN (Fx_load_color_file, 1);
3408extern void syms_of_xfaces (void); 3408extern void syms_of_xfaces (void);
3409 3409
3410#ifndef HAVE_GETLOADAVG
3411/* Defined in getloadavg.c */
3412extern int getloadavg (double *, int);
3413#endif
3414
3415#ifdef HAVE_X_WINDOWS 3410#ifdef HAVE_X_WINDOWS
3416/* Defined in xfns.c */ 3411/* Defined in xfns.c */
3417extern void syms_of_xfns (void); 3412extern void syms_of_xfns (void);
diff --git a/src/s/freebsd.h b/src/s/freebsd.h
index 222ebc91c4a..24b34e02f69 100644
--- a/src/s/freebsd.h
+++ b/src/s/freebsd.h
@@ -25,8 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 25
26#define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base) 26#define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
27 27
28#define HAVE_GETLOADAVG 1
29
30/* This silences a few compilation warnings. */ 28/* This silences a few compilation warnings. */
31#undef BSD_SYSTEM 29#undef BSD_SYSTEM
32#if __FreeBSD__ == 1 30#if __FreeBSD__ == 1
diff --git a/src/s/netbsd.h b/src/s/netbsd.h
index 8a639b93c84..52cda717a2d 100644
--- a/src/s/netbsd.h
+++ b/src/s/netbsd.h
@@ -21,8 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21/* Get most of the stuff from bsd-common. */ 21/* Get most of the stuff from bsd-common. */
22#include "bsd-common.h" 22#include "bsd-common.h"
23 23
24#define HAVE_GETLOADAVG 1
25
26#define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base) 24#define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
27 25
28#define DEFAULT_SOUND_DEVICE "/dev/audio" 26#define DEFAULT_SOUND_DEVICE "/dev/audio"
@@ -43,4 +41,3 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
43 41
44/* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method. */ 42/* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method. */
45#define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS 43#define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS
46