From: Mike Winter Date: Wed, 19 Oct 2016 19:01:23 +0000 (-0600) Subject: Check for existence of sys/param.h before using Posix constants. X-Git-Tag: v11.5.2~12^2^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=79ecfabaa4f92a6320bfd93da78a1acd4338ea21;p=sysstat Check for existence of sys/param.h before using Posix constants. Modify tapestat to use the same checks as pidstat. --- diff --git a/Makefile.in b/Makefile.in index b25c57a..efb56ce 100644 --- a/Makefile.in +++ b/Makefile.in @@ -94,6 +94,10 @@ SYSMACROS = @SYSMACROS@ ifeq ($(SYSMACROS),y) DFLAGS += -DHAVE_SYS_SYSMACROS_H endif +SYSPARAM = @SYSPARAM@ +ifeq ($(SYSPARAM),y) + DFLAGS += -DHAVE_SYS_PARAM_H +endif NLS = @NLS@ ifeq ($(NLS),y) REQUIRE_NLS = -DUSE_NLS -DPACKAGE=\"$(PACKAGE)\" -DLOCALEDIR=\"$(NLS_DIR)\" diff --git a/configure b/configure index 52fa519..46a7b10 100755 --- a/configure +++ b/configure @@ -658,6 +658,7 @@ SA_DIR sa_dir SA_LIB_DIR sa_lib_dir +SYSPARAM SYSMACROS INITD_DIR INIT_DIR @@ -4019,6 +4020,7 @@ echo . HAVE_LIBINTL_H= HAVE_LOCALE_H= HAVE_SYS_SYSMACROS_H= +HAVE_SYS_PARAM_H= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : @@ -4409,6 +4411,18 @@ fi done +for ac_header in sys/param.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_param_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_PARAM_H 1 +_ACEOF + HAVE_SYS_PARAM_H=1 +fi + +done + for ac_header in sys/stat.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/stat.h" "ac_cv_header_sys_stat_h" "$ac_includes_default" @@ -4927,6 +4941,13 @@ else fi +if test $HAVE_SYS_PARAM_H; then + SYSPARAM="y" +else + SYSPARAM="n" +fi + + # Set sadc directory if test $prefix != "NONE"; then AuxPrefix=$prefix diff --git a/configure.in b/configure.in index 72d8774..c66b000 100644 --- a/configure.in +++ b/configure.in @@ -58,6 +58,7 @@ echo . HAVE_LIBINTL_H= HAVE_LOCALE_H= HAVE_SYS_SYSMACROS_H= +HAVE_SYS_PARAM_H= AC_HEADER_STDC AC_HEADER_DIRENT AC_CHECK_HEADERS(ctype.h) @@ -70,6 +71,7 @@ AC_CHECK_HEADERS(signal.h) AC_CHECK_HEADERS(stdio.h) AC_CHECK_HEADERS(sys/file.h) AC_CHECK_HEADERS(sys/ioctl.h) +AC_CHECK_HEADERS(sys/param.h, HAVE_SYS_PARAM_H=1) AC_CHECK_HEADERS(sys/stat.h) AC_CHECK_HEADERS(sys/sysmacros.h, HAVE_SYS_SYSMACROS_H=1) @@ -209,6 +211,13 @@ else fi AC_SUBST(SYSMACROS) +if test $HAVE_SYS_PARAM_H; then + SYSPARAM="y" +else + SYSPARAM="n" +fi +AC_SUBST(SYSPARAM) + # Set sadc directory if test $prefix != "NONE"; then AuxPrefix=$prefix diff --git a/pidstat.h b/pidstat.h index c8ea057..7904552 100644 --- a/pidstat.h +++ b/pidstat.h @@ -2,13 +2,13 @@ * pidstat: Display per-process statistics. * (C) 2007-2016 by Sebastien Godard (sysstat orange.fr) */ - -#include -#undef HZ - #ifndef _PIDSTAT_H #define _PIDSTAT_H +#ifdef HAVE_SYS_PARAM_H +#include +#undef HZ +#endif #define K_SELF "SELF" @@ -18,9 +18,19 @@ #define NR_PID_PREALLOC 100 +#ifdef _POSIX_ARG_MAX #define MAX_COMM_LEN _POSIX_ARG_MAX #define MAX_CMDLINE_LEN _POSIX_ARG_MAX +#else +#define MAX_COMM_LEN 128 +#define MAX_CMDLINE_LEN 128 +#endif + +#ifdef LOGIN_NAME_MAX #define MAX_USER_LEN LOGIN_NAME_MAX +#else +#define MAX_USER_LEN 32 +#endif /* Activities */ #define P_A_CPU 0x01 diff --git a/tapestat.c b/tapestat.c index b06d1d5..a7614c1 100644 --- a/tapestat.c +++ b/tapestat.c @@ -36,8 +36,14 @@ #include #include #include + +#ifdef HAVE_SYS_PARAM_H #include #undef HZ /* sys/param.h defines HZ but needed for MAXPATHLEN */ +#endif +#ifndef MAXPATHLEN +#define MAXPATHLEN 256 +#endif #include "version.h" #include "tapestat.h"