diff options
-rw-r--r-- | Makefile | 4 | ||||
-rwxr-xr-x | configure | 21 | ||||
-rw-r--r-- | configure.local.example | 3 | ||||
-rw-r--r-- | dba.c | 8 | ||||
-rw-r--r-- | dba_write.c | 6 | ||||
-rw-r--r-- | dbm.c | 6 | ||||
-rw-r--r-- | dbm_map.c | 6 | ||||
-rw-r--r-- | test-be32toh.c | 11 | ||||
-rw-r--r-- | test-ntohl.c | 7 |
9 files changed, 71 insertions, 1 deletions
@@ -19,7 +19,8 @@ VERSION = 1.14.0 # === LIST OF FILES ==================================================== -TESTSRCS = test-dirent-namlen.c \ +TESTSRCS = test-be32toh.c \ + test-dirent-namlen.c \ test-EFTYPE.c \ test-err.c \ test-fts.c \ @@ -28,6 +29,7 @@ TESTSRCS = test-dirent-namlen.c \ test-isblank.c \ test-mkdtemp.c \ test-nanosleep.c \ + test-ntohl.c \ test-ohash.c \ test-PATH_MAX.c \ test-pledge.c \ @@ -50,6 +50,7 @@ BUILD_CGI=0 HAVE_DIRENT_NAMLEN= HAVE_EFTYPE= +HAVE_ENDIAN= HAVE_ERR= HAVE_FTS= HAVE_GETLINE= @@ -57,6 +58,7 @@ HAVE_GETSUBOPT= HAVE_ISBLANK= HAVE_MKDTEMP= HAVE_NANOSLEEP= +HAVE_NTOHL= HAVE_OHASH= HAVE_PATH_MAX= HAVE_PLEDGE= @@ -72,6 +74,7 @@ HAVE_STRLCPY= HAVE_STRPTIME= HAVE_STRSEP= HAVE_STRTONUM= +HAVE_SYS_ENDIAN= HAVE_VASPRINTF= HAVE_WCHAR= @@ -197,6 +200,8 @@ get_locale() { # --- library functions --- runtest dirent-namlen DIRENT_NAMLEN || true +runtest be32toh ENDIAN || true +runtest be32toh SYS_ENDIAN -DSYS_ENDIAN || true runtest EFTYPE EFTYPE || true runtest err ERR || true runtest fts FTS || true @@ -204,6 +209,7 @@ runtest getline GETLINE || true runtest getsubopt GETSUBOPT || true runtest isblank ISBLANK || true runtest mkdtemp MKDTEMP || true +runtest ntohl NTOHL || true runtest PATH_MAX PATH_MAX || true runtest pledge PLEDGE || true runtest sandbox_init SANDBOX_INIT || true @@ -220,6 +226,14 @@ runtest strsep STRSEP || true runtest strtonum STRTONUM || true runtest vasprintf VASPRINTF || true +if [ ${HAVE_ENDIAN} -eq 0 -a \ + ${HAVE_SYS_ENDIAN} -eq 0 -a \ + ${HAVE_NTOHL} -eq 0 ]; then + echo "FATAL: no endian conversion functions found" 1>&2 + echo "FATAL: no endian conversion functions found" 1>&3 + exit 1 +fi + # --- wide character and locale support --- if get_locale; then runtest wchar WCHAR -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || true @@ -296,15 +310,21 @@ echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\"" [ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\"" [ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL" [ ${HAVE_PATH_MAX} -eq 0 ] && echo "#define PATH_MAX 4096" +if [ ${HAVE_ENDIAN} -eq 0 -a ${HAVE_SYS_ENDIAN} -eq 0 ]; then + echo "#define be32toh ntohl" + echo "#define htobe32 htonl" +fi cat << __HEREDOC__ #define HAVE_DIRENT_NAMLEN ${HAVE_DIRENT_NAMLEN} +#define HAVE_ENDIAN ${HAVE_ENDIAN} #define HAVE_ERR ${HAVE_ERR} #define HAVE_FTS ${HAVE_FTS} #define HAVE_GETLINE ${HAVE_GETLINE} #define HAVE_GETSUBOPT ${HAVE_GETSUBOPT} #define HAVE_ISBLANK ${HAVE_ISBLANK} #define HAVE_MKDTEMP ${HAVE_MKDTEMP} +#define HAVE_NTOHL ${HAVE_NTOHL} #define HAVE_PLEDGE ${HAVE_PLEDGE} #define HAVE_PROGNAME ${HAVE_PROGNAME} #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY} @@ -318,6 +338,7 @@ cat << __HEREDOC__ #define HAVE_STRPTIME ${HAVE_STRPTIME} #define HAVE_STRSEP ${HAVE_STRSEP} #define HAVE_STRTONUM ${HAVE_STRTONUM} +#define HAVE_SYS_ENDIAN ${HAVE_SYS_ENDIAN} #define HAVE_VASPRINTF ${HAVE_VASPRINTF} #define HAVE_WCHAR ${HAVE_WCHAR} #define HAVE_OHASH ${HAVE_OHASH} diff --git a/configure.local.example b/configure.local.example index d9652f1d..1c68e4b5 100644 --- a/configure.local.example +++ b/configure.local.example @@ -227,6 +227,7 @@ CFLAGS="-g" # be regarded as successful). HAVE_DIRENT_NAMLEN=0 +HAVE_ENDIAN=0 HAVE_EFTYPE=0 HAVE_ERR=0 HAVE_FTS=0 @@ -234,6 +235,7 @@ HAVE_GETLINE=0 HAVE_GETSUBOPT=0 HAVE_ISBLANK=0 HAVE_MKDTEMP=0 +HAVE_NTOHL=0 HAVE_OHASH=0 HAVE_PATH_MAX=0 HAVE_PLEDGE=0 @@ -248,5 +250,6 @@ HAVE_STRLCPY=0 HAVE_STRPTIME=0 HAVE_STRSEP=0 HAVE_STRTONUM=0 +HAVE_SYS_ENDIAN=0 HAVE_VASPRINTF=0 HAVE_WCHAR=0 @@ -17,8 +17,16 @@ * Allocation-based version of the mandoc database, for read-write access. * The interface is defined in "dba.h". */ +#include "config.h" + #include <sys/types.h> +#if HAVE_ENDIAN #include <endian.h> +#elif HAVE_SYS_ENDIAN +#include <sys/endian.h> +#elif HAVE_NTOHL +#include <arpa/inet.h> +#endif #include <errno.h> #include <stdint.h> #include <stdlib.h> diff --git a/dba_write.c b/dba_write.c index 8b911f90..80574518 100644 --- a/dba_write.c +++ b/dba_write.c @@ -20,7 +20,13 @@ #include "config.h" #include <assert.h> +#if HAVE_ENDIAN #include <endian.h> +#elif HAVE_SYS_ENDIAN +#include <sys/endian.h> +#elif HAVE_NTOHL +#include <arpa/inet.h> +#endif #if HAVE_ERR #include <err.h> #endif @@ -20,7 +20,13 @@ #include "config.h" #include <assert.h> +#if HAVE_ENDIAN #include <endian.h> +#elif HAVE_SYS_ENDIAN +#include <sys/endian.h> +#elif HAVE_NTOHL +#include <arpa/inet.h> +#endif #if HAVE_ERR #include <err.h> #endif @@ -24,7 +24,13 @@ #include <sys/stat.h> #include <sys/types.h> +#if HAVE_ENDIAN #include <endian.h> +#elif HAVE_SYS_ENDIAN +#include <sys/endian.h> +#elif HAVE_NTOHL +#include <arpa/inet.h> +#endif #if HAVE_ERR #include <err.h> #endif diff --git a/test-be32toh.c b/test-be32toh.c new file mode 100644 index 00000000..471e85ea --- /dev/null +++ b/test-be32toh.c @@ -0,0 +1,11 @@ +#ifdef SYS_ENDIAN +#include <sys/endian.h> +#else +#include <endian.h> +#endif + +int +main(void) +{ + return htobe32(be32toh(0x3a7d0cdb)) != 0x3a7d0cdb; +} diff --git a/test-ntohl.c b/test-ntohl.c new file mode 100644 index 00000000..52dcc256 --- /dev/null +++ b/test-ntohl.c @@ -0,0 +1,7 @@ +#include <arpa/inet.h> + +int +main(void) +{ + return htonl(ntohl(0x3a7d0cdb)) != 0x3a7d0cdb; +} |