diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-05-12 19:15:18 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-05-12 19:15:18 -0400 |
commit | f1f6d08d2011f1b09b66e41a29dc18020a15f072 (patch) | |
tree | f485384f509efb8a0dfdd6b97e94e26bd274bb8a | |
parent | 7c506d8dc964781e59c1b9b5d6e43fb90e83b722 (diff) | |
download | gpsd-f1f6d08d2011f1b09b66e41a29dc18020a15f072.tar.gz |
Portability cleanup for endianness.
-rw-r--r-- | driver_superstar2.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/driver_superstar2.c b/driver_superstar2.c index 5bd61791..f7e0cdfc 100644 --- a/driver_superstar2.c +++ b/driver_superstar2.c @@ -3,8 +3,17 @@ * BSD terms apply: see the file COPYING in the distribution root for details. */ #include <sys/types.h> + +#include "gpsd_config.h" + #include <stdio.h> #include <stdlib.h> +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> /* for htons(3) */ +#endif +#ifdef HAVE_ARPA_INET_H +#include <arpa/inet.h> /* for htons(3) */ +#endif /* HAVE_ARPA_INET_H */ #include <string.h> #include <math.h> #include <ctype.h> @@ -376,7 +385,7 @@ superstar2_write(struct gps_device_t *session, char *msg, size_t msglen) for (i = 0; i < (ssize_t) (msglen - 2); i++) c += (unsigned short)msg[i]; c += 0x100; - // c = htons(c); // FIX-ME: is this needed on big-endian machines? + c = htons(c); (void)memcpy(msg + (int)msg[3] + 4, &c, 2); gpsd_report(LOG_IO, "writing superstar2 control type %d len %zu:%s\n", (int)msg[1] & 0x7f, msglen, |