Import getloadavg module from gnulib.

This commit is contained in:
Paul Eggert 2011-02-07 23:05:03 -08:00
parent 226590f8d1
commit 79ab4b7f0e
19 changed files with 2399 additions and 765 deletions

View file

@ -1,3 +1,24 @@
2011-02-08 Paul Eggert <eggert@cs.ucla.edu>
Import getloadavg module from gnulib.
* .bzrignore: Add lib/stdlib.h.
* Makefile.in (GNULIB_MODULES): Add getloadavg.
* admin/notes/copyright: Remove src/getloadavg.c as a special case.
* configure.in (LIBS_SYSTEM): Omit -lkstat on sol2*; gnulib does this.
(AC_CONFIG_LIBOBJ_DIR, AC_FUNC_GETLOADAVG, GETLOADAVG_FILES):
Remove; gnulib does this now.
* lib/getloadavg.c: Rename from src/getloadavg.c, and sync
from gnulib. This adds support for several other systems, such
as Tru64 4.0D, QNX, AIX perfstat, etc. It also fixes a potential
buffer overrun on Linux hosts under very high load, and on hosts
that maintain a channel to the load average file it makes sure
the file descriptor is close-on-exec (on hosts that support this)
and is not stdin, stdout, or stderr.
* lib/stdlib.in.h, m4/getloadavg.m4, m4/stdlib_h.m4: New files,
from gnulib.
* aclocal.m4, configure, lib/Makefile.in, lib/gnulib.mk, m4/gl-comp.m4:
* src/config.in: Regenerate.
2011-02-06 Paul Eggert <eggert@cs.ucla.edu>
gnulib: allow multiple gnulib generated replacements to coexist

View file

@ -330,7 +330,7 @@ DOS_gnulib_comp.m4 = gl-comp.m4
# Update modules from gnulib, for maintainers, who should have it in
# $(gnulib_srcdir) (relative to $(srcdir) and should have build tools
# as per $(gnulib_srcdir)/DEPENDENCIES.
GNULIB_MODULES = dtoastr getopt-gnu ignore-value mktime strftime
GNULIB_MODULES = dtoastr getloadavg getopt-gnu ignore-value mktime strftime
GNULIB_TOOL_FLAGS = \
--import --no-changelog --no-vc-files --makefile-name=gnulib.mk
sync-from-gnulib: $(gnulib_srcdir)

2
aclocal.m4 vendored
View file

@ -987,6 +987,7 @@ AC_SUBST([am__untar])
m4_include([m4/00gnulib.m4])
m4_include([m4/c-strtod.m4])
m4_include([m4/extensions.m4])
m4_include([m4/getloadavg.m4])
m4_include([m4/getopt.m4])
m4_include([m4/gl-comp.m4])
m4_include([m4/gnulib-common.m4])
@ -995,6 +996,7 @@ m4_include([m4/mktime.m4])
m4_include([m4/multiarch.m4])
m4_include([m4/stdbool.m4])
m4_include([m4/stddef_h.m4])
m4_include([m4/stdlib_h.m4])
m4_include([m4/strftime.m4])
m4_include([m4/time_h.m4])
m4_include([m4/time_r.m4])

View file

