aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-08-05 23:15:08 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-08-05 23:15:08 +0000
commit83a44904f7c78e291160d641ce52aff6713689bf (patch)
tree42720b1d97ceb35bd04f4202bcd2393fa7f4440e
parentd300e64bd3801d0e4ea69e807c86fd1aa2e743b2 (diff)
downloadmandoc-83a44904f7c78e291160d641ce52aff6713689bf.tar.gz
mandoc-83a44904f7c78e291160d641ce52aff6713689bf.tar.zst
mandoc-83a44904f7c78e291160d641ce52aff6713689bf.zip
The concept of endianness seems to be somewhat newfangled, so the
respective conversion functions are not yet properly standardized. Rumour has it that POSIX is working on it, though. For now, sprinkle some configuration glue.
-rw-r--r--Makefile6
-rwxr-xr-xconfigure23
-rw-r--r--configure.local.example5
-rw-r--r--dba.c10
-rw-r--r--dba_write.c8
-rw-r--r--dbm.c8
-rw-r--r--dbm_map.c8
-rw-r--r--test-be32toh.c11
-rw-r--r--test-ntohl.c7
9 files changed, 78 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 769a62a7..61c18bfd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.491 2016/08/02 11:09:46 schwarze Exp $
+# $Id: Makefile,v 1.492 2016/08/05 23:15:08 schwarze Exp $
#
# Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
# Copyright (c) 2011, 2013-2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 \
diff --git a/configure b/configure
index 64ba1a91..1aa95cc5 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: configure,v 1.49 2016/08/02 11:09:46 schwarze Exp $
+# $Id: configure,v 1.50 2016/08/05 23:15:08 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -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 98f5f1ff..7554fe30 100644
--- a/configure.local.example
+++ b/configure.local.example
@@ -1,4 +1,4 @@
-# $Id: configure.local.example,v 1.19 2016/08/02 11:09:46 schwarze Exp $
+# $Id: configure.local.example,v 1.20 2016/08/05 23:15:08 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -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
diff --git a/dba.c b/dba.c
index 426d40b3..0a1b656d 100644
--- a/dba.c
+++ b/dba.c
@@ -1,4 +1,4 @@
-/* $Id: dba.c,v 1.4 2016/08/05 21:38:11 schwarze Exp $ */
+/* $Id: dba.c,v 1.5 2016/08/05 23:15:08 schwarze Exp $ */
/*
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -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 31afa4fa..89883b87 100644
--- a/dba_write.c
+++ b/dba_write.c
@@ -1,4 +1,4 @@
-/* $Id: dba_write.c,v 1.2 2016/07/20 00:23:14 schwarze Exp $ */
+/* $Id: dba_write.c,v 1.3 2016/08/05 23:15:08 schwarze Exp $ */
/*
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -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
diff --git a/dbm.c b/dbm.c
index 4f1926cc..0c0a8b18 100644
--- a/dbm.c
+++ b/dbm.c
@@ -1,4 +1,4 @@
-/* $Id: dbm.c,v 1.2 2016/07/20 00:23:14 schwarze Exp $ */
+/* $Id: dbm.c,v 1.3 2016/08/05 23:15:08 schwarze Exp $ */
/*
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -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
diff --git a/dbm_map.c b/dbm_map.c
index 724a9f68..4ac5fa39 100644
--- a/dbm_map.c
+++ b/dbm_map.c
@@ -1,4 +1,4 @@
-/* $Id: dbm_map.c,v 1.2 2016/07/20 00:23:14 schwarze Exp $ */
+/* $Id: dbm_map.c,v 1.3 2016/08/05 23:15:08 schwarze Exp $ */
/*
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -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;
+}