summaryrefslogtreecommitdiff
path: root/driver_garmin.c
diff options
context:
space:
mode:
authorGreg Troxel <gdt@ir.bbn.com>2010-12-06 08:07:47 -0500
committerGreg Troxel <gdt@ir.bbn.com>2010-12-06 08:07:47 -0500
commita85f86cbf1bd2593696780ec3d2a71605a8aaefd (patch)
treef377420b118f34eb8feceb8734bfb8ca832fd9f1 /driver_garmin.c
parent09fe50e23e6bbcbeaf70cdf73d18146e650154bb (diff)
downloadgpsd-a85f86cbf1bd2593696780ec3d2a71605a8aaefd.tar.gz
Find {,sys/}endian.h via autoconf.
A recent commit introduced an unconditional include of endian.h, which is not specified by POSIX and thus nonportable. Apparently lacking a portable way to get the needed le16toh etc. functions for dealing with remote data from a le machine on the host, use autoconf to search for endian.h (on Linux) and sys/endian.h (on NetBSD). Add an explicit failure for lacking either header.
Diffstat (limited to 'driver_garmin.c')
-rw-r--r--driver_garmin.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/driver_garmin.c b/driver_garmin.c
index 5073c7ba..f8a179c0 100644
--- a/driver_garmin.c
+++ b/driver_garmin.c
@@ -80,7 +80,6 @@
#define __USE_POSIX199309 1
#include <math.h>
-#include <endian.h> /* handle endianess */
#include <string.h>
#ifndef S_SPLINT_S
@@ -89,6 +88,21 @@
#include <errno.h>
#include "gpsd_config.h"
+
+/*
+ * gpsd uses non-POSIX le16toh. Attempt to deal with this portably,
+ * failing obviously on systems that don't have support.
+ * Systems known to work: Linux, NetBSD
+ */
+#if defined(HAVE_ENDIAN_H)
+#include <endian.h>
+#else
+#if defined(HAVE_SYS_ENDIAN_H)
+#else /* HAVE_SYS_ENDIAN_H */
+#error gpsd uses non-POSIX le16toh; platform does not have {,sys/}endian.h
+#endif /* HAVE_SYS_ENDIAN_H */
+#endif /* HAVE_ENDIAN_H */
+
#if defined (HAVE_SYS_SELECT_H)
#include <sys/select.h>
#endif