@ -631,7 +631,6 @@ alone (may import them from Gnulib again). These are:
warn-on-use.h
lib/*.[ch]
lib/gnulib.mk
src/getloadavg.c
src/gmalloc.c
src/md5.c
src/md5.h

1306
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -984,7 +984,7 @@ case "$opsys" in
hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
sol2*) LIBS_SYSTEM="-lsocket -lnsl -lkstat" ;;
sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
## Motif needs -lgen.
unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
@ -1000,9 +1000,6 @@ else
CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
fi
dnl For AC_FUNC_GETLOADAVG, at least:
AC_CONFIG_LIBOBJ_DIR(src)
dnl Do this early because it can frob feature test macros for Unix-98 &c.
AC_SYS_LARGEFILE
@ -2665,8 +2662,6 @@ fi
AC_CHECK_HEADERS(sys/un.h)
AC_FUNC_GETLOADAVG
AC_FUNC_FSEEKO
AC_FUNC_GETPGRP
@ -3115,7 +3110,6 @@ fi
S_FILE="\$(srcdir)/${opsysfile}"
AC_SUBST(M_FILE)
AC_SUBST(S_FILE)
AC_SUBST(GETLOADAVG_LIBS)
AC_SUBST(ns_appdir)
AC_SUBST(ns_appbindir)
AC_SUBST(ns_appresdir)

View file

@ -24,7 +24,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# 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
# 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
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
@ -51,14 +51,15 @@ subdir = lib
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
$(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/extensions.m4 \
$(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gl-comp.m4 \
$(top_srcdir)/m4/gnulib-common.m4 \
$(top_srcdir)/m4/getloadavg.m4 $(top_srcdir)/m4/getopt.m4 \
$(top_srcdir)/m4/gl-comp.m4 $(top_srcdir)/m4/gnulib-common.m4 \
$(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/mktime.m4 \
$(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/stdbool.m4 \
$(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/strftime.m4 \
$(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \
$(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/unistd_h.m4 \
$(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/configure.in
$(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \
$(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/time_h.m4 \
$(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \
$(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/wchar_t.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -134,6 +135,9 @@ GCONF_LIBS = @GCONF_LIBS@
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
GETOPT_H = @GETOPT_H@
GMALLOC_OBJ = @GMALLOC_OBJ@
GNULIB_ATOLL = @GNULIB_ATOLL@
GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
GNULIB_CHOWN = @GNULIB_CHOWN@
GNULIB_CLOSE = @GNULIB_CLOSE@
GNULIB_DUP2 = @GNULIB_DUP2@
@ -150,27 +154,47 @@ GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
GNULIB_GRANTPT = @GNULIB_GRANTPT@
GNULIB_LCHOWN = @GNULIB_LCHOWN@
GNULIB_LINK = @GNULIB_LINK@
GNULIB_LINKAT = @GNULIB_LINKAT@
GNULIB_LSEEK = @GNULIB_LSEEK@
GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
GNULIB_MKTIME = @GNULIB_MKTIME@
GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
GNULIB_PIPE = @GNULIB_PIPE@
GNULIB_PIPE2 = @GNULIB_PIPE2@
GNULIB_PREAD = @GNULIB_PREAD@
GNULIB_PTSNAME = @GNULIB_PTSNAME@
GNULIB_PUTENV = @GNULIB_PUTENV@
GNULIB_PWRITE = @GNULIB_PWRITE@
GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
GNULIB_READLINK = @GNULIB_READLINK@
GNULIB_READLINKAT = @GNULIB_READLINKAT@
GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
GNULIB_REALPATH = @GNULIB_REALPATH@
GNULIB_RMDIR = @GNULIB_RMDIR@
GNULIB_RPMATCH = @GNULIB_RPMATCH@
GNULIB_SETENV = @GNULIB_SETENV@
GNULIB_SLEEP = @GNULIB_SLEEP@
GNULIB_STRPTIME = @GNULIB_STRPTIME@
GNULIB_STRTOD = @GNULIB_STRTOD@
GNULIB_STRTOLL = @GNULIB_STRTOLL@
GNULIB_STRTOULL = @GNULIB_STRTOULL@
GNULIB_SYMLINK = @GNULIB_SYMLINK@
GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
GNULIB_TIMEGM = @GNULIB_TIMEGM@
GNULIB_TIME_R = @GNULIB_TIME_R@
GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
@ -178,8 +202,11 @@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
GNULIB_UNLINK = @GNULIB_UNLINK@
GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
GNULIB_UNSETENV = @GNULIB_UNSETENV@
GNULIB_USLEEP = @GNULIB_USLEEP@
GNULIB_WRITE = @GNULIB_WRITE@
GNULIB__EXIT = @GNULIB__EXIT@
GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@
GREP = @GREP@
GTK_CFLAGS = @GTK_CFLAGS@
@ -187,15 +214,20 @@ GTK_LIBS = @GTK_LIBS@
GTK_OBJ = @GTK_OBJ@
GZIP_INFO = @GZIP_INFO@
GZIP_PROG = @GZIP_PROG@
HAVE_ATOLL = @HAVE_ATOLL@
HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
HAVE_CHOWN = @HAVE_CHOWN@
HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
HAVE_DUP2 = @HAVE_DUP2@
HAVE_DUP3 = @HAVE_DUP3@
HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
@ -210,30 +242,50 @@ HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
HAVE_GETLOGIN = @HAVE_GETLOGIN@
HAVE_GETOPT_H = @HAVE_GETOPT_H@
HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
HAVE_GRANTPT = @HAVE_GRANTPT@
HAVE_LCHOWN = @HAVE_LCHOWN@
HAVE_LINK = @HAVE_LINK@
HAVE_LINKAT = @HAVE_LINKAT@
HAVE_MAKEINFO = @HAVE_MAKEINFO@
HAVE_MKDTEMP = @HAVE_MKDTEMP@
HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
HAVE_MKSTEMP = @HAVE_MKSTEMP@
HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
HAVE_OS_H = @HAVE_OS_H@
HAVE_PIPE = @HAVE_PIPE@
HAVE_PIPE2 = @HAVE_PIPE2@
HAVE_PREAD = @HAVE_PREAD@
HAVE_PTSNAME = @HAVE_PTSNAME@
HAVE_PWRITE = @HAVE_PWRITE@
HAVE_RANDOM_H = @HAVE_RANDOM_H@
HAVE_RANDOM_R = @HAVE_RANDOM_R@
HAVE_READLINK = @HAVE_READLINK@
HAVE_READLINKAT = @HAVE_READLINKAT@
HAVE_REALPATH = @HAVE_REALPATH@
HAVE_RPMATCH = @HAVE_RPMATCH@
HAVE_SETENV = @HAVE_SETENV@
HAVE_SLEEP = @HAVE_SLEEP@
HAVE_STRPTIME = @HAVE_STRPTIME@
HAVE_STRTOD = @HAVE_STRTOD@
HAVE_STRTOLL = @HAVE_STRTOLL@
HAVE_STRTOULL = @HAVE_STRTOULL@
HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
HAVE_SYMLINK = @HAVE_SYMLINK@
HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
HAVE_TIMEGM = @HAVE_TIMEGM@
HAVE_UNISTD_H = @HAVE_UNISTD_H@
HAVE_UNLINKAT = @HAVE_UNLINKAT@
HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
HAVE_USLEEP = @HAVE_USLEEP@
HAVE_WCHAR_T = @HAVE_WCHAR_T@
HAVE_XSERVER = @HAVE_XSERVER@
HAVE__BOOL = @HAVE__BOOL@
HAVE__EXIT = @HAVE__EXIT@
IMAGEMAGICK_CFLAGS = @IMAGEMAGICK_CFLAGS@
IMAGEMAGICK_LIBS = @IMAGEMAGICK_LIBS@
INCLUDE_NEXT = @INCLUDE_NEXT@
@ -300,10 +352,12 @@ M_FILE = @M_FILE@
NEED_SETGID = @NEED_SETGID@
NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
NEXT_GETOPT_H = @NEXT_GETOPT_H@
NEXT_STDDEF_H = @NEXT_STDDEF_H@
NEXT_STDLIB_H = @NEXT_STDLIB_H@
NEXT_TIME_H = @NEXT_TIME_H@
NEXT_UNISTD_H = @NEXT_UNISTD_H@
NS_OBJ = @NS_OBJ@
@ -330,6 +384,8 @@ PROFILING_CFLAGS = @PROFILING_CFLAGS@
PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
RALLOC_OBJ = @RALLOC_OBJ@
RANLIB = @RANLIB@
REPLACE_CALLOC = @REPLACE_CALLOC@
REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
REPLACE_CHOWN = @REPLACE_CHOWN@
REPLACE_CLOSE = @REPLACE_CLOSE@
REPLACE_DUP = @REPLACE_DUP@
@ -345,19 +401,27 @@ REPLACE_LINK = @REPLACE_LINK@
REPLACE_LINKAT = @REPLACE_LINKAT@
REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
REPLACE_LSEEK = @REPLACE_LSEEK@
REPLACE_MALLOC = @REPLACE_MALLOC@
REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
REPLACE_MKTIME = @REPLACE_MKTIME@
REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
REPLACE_NULL = @REPLACE_NULL@
REPLACE_PREAD = @REPLACE_PREAD@
REPLACE_PUTENV = @REPLACE_PUTENV@
REPLACE_PWRITE = @REPLACE_PWRITE@
REPLACE_READLINK = @REPLACE_READLINK@
REPLACE_REALLOC = @REPLACE_REALLOC@
REPLACE_REALPATH = @REPLACE_REALPATH@
REPLACE_RMDIR = @REPLACE_RMDIR@
REPLACE_SETENV = @REPLACE_SETENV@
REPLACE_SLEEP = @REPLACE_SLEEP@
REPLACE_STRTOD = @REPLACE_STRTOD@
REPLACE_SYMLINK = @REPLACE_SYMLINK@
REPLACE_TIMEGM = @REPLACE_TIMEGM@
REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
REPLACE_UNLINK = @REPLACE_UNLINK@
REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
REPLACE_UNSETENV = @REPLACE_UNSETENV@
REPLACE_USLEEP = @REPLACE_USLEEP@
REPLACE_WRITE = @REPLACE_WRITE@
RSVG_CFLAGS = @RSVG_CFLAGS@
@ -471,23 +535,23 @@ x_default_search_path = @x_default_search_path@
# present in all Makefile.am that need it. This is ensured by the applicability
# 'all' defined above.
BUILT_SOURCES = arg-nonnull.h c++defs.h $(GETOPT_H) $(STDBOOL_H) \
$(STDDEF_H) time.h unistd.h warn-on-use.h
$(STDDEF_H) stdlib.h time.h unistd.h warn-on-use.h
EXTRA_DIST = $(top_srcdir)/./arg-nonnull.h $(top_srcdir)/./c++defs.h \
ftoastr.c ftoastr.h getopt.c getopt.in.h getopt1.c \
getopt_int.h intprops.h mktime-internal.h mktime.c \
stdbool.in.h stddef.in.h strftime.c strftime.h time.in.h \
time_r.c unistd.in.h $(top_srcdir)/./warn-on-use.h
ftoastr.c ftoastr.h getloadavg.c getopt.c getopt.in.h \
getopt1.c getopt_int.h intprops.h mktime-internal.h mktime.c \
stdbool.in.h stddef.in.h stdlib.in.h strftime.c strftime.h \
time.in.h time_r.c unistd.in.h $(top_srcdir)/./warn-on-use.h
MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \
c++defs.h c++defs.h-t getopt.h getopt.h-t stdbool.h \
stdbool.h-t stddef.h stddef.h-t time.h time.h-t unistd.h \
unistd.h-t warn-on-use.h warn-on-use.h-t
stdbool.h-t stddef.h stddef.h-t stdlib.h stdlib.h-t time.h \
time.h-t unistd.h unistd.h-t warn-on-use.h warn-on-use.h-t
noinst_LIBRARIES = libgnu.a
DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src
libgnu_a_SOURCES = dtoastr.c gettext.h ignore-value.h
libgnu_a_LIBADD = $(gl_LIBOBJS)
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
EXTRA_libgnu_a_SOURCES = ftoastr.c getopt.c getopt1.c mktime.c \
strftime.c time_r.c
EXTRA_libgnu_a_SOURCES = ftoastr.c getloadavg.c getopt.c getopt1.c \
mktime.c strftime.c time_r.c
ARG_NONNULL_H = arg-nonnull.h
CXXDEFS_H = c++defs.h
WARN_ON_USE_H = warn-on-use.h
@ -542,6 +606,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtoastr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getloadavg.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@
@ -818,6 +883,82 @@ stddef.h: stddef.in.h
} > $@-t && \
mv $@-t $@
# We need the following in order to create <stdlib.h> when the system
# doesn't have one that works with the given compiler.
stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
-e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \
-e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
-e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
-e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
-e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
-e 's|@''GNULIB_GRANTPT''@|$(GNULIB_GRANTPT)|g' \
-e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
-e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
-e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \
-e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \
-e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
-e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
-e 's|@''GNULIB_PTSNAME''@|$(GNULIB_PTSNAME)|g' \
-e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
-e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
-e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
-e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \
-e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
-e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
-e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
-e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
-e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
-e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \
-e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \
-e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
-e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
-e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
-e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
-e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
-e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
-e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
-e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
-e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
-e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
-e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
-e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
-e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
-e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
-e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
-e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
-e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
-e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
-e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
-e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
-e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
-e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
-e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
-e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
-e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
-e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
-e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
-e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
-e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
-e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
-e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/stdlib.in.h; \
} > $@-t && \
mv $@-t $@
# We need the following in order to create <time.h> when the system
# doesn't have one that works with the given compiler.
time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)

View file

@ -1,15 +1,15 @@
/* Get the system load averages.
Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995,
1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2011 Free Software
Foundation, Inc.
NOTE: The canonical source of this file is maintained with gnulib.
Bugs can be reported to bug-gnulib@gnu.org.
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -17,62 +17,62 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Compile-time symbols that this file uses:
HAVE_PSTAT_GETDYNAMIC Define this if your system has the
HAVE_PSTAT_GETDYNAMIC Define this if your system has the
pstat_getdynamic function. I think it
is unique to HPUX9. The best way to get the
definition is through the AC_FUNC_GETLOADAVG
macro that comes with autoconf 2.13 or newer.
If that isn't an option, then just put
AC_CHECK_FUNCS(pstat_getdynamic) in your
configure.in file.
FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
KERNEL_FILE Pathname of the kernel to nlist.
LDAV_CVT() Scale the load average from the kernel.
Returns a double.
LDAV_SYMBOL Name of kernel symbol giving load average.
LOAD_AVE_TYPE Type of the load average array in the kernel.
Must be defined unless one of
apollo, DGUX, NeXT, or UMAX is defined;
is unique to HPUX9. The best way to get the
definition is through the AC_FUNC_GETLOADAVG
macro that comes with autoconf 2.13 or newer.
If that isn't an option, then just put
AC_CHECK_FUNCS(pstat_getdynamic) in your
configure.in file.
HAVE_LIBPERFSTAT Define this if your system has the
perfstat_cpu_total function in libperfstat (AIX).
FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
KERNEL_FILE Name of the kernel file to nlist.
LDAV_CVT() Scale the load average from the kernel.
Returns a double.
LDAV_SYMBOL Name of kernel symbol giving load average.
LOAD_AVE_TYPE Type of the load average array in the kernel.
Must be defined unless one of
apollo, DGUX, NeXT, or UMAX is defined;
or we have libkstat;
otherwise, no load average is available.
otherwise, no load average is available.
HAVE_NLIST_H nlist.h is available. NLIST_STRUCT defaults
to this.
NLIST_STRUCT Include nlist.h, not a.out.h, and
the nlist n_name element is a pointer,
not an array.
NLIST_STRUCT Include nlist.h, not a.out.h.
N_NAME_POINTER The nlist n_name element is a pointer,
not an array.
HAVE_STRUCT_NLIST_N_UN_N_NAME `n_un.n_name' is member of `struct nlist'.
LINUX_LDAV_FILE [__linux__]: File containing load averages.
HAVE_LOCALE_H locale.h is available.
HAVE_SETLOCALE The `setlocale' function is available.
LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing
load averages.
Specific system predefines this file uses, aside from setting
default values if not emacs:
apollo
BSD Real BSD, not just BSD-like.
BSD Real BSD, not just BSD-like.
convex
DGUX
eunice UNIX emulator under VMS.
eunice UNIX emulator under VMS.
hpux
__MSDOS__ No-op for MSDOS.
__MSDOS__ No-op for MSDOS.
NeXT
sgi
sequent Sequent Dynix 3.x.x (BSD)
_SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV)
sequent Sequent Dynix 3.x.x (BSD)
_SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV)
sony_news NEWS-OS (works at least for 4.1C)
UMAX
UMAX4_3
VMS
WINDOWS32 No-op for Windows95/NT.
__linux__ Linux: assumes /proc filesystem mounted.
Support from Michael K. Johnson.
__NetBSD__ NetBSD: assumes /kern filesystem mounted.
WINDOWS32 No-op for Windows95/NT.
__linux__ Linux: assumes /proc file system mounted.
Support from Michael K. Johnson.
__CYGWIN__ Cygwin emulates linux /proc/loadavg.
__NetBSD__ NetBSD: assumes /kern file system mounted.
In addition, to avoid nesting many #ifdefs, we internally set
LDAV_DONE to indicate that the load average has been computed.
@ -80,41 +80,35 @@
We also #define LDAV_PRIVILEGED if a program will require
special installation to be able to call getloadavg. */
/* This should always be first. */
#ifdef HAVE_CONFIG_H
/* "configure" defines CONFIGURING_GETLOADAVG to sidestep problems
with partially-configured source directories. */
#ifndef CONFIGURING_GETLOADAVG
# include <config.h>
# include <stdbool.h>
#endif
#include <sys/types.h>
/* Specification. */
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
/* Exclude all the code except the test program at the end
if the system has its own `getloadavg' function. */
#ifndef HAVE_GETLOADAVG
# include <sys/types.h>
/* Both the Emacs and non-Emacs sections want this. Some
configuration files' definitions for the LOAD_AVE_CVT macro (like
sparc.h's) use macros like FSCALE, defined here. */
#if defined (unix) || defined (__unix)
# include <sys/param.h>
#endif
# if defined (unix) || defined (__unix)
# include <sys/param.h>
# endif
/* Exclude all the code except the test program at the end
if the system has its own `getloadavg' function.
The declaration of `errno' is needed by the test program
as well as the function itself, so it comes first. */
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
#ifndef HAVE_SETLOCALE
# define setlocale(Category, Locale) /* empty */
#endif
#ifndef HAVE_GETLOADAVG
# include "intprops.h"
/* The existing Emacs configuration files define a macro called
LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and
@ -126,7 +120,7 @@ extern int errno;
LOAD_AVE_CVT, but future machine config files should just define
LDAV_CVT directly. */
# if !defined(LDAV_CVT) && defined(LOAD_AVE_CVT)
# if !defined (LDAV_CVT) && defined (LOAD_AVE_CVT)
# define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0)
# endif
@ -170,11 +164,11 @@ extern int errno;
# define sun
# endif
# if defined(hp300) && !defined(hpux)
# if defined (hp300) && !defined (hpux)
# define MORE_BSD
# endif
# if defined(ultrix) && defined(mips)
# if defined (ultrix) && defined (mips)
# define decstation
# endif
@ -182,7 +176,7 @@ extern int errno;
# define SVR4
# endif
# if (defined(sun) && defined(SVR4)) || defined (SOLARIS2)
# if (defined (sun) && defined (SVR4)) || defined (SOLARIS2)
# define SUNOS_5
# endif
@ -192,6 +186,8 @@ extern int errno;
# include <sys/socket.h>
# include <net/route.h>
# include <sys/table.h>
/* Tru64 4.0D's table.h redefines sys */
# undef sys
# endif
# if defined (__osf__) && (defined (mips) || defined (__mips__))
@ -203,7 +199,7 @@ extern int errno;
default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>. Combine
that with a couple of other things and we'll have a unique match. */
# if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES)
# define tek4300 /* Define by emacs, but not by other users. */
# define tek4300 /* Define by emacs, but not by other users. */
# endif
@ -254,11 +250,11 @@ extern int errno;
# define LOAD_AVE_TYPE long
# endif
# if defined(alliant) && defined(i860) /* Alliant FX/2800 */
# if defined (alliant) && defined (i860) /* Alliant FX/2800 */
# define LOAD_AVE_TYPE long
# endif
# ifdef _AIX
# if defined _AIX && ! defined HAVE_LIBPERFSTAT
# define LOAD_AVE_TYPE long
# endif
@ -278,7 +274,7 @@ extern int errno;
# define FSCALE 1024.0
# endif
# if defined(alliant) && defined(i860) /* Alliant FX/2800 */
# if defined (alliant) && defined (i860) /* Alliant FX/2800 */
/* <sys/param.h> defines an incorrect value for FSCALE on an
Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */
# undef FSCALE
@ -286,7 +282,7 @@ extern int errno;
# endif
# ifndef FSCALE
# ifndef FSCALE
/* SunOS and some others define FSCALE in sys/param.h. */
@ -294,7 +290,7 @@ extern int errno;
# define FSCALE 2048.0
# endif
# if defined(MIPS) || defined(SVR4) || defined(decstation)
# if defined (MIPS) || defined (SVR4) || defined (decstation)
# define FSCALE 256
# endif
@ -313,11 +309,11 @@ extern int errno;
# define FSCALE 100.0
# endif
# ifdef _AIX
# if defined _AIX && !defined HAVE_LIBPERFSTAT
# define FSCALE 65536.0
# endif
# endif /* Not FSCALE. */
# endif /* Not FSCALE. */
# if !defined (LDAV_CVT) && defined (FSCALE)
# define LDAV_CVT(n) (((double) (n)) / FSCALE)
@ -329,7 +325,7 @@ extern int errno;
# endif
# endif
# if defined(sgi) || (defined(mips) && !defined(BSD))
# if defined (sgi) || (defined (mips) && !defined (BSD))
# define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31))
# endif
@ -342,7 +338,7 @@ extern int errno;
# define KERNEL_FILE "/hp-ux"
# endif
# if !defined(KERNEL_FILE) && (defined(_SEQUENT_) || defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || (defined (ardent) && defined (titan)))
# if !defined (KERNEL_FILE) && (defined (_SEQUENT_) || defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan)))
# define KERNEL_FILE "/unix"
# endif
@ -351,22 +347,21 @@ extern int errno;
# define LDAV_SYMBOL "_Loadavg"
# endif
# if !defined(LDAV_SYMBOL) && ((defined(hpux) && !defined(hp9000s300)) || defined(_SEQUENT_) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX))
# 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)))
# define LDAV_SYMBOL "avenrun"
# endif
# include <unistd.h>
# include <stdio.h>
/* LOAD_AVE_TYPE should only get defined if we're going to use the
nlist method. */
# if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL))
# if !defined (LOAD_AVE_TYPE) && (defined (BSD) || defined (LDAV_CVT) || defined (KERNEL_FILE) || defined (LDAV_SYMBOL))
# define LOAD_AVE_TYPE double
# endif
# ifdef LOAD_AVE_TYPE
# ifndef VMS
# ifndef __VMS
# ifndef __linux__
# ifndef NLIST_STRUCT
# include <a.out.h>
@ -375,7 +370,6 @@ extern int errno;
# endif /* NLIST_STRUCT */
# ifdef SUNOS_5
# include <fcntl.h>
# include <kvm.h>
# include <kstat.h>
# endif
@ -393,7 +387,7 @@ extern int errno;
# endif /* LDAV_SYMBOL */
# endif /* __linux__ */
# else /* VMS */
# else /* __VMS */
# ifndef eunice
# include <iodef.h>
@ -401,7 +395,7 @@ extern int errno;
# else /* eunice */
# include <vms/iodef.h>
# endif /* eunice */
# endif /* VMS */
# endif /* __VMS */
# ifndef LDAV_CVT
# define LDAV_CVT(n) ((double) (n))
@ -409,7 +403,16 @@ extern int errno;
# endif /* LOAD_AVE_TYPE */
# if defined(__GNU__) && !defined (NeXT)
# if defined HAVE_LIBPERFSTAT
# include <sys/protosw.h>
# include <libperfstat.h>
# include <sys/proc.h>
# ifndef SBITS
# define SBITS 16
# endif
# endif
# if defined (__GNU__) && !defined (NeXT)
/* Note that NeXT Openstep defines __GNU__ even though it should not. */
/* GNU system acts much like NeXT, for load average purposes,
but not exactly. */
@ -430,7 +433,6 @@ extern int errno;
# endif /* sgi */
# ifdef UMAX
# include <stdio.h>
# include <signal.h>
# include <sys/time.h>
# include <sys/wait.h>
@ -456,17 +458,16 @@ extern int errno;
# include <sys/dg_sys_info.h>
# endif
# if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
# if (defined __linux__ || defined __CYGWIN__ || defined SUNOS_5 \
|| (defined LOAD_AVE_TYPE && ! defined __VMS))
# include <fcntl.h>
# else
# include <sys/file.h>
# endif
/* Avoid static vars inside a function since in HPUX they dump as pure. */
# ifdef NeXT
static processor_set_t default_set;
static int getloadavg_initialized;
static bool getloadavg_initialized;
# endif /* NeXT */
# ifdef UMAX
@ -475,26 +476,26 @@ static unsigned int samples;
# endif /* UMAX */
# ifdef DGUX
static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
# endif /* DGUX */
#if !defined(HAVE_LIBKSTAT) && defined(LOAD_AVE_TYPE)
# if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE)
/* File descriptor open to /dev/kmem or VMS load ave driver. */
static int channel;
/* Nonzero if channel is valid. */
static int getloadavg_initialized;
/* True if channel is valid. */
static bool getloadavg_initialized;
/* Offset in kmem to seek to read load average, or 0 means invalid. */
static long offset;
# if !defined(VMS) && !defined(sgi) && !defined(__linux__)
# if ! defined __VMS && ! defined sgi && ! defined __linux__
static struct nlist name_list[2];
# endif /* Not VMS or sgi */
# endif
# ifdef SUNOS_5
static kvm_t *kd;
# endif /* SUNOS_5 */
#endif /* LOAD_AVE_TYPE && !HAVE_LIBKSTAT */
# endif /* LOAD_AVE_TYPE && !HAVE_LIBKSTAT */
/* Put the 1 minute, 5 minute and 15 minute load averages
into the first NELEM elements of LOADAVG.
@ -502,11 +503,9 @@ static kvm_t *kd;
or -1 if an error occurred. */
int
getloadavg (loadavg, nelem)
double loadavg[];
int nelem;
getloadavg (double loadavg[], int nelem)
{
int elem = 0; /* Return value. */
int elem = 0; /* Return value. */
# ifdef NO_GET_LOAD_AVG
# define LDAV_DONE
@ -527,7 +526,7 @@ getloadavg (loadavg, nelem)
if (kc == 0)
return -1;
ksp = kstat_lookup (kc, "unix", 0, "system_misc");
if (ksp == 0 )
if (ksp == 0)
return -1;
if (kstat_read (kc, ksp, 0) == -1)
return -1;
@ -542,22 +541,22 @@ getloadavg (loadavg, nelem)
}
if (nelem >= 1)
loadavg[elem++] = (double) kn->value.ul/FSCALE;
loadavg[elem++] = (double) kn->value.ul / FSCALE;
if (nelem >= 2)
{
kn = kstat_data_lookup (ksp, "avenrun_5min");
if (kn != 0)
{
loadavg[elem++] = (double) kn->value.ul/FSCALE;
{
loadavg[elem++] = (double) kn->value.ul / FSCALE;
if (nelem >= 3)
{
kn = kstat_data_lookup (ksp, "avenrun_15min");
if (kn != 0)
loadavg[elem++] = (double) kn->value.ul/FSCALE;
}
}
if (nelem >= 3)
{
kn = kstat_data_lookup (ksp, "avenrun_15min");
if (kn != 0)
loadavg[elem++] = (double) kn->value.ul / FSCALE;
}
}
}
kstat_close (kc);
@ -580,7 +579,23 @@ getloadavg (loadavg, nelem)
# endif /* hpux && HAVE_PSTAT_GETDYNAMIC */
# if !defined (LDAV_DONE) && defined (__linux__)
# if ! defined LDAV_DONE && defined HAVE_LIBPERFSTAT
# define LDAV_DONE
# undef LOAD_AVE_TYPE
/* Use perfstat_cpu_total because we don't have to be root. */
{
perfstat_cpu_total_t cpu_stats;
int result = perfstat_cpu_total (NULL, &cpu_stats, sizeof cpu_stats, 1);
if (result == -1)
return result;
loadavg[0] = cpu_stats.loadavg[0] / (double)(1 << SBITS);
loadavg[1] = cpu_stats.loadavg[1] / (double)(1 << SBITS);
loadavg[2] = cpu_stats.loadavg[2] / (double)(1 << SBITS);
elem = 3;
}
# endif
# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__))
# define LDAV_DONE
# undef LOAD_AVE_TYPE
@ -588,32 +603,50 @@ getloadavg (loadavg, nelem)
# define LINUX_LDAV_FILE "/proc/loadavg"
# endif
char ldavgbuf[40];
double load_ave[3];
char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
char const *ptr = ldavgbuf;
int fd, count;
fd = open (LINUX_LDAV_FILE, O_RDONLY);
if (fd == -1)
return -1;
count = read (fd, ldavgbuf, 40);
count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
(void) close (fd);
if (count <= 0)
return -1;
ldavgbuf[count] = '\0';
/* The following sscanf must use the C locale. */
setlocale (LC_NUMERIC, "C");
count = sscanf (ldavgbuf, "%lf %lf %lf",
&load_ave[0], &load_ave[1], &load_ave[2]);
setlocale (LC_NUMERIC, "");
if (count < 1)
return -1;
for (elem = 0; elem < nelem; elem++)
{
double numerator = 0;
double denominator = 1;
bool have_digit = false;
for (elem = 0; elem < nelem && elem < count; elem++)
loadavg[elem] = load_ave[elem];
while (*ptr == ' ')
ptr++;
/* Finish if this number is missing, and report an error if all
were missing. */
if (! ('0' <= *ptr && *ptr <= '9'))
{
if (elem == 0)
return -1;
break;
}
while ('0' <= *ptr && *ptr <= '9')
numerator = 10 * numerator + (*ptr++ - '0');
if (*ptr == '.')
for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
loadavg[elem++] = numerator / denominator;
}
return elem;
# endif /* __linux__ */
# endif /* __linux__ || __CYGWIN__ */
# if !defined (LDAV_DONE) && defined (__NetBSD__)
# define LDAV_DONE
@ -631,8 +664,8 @@ getloadavg (loadavg, nelem)
if (fp == NULL)
return -1;
count = fscanf (fp, "%lu %lu %lu %lu\n",
&load_ave[0], &load_ave[1], &load_ave[2],
&scale);
&load_ave[0], &load_ave[1], &load_ave[2],
&scale);
(void) fclose (fp);
if (count != 4)
return -1;
@ -650,7 +683,7 @@ getloadavg (loadavg, nelem)
host_t host;
struct processor_set_basic_info info;
unsigned info_count;
unsigned int info_count;
/* We only know how to get the 1-minute average for this system,
so even if the caller asks for more than 1, we only return 1. */
@ -658,21 +691,21 @@ getloadavg (loadavg, nelem)
if (!getloadavg_initialized)
{
if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS)
getloadavg_initialized = 1;
getloadavg_initialized = true;
}
if (getloadavg_initialized)
{
info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
(processor_set_info_t) &info, &info_count)
!= KERN_SUCCESS)
getloadavg_initialized = 0;
(processor_set_info_t) &info, &info_count)
!= KERN_SUCCESS)
getloadavg_initialized = false;
else
{
if (nelem > 0)
loadavg[elem++] = (double) info.load_average / LOAD_SCALE;
}
{
if (nelem > 0)
loadavg[elem++] = (double) info.load_average / LOAD_SCALE;
}
}
if (!getloadavg_initialized)
@ -704,24 +737,24 @@ getloadavg (loadavg, nelem)
desc.sd_size = sizeof conf;
if (inq_stats (1, &desc))
return -1;
return -1;
c = 0;
for (i = 0; i < conf.config_maxclass; ++i)
{
struct class_stats stats;
memset (&stats, 0, sizeof stats);
{
struct class_stats stats;
memset (&stats, 0, sizeof stats);
desc.sd_type = CPUTYPE_CLASS;
desc.sd_objid = i;
desc.sd_addr = (char *) &stats;
desc.sd_size = sizeof stats;
desc.sd_type = CPUTYPE_CLASS;
desc.sd_objid = i;
desc.sd_addr = (char *) &stats;
desc.sd_size = sizeof stats;
if (inq_stats (1, &desc))
return -1;
if (inq_stats (1, &desc))
return -1;
c += stats.class_numcpus;
}
c += stats.class_numcpus;
}
cpus = c;
samples = cpus < 2 ? 3 : (2 * cpus / 3);
}
@ -742,7 +775,7 @@ getloadavg (loadavg, nelem)
{
load += proc_sum_data.ps_nrun[j];
if (j++ == PS_NRUNSIZE)
j = 0;
j = 0;
}
if (nelem > 0)
@ -755,8 +788,8 @@ getloadavg (loadavg, nelem)
it's not supposed to fail. The first argument is for no
apparent reason of type `long int *'. */
dg_sys_info ((long int *) &load_info,
DG_SYS_INFO_LOAD_INFO_TYPE,
DG_SYS_INFO_LOAD_VERSION_0);
DG_SYS_INFO_LOAD_INFO_TYPE,
DG_SYS_INFO_LOAD_VERSION_0);
if (nelem > 0)
loadavg[elem++] = load_info.one_minute;
@ -800,7 +833,7 @@ getloadavg (loadavg, nelem)
= (load_ave.tl_lscale == 0
? load_ave.tl_avenrun.d[0]
: (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale));
# endif /* OSF_MIPS */
# endif /* OSF_MIPS */
# if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32))
# define LDAV_DONE
@ -820,15 +853,15 @@ getloadavg (loadavg, nelem)
for (elem = 0; elem < nelem; elem++)
loadavg[elem]
= (load_ave.tl_lscale == 0
? load_ave.tl_avenrun.d[elem]
: (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
? load_ave.tl_avenrun.d[elem]
: (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
# endif /* OSF_ALPHA */
# if !defined (LDAV_DONE) && defined (VMS)
# if ! defined LDAV_DONE && defined __VMS
/* VMS specific code -- read from the Load Ave driver. */
LOAD_AVE_TYPE load_ave[3];
static int getloadavg_initialized = 0;
static bool getloadavg_initialized;
# ifdef eunice
struct
{
@ -848,27 +881,27 @@ getloadavg (loadavg, nelem)
$DESCRIPTOR (descriptor, "LAV0:");
# endif
if (sys$assign (&descriptor, &channel, 0, 0) & 1)
getloadavg_initialized = 1;
getloadavg_initialized = true;
}
/* Read the load average vector. */
if (getloadavg_initialized
&& !(sys$qiow (0, channel, IO$_READVBLK, 0, 0, 0,
load_ave, 12, 0, 0, 0, 0) & 1))
load_ave, 12, 0, 0, 0, 0) & 1))
{
sys$dassgn (channel);
getloadavg_initialized = 0;
getloadavg_initialized = false;
}
if (!getloadavg_initialized)
return -1;
# endif /* VMS */
# endif /* ! defined LDAV_DONE && defined __VMS */
# if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE) && !defined(VMS)
# if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS
/* UNIX-specific code -- read the average from /dev/kmem. */
# define LDAV_PRIVILEGED /* This code requires special installation. */
# define LDAV_PRIVILEGED /* This code requires special installation. */
LOAD_AVE_TYPE load_ave[3];
@ -876,7 +909,7 @@ getloadavg (loadavg, nelem)
if (offset == 0)
{
# ifndef sgi
# ifndef NLIST_STRUCT
# if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
strcpy (name_list[0].n_name, LDAV_SYMBOL);
strcpy (name_list[1].n_name, "");
# else /* NLIST_STRUCT */
@ -892,25 +925,25 @@ getloadavg (loadavg, nelem)
# ifndef SUNOS_5
if (
# if !(defined (_AIX) && !defined (ps2))
nlist (KERNEL_FILE, name_list)
nlist (KERNEL_FILE, name_list)
# else /* _AIX */
knlist (name_list, 1, sizeof (name_list[0]))
knlist (name_list, 1, sizeof (name_list[0]))
# endif
>= 0)
/* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i. */
{
>= 0)
/* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i. */
{
# ifdef FIXUP_KERNEL_SYMBOL_ADDR
FIXUP_KERNEL_SYMBOL_ADDR (name_list);
FIXUP_KERNEL_SYMBOL_ADDR (name_list);
# endif
offset = name_list[0].n_value;
}
offset = name_list[0].n_value;
}
# endif /* !SUNOS_5 */
# else /* sgi */
int ldav_off;
ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
if (ldav_off != -1)
offset = (long) ldav_off & 0x7fffffff;
offset = (long int) ldav_off & 0x7fffffff;
# endif /* sgi */
}
@ -918,30 +951,39 @@ getloadavg (loadavg, nelem)
if (!getloadavg_initialized)
{
# ifndef SUNOS_5
channel = open ("/dev/kmem", 0);
if (channel >= 0)
{
/* Set the channel to close on exec, so it does not
litter any child's descriptor table. */
# ifdef F_SETFD
# ifndef FD_CLOEXEC
# define FD_CLOEXEC 1
# endif
(void) fcntl (channel, F_SETFD, FD_CLOEXEC);
/* Set the channel to close on exec, so it does not
litter any child's descriptor table. */
# ifndef O_CLOEXEC
# define O_CLOEXEC 0
# endif
getloadavg_initialized = 1;
}
int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
if (0 <= fd)
{
# if F_DUPFD_CLOEXEC
if (fd <= STDERR_FILENO)
{
int fd1 = fcntl (fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
close (fd);
fd = fd1;
}
# endif
if (0 <= fd)
{
channel = fd;
getloadavg_initialized = true;
}
}
# else /* SUNOS_5 */
/* We pass 0 for the kernel, corefile, and swapfile names
to use the currently running kernel. */
to use the currently running kernel. */
kd = kvm_open (0, 0, 0, O_RDONLY, 0);
if (kd != 0)
{
/* nlist the currently running kernel. */
kvm_nlist (kd, name_list);
offset = name_list[0].n_value;
getloadavg_initialized = 1;
}
{
/* nlist the currently running kernel. */
kvm_nlist (kd, name_list);
offset = name_list[0].n_value;
getloadavg_initialized = true;
}
# endif /* SUNOS_5 */
}
@ -951,25 +993,25 @@ getloadavg (loadavg, nelem)
/* Try to read the load. */
# ifndef SUNOS_5
if (lseek (channel, offset, 0) == -1L
|| read (channel, (char *) load_ave, sizeof (load_ave))
!= sizeof (load_ave))
{
close (channel);
getloadavg_initialized = 0;
}
|| read (channel, (char *) load_ave, sizeof (load_ave))
!= sizeof (load_ave))
{
close (channel);
getloadavg_initialized = false;
}
# else /* SUNOS_5 */
if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
!= sizeof (load_ave))
!= sizeof (load_ave))
{
kvm_close (kd);
getloadavg_initialized = 0;
}
getloadavg_initialized = false;
}
# endif /* SUNOS_5 */
}
if (offset == 0 || !getloadavg_initialized)
return -1;
# endif /* LOAD_AVE_TYPE and not VMS */
# endif /* ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS */
# if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS. */
if (nelem > 0)
@ -982,23 +1024,20 @@ getloadavg (loadavg, nelem)
# define LDAV_DONE
# endif /* !LDAV_DONE && LOAD_AVE_TYPE */
# ifdef LDAV_DONE
return elem;
# else
# if !defined LDAV_DONE
/* Set errno to zero to indicate that there was no particular error;
this function just can't work at all on this system. */
errno = 0;
return -1;
elem = -1;
# endif
return elem;
}
#endif /* ! HAVE_GETLOADAVG */
#ifdef TEST
void
main (argc, argv)
int argc;
char **argv;
int
main (int argc, char **argv)
{
int naptime = 0;
@ -1010,28 +1049,27 @@ main (argc, argv)
double avg[3];
int loads;
errno = 0; /* Don't be misled if it doesn't set errno. */
errno = 0; /* Don't be misled if it doesn't set errno. */
loads = getloadavg (avg, 3);
if (loads == -1)
{
perror ("Error getting load average");
exit (1);
}
{
perror ("Error getting load average");
return EXIT_FAILURE;
}
if (loads > 0)
printf ("1-minute: %f ", avg[0]);
printf ("1-minute: %f ", avg[0]);
if (loads > 1)
printf ("5-minute: %f ", avg[1]);
printf ("5-minute: %f ", avg[1]);
if (loads > 2)
printf ("15-minute: %f ", avg[2]);
printf ("15-minute: %f ", avg[2]);
if (loads > 0)
putchar ('\n');
putchar ('\n');
if (naptime == 0)
break;
break;
sleep (naptime);
}
exit (0);
return EXIT_SUCCESS;
}
#endif /* TEST */

View file

@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# 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
# 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
MOSTLYCLEANFILES += core *.stackdump
@ -79,6 +79,15 @@ EXTRA_libgnu_a_SOURCES += ftoastr.c
## end gnulib module dtoastr
## begin gnulib module getloadavg
EXTRA_DIST += getloadavg.c
EXTRA_libgnu_a_SOURCES += getloadavg.c
## end gnulib module getloadavg
## begin gnulib module getopt-posix
BUILT_SOURCES += $(GETOPT_H)
@ -175,6 +184,91 @@ EXTRA_DIST += stddef.in.h
## end gnulib module stddef
## begin gnulib module stdlib
BUILT_SOURCES += stdlib.h
# We need the following in order to create <stdlib.h> when the system
# doesn't have one that works with the given compiler.
stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
-e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \
-e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
-e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
-e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
-e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
-e 's|@''GNULIB_GRANTPT''@|$(GNULIB_GRANTPT)|g' \
-e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
-e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
-e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \
-e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \
-e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
-e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
-e 's|@''GNULIB_PTSNAME''@|$(GNULIB_PTSNAME)|g' \
-e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
-e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
-e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
-e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \
-e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
-e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
-e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
-e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
-e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
-e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \
-e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \
-e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
-e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
-e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
-e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
-e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
-e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
-e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
-e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
-e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
-e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
-e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
-e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
-e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
-e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
-e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
-e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
-e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
-e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
-e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
-e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
-e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
-e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
-e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
-e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
-e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
-e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
-e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
-e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
-e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
-e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
-e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
-e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/stdlib.in.h; \
} > $@-t && \
mv $@-t $@
MOSTLYCLEANFILES += stdlib.h stdlib.h-t
EXTRA_DIST += stdlib.in.h
## end gnulib module stdlib
## begin gnulib module strftime

725
lib/stdlib.in.h Normal file
View file

@ -0,0 +1,725 @@
/* A GNU-like <stdlib.h>.
Copyright (C) 1995, 2001-2004, 2006-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
#if defined __need_malloc_and_calloc
/* Special invocation convention inside glibc header files. */
#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
#else
/* Normal invocation convention. */
#ifndef _GL_STDLIB_H
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
#ifndef _GL_STDLIB_H
#define _GL_STDLIB_H
/* NetBSD 5.0 mis-defines NULL. */
#include <stddef.h>
/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
# include <sys/wait.h>
#endif
/* Solaris declares getloadavg() in <sys/loadavg.h>. */
#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
# include <sys/loadavg.h>
#endif
/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
from <stdlib.h> if _REENTRANT is defined. Include it always. */
#if @HAVE_RANDOM_H@
# include <random.h>
#endif
#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@)
# include <stdint.h>
#endif
#if !@HAVE_STRUCT_RANDOM_DATA@
/* Define 'struct random_data'.
But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
# if !GNULIB_defined_struct_random_data
struct random_data
{
int32_t *fptr; /* Front pointer. */
int32_t *rptr; /* Rear pointer. */
int32_t *state; /* Array of state values. */
int rand_type; /* Type of random number generator. */
int rand_deg; /* Degree of random number generator. */
int rand_sep; /* Distance between front and rear. */
int32_t *end_ptr; /* Pointer behind state table. */
};
# define GNULIB_defined_struct_random_data 1
# endif
#endif
#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
/* But avoid namespace pollution on glibc systems and native Windows. */
# include <unistd.h>
#endif
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(Spec) /* empty */
# endif
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
/* Some systems do not define EXIT_*, despite otherwise supporting C89. */
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
#endif
/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
with proper operation of xargs. */
#ifndef EXIT_FAILURE
# define EXIT_FAILURE 1
#elif EXIT_FAILURE != 1
# undef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif
#if @GNULIB__EXIT@
/* Terminate the current process with the given return code, without running
the 'atexit' handlers. */
# if !@HAVE__EXIT@
_GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__)));
# endif
_GL_CXXALIAS_SYS (_Exit, void, (int status));
_GL_CXXALIASWARN (_Exit);
#elif defined GNULIB_POSIXCHECK
# undef _Exit
# if HAVE_RAW_DECL__EXIT
_GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
"use gnulib module _Exit for portability");
# endif
#endif
#if @GNULIB_ATOLL@
/* Parse a signed decimal integer.
Returns the value of the integer. Errors are not detected. */
# if !@HAVE_ATOLL@
_GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
_GL_CXXALIASWARN (atoll);
#elif defined GNULIB_POSIXCHECK
# undef atoll
# if HAVE_RAW_DECL_ATOLL
_GL_WARN_ON_USE (atoll, "atoll is unportable - "
"use gnulib module atoll for portability");
# endif
#endif
#if @GNULIB_CALLOC_POSIX@
# if @REPLACE_CALLOC@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef calloc
# define calloc rpl_calloc
# endif
_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
# else
_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
# endif
_GL_CXXALIASWARN (calloc);
#elif defined GNULIB_POSIXCHECK
# undef calloc
/* Assume calloc is always declared. */
_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
"use gnulib module calloc-posix for portability");
#endif
#if @GNULIB_CANONICALIZE_FILE_NAME@
# if @REPLACE_CANONICALIZE_FILE_NAME@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define canonicalize_file_name rpl_canonicalize_file_name
# endif
_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
# else
# if !@HAVE_CANONICALIZE_FILE_NAME@
_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
# endif
_GL_CXXALIASWARN (canonicalize_file_name);
#elif defined GNULIB_POSIXCHECK
# undef canonicalize_file_name
# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
_GL_WARN_ON_USE (canonicalize_file_name,
"canonicalize_file_name is unportable - "
"use gnulib module canonicalize-lgpl for portability");
# endif
#endif
#if @GNULIB_GETLOADAVG@
/* Store max(NELEM,3) load average numbers in LOADAVG[].
The three numbers are the load average of the last 1 minute, the last 5
minutes, and the last 15 minutes, respectively.
LOADAVG is an array of NELEM numbers. */
# if !@HAVE_DECL_GETLOADAVG@
_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
_GL_CXXALIASWARN (getloadavg);
#elif defined GNULIB_POSIXCHECK
# undef getloadavg
# if HAVE_RAW_DECL_GETLOADAVG
_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
"use gnulib module getloadavg for portability");
# endif
#endif
#if @GNULIB_GETSUBOPT@
/* Assuming *OPTIONP is a comma separated list of elements of the form
"token" or "token=value", getsubopt parses the first of these elements.
If the first element refers to a "token" that is member of the given
NULL-terminated array of tokens:
- It replaces the comma with a NUL byte, updates *OPTIONP to point past
the first option and the comma, sets *VALUEP to the value of the
element (or NULL if it doesn't contain an "=" sign),
- It returns the index of the "token" in the given array of tokens.
Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
For more details see the POSIX:2001 specification.
http://www.opengroup.org/susv3xsh/getsubopt.html */
# if !@HAVE_GETSUBOPT@
_GL_FUNCDECL_SYS (getsubopt, int,
(char **optionp, char *const *tokens, char **valuep)
_GL_ARG_NONNULL ((1, 2, 3)));
# endif
_GL_CXXALIAS_SYS (getsubopt, int,
(char **optionp, char *const *tokens, char **valuep));
_GL_CXXALIASWARN (getsubopt);
#elif defined GNULIB_POSIXCHECK
# undef getsubopt
# if HAVE_RAW_DECL_GETSUBOPT
_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
"use gnulib module getsubopt for portability");
# endif
#endif
#if @GNULIB_GRANTPT@
/* Change the ownership and access permission of the slave side of the
pseudo-terminal whose master side is specified by FD. */
# if !@HAVE_GRANTPT@
_GL_FUNCDECL_SYS (grantpt, int, (int fd));
# endif
_GL_CXXALIAS_SYS (grantpt, int, (int fd));
_GL_CXXALIASWARN (grantpt);
#elif defined GNULIB_POSIXCHECK
# undef grantpt
# if HAVE_RAW_DECL_GRANTPT
_GL_WARN_ON_USE (ptsname, "grantpt is not portable - "
"use gnulib module grantpt for portability");
# endif
#endif
#if @GNULIB_MALLOC_POSIX@
# if @REPLACE_MALLOC@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef malloc
# define malloc rpl_malloc
# endif
_GL_FUNCDECL_RPL (malloc, void *, (size_t size));
_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
# else
_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
# endif
_GL_CXXALIASWARN (malloc);
#elif defined GNULIB_POSIXCHECK
# undef malloc
/* Assume malloc is always declared. */
_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
"use gnulib module malloc-posix for portability");
#endif
#if @GNULIB_MKDTEMP@
/* Create a unique temporary directory from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
they are replaced with a string that makes the directory name unique.
Returns TEMPLATE, or a null pointer if it cannot get a unique name.
The directory is created mode 700. */
# if !@HAVE_MKDTEMP@
_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
_GL_CXXALIASWARN (mkdtemp);
#elif defined GNULIB_POSIXCHECK
# undef mkdtemp
# if HAVE_RAW_DECL_MKDTEMP
_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
"use gnulib module mkdtemp for portability");
# endif
#endif
#if @GNULIB_MKOSTEMP@
/* Create a unique temporary file from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
they are replaced with a string that makes the file name unique.
The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
and O_TEXT, O_BINARY (defined in "binary-io.h").
The file is then created, with the specified flags, ensuring it didn't exist
before.
The file is created read-write (mask at least 0600 & ~umask), but it may be
world-readable and world-writable (mask 0666 & ~umask), depending on the
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
# if !@HAVE_MKOSTEMP@
_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
_GL_CXXALIASWARN (mkostemp);
#elif defined GNULIB_POSIXCHECK
# undef mkostemp
# if HAVE_RAW_DECL_MKOSTEMP
_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
"use gnulib module mkostemp for portability");
# endif
#endif
#if @GNULIB_MKOSTEMPS@
/* Create a unique temporary file from TEMPLATE.
The last six characters of TEMPLATE before a suffix of length
SUFFIXLEN must be "XXXXXX";
they are replaced with a string that makes the file name unique.
The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
and O_TEXT, O_BINARY (defined in "binary-io.h").
The file is then created, with the specified flags, ensuring it didn't exist
before.
The file is created read-write (mask at least 0600 & ~umask), but it may be
world-readable and world-writable (mask 0666 & ~umask), depending on the
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
# if !@HAVE_MKOSTEMPS@
_GL_FUNCDECL_SYS (mkostemps, int,
(char * /*template*/, int /*suffixlen*/, int /*flags*/)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (mkostemps, int,
(char * /*template*/, int /*suffixlen*/, int /*flags*/));
_GL_CXXALIASWARN (mkostemps);
#elif defined GNULIB_POSIXCHECK
# undef mkostemps
# if HAVE_RAW_DECL_MKOSTEMPS
_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
"use gnulib module mkostemps for portability");
# endif
#endif
#if @GNULIB_MKSTEMP@
/* Create a unique temporary file from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
they are replaced with a string that makes the file name unique.
The file is then created, ensuring it didn't exist before.
The file is created read-write (mask at least 0600 & ~umask), but it may be
world-readable and world-writable (mask 0666 & ~umask), depending on the
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
# if @REPLACE_MKSTEMP@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define mkstemp rpl_mkstemp
# endif
_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
# else
# if ! @HAVE_MKSTEMP@
_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
# endif
_GL_CXXALIASWARN (mkstemp);
#elif defined GNULIB_POSIXCHECK
# undef mkstemp
# if HAVE_RAW_DECL_MKSTEMP
_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
"use gnulib module mkstemp for portability");
# endif
#endif
#if @GNULIB_MKSTEMPS@
/* Create a unique temporary file from TEMPLATE.
The last six characters of TEMPLATE prior to a suffix of length
SUFFIXLEN must be "XXXXXX";
they are replaced with a string that makes the file name unique.
The file is then created, ensuring it didn't exist before.
The file is created read-write (mask at least 0600 & ~umask), but it may be
world-readable and world-writable (mask 0666 & ~umask), depending on the
implementation.
Returns the open file descriptor if successful, otherwise -1 and errno
set. */
# if !@HAVE_MKSTEMPS@
_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
_GL_CXXALIASWARN (mkstemps);
#elif defined GNULIB_POSIXCHECK
# undef mkstemps
# if HAVE_RAW_DECL_MKSTEMPS
_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
"use gnulib module mkstemps for portability");
# endif
#endif
#if @GNULIB_PTSNAME@
/* Return the pathname of the pseudo-terminal slave associated with
the master FD is open on, or NULL on errors. */
# if !@HAVE_PTSNAME@
_GL_FUNCDECL_SYS (ptsname, char *, (int fd));
# endif
_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
_GL_CXXALIASWARN (ptsname);
#elif defined GNULIB_POSIXCHECK
# undef ptsname
# if HAVE_RAW_DECL_PTSNAME
_GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
"use gnulib module ptsname for portability");
# endif
#endif
#if @GNULIB_PUTENV@
# if @REPLACE_PUTENV@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef putenv
# define putenv rpl_putenv
# endif
_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (putenv, int, (char *string));
# else
_GL_CXXALIAS_SYS (putenv, int, (char *string));
# endif
_GL_CXXALIASWARN (putenv);
#endif
#if @GNULIB_RANDOM_R@
# if !@HAVE_RANDOM_R@
# ifndef RAND_MAX
# define RAND_MAX 2147483647
# endif
# endif
#endif
#if @GNULIB_RANDOM_R@
# if !@HAVE_RANDOM_R@
_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
_GL_CXXALIASWARN (random_r);
#elif defined GNULIB_POSIXCHECK
# undef random_r
# if HAVE_RAW_DECL_RANDOM_R
_GL_WARN_ON_USE (random_r, "random_r is unportable - "
"use gnulib module random_r for portability");
# endif
#endif
#if @GNULIB_RANDOM_R@
# if !@HAVE_RANDOM_R@
_GL_FUNCDECL_SYS (srandom_r, int,
(unsigned int seed, struct random_data *rand_state)
_GL_ARG_NONNULL ((2)));
# endif
_GL_CXXALIAS_SYS (srandom_r, int,
(unsigned int seed, struct random_data *rand_state));
_GL_CXXALIASWARN (srandom_r);
#elif defined GNULIB_POSIXCHECK
# undef srandom_r
# if HAVE_RAW_DECL_SRANDOM_R
_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
"use gnulib module random_r for portability");
# endif
#endif
#if @GNULIB_RANDOM_R@
# if !@HAVE_RANDOM_R@
_GL_FUNCDECL_SYS (initstate_r, int,
(unsigned int seed, char *buf, size_t buf_size,
struct random_data *rand_state)
_GL_ARG_NONNULL ((2, 4)));
# endif
_GL_CXXALIAS_SYS (initstate_r, int,
(unsigned int seed, char *buf, size_t buf_size,
struct random_data *rand_state));
_GL_CXXALIASWARN (initstate_r);
#elif defined GNULIB_POSIXCHECK
# undef initstate_r
# if HAVE_RAW_DECL_INITSTATE_R
_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
"use gnulib module random_r for portability");
# endif
#endif
#if @GNULIB_RANDOM_R@
# if !@HAVE_RANDOM_R@
_GL_FUNCDECL_SYS (setstate_r, int,
(char *arg_state, struct random_data *rand_state)
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (setstate_r, int,
(char *arg_state, struct random_data *rand_state));
_GL_CXXALIASWARN (setstate_r);
#elif defined GNULIB_POSIXCHECK
# undef setstate_r
# if HAVE_RAW_DECL_SETSTATE_R
_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
"use gnulib module random_r for portability");
# endif
#endif
#if @GNULIB_REALLOC_POSIX@
# if @REPLACE_REALLOC@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef realloc
# define realloc rpl_realloc
# endif
_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
# else
_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
# endif
_GL_CXXALIASWARN (realloc);
#elif defined GNULIB_POSIXCHECK
# undef realloc
/* Assume realloc is always declared. */
_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
"use gnulib module realloc-posix for portability");
#endif
#if @GNULIB_REALPATH@
# if @REPLACE_REALPATH@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define realpath rpl_realpath
# endif
_GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
# else
# if !@HAVE_REALPATH@
_GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
# endif
_GL_CXXALIASWARN (realpath);
#elif defined GNULIB_POSIXCHECK
# undef realpath
# if HAVE_RAW_DECL_REALPATH
_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
"canonicalize or canonicalize-lgpl for portability");
# endif
#endif
#if @GNULIB_RPMATCH@
/* Test a user response to a question.
Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
# if !@HAVE_RPMATCH@
_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
_GL_CXXALIASWARN (rpmatch);
#elif defined GNULIB_POSIXCHECK
# undef rpmatch
# if HAVE_RAW_DECL_RPMATCH
_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
"use gnulib module rpmatch for portability");
# endif
#endif
#if @GNULIB_SETENV@
/* Set NAME to VALUE in the environment.
If REPLACE is nonzero, overwrite an existing value. */
# if @REPLACE_SETENV@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef setenv
# define setenv rpl_setenv
# endif
_GL_FUNCDECL_RPL (setenv, int,
(const char *name, const char *value, int replace)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (setenv, int,
(const char *name, const char *value, int replace));
# else
# if !@HAVE_DECL_SETENV@
_GL_FUNCDECL_SYS (setenv, int,
(const char *name, const char *value, int replace)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (setenv, int,
(const char *name, const char *value, int replace));
# endif
# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
_GL_CXXALIASWARN (setenv);
# endif
#elif defined GNULIB_POSIXCHECK
# undef setenv
# if HAVE_RAW_DECL_SETENV
_GL_WARN_ON_USE (setenv, "setenv is unportable - "
"use gnulib module setenv for portability");
# endif
#endif
#if @GNULIB_STRTOD@
/* Parse a double from STRING, updating ENDP if appropriate. */
# if @REPLACE_STRTOD@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define strtod rpl_strtod
# endif
_GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
# else
# if !@HAVE_STRTOD@
_GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
# endif
_GL_CXXALIASWARN (strtod);
#elif defined GNULIB_POSIXCHECK
# undef strtod
# if HAVE_RAW_DECL_STRTOD
_GL_WARN_ON_USE (strtod, "strtod is unportable - "
"use gnulib module strtod for portability");
# endif
#endif
#if @GNULIB_STRTOLL@
/* Parse a signed integer whose textual representation starts at STRING.
The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
"0x").
If ENDPTR is not NULL, the address of the first byte after the integer is
stored in *ENDPTR.
Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
to ERANGE. */
# if !@HAVE_STRTOLL@
_GL_FUNCDECL_SYS (strtoll, long long,
(const char *string, char **endptr, int base)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (strtoll, long long,
(const char *string, char **endptr, int base));
_GL_CXXALIASWARN (strtoll);
#elif defined GNULIB_POSIXCHECK
# undef strtoll
# if HAVE_RAW_DECL_STRTOLL
_GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
"use gnulib module strtoll for portability");
# endif
#endif
#if @GNULIB_STRTOULL@
/* Parse an unsigned integer whose textual representation starts at STRING.
The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
"0x").
If ENDPTR is not NULL, the address of the first byte after the integer is
stored in *ENDPTR.
Upon overflow, the return value is ULLONG_MAX, and errno is set to
ERANGE. */
# if !@HAVE_STRTOULL@
_GL_FUNCDECL_SYS (strtoull, unsigned long long,
(const char *string, char **endptr, int base)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (strtoull, unsigned long long,
(const char *string, char **endptr, int base));
_GL_CXXALIASWARN (strtoull);
#elif defined GNULIB_POSIXCHECK
# undef strtoull
# if HAVE_RAW_DECL_STRTOULL
_GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
"use gnulib module strtoull for portability");
# endif
#endif
#if @GNULIB_UNLOCKPT@
/* Unlock the slave side of the pseudo-terminal whose master side is specified
by FD, so that it can be opened. */
# if !@HAVE_UNLOCKPT@
_GL_FUNCDECL_SYS (unlockpt, int, (int fd));
# endif
_GL_CXXALIAS_SYS (unlockpt, int, (int fd));
_GL_CXXALIASWARN (unlockpt);
#elif defined GNULIB_POSIXCHECK
# undef unlockpt
# if HAVE_RAW_DECL_UNLOCKPT
_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
"use gnulib module unlockpt for portability");
# endif
#endif
#if @GNULIB_UNSETENV@
/* Remove the variable NAME from the environment. */
# if @REPLACE_UNSETENV@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef unsetenv
# define unsetenv rpl_unsetenv
# endif
_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
# else
# if !@HAVE_DECL_UNSETENV@
_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
# endif
# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
_GL_CXXALIASWARN (unsetenv);
# endif
#elif defined GNULIB_POSIXCHECK
# undef unsetenv
# if HAVE_RAW_DECL_UNSETENV
_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
"use gnulib module unsetenv for portability");
# endif
#endif
#endif /* _GL_STDLIB_H */
#endif /* _GL_STDLIB_H */
#endif

189
m4/getloadavg.m4 Normal file
View file

@ -0,0 +1,189 @@
# Check for getloadavg.
# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2011 Free Software
# Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 2
# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
# New applications should use gl_GETLOADAVG instead.
# gl_GETLOADAVG(LIBOBJDIR)
# ------------------------
AC_DEFUN([gl_GETLOADAVG],
[AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
# Persuade glibc <stdlib.h> to declare getloadavg().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
gl_have_func=no # yes means we've found a way to get the load average.
# Make sure getloadavg.c is where it belongs, at configure-time.
test -f "$srcdir/$1/getloadavg.c" ||
AC_MSG_ERROR([$srcdir/$1/getloadavg.c is missing])
gl_save_LIBS=$LIBS
# Check for getloadavg, but be sure not to touch the cache variable.
(AC_CHECK_FUNC([getloadavg], [exit 0], [exit 1])) && gl_have_func=yes
# On HPUX9, an unprivileged user can get load averages through this function.
AC_CHECK_FUNCS([pstat_getdynamic])
# Solaris has libkstat which does not require root.
AC_CHECK_LIB([kstat], [kstat_open])
test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes
# AIX has libperfstat which does not require root
AC_CHECK_LIB([perfstat], [perfstat_cpu_total])
test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes
# Some systems with -lutil have (and need) -lkvm as well, some do not.
# On Solaris, -lkvm requires nlist from -lelf, so check that first
# to get the right answer into the cache.
# For kstat on solaris, we need to test for libelf and libkvm to force the
# definition of SVR4 below.
if test $gl_have_func = no; then
AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"])
AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"])
# Check for the 4.4BSD definition of getloadavg.
AC_CHECK_LIB([util], [getloadavg],
[LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes])
fi
if test $gl_have_func = no; then
# There is a commonly available library for RS/6000 AIX.
# Since it is not a standard part of AIX, it might be installed locally.
gl_getloadavg_LIBS=$LIBS
LIBS="-L/usr/local/lib $LIBS"
AC_CHECK_LIB([getloadavg], [getloadavg],
[LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS])
fi
# Make sure it is really in the library, if we think we found it,
# otherwise set up the replacement function.
AC_CHECK_FUNCS([getloadavg], [],
[gl_PREREQ_GETLOADAVG])
# Some definitions of getloadavg require that the program be installed setgid.
AC_CACHE_CHECK([whether getloadavg requires setgid],
gl_cv_func_getloadavg_setgid,
[AC_EGREP_CPP([Yowza Am I SETGID yet],
[#define CONFIGURING_GETLOADAVG
#include "$srcdir/$1/getloadavg.c"
#ifdef LDAV_PRIVILEGED
Yowza Am I SETGID yet
#endif
],
gl_cv_func_getloadavg_setgid=yes,
gl_cv_func_getloadavg_setgid=no)])
if test $gl_cv_func_getloadavg_setgid = yes; then
NEED_SETGID=true
AC_DEFINE([GETLOADAVG_PRIVILEGED], [1],
[Define to 1 if the `getloadavg' function needs to be run setuid
or setgid.])
else
NEED_SETGID=false
fi
AC_SUBST([NEED_SETGID])dnl
if test $gl_cv_func_getloadavg_setgid = yes; then
AC_CACHE_CHECK([group of /dev/kmem], [gl_cv_group_kmem],
[ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
# If we got an error (system does not support symlinks), try without -L.
test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
gl_cv_group_kmem=`echo $ac_ls_output \
| sed -ne ['s/[ ][ ]*/ /g
s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/
/ /s/.* //;p']`
])
AC_SUBST([KMEM_GROUP], [$gl_cv_group_kmem])dnl
fi
if test "x$gl_save_LIBS" = x; then
GETLOADAVG_LIBS=$LIBS
else
GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$gl_save_LIBS!!"`
fi
LIBS=$gl_save_LIBS
AC_SUBST([GETLOADAVG_LIBS])dnl
# Test whether the system declares getloadavg. Solaris has the function
# but declares it in <sys/loadavg.h>, not <stdlib.h>.
AC_CHECK_HEADERS([sys/loadavg.h])
if test $ac_cv_header_sys_loadavg_h = yes; then
HAVE_SYS_LOADAVG_H=1
else
HAVE_SYS_LOADAVG_H=0
fi
AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0],
[#if HAVE_SYS_LOADAVG_H
# include <sys/loadavg.h>
#endif
#include <stdlib.h>])
])# gl_GETLOADAVG
# gl_PREREQ_GETLOADAVG
# --------------------
# Set up the AC_LIBOBJ replacement of `getloadavg'.
AC_DEFUN([gl_PREREQ_GETLOADAVG],
[AC_LIBOBJ([getloadavg])
AC_DEFINE([C_GETLOADAVG], [1], [Define to 1 if using `getloadavg.c'.])
# Figure out what our getloadavg.c needs.
gl_have_func=no
AC_CHECK_HEADER([sys/dg_sys_info.h],
[gl_have_func=yes
AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
AC_CHECK_LIB([dgc], [dg_sys_info])])
# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
# Irix 4.0.5F has the header but not the library.
if test $gl_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \
&& test "$ac_cv_lib_kvm_kvm_open" = yes; then
gl_have_func=yes
AC_DEFINE([SVR4], [1], [Define to 1 on System V Release 4.])
fi
if test $gl_have_func = no; then
AC_CHECK_HEADER([inq_stats/cpustats.h],
[gl_have_func=yes
AC_DEFINE([UMAX], [1], [Define to 1 for Encore UMAX.])
AC_DEFINE([UMAX4_3], [1],
[Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
instead of <sys/cpustats.h>.])])
fi
if test $gl_have_func = no; then
AC_CHECK_HEADER([sys/cpustats.h],
[gl_have_func=yes; AC_DEFINE([UMAX])])
fi
if test $gl_have_func = no; then
AC_CHECK_HEADERS([mach/mach.h])
fi
AC_CHECK_HEADERS([nlist.h],
[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
[AC_DEFINE([NLIST_NAME_UNION], [1],
[Define to 1 if your `struct nlist' has an
`n_un' member. Obsolete, depend on
`HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
[@%:@include <nlist.h>])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
[[struct nlist x;
#ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
x.n_un.n_name = "";
#else
x.n_name = "";
#endif]])],
[AC_DEFINE([N_NAME_POINTER], [1],
[Define to 1 if the nlist n_name member is a pointer])])
])dnl
])# gl_PREREQ_GETLOADAVG

