Detect undefined PATH_MAX

POSIX does not require PATH_MAX be defined when there is not actual
limit to its value.  This affects HURD based systems.  Work around
this by defining PATH_MAX to 4096 (as on Linux) when this is not
defined.

Also, clean up inclusions of limits.h and remove autoconf check for
this header as we do not use macro shields for its inclusion anyway.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Allan McRae 2010-12-18 04:48:09 +10:00 committed by Dan McGee
parent fcc09bd7e3
commit 81dd9d3ebc
11 changed files with 25 additions and 5 deletions

View File

@ -125,3 +125,19 @@ extern int getmntinfo (struct statfs **, int);
[Defined as the filesystem stats type ('statvfs' or 'statfs')])
])
dnl Checks for PATH_MAX and defines it if not present
AC_DEFUN([PATH_MAX_DEFINED],
[AC_CACHE_CHECK([PATH_MAX defined], path_max_cv_defined,
[AC_EGREP_CPP(yes, [[
#include <limits.h>
#if defined(PATH_MAX)
yes
#endif
]],
[path_max_cv_defined=yes],
[path_max_cv_defined=no])]
)
if test $path_max_cv_defined = no; then
AC_DEFINE([PATH_MAX], 4096, [Define if PATH_MAX is undefined by limits.h.])
fi
])

View File

@ -172,7 +172,7 @@ AS_IF([test "x$with_fetch" != "xno"],
AM_CONDITIONAL([HAVE_LIBFETCH], [test "x$ac_cv_lib_fetch_fetchParseURL" = "xyes"])
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h mntent.h string.h strings.h \
AC_CHECK_HEADERS([fcntl.h glob.h libintl.h locale.h mntent.h string.h strings.h \
sys/ioctl.h sys/mount.h sys/param.h sys/statvfs.h sys/syslimits.h \
sys/time.h sys/types.h sys/ucred.h syslog.h wchar.h])
@ -185,6 +185,7 @@ AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_TYPE_UID_T
AC_STRUCT_DIRENT_D_TYPE
PATH_MAX_DEFINED
# Checks for library functions.
AC_FUNC_FORK

View File

@ -23,6 +23,7 @@
#include <errno.h>
#include <ctype.h>
#include <locale.h>
#include <limits.h>
/* libarchive */
#include <archive.h>

View File

@ -23,7 +23,6 @@
#define _ALPM_DB_H
#include "alpm.h"
#include <limits.h>
#include <time.h>
/* libarchive */

View File

@ -29,7 +29,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <limits.h>
/* the following two are needed on BSD for libfetch */
#if defined(HAVE_SYS_SYSLIMITS_H)
#include <sys/syslimits.h> /* PATH_MAX */

View File

@ -22,7 +22,6 @@
/* TODO: needed for the libfetch stuff, unfortunately- we should kill it */
#include <stdio.h>
#include <limits.h>
/* the following two are needed on BSD for libfetch */
#if defined(HAVE_SYS_SYSLIMITS_H)
#include <sys/syslimits.h> /* PATH_MAX */

View File

@ -25,7 +25,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>

View File

@ -31,6 +31,7 @@
#include <stdint.h> /* intmax_t */
#include <unistd.h>
#include <time.h>
#include <limits.h>
/* libalpm */
#include "sync.h"

View File

@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <errno.h>
#include <limits.h>
/* libalpm */
#include "trans.h"

View File

@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>