* mdocml: The concept of endianness seems to be somewhat newfangled, so
@ 2016-08-05 23:15 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2016-08-05 23:15 UTC (permalink / raw)
To: source
Log Message:
-----------
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.
Modified Files:
--------------
mdocml:
Makefile
configure
configure.local.example
dba.c
dba_write.c
dbm.c
dbm_map.c
Added Files:
-----------
mdocml:
test-be32toh.c
test-ntohl.c
Revision Data
-------------
Index: dbm.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/dbm.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ldbm.c -Ldbm.c -u -p -r1.2 -r1.3
--- dbm.c
+++ dbm.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
Index: configure.local.example
===================================================================
RCS file: /home/cvs/mdocml/mdocml/configure.local.example,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lconfigure.local.example -Lconfigure.local.example -u -p -r1.19 -r1.20
--- configure.local.example
+++ 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
--- /dev/null
+++ 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;
+}
--- /dev/null
+++ test-ntohl.c
@@ -0,0 +1,7 @@
+#include <arpa/inet.h>
+
+int
+main(void)
+{
+ return htonl(ntohl(0x3a7d0cdb)) != 0x3a7d0cdb;
+}
Index: dbm_map.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/dbm_map.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ldbm_map.c -Ldbm_map.c -u -p -r1.2 -r1.3
--- dbm_map.c
+++ dbm_map.c
@@ -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
Index: Makefile
===================================================================
RCS file: /home/cvs/mdocml/mdocml/Makefile,v
retrieving revision 1.491
retrieving revision 1.492
diff -LMakefile -LMakefile -u -p -r1.491 -r1.492
--- Makefile
+++ Makefile
@@ -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 \
Index: configure
===================================================================
RCS file: /home/cvs/mdocml/mdocml/configure,v
retrieving revision 1.49
retrieving revision 1.50
diff -Lconfigure -Lconfigure -u -p -r1.49 -r1.50
--- configure
+++ configure
@@ -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 \"${MANPAT
[ -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}
Index: dba_write.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/dba_write.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ldba_write.c -Ldba_write.c -u -p -r1.2 -r1.3
--- dba_write.c
+++ 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
Index: dba.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/dba.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -Ldba.c -Ldba.c -u -p -r1.4 -r1.5
--- dba.c
+++ dba.c
@@ -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>
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-05 23:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-05 23:15 mdocml: The concept of endianness seems to be somewhat newfangled, so schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).