[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] [PATCH 5/6] Fixes usleep() and other issues in contrib/ p
From: |
Gary E. Miller |
Subject: |
Re: [gpsd-dev] [PATCH 5/6] Fixes usleep() and other issues in contrib/ programs. |
Date: |
Tue, 6 Sep 2016 17:15:59 -0700 |
Yo Fred!
Bad form to put 4 unrelated issues in one patch. Can you please
split these up?
On Mon, 5 Sep 2016 18:09:27 -0700
Fred Wright <address@hidden> wrote:
> 1) Adds missing includes to binreplay and motosend, to get rid of
> some warnings.
>
> 2) Replaces usleep() with gps_usleep() everywhere.
>
> 3) Adds explicit recipes for objects build from root dir,
> mainly to avoid warnings about mixed build environments.
>
> 4) Removes references to ppscheck, which was moved to the root.
>
> TESTED:
> Ran "scons build-all check" in the root, and "scons" in contrib/,
> under OSX.
> ---
> contrib/SConstruct | 17 +++++++++++------
> contrib/ashctl.c | 4 +++-
> contrib/binlog.c | 4 +++-
> contrib/binreplay.c | 6 ++++--
> contrib/motosend.c | 5 ++++-
> 5 files changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/contrib/SConstruct b/contrib/SConstruct
> index 5a0e9fc..013c359 100644
> --- a/contrib/SConstruct
> +++ b/contrib/SConstruct
> @@ -3,11 +3,16 @@
> # won't get used on a daily basis, but someone might find them
> useful for # tinkering with their gear.
>
> -ashctl = Program("ashctl", ["ashctl.c", "../strl.c"])
> -binlog = Program("binlog", "binlog.c")
> -binreplay = Program("binreplay", "binreplay.c",
> parse_flags=['-lutil']) +# Note that "../gpsd_config.h" must already
> have been built. +
> +strl = StaticObject("strl", "../strl.c")
> +gps_usleep = StaticObject("gps_usleep", "../gps_usleep.c")
> +
> +ashctl = Program("ashctl", ["ashctl.c", strl, gps_usleep])
> +binlog = Program("binlog", ["binlog.c", gps_usleep])
> +binreplay = Program("binreplay", ["binreplay.c", gps_usleep],
> + parse_flags=['-lutil'])
> lla2ecef = Program("lla2ecef", "lla2ecef.c", parse_flags=['-lm'])
> -motosend = Program("motosend", ["motosend.c", "../strl.c"])
> -ppscheck = Program("ppscheck", "ppscheck.c")
> +motosend = Program("motosend", ["motosend.c", strl, gps_usleep])
>
> -Default(ashctl, binlog, binreplay, lla2ecef, motosend, ppscheck)
> +Default(ashctl, binlog, binreplay, lla2ecef, motosend)
> diff --git a/contrib/ashctl.c b/contrib/ashctl.c
> index fdf04bf..e2e1b28 100644
> --- a/contrib/ashctl.c
> +++ b/contrib/ashctl.c
> @@ -13,6 +13,8 @@
> #include <termios.h>
> #include <unistd.h>
>
> +extern int gps_usleep(unsigned int useconds);
> +
> #define MODE_RAW 0
> #define MODE_NORMAL 1
> #define ASHSPD_9600 5
> @@ -167,7 +169,7 @@ static int nmea_send(int fd, const char *fmt, ...
> ) tcflush(fd, TCIOFLUSH);
> status = (size_t)write(fd, buf, strlen(buf));
> tcdrain(fd);
> - usleep(100000);
> + gps_usleep(100000);
> if (status == strlen(buf)) {
> return (int)status;
> } else {
> diff --git a/contrib/binlog.c b/contrib/binlog.c
> index 3093732..f89847e 100644
> --- a/contrib/binlog.c
> +++ b/contrib/binlog.c
> @@ -13,6 +13,8 @@
> #include <termios.h>
> #include <unistd.h>
>
> +extern int gps_usleep(unsigned int useconds);
> +
> void spinner(int );
>
> int main(int argc, char **argv) {
> @@ -61,7 +63,7 @@ int main(int argc, char **argv) {
> int l = read(ifd, buf, BUFSIZ);
> if (l > 0)
> assert(write(ofd, buf, l) > 0);
> - usleep(1000);
> + gps_usleep(1000);
> memset(buf, 0, BUFSIZ);
> spinner( n++ );
> }
> diff --git a/contrib/binreplay.c b/contrib/binreplay.c
> index 36389e0..a4111d5 100644
> --- a/contrib/binreplay.c
> +++ b/contrib/binreplay.c
> @@ -13,13 +13,15 @@
> #include <termios.h>
> #include <unistd.h>
> #include <string.h>
> +#include <stdlib.h>
> #ifndef __GLIBC__
> #include <util.h>
> #else
> - #include <stdlib.h>
> #include <pty.h>
> #endif
>
> +extern int gps_usleep(unsigned int useconds);
> +
>
> #define WRLEN 64
> void spinner(int);
> @@ -117,7 +119,7 @@ int main( int argc, char **argv){
> tcflush(sfd, TCIFLUSH);
> }
> spinner( len );
> - usleep(sleeptime);
> + gps_usleep(sleeptime);
> }
>
> munmap(buf, sb.st_size);
> diff --git a/contrib/motosend.c b/contrib/motosend.c
> index 0778fda..b454809 100644
> --- a/contrib/motosend.c
> +++ b/contrib/motosend.c
> @@ -13,6 +13,9 @@
> #include <termios.h>
> #include <unistd.h>
> #include <limits.h>
> +#include <time.h>
> +
> +extern int gps_usleep(unsigned int useconds);
>
> /*
> * @@Cj - receiver ID
> @@ -82,7 +85,7 @@ int main(int argc, char **argv) {
> tcflush(fd, TCIOFLUSH);
> t = 0; n = 0;
> while (1){
> - usleep(1000);
> + gps_usleep(1000);
> memset(buf, 0, BSIZ);
> if ((l = read(fd, buf, BSIZ)) == -1)
> if (!(EINTR == errno || EAGAIN == errno))
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
address@hidden Tel:+1 541 382 8588
pgpbmVl8qz14g.pgp
Description: OpenPGP digital signature
[gpsd-dev] [PATCH 6/6] Eliminates the one use of the portability-challenged alloca()., Fred Wright, 2016/09/05
[gpsd-dev] [PATCH 2/6] bzero() is gone in POSIX 2008. Use memset(), Fred Wright, 2016/09/05
[gpsd-dev] [PATCH 3/6] bcopy() gone in POSIX 2008., Fred Wright, 2016/09/05
Re: [gpsd-dev] [PATCH 1/6] Reverts most C99-related changes., Gary E. Miller, 2016/09/05