Use AC_CHECK_MEMBERS to check for dirent name length flds (#2923)
If `struct dirent` has `namlen` field, define `HAVE_DIRENT_NAMLEN`. If the field is instead `namelen`, define `HAVE_DIRENT_NAMELEN` (case of QNX). Use this checks in `rktio_fs.c` and simplify `platform.h`.
This commit is contained in:
parent
219bac7fe7
commit
b1b8beece5
80
racket/src/rktio/configure
vendored
80
racket/src/rktio/configure
vendored
|
@ -621,6 +621,8 @@ ac_includes_default="\
|
||||||
|
|
||||||
ac_subst_vars='LTLIBOBJS
|
ac_subst_vars='LTLIBOBJS
|
||||||
LIBOBJS
|
LIBOBJS
|
||||||
|
HAVE_DIRENT_NAMELEN
|
||||||
|
HAVE_DIRENT_NAMLEN
|
||||||
RKTIO_NO_ICONV
|
RKTIO_NO_ICONV
|
||||||
HIDE_STANDALONE
|
HIDE_STANDALONE
|
||||||
HIDE_NOT_STANDALONE
|
HIDE_NOT_STANDALONE
|
||||||
|
@ -1668,6 +1670,63 @@ $as_echo "$ac_res" >&6; }
|
||||||
|
|
||||||
} # ac_fn_c_check_header_compile
|
} # ac_fn_c_check_header_compile
|
||||||
|
|
||||||
|
# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
|
||||||
|
# ----------------------------------------------------
|
||||||
|
# Tries to find if the field MEMBER exists in type AGGR, after including
|
||||||
|
# INCLUDES, setting cache variable VAR accordingly.
|
||||||
|
ac_fn_c_check_member ()
|
||||||
|
{
|
||||||
|
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
|
||||||
|
$as_echo_n "checking for $2.$3... " >&6; }
|
||||||
|
if eval \${$4+:} false; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
$5
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
static $2 ac_aggr;
|
||||||
|
if (ac_aggr.$3)
|
||||||
|
return 0;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_compile "$LINENO"; then :
|
||||||
|
eval "$4=yes"
|
||||||
|
else
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
$5
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
static $2 ac_aggr;
|
||||||
|
if (sizeof ac_aggr.$3)
|
||||||
|
return 0;
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_compile "$LINENO"; then :
|
||||||
|
eval "$4=yes"
|
||||||
|
else
|
||||||
|
eval "$4=no"
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
fi
|
||||||
|
eval ac_res=\$$4
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
|
||||||
|
$as_echo "$ac_res" >&6; }
|
||||||
|
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
|
||||||
|
|
||||||
|
} # ac_fn_c_check_member
|
||||||
|
|
||||||
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
|
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------------------
|
||||||
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
|
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
|
||||||
|
@ -4109,6 +4168,24 @@ $as_echo "#define RKTIO_BIG_ENDIAN 1" >>confdefs.h
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Struct dirent
|
||||||
|
ac_fn_c_check_member "$LINENO" "struct dirent" "d_namelen" "ac_cv_member_struct_dirent_d_namelen" "#include <dirent.h>
|
||||||
|
"
|
||||||
|
if test "x$ac_cv_member_struct_dirent_d_namelen" = xyes; then :
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_DIRENT_NAMELEN 1" >>confdefs.h
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
ac_fn_c_check_member "$LINENO" "struct dirent" "d_namlen" "ac_cv_member_struct_dirent_d_namlen" "#include <dirent.h>
|
||||||
|
"
|
||||||
|
if test "x$ac_cv_member_struct_dirent_d_namlen" = xyes; then :
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_DIRENT_NAMLEN 1" >>confdefs.h
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo" >&5
|
||||||
$as_echo_n "checking for getaddrinfo... " >&6; }
|
$as_echo_n "checking for getaddrinfo... " >&6; }
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
@ -4528,6 +4605,9 @@ CPPFLAGS="$CPPFLAGS $PREFLAGS"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,14 @@ if test "${endianness}" = "big" ; then
|
||||||
AC_DEFINE(RKTIO_BIG_ENDIAN,1,[Big endian])
|
AC_DEFINE(RKTIO_BIG_ENDIAN,1,[Big endian])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Struct dirent
|
||||||
|
AC_CHECK_MEMBER([struct dirent.d_namelen],
|
||||||
|
[AC_DEFINE(HAVE_DIRENT_NAMELEN, 1, [struct dirent has field namelen])],,
|
||||||
|
[#include <dirent.h>])
|
||||||
|
AC_CHECK_MEMBER([struct dirent.d_namlen],
|
||||||
|
[AC_DEFINE(HAVE_DIRENT_NAMLEN, 1, [struct dirent has field namlen])],,
|
||||||
|
[#include <dirent.h>])
|
||||||
|
|
||||||
AC_MSG_CHECKING([for getaddrinfo])
|
AC_MSG_CHECKING([for getaddrinfo])
|
||||||
AC_TRY_LINK([#include <sys/types.h>
|
AC_TRY_LINK([#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
@ -426,6 +434,9 @@ AC_SUBST(HIDE_STANDALONE)
|
||||||
|
|
||||||
AC_SUBST(RKTIO_NO_ICONV)
|
AC_SUBST(RKTIO_NO_ICONV)
|
||||||
|
|
||||||
|
AC_SUBST(HAVE_DIRENT_NAMLEN)
|
||||||
|
AC_SUBST(HAVE_DIRENT_NAMELEN)
|
||||||
|
|
||||||
makefiles="Makefile"
|
makefiles="Makefile"
|
||||||
|
|
||||||
AC_OUTPUT($makefiles)
|
AC_OUTPUT($makefiles)
|
||||||
|
|
|
@ -60,3 +60,8 @@ typedef unsigned long long rktio_uint64_t;
|
||||||
|
|
||||||
/* In case iconv is not available: */
|
/* In case iconv is not available: */
|
||||||
#undef RKTIO_NO_ICONV
|
#undef RKTIO_NO_ICONV
|
||||||
|
|
||||||
|
/* Fields of struct dirent */
|
||||||
|
#undef HAVE_DIRENT_NAMLEN
|
||||||
|
#undef HAVE_DIRENT_NAMELEN
|
||||||
|
|
||||||
|
|
|
@ -1487,12 +1487,13 @@ char *rktio_directory_list_step(rktio_t *rktio, rktio_directory_list_t *dl)
|
||||||
while ((e = readdir(dl->dir))) {
|
while ((e = readdir(dl->dir))) {
|
||||||
int nlen;
|
int nlen;
|
||||||
|
|
||||||
# ifdef DIRENT_NO_NAMLEN
|
# ifdef HAVE_DIRENT_NAMLEN
|
||||||
nlen = strlen(e->d_name);
|
nlen = e->d_namlen;
|
||||||
# elif defined(__QNX__) || defined(__QNXNTO__)
|
# elif HAVE_DIRENT_NAMELEN
|
||||||
|
/* Case for QNX - which seems to define d_namelen instead */
|
||||||
nlen = e->d_namelen;
|
nlen = e->d_namelen;
|
||||||
# else
|
# else
|
||||||
nlen = e->d_namlen;
|
nlen = strlen(e->d_name);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(RKTIO_SYSTEM_UNIX) || defined(RKTIO_SYSTEM_WINDOWS)
|
# if defined(RKTIO_SYSTEM_UNIX) || defined(RKTIO_SYSTEM_WINDOWS)
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
# ifdef ECHRNG
|
# ifdef ECHRNG
|
||||||
/* Solaris */
|
/* Solaris */
|
||||||
# define DIRENT_NO_NAMLEN
|
|
||||||
# define NO_USLEEP
|
# define NO_USLEEP
|
||||||
# define USE_ULIMIT
|
# define USE_ULIMIT
|
||||||
# define SOME_FDS_ARE_NOT_SELECTABLE
|
# define SOME_FDS_ARE_NOT_SELECTABLE
|
||||||
|
@ -44,8 +43,6 @@
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
|
||||||
# define DIRENT_NO_NAMLEN
|
|
||||||
|
|
||||||
# define USE_TIMEZONE_VAR_W_DLS
|
# define USE_TIMEZONE_VAR_W_DLS
|
||||||
# define USE_TZNAME_VAR
|
# define USE_TZNAME_VAR
|
||||||
|
|
||||||
|
@ -91,8 +88,6 @@
|
||||||
#if (defined(mips) || defined(__mips)) \
|
#if (defined(mips) || defined(__mips)) \
|
||||||
&& !(defined(ultrix) || defined(__ultrix) || defined(__linux__) || defined(__OpenBSD__))
|
&& !(defined(ultrix) || defined(__ultrix) || defined(__linux__) || defined(__OpenBSD__))
|
||||||
|
|
||||||
# define DIRENT_NO_NAMLEN
|
|
||||||
|
|
||||||
# define BSTRING_INCLUDE
|
# define BSTRING_INCLUDE
|
||||||
|
|
||||||
# define NO_USLEEP
|
# define NO_USLEEP
|
||||||
|
@ -106,8 +101,6 @@
|
||||||
|
|
||||||
#if defined(ultrix) || defined(__ultrix)
|
#if defined(ultrix) || defined(__ultrix)
|
||||||
|
|
||||||
# define DIRENT_NO_NAMLEN
|
|
||||||
|
|
||||||
# define NO_USLEEP
|
# define NO_USLEEP
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -134,15 +127,6 @@
|
||||||
# define USE_TIMEZONE_VAR_W_DLS
|
# define USE_TIMEZONE_VAR_W_DLS
|
||||||
# define USE_TZNAME_VAR
|
# define USE_TZNAME_VAR
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************** x86/SCO Unix with gcc ****************/
|
|
||||||
/* Contributed by Atanas Ivanov <nasko@noac.bg> */
|
|
||||||
|
|
||||||
#if defined(_M_XENIX) && defined(_M_SYSV)
|
|
||||||
|
|
||||||
# define DIRENT_NO_NAMLEN
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************** Windows with MSVC or MinGW *****************/
|
/****************** Windows with MSVC or MinGW *****************/
|
||||||
|
@ -157,7 +141,6 @@
|
||||||
# define MKDIR_NO_MODE_FLAG
|
# define MKDIR_NO_MODE_FLAG
|
||||||
# endif
|
# endif
|
||||||
# if defined(__BORLANDC__)
|
# if defined(__BORLANDC__)
|
||||||
# define DIRENT_NO_NAMLEN
|
|
||||||
# define MKDIR_NO_MODE_FLAG
|
# define MKDIR_NO_MODE_FLAG
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -169,8 +152,6 @@
|
||||||
|
|
||||||
# define RKTIO_BINARY O_BINARY
|
# define RKTIO_BINARY O_BINARY
|
||||||
|
|
||||||
# define DIRENT_NO_NAMLEN
|
|
||||||
|
|
||||||
# define SIGCHILD_DOESNT_INTERRUPT_SELECT
|
# define SIGCHILD_DOESNT_INTERRUPT_SELECT
|
||||||
|
|
||||||
# define CANT_SET_SOCKET_BUFSIZE
|
# define CANT_SET_SOCKET_BUFSIZE
|
||||||
|
@ -275,10 +256,6 @@
|
||||||
/* NO_READDIR means that there is no opendir() and readdir() for
|
/* NO_READDIR means that there is no opendir() and readdir() for
|
||||||
implementing directory-list. */
|
implementing directory-list. */
|
||||||
|
|
||||||
/* DIRENT_NO_NAMLEN specifies that dirent entries do not have a
|
|
||||||
d_namlen field; this is used only when NO_READDIR is not
|
|
||||||
specified. */
|
|
||||||
|
|
||||||
/* MKDIR_NO_MODE_FLAG specifies that mkdir() takes only one argument,
|
/* MKDIR_NO_MODE_FLAG specifies that mkdir() takes only one argument,
|
||||||
instead of a directory name and mode flags. */
|
instead of a directory name and mode flags. */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user