View file

@ -31,6 +31,7 @@ AC_DEFUN([gl_EARLY],
# Code from module dtoastr:
# Code from module extensions:
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
# Code from module getloadavg:
# Code from module getopt-gnu:
# Code from module getopt-posix:
# Code from module gettext-h:
@ -41,6 +42,7 @@ AC_DEFUN([gl_EARLY],
# Code from module multiarch:
# Code from module stdbool:
# Code from module stddef:
# Code from module stdlib:
# Code from module strftime:
# Code from module time:
# Code from module time_r:
@ -69,6 +71,9 @@ AC_DEFUN([gl_INIT],
# Code from module dtoastr:
AC_REQUIRE([gl_C99_STRTOLD])
# Code from module extensions:
# Code from module getloadavg:
gl_GETLOADAVG([$gl_source_base])
gl_STDLIB_MODULE_INDICATOR([getloadavg])
# Code from module getopt-gnu:
gl_FUNC_GETOPT_GNU
gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
@ -90,6 +95,8 @@ AC_DEFUN([gl_INIT],
AM_STDBOOL_H
# Code from module stddef:
gl_STDDEF_H
# Code from module stdlib:
gl_STDLIB_H
# Code from module strftime:
gl_FUNC_GNU_STRFTIME
# Code from module time:
@ -246,6 +253,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/dtoastr.c
lib/ftoastr.c
lib/ftoastr.h
lib/getloadavg.c
lib/getopt.c
lib/getopt.in.h
lib/getopt1.c
@ -257,6 +265,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/mktime.c
lib/stdbool.in.h
lib/stddef.in.h
lib/stdlib.in.h
lib/strftime.c
lib/strftime.h
lib/time.in.h
@ -265,6 +274,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/00gnulib.m4
m4/c-strtod.m4
m4/extensions.m4
m4/getloadavg.m4
m4/getopt.m4
m4/gnulib-common.m4
m4/include_next.m4
@ -272,6 +282,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/multiarch.m4
m4/stdbool.m4
m4/stddef_h.m4
m4/stdlib_h.m4
m4/strftime.m4
m4/time_h.m4
m4/time_r.m4

107
m4/stdlib_h.m4 Normal file
View file

@ -0,0 +1,107 @@
# stdlib_h.m4 serial 35
dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_STDLIB_H],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
gl_NEXT_HEADERS([stdlib.h])
AC_CHECK_HEADERS([random.h], [], [], [AC_INCLUDES_DEFAULT])
if test $ac_cv_header_random_h = yes; then
HAVE_RANDOM_H=1
else
HAVE_RANDOM_H=0
fi
AC_SUBST([HAVE_RANDOM_H])
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use, and which is not
dnl guaranteed by C89.
gl_WARN_ON_USE_PREPARE([[#include <stdlib.h>
#if HAVE_SYS_LOADAVG_H
# include <sys/loadavg.h>
#endif
#if HAVE_RANDOM_H
# include <random.h>
#endif
]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp
mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r
setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt
unsetenv])
])
AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
[
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
dnl Define it also as a C macro, for the benefit of the unit tests.
gl_MODULE_INDICATOR_FOR_TESTS([$1])
])
AC_DEFUN([gl_STDLIB_H_DEFAULTS],
[
GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT])
GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL])
GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME])
GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG])
GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT])
GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP])
GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS])
GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS])
GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME])
GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH])
GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL])
GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX])
GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT])
GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE__EXIT=1; AC_SUBST([HAVE__EXIT])
HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT])
HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV])
HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT])
HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV])
REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC])
REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC])
REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC])
REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
])

