[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] [PATCH 4/6] Replaces deprecated usleep() with nanosleep()
Re: [gpsd-dev] [PATCH 4/6] Replaces deprecated usleep() with nanosleep()-based alternative.
Fri, 9 Sep 2016 13:40:12 -0700 (PDT)
On Tue, 6 Sep 2016, Gary E. Miller wrote:
> No need. usleep() was all removed in:
> commit e67e4118a0cbb5b5cecc62e7440299d0b5b35a37
True, but my way of removing it was better. :-)
> I don't think it is worth the overhead to wrap a basic POSIX 1993 call.
On the contrary, wrapping system calls so that they appear in only one
place is good practice in general, both to have one place to deal with any
portability tweaks, and to have one place to set a breakpoint on a given
call. The intrinsic overhead of a system call is so large that the added
overhead of an extra function call is down in the noise (granted, not
entirely true if the call is implemented via a VDSO). And worrying about
extra overhead on a function whose purpose is to waste time is pretty
In some programs, I've wrapped *all* system calls in local functions, and
accessed those functions through a vector table, so that the entire
program can be sandboxed for unit testing, without resorting to
platform-specific means of intercepting system calls.
Having multiple places that convert a scalar sleep value to a struct
timespec violates the DRY principle of good programming practice. See:
But I'm not going to worry about pushing this right now.
[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