[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] [PATCH 1/6] Reverts most C99-related changes.
From: |
Gary E. Miller |
Subject: |
Re: [gpsd-dev] [PATCH 1/6] Reverts most C99-related changes. |
Date: |
Mon, 5 Sep 2016 18:24:03 -0700 |
Yo Fred!
Could you change this so it still forces C99 and POSIX 2001 on Linux?
On Mon, 5 Sep 2016 18:09:23 -0700
Fred Wright <address@hidden> wrote:
> The C99 compatibility effort was ultimately put aside for now,
> but not without leaving some changes that broke some builds,
> some changes that violated the rule about never manipulating
> the macros beginning with double underscores, and some changes
> that could be done better. This change reverts most of the
> C99 changes, keeping only the ones that are appropriate as is.
> A few more will be reintroduced in modified or redone form.
>
> List of relevant commits (reverse chronological):
> -------------------------------------------------
> N d8eae2c for INADDR_LOOPBACK() FreeBSD wants __BSD_VISIBLE
> Y bc4a4a9 Comment why time.h needed
> N a7729b6 for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999
> Y 8066c57 Well, duh, You can't change a constant!
> N a1acc3a Fixups for NetBSD
> N 1b6571a __DARWIN_C_LEVEL and _DARWIN_C_SOURCE to silence some
> warnings. Y bbbc307 OS X has no sys/sysmacros.h, so hide it.
> Y 1d29f15 OS X incorrectly complains about an uninitializzed variable.
> N 0868e9c If you specify XOPEN version, you must specify POSIX
> version. N 8bf402d Stop forcing C99 and POSIX 2001.
> N e24c36e Enforce POSIX 2001 by default.
> N dbf849d Fix for C99 and POSIX 2001.
> N ff398eb In POSIX 2001, getsid() needs _XOPEN_SOURCE >= 500
> N bdc2109 Force C99 with -D_ISOC99_SOURCE
> N 40cf257 I can not figure out why this file will not C99. Punt.
> N 558586b putenv() needs _XOPEN_SOURCE
> Y 2a72002 uint to unsigned int. uint gone in C99.
> N 31ece69 cfmakeraw() needs _DEFAULT_SOURCE
> N 87b7df3 sys/ipc.h needs _XOPEN_SOURCE
> N d01483e daemon() needs _DEFAULT_SOURCE
> N d5b3f16 daemon() needs _DEFAULT_SOURCE
> P 4c8a74f strsep() and daemon() needs _DEFAULT_SOURCE, replace bcopy()
> R 0260b7d alloca() needs alloca.h
> P 6692860 bzero() is gone in POSIX 2008. Use memset()
> N 8f8f6ed isascii() needs _XOPEN_SOURCE 500
> N 67f0cb9 nice() needs _XOPEN_SOURCE 500, setgroups(), daemon() needs
> _DEFAULT_SOURCE N 5e844a4 nice() needs _XOPEN_SOURCE 500 defined
> N cca1925 C99 requires _XOPEN_SOURCE 500 for M_LN2
> N aca3818 sys/ipc.h needs XOPEN_SOURCE 500
> Y 9a4bd35 With C99, macro() needs sys/sysmacros.h
> N b4715a2 Fix a warning when C99 specified.
> Y e9fdd7e More uint to unsigned int.
> Y 51500bb uint was rmoved in C99. If gpsd enforce C99, then uint
> must go. R e67e411 usleep() is removed from POSIX-2008. Replace with
> nanosleep() N 1721d7c Prepare to insis on C99 and POSIX 2001.
>
> Legend:
> -------
> Y - Kept as is
> N - Dropped
> P - To be partially reintroduced
> R - To be redone
>
> TESTED:
> Ran "scons build-all check" successfully on:
> OSX: 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
> Linux: Ubuntu 14.04.1, CentOS 7
> FreeBSD 10.1
> OpenBSD 5.6
> NetBSD 6.1.5
> ---
> SConstruct | 6 ------
> contrib/ashctl.c | 7 +------
> contrib/binlog.c | 8 ++------
> contrib/binreplay.c | 6 +-----
> contrib/motosend.c | 13 ++++---------
> driver_ais.c | 6 ------
> driver_garmin.c | 7 +------
> driver_garmin_txt.c | 4 ++--
> driver_nmea0183.c | 4 ----
> driver_nmea2000.c | 6 +-----
> driver_sirf.c | 2 +-
> driver_tsip.c | 7 -------
> driver_zodiac.c | 7 -------
> drivers.c | 19 ++-----------------
> gps2udp.c | 5 +----
> gpsctl.c | 20 +-------------------
> gpsd.c | 22 +---------------------
> gpsd_json.c | 10 ----------
> gpsmon.c | 18 ++----------------
> gpspacket.c | 4 ----
> gpspipe.c | 8 +-------
> gpxlogger.c | 4 ----
> lcdgps.c | 3 ---
> libgps_core.c | 4 ----
> libgps_shm.c | 4 ----
> libgpsd_core.c | 13 -------------
> monitor_nmea0183.c | 4 ----
> netlib.c | 4 ----
> ntpshmmon.c | 13 ++-----------
> ntpshmwrite.c | 3 ---
> serial.c | 10 +---------
> shmexport.c | 4 ----
> timebase.c | 3 ---
> timehint.c | 7 -------
> 34 files changed, 24 insertions(+), 241 deletions(-)
>
> diff --git a/SConstruct b/SConstruct
> index 5996513..a5be834 100644
> --- a/SConstruct
> +++ b/SConstruct
> @@ -379,12 +379,6 @@ if 'CCFLAGS' not in os.environ:
> else:
> env.Append(CCFLAGS=['-O2'])
>
> -# We are C99, tell the world
> -#env.Append(CFLAGS=['-D_ISOC99_SOURCE'])
> -
> -# We are POSIX 2001, tell the world
> -#env.Append(CFLAGS=['-D_POSIX_C_SOURCE=200112L'])
> -
> # Get a slight speedup by not doing automatic RCS and SCCS fetches.
> env.SourceCode('.', None)
>
> diff --git a/contrib/ashctl.c b/contrib/ashctl.c
> index f1cfdcf..fdf04bf 100644
> --- a/contrib/ashctl.c
> +++ b/contrib/ashctl.c
> @@ -157,7 +157,6 @@ static int nmea_send(int fd, const char *fmt, ...
> ) size_t status;
> char buf[BUFSIZ];
> va_list ap;
> - struct timespec delay;
>
> va_start(ap, fmt) ;
> (void)vsnprintf(buf, sizeof(buf)-5, fmt, ap);
> @@ -168,11 +167,7 @@ static int nmea_send(int fd, const char
> *fmt, ... ) tcflush(fd, TCIOFLUSH);
> status = (size_t)write(fd, buf, strlen(buf));
> tcdrain(fd);
> - /* wait 100,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 100000000L;
> - nanosleep(&delay, NULL);
> -
> + usleep(100000);
> if (status == strlen(buf)) {
> return (int)status;
> } else {
> diff --git a/contrib/binlog.c b/contrib/binlog.c
> index 0e2c7cf..8e5e8d9 100644
> --- a/contrib/binlog.c
> +++ b/contrib/binlog.c
> @@ -19,7 +19,6 @@ int main(int argc, char **argv) {
> int speed, n, ifd, ofd;
> struct termios term;
> char buf[BUFSIZ];
> - struct timespec delay;
>
> if (argc != 4){
> fprintf(stderr, "usage: binlog <speed> <port>
> <logfile>\n"); @@ -62,11 +61,8 @@ int main(int argc, char **argv) {
> int l = read(ifd, buf, BUFSIZ);
> if (l > 0)
> assert(write(ofd, buf, l) > 0);
> - /* wait 1,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 1000000L;
> - nanosleep(&delay, NULL);
> - memset(buf, 0, BUFSIZ);
> + usleep(1000);
> + bzero(buf, BUFSIZ);
> spinner( n++ );
> }
> /* NOTREACHED */
> diff --git a/contrib/binreplay.c b/contrib/binreplay.c
> index 8b68bc1..36389e0 100644
> --- a/contrib/binreplay.c
> +++ b/contrib/binreplay.c
> @@ -31,7 +31,6 @@ int main( int argc, char **argv){
> char *buf, tn[32];
> int ifd, ofd, sfd;
> int dflag = 0, c, sleeptime, len, speed = 0;
> - struct timespec delay;
>
> while((c = getopt(argc, argv, "d:r:s:")) != -1) {
> switch(c){
> @@ -118,10 +117,7 @@ int main( int argc, char **argv){
> tcflush(sfd, TCIFLUSH);
> }
> spinner( len );
> - /* wait sleeptime Sec */
> - delay.tv_sec = (time_t)(sleeptime / 1000000000L);
> - delay.tv_nsec = sleeptime % 1000000000L;
> - nanosleep(&delay, NULL);
> + usleep(sleeptime);
> }
>
> munmap(buf, sb.st_size);
> diff --git a/contrib/motosend.c b/contrib/motosend.c
> index bd08b5f..3073158 100644
> --- a/contrib/motosend.c
> +++ b/contrib/motosend.c
> @@ -31,7 +31,6 @@ int main(int argc, char **argv) {
> struct termios term;
> char buf[BSIZ];
> time_t s, t;
> - struct timespec delay;
>
> if (argc != 5){
> fprintf(stderr, "usage: motosend <speed> <port>
> msgtype moto-body-hex\n"); @@ -83,12 +82,8 @@ int main(int argc, char
> **argv) { tcflush(fd, TCIOFLUSH);
> t = 0; n = 0;
> while (1){
> - /* wait 1,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 1000000L;
> - nanosleep(&delay, NULL);
> -
> - memset(buf, 0, BSIZ);
> + usleep(1000);
> + bzero(buf, BSIZ);
> if ((l = read(fd, buf, BSIZ)) == -1)
> if (!(EINTR == errno || EAGAIN == errno))
> err(1, "read");
> @@ -126,7 +121,7 @@ static int moto_send(int fd, char *type, char
> *body ) { if ((buf = malloc(l+7)) == NULL)
> return -1;
>
> - memset(buf, 0, l+7);
> + bzero(buf, l+7);
> buf[0] = '@'; buf[1] = '@';
> buf[2] = type[0]; buf[3] = type[1];
>
> @@ -179,7 +174,7 @@ int gpsd_hexpack(char *src, char *dst, int len)
> if ((l < 1) || (l > len))
> return -1;
>
> - memset(dst, 0, len);
> + bzero(dst, len);
> for (i = 0; i < l; i++) {
> int k;
> if ((k = hex2bin(src+i*2)) != -1)
> diff --git a/driver_ais.c b/driver_ais.c
> index f7c5a79..d79e457 100644
> --- a/driver_ais.c
> +++ b/driver_ais.c
> @@ -15,12 +15,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* isascii() needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -/* strlcpy() needs _DARWIN_C_SOURCE */
> -#define _DARWIN_C_SOURCE
> -
> #include <stdlib.h>
> #include <string.h>
> #include <ctype.h>
> diff --git a/driver_garmin.c b/driver_garmin.c
> index 4ecb960..c80b842 100644
> --- a/driver_garmin.c
> +++ b/driver_garmin.c
> @@ -1027,7 +1027,6 @@ gps_mask_t garmin_ser_parse(struct gps_device_t
> *session) unsigned char pkt_len = 0;
> unsigned char chksum = 0;
> gps_mask_t mask = 0;
> - struct timespec delay;
>
> gpsd_log(&session->context->errout, LOG_RAW, "Garmin:
> garmin_ser_parse()\n"); if (6 > len) {
> @@ -1159,11 +1158,7 @@ gps_mask_t garmin_ser_parse(struct
> gps_device_t *session)
> // sending ACK too soon might hang the session
> // so send ACK last, after a pause
> - /* wait 300 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 300000L;
> - nanosleep(&delay, NULL);
> -
> + (void)usleep(300);
> Send_ACK();
> gpsd_log(&session->context->errout, LOG_DATA,
> "Garmin: garmin_ser_parse( )\n");
> diff --git a/driver_garmin_txt.c b/driver_garmin_txt.c
> index c14c516..8631ee3 100644
> --- a/driver_garmin_txt.c
> +++ b/driver_garmin_txt.c
> @@ -155,7 +155,7 @@ static int gar_decode(const struct gps_context_t
> *context, return -1;
> }
>
> - memset(buf, 0, (int)sizeof(buf));
> + bzero(buf, (int)sizeof(buf));
> (void)strlcpy(buf, data, length);
> gpsd_log(&context->errout, LOG_RAW + 2, "Decoded string: %s\n",
> buf);
> @@ -223,7 +223,7 @@ static int gar_int_decode(const struct
> gps_context_t *context, return -1;
> }
>
> - memset(buf, 0, (int)sizeof(buf));
> + bzero(buf, (int)sizeof(buf));
> (void)strlcpy(buf, data, length);
> gpsd_log(&context->errout, LOG_RAW + 2, "Decoded string: %s\n",
> buf);
> diff --git a/driver_nmea0183.c b/driver_nmea0183.c
> index 337e90c..58c57ec 100644
> --- a/driver_nmea0183.c
> +++ b/driver_nmea0183.c
> @@ -2,10 +2,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999 */
> -#define __ISO_C_VISIBLE 1999
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdbool.h>
> diff --git a/driver_nmea2000.c b/driver_nmea2000.c
> index 47b051b..c5c6a8b 100644
> --- a/driver_nmea2000.c
> +++ b/driver_nmea2000.c
> @@ -4,10 +4,6 @@
> * This file is Copyright (c) 2012 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* need this for strnlen() and struct ifreq */
> -#define _DEFAULT_SOURCE
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdbool.h>
> @@ -19,8 +15,8 @@
> #include <fcntl.h>
> #include <unistd.h>
> #include <sys/socket.h>
> -#include <sys/ioctl.h>
> #include <net/if.h>
> +#include <sys/ioctl.h>
>
> #include "gpsd.h"
> #include "libgps.h"
> diff --git a/driver_sirf.c b/driver_sirf.c
> index deec232..a377d7f 100644
> --- a/driver_sirf.c
> +++ b/driver_sirf.c
> @@ -415,7 +415,7 @@ static gps_mask_t sirf_msg_debug(struct
> gps_device_t *device, char msgbuf[MAX_PACKET_LENGTH * 3 + 2];
> int i;
>
> - memset(msgbuf, 0, (int)sizeof(msgbuf));
> + bzero(msgbuf, (int)sizeof(msgbuf));
>
> if (0xe1 == buf[0]) { /* Development statistics messages
> */ for (i = 2; i < (int)len; i++)
> diff --git a/driver_tsip.c b/driver_tsip.c
> index 34a53e8..5e09433 100644
> --- a/driver_tsip.c
> +++ b/driver_tsip.c
> @@ -12,13 +12,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* if we insist on C99, then we need this to get M_LN2 from math.h */
> -/* 500 mean X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -/* round() needs _POSIX_C_SOURCE >= 200112L */
> -#define _POSIX_C_SOURCE 200112L
> -
> #include <sys/time.h> /* for select() */
> #include <string.h>
> #include <stdio.h>
> diff --git a/driver_zodiac.c b/driver_zodiac.c
> index e1ce407..65f76f0 100644
> --- a/driver_zodiac.c
> +++ b/driver_zodiac.c
> @@ -9,13 +9,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* if we insisnt on C99, then we need this to get M_LN2 from math.h
> */ -/* 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -/* round() needs _POSIX_C_SOURCE >= 200112L */
> -#define _POSIX_C_SOURCE 200112L
> -
> #include <stdio.h>
> #include <stdbool.h>
> #include <string.h>
> diff --git a/drivers.c b/drivers.c
> index 98a2485..85b12a9 100644
> --- a/drivers.c
> +++ b/drivers.c
> @@ -2,10 +2,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999 */
> -#define __ISO_C_VISIBLE 1999
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdbool.h>
> @@ -291,15 +287,10 @@ const struct gps_type_t driver_nmea0183 = {
> static void garmin_mode_switch(struct gps_device_t *session, int
> mode) /* only does anything in one direction, going to Garmin binary
> driver */ {
> - struct timespec delay;
> -
> if (mode == MODE_BINARY) {
> (void)nmea_send(session, "$PGRMC1,1,2,1,,,,2,W,N");
> (void)nmea_send(session, "$PGRMI,,,,,,,R");
> - /* wait 333 uSec, standard Garmin settling time */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 333000L;
> - nanosleep(&delay, NULL);
> + (void)usleep(333); /* standard Garmin settling time */
> }
> }
> #endif /* RECONFIGURE_ENABLE */
> @@ -612,17 +603,11 @@ static const struct gps_type_t driver_tripmate
> = {
> static void earthmate_event_hook(struct gps_device_t *session,
> event_t event) {
> - struct timespec delay;
> -
> if (session->context->readonly)
> return;
> if (event == event_triggermatch) {
> (void)gpsd_write(session, "EARTHA\r\n", 8);
> - /* wait 10,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 10000000L;
> - nanosleep(&delay, NULL);
> -
> + (void)usleep(10000);
> (void)gpsd_switch_driver(session, "Zodiac");
> }
> }
> diff --git a/gps2udp.c b/gps2udp.c
> index b07eaa1..8345079 100644
> --- a/gps2udp.c
> +++ b/gps2udp.c
> @@ -12,9 +12,6 @@
> *
> */
>
> -/* strsep() and daemon() needs _DEFAULT_SOURCE */
> -#define _DEFAULT_SOURCE
> -
> #include <time.h>
> #include "gpsd_config.h"
>
> @@ -168,7 +165,7 @@ static int open_udp(char **hostport)
> return (-1);
> }
>
> - memcpy( &remote[channel].sin_addr, hp->h_addr, hp->h_length);
> + bcopy((char *)hp->h_addr, (char *)&remote[channel].sin_addr,
> hp->h_length); remote[channel].sin_port = htons((in_port_t)portnum);
> }
> return (0);
> diff --git a/gpsctl.c b/gpsctl.c
> index 6f392f9..e3835bd 100644
> --- a/gpsctl.c
> +++ b/gpsctl.c
> @@ -4,17 +4,6 @@
> * BSD terms apply: see the file COPYING in the distribution root
> for details. *
> */
> -
> -/* sys/ipc.h needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -/* pselect() needs _POSIX_C_SOURCE >= 200112L */
> -#define _POSIX_C_SOURCE 200112L
> -/* strlcpy() needs _DARWIN_C_SOURCE */
> -#define _DARWIN_C_SOURCE
> -
> -/* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999 */
> -#define __ISO_C_VISIBLE 1999
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdbool.h>
> @@ -54,18 +43,11 @@ static bool hunting = true;
> static void settle(struct gps_device_t *session)
> /* allow the device to settle after a control operation */
> {
> - struct timespec delay;
> -
> /*
> * See the 'deep black magic' comment in serial.c:set_serial().
> */
> (void)tcdrain(session->gpsdata.gps_fd);
> -
> - /* wait 50,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 50000000L;
> - nanosleep(&delay, NULL);
> -
> + (void)usleep(50000);
> (void)tcdrain(session->gpsdata.gps_fd);
> }
> #endif /* defined(RECONFIGURE_ENABLE) || defined(CONTROLSEND_ENABLE)
> */ diff --git a/gpsd.c b/gpsd.c
> index 8fa0b0e..726cba4 100644
> --- a/gpsd.c
> +++ b/gpsd.c
> @@ -6,20 +6,6 @@
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
>
> -/* nice() needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -/* setgroups() and daemon() needs _DEFAULT_SOURCE */
> -#define _DEFAULT_SOURCE
> -/* vsnprintf() needs __DARWIN_C_LEVEL >= 200112L */
> -#define __DARWIN_C_LEVEL 200112L
> -/* strlcpy() needs _DARWIN_C_SOURCE */
> -#define _DARWIN_C_SOURCE
> -
> -/* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999 */
> -#define __ISO_C_VISIBLE 1999
> -/* for INADDR_LOOPBACK() FreeBSD wants __BSD_VISIBLE */
> -#define __BSD_VISIBLE
> -
> #include <sys/stat.h>
> #include <sys/types.h>
> #include <sys/time.h> /* for select() */
> @@ -1014,7 +1000,6 @@ static void set_serial(struct gps_device_t
> *device, unsigned int stopbits = device->gpsdata.dev.stopbits;
> char parity = device->gpsdata.dev.parity;
> int wordsize = 8;
> - struct timespec delay;
>
> #ifndef __clang_analyzer__
> while (isspace((unsigned char) *modestring))
> @@ -1057,12 +1042,7 @@ static void set_serial(struct gps_device_t
> *device,
> * across any given type of UART.
> */
> (void)tcdrain(device->gpsdata.gps_fd);
> -
> - /* wait 50,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 50000000L;
> - nanosleep(&delay, NULL);
> -
> + (void)usleep(50000);
> gpsd_set_speed(device, speed, parity, stopbits);
> }
> }
> diff --git a/gpsd_json.c b/gpsd_json.c
> index c089377..8a4adab 100644
> --- a/gpsd_json.c
> +++ b/gpsd_json.c
> @@ -14,16 +14,6 @@ PERMISSIONS
>
> ***************************************************************************/
>
> -/* isascii() needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -/* vsnprintf() needs __DARWIN_C_LEVEL >= 200112L */
> -#define __DARWIN_C_LEVEL 200112L
> -/* strlcpy() needs _DARWIN_C_SOURCE */
> -#define _DARWIN_C_SOURCE
> -
> -/* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999 */
> -#define __ISO_C_VISIBLE 1999
> -
> #include <stdio.h>
> #include <math.h>
> #include <assert.h>
> diff --git a/gpsmon.c b/gpsmon.c
> index ea0991b..ee4aaeb 100644
> --- a/gpsmon.c
> +++ b/gpsmon.c
> @@ -4,10 +4,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999 */
> -#define __ISO_C_VISIBLE 1999
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdbool.h>
> @@ -865,7 +861,6 @@ static bool do_command(const char *line)
> {
> #ifdef RECONFIGURE_ENABLE
> unsigned int v;
> - struct timespec delay;
> #endif /* RECONFIGURE_ENABLE */
> #ifdef CONTROLSEND_ENABLE
> unsigned char buf[BUFLEN];
> @@ -968,12 +963,7 @@ static bool do_command(const char *line)
> switcher->mode_switcher(&session, (int)v);
> context.readonly = true;
> (void)tcdrain(session.gpsdata.gps_fd);
> -
> - /* wait 50,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 50000000L;
> - nanosleep(&delay, NULL);
> -
> + (void)usleep(50000);
> /*
> * Session device change will be set to NMEA when
> * gpsmon resyncs. So stash the current type to
> @@ -1045,11 +1035,7 @@ static bool do_command(const char *line)
> * buffer.
> */
> (void)tcdrain(session.gpsdata.gps_fd);
> - /* wait 50,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 50000000L;
> - nanosleep(&delay, NULL);
> -
> + (void)usleep(50000);
> (void)gpsd_set_speed(&session, speed,
> parity, stopbits);
> } else
> diff --git a/gpspacket.c b/gpspacket.c
> index 58ec5db..0c9ade2 100644
> --- a/gpspacket.c
> +++ b/gpspacket.c
> @@ -5,10 +5,6 @@
> * BSD terms apply: see the file COPYING in the distribution root
> for details. *
> */
> -
> -/* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999 */
> -#define __ISO_C_VISIBLE 1999
> -
> #include <Python.h>
>
> #include <stdio.h>
> diff --git a/gpspipe.c b/gpspipe.c
> index 6e133f4..33d015c 100644
> --- a/gpspipe.c
> +++ b/gpspipe.c
> @@ -23,12 +23,6 @@
> *
> */
>
> -/* cfmakeraw() needs _DEFAULT_SOURCE */
> -#define _DEFAULT_SOURCE
> -/* daemon() needs _DEFAULT_SOURCE */
> -#define _DEFAULT_SOURCE
> -
> -
> #include <time.h> /* for time_t */
> #include "gpsd_config.h"
>
> @@ -83,7 +77,7 @@ static void open_serial(char *device)
> }
>
> /* Clear struct for new port settings. */
> - memset(&newtio, 0, sizeof(newtio));
> + bzero(&newtio, sizeof(newtio));
>
> /* make it raw */
> (void)cfmakeraw(&newtio);
> diff --git a/gpxlogger.c b/gpxlogger.c
> index 99bb3d0..d7ea508 100644
> --- a/gpxlogger.c
> +++ b/gpxlogger.c
> @@ -2,10 +2,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* daemon() needs _DEFAULT_SOURCE */
> -#define _DEFAULT_SOURCE
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdbool.h>
> diff --git a/lcdgps.c b/lcdgps.c
> index 75f9917..910f38d 100644
> --- a/lcdgps.c
> +++ b/lcdgps.c
> @@ -33,9 +33,6 @@
>
> #define CLIMB 3
>
> -/* daemon() needs _DEFAULT_SOURCE */
> -#define _DEFAULT_SOURCE
> -
> #include <netdb.h>
> #ifndef AF_UNSPEC
> #include <sys/types.h>
> diff --git a/libgps_core.c b/libgps_core.c
> index 644b96d..ca580bd 100644
> --- a/libgps_core.c
> +++ b/libgps_core.c
> @@ -5,10 +5,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999 */
> -#define __ISO_C_VISIBLE 1999
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdarg.h>
> diff --git a/libgps_shm.c b/libgps_shm.c
> index a9250ca..75aba8a 100644
> --- a/libgps_shm.c
> +++ b/libgps_shm.c
> @@ -14,10 +14,6 @@ PERMISSIONS
> BSD terms apply: see the file COPYING in the distribution root
> for details.
> ***************************************************************************/
> -
> -/* sys/ipc.h needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -
> #include <time.h> /* for time_t */
> #include "gpsd_config.h"
>
> diff --git a/libgpsd_core.c b/libgpsd_core.c
> index 377674c..3fef4a8 100644
> --- a/libgpsd_core.c
> +++ b/libgpsd_core.c
> @@ -9,22 +9,9 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* getsid() needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -/* isfinite() and pselect() needs _POSIX_C_SOURCE >= 200112L */
> -#define _POSIX_C_SOURCE 200112L
> -/* strlcpy() needs _DARWIN_C_SOURCE */
> -#define _DARWIN_C_SOURCE
> -
> -
> #include <time.h>
> #include <stdio.h>
> -
> -/* alloca() in stdlib.h needs __USE_MISC on Linux */
> -#define __USE_MISC
> #include <stdlib.h>
> -
> #include <stdbool.h>
> #include <libgen.h>
> #include <math.h>
> diff --git a/monitor_nmea0183.c b/monitor_nmea0183.c
> index a150ac4..426d9b0 100644
> --- a/monitor_nmea0183.c
> +++ b/monitor_nmea0183.c
> @@ -6,10 +6,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* for vsnprintf() FreeBSD wants __ISO_C_VISIBLE >= 1999 */
> -#define __ISO_C_VISIBLE 1999
> -
> #include <stdio.h>
> #include <string.h>
> #include <math.h>
> diff --git a/netlib.c b/netlib.c
> index cc1c7bf..a0403cd 100644
> --- a/netlib.c
> +++ b/netlib.c
> @@ -2,10 +2,6 @@
> * This file is Copyright (c) 2010 by the GPSD project
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
> -
> -/* for INADDR_LOOPBACK() FreeBSD wants __BSD_VISIBLE */
> -#define __BSD_VISIBLE
> -
> #include <string.h>
> #include <fcntl.h>
> #include <netdb.h>
> diff --git a/ntpshmmon.c b/ntpshmmon.c
> index f8768a3..8706f41 100644
> --- a/ntpshmmon.c
> +++ b/ntpshmmon.c
> @@ -4,10 +4,6 @@
> * BSD terms apply: see the file COPYING in the distribution root
> for details. *
> */
> -
> -/* sys/ipc.h needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -
> #include <stdio.h>
> #include <string.h> /* for memset() */
> #include <stdlib.h>
> @@ -102,7 +98,6 @@ int main(int argc, char **argv)
> do {
> /* the current segment */
> struct shm_stat_t shm_stat;
> - struct timespec delay;
>
> for (i = 0; i < NTPSEGMENTS; i++) {
> long long diff; /* 32 bit long is too short for a
> timespec */ @@ -169,7 +164,7 @@ int main(int argc, char **argv)
> * That is a 200 millSec cycle, minimum 20 milliSec duration
> * we will wait 1 milliSec out of caution
> *
> - * and, of course, nanosleep() may sleep a lot longer than
> we ask...
> + * and, of course, usleep() may sleep a lot longer than we
> ask... */
> if ( timeout ) {
> /* do not read time unless it matters */
> @@ -178,11 +173,7 @@ int main(int argc, char **argv)
> break;
> }
> }
> -
> - /* wait 1,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 1000000L;
> - nanosleep(&delay, NULL);
> + (void)usleep((useconds_t)1000);
> } while ( 0 < nsamples );
>
> exit(EXIT_SUCCESS);
> diff --git a/ntpshmwrite.c b/ntpshmwrite.c
> index a9bfa02..9cb43a2 100644
> --- a/ntpshmwrite.c
> +++ b/ntpshmwrite.c
> @@ -5,9 +5,6 @@
> * see the file COPYING in the distribution root for details.
> */
>
> -/* sys/ipc.h needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -
> #include <string.h>
> #include <libgen.h>
> #include <stdbool.h>
> diff --git a/serial.c b/serial.c
> index 0d68546..0a17007 100644
> --- a/serial.c
> +++ b/serial.c
> @@ -3,9 +3,6 @@
> * BSD terms apply: see the file COPYING in the distribution root
> for details. */
>
> -/* cfmakeraw() needs _DEFAULT_SOURCE */
> -#define _DEFAULT_SOURCE
> -
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <sys/ioctl.h>
> @@ -261,7 +258,6 @@ void gpsd_set_speed(struct gps_device_t *session,
> speed_t speed, char parity, unsigned int
> stopbits) {
> speed_t rate;
> - struct timespec delay;
>
> /*
> * Yes, you can set speeds that aren't in the hunt loop. If you
> @@ -387,11 +383,7 @@ void gpsd_set_speed(struct gps_device_t *session,
> * occasional failure to lock.
> */
> (void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH);
> -
> - /* wait 200,000 uSec */
> - delay.tv_sec = 0;
> - delay.tv_nsec = 200000000L;
> - nanosleep(&delay, NULL);
> + (void)usleep(200000);
> (void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH);
> }
> gpsd_log(&session->context->errout, LOG_INF,
> diff --git a/shmexport.c b/shmexport.c
> index cef94d7..2a0e416 100644
> --- a/shmexport.c
> +++ b/shmexport.c
> @@ -14,10 +14,6 @@ PERMISSIONS
> BSD terms apply: see the file COPYING in the distribution root
> for details.
> ***************************************************************************/
> -
> -/* sys/ipc.h needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -
> #include <time.h> /* for time_t */
> #include "gpsd_config.h"
>
> diff --git a/timebase.c b/timebase.c
> index 227736d..b2e7939 100644
> --- a/timebase.c
> +++ b/timebase.c
> @@ -190,9 +190,6 @@ BSD terms apply: see the file COPYING in the
> distribution root for details.
>
> *****************************************************************************/
>
> -/* putenv() needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -
> #include <stdlib.h>
> #include <string.h>
> #include <ctype.h>
> diff --git a/timehint.c b/timehint.c
> index c8b4bb8..dbbf09a 100644
> --- a/timehint.c
> +++ b/timehint.c
> @@ -8,13 +8,6 @@
> * see the file COPYING in the distribution root for details.
> */
>
> -/* nice() needs _XOPEN_SOURCE, 500 means X/Open 1995 */
> -#define _XOPEN_SOURCE 500
> -/* snprintf() needs __DARWIN_C_LEVEL >= 200112L */
> -#define __DARWIN_C_LEVEL 200112L
> -/* snprintf() needs _DARWIN_C_SOURCE */
> -#define _DARWIN_C_SOURCE
> -
> #include <string.h>
> #include <libgen.h>
> #include <stdbool.h>
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
address@hidden Tel:+1 541 382 8588
pgpLM_XSpTUsy.pgp
Description: OpenPGP digital signature