View file

@ -1,3 +1,13 @@
2011-02-08 Paul Eggert <eggert@cs.ucla.edu>
Import getloadavg module from gnulib.
* deps.mk (getloadavg.o): Remove; gnulib now does this.
* lisp.h (getloadavg) [!defined HAVE_GETLOADAVG]: Remove; gnulib
now does this.
* src/s/freebsd.h (HAVE_GETLOADAVG): Remove; gnulib now does this.
* src/s/netbsd.h (HAVE_GETLOADAVG): Likewise.
* config.in: Regenerate.
2011-02-07 Paul Eggert <eggert@cs.ucla.edu>
conform to C89 pointer rules

View file

@ -408,6 +408,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if using libotf. */
#undef HAVE_LIBOTF
/* Define to 1 if you have the `perfstat' library (-lperfstat). */
#undef HAVE_LIBPERFSTAT
/* Define to 1 if you have the <libpng/png.h> header file. */
#undef HAVE_LIBPNG_PNG_H
@ -558,6 +561,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the `random' function. */
#undef HAVE_RANDOM
/* Define to 1 if you have the <random.h> header file. */
#undef HAVE_RANDOM_H
/* Define to 1 if you have the `recvfrom' function. */
#undef HAVE_RECVFROM
@ -672,6 +678,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the `sysinfo' function. */
#undef HAVE_SYSINFO
/* Define to 1 if you have the <sys/loadavg.h> header file. */
#undef HAVE_SYS_LOADAVG_H
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
@ -889,6 +898,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you are using NS windowing under GNUstep. */
#undef NS_IMPL_GNUSTEP
/* Define to 1 if the nlist n_name member is a pointer */
#undef N_NAME_POINTER
/* Define if the C compiler is the linker. */
#undef ORDINARY_LINK

View file

@ -115,7 +115,6 @@ fringe.o: fringe.c dispextern.h nsgui.h frame.h window.h buffer.h termhooks.h \
ftfont.o: ftfont.c dispextern.h frame.h character.h charset.h composite.h \
font.h lisp.h $(config_h) blockinput.h atimer.h systime.h coding.h \
fontset.h ccl.h ftfont.h globals.h
getloadavg.o: getloadavg.c $(config_h)
gnutls.o: gnutls.c gnutls.h process.h ../lib/unistd.h \
lisp.h globals.h $(config_h)
gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h lisp.h $(config_h) \

View file

@ -3407,11 +3407,6 @@ EXFUN (Fclear_face_cache, 1);
EXFUN (Fx_load_color_file, 1);
extern void syms_of_xfaces (void);
#ifndef HAVE_GETLOADAVG
/* Defined in getloadavg.c */
extern int getloadavg (double *, int);
#endif
#ifdef HAVE_X_WINDOWS
/* Defined in xfns.c */
extern void syms_of_xfns (void);

View file

@ -25,8 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
#define HAVE_GETLOADAVG 1
/* This silences a few compilation warnings. */
#undef BSD_SYSTEM
#if __FreeBSD__ == 1

View file

@ -21,8 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Get most of the stuff from bsd-common. */
#include "bsd-common.h"
#define HAVE_GETLOADAVG 1
#define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
#define DEFAULT_SOUND_DEVICE "/dev/audio"
@ -43,4 +41,3 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method. */
#define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS