summaryrefslogtreecommitdiff
path: root/gpspipe.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-03-02 00:16:51 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-03-02 00:16:51 -0500
commit0e120c4bdbfd309ec8a5bbd4005d82edd7700bd3 (patch)
tree9876c64c7ad5fde20e5b537cb2aebe7cdf0f460d /gpspipe.c
parent44b3532e07d2e3790a75ccd5a75f19deefa71e82 (diff)
downloadgpsd-0e120c4bdbfd309ec8a5bbd4005d82edd7700bd3.tar.gz
Complete port of clock_gettime(3) and teach gpsipe to use it.
This eliminates the last gettimeofday(3) from the code. POSIX.1-2008 marked it obsolete. All regression tests pass.
Diffstat (limited to 'gpspipe.c')
-rw-r--r--gpspipe.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gpspipe.c b/gpspipe.c
index 66d9c197..6de59b2c 100644
--- a/gpspipe.c
+++ b/gpspipe.c
@@ -34,7 +34,6 @@
#include <fcntl.h>
#include <termios.h>
#include <time.h>
-#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/select.h>
@@ -43,6 +42,8 @@
#endif /* S_SPLINT_S */
#include "gpsd.h"
+
+#include "gpsd_config.h"
#include "gpsdclient.h"
#include "revision.h"
@@ -333,10 +334,10 @@ int main(int argc, char **argv)
}
if (new_line && timestamp) {
char tmstr_u[20]; // time with "usec" resolution
- struct timeval now;
+ struct timespec now;
struct tm *tmp_now;
- (void)gettimeofday( &now, NULL );
+ (void)clock_gettime(CLOCK_REALTIME, &now);
tmp_now = localtime((time_t *)&(now.tv_sec));
(void)strftime(tmstr, sizeof(tmstr), format, tmp_now);
new_line = 0;
@@ -346,11 +347,11 @@ int main(int argc, char **argv)
(void)snprintf(tmstr_u, sizeof(tmstr_u),
" %ld.%06ld",
(long)now.tv_sec,
- (long)now.tv_usec);
+ (long)now.tv_nsec/1000);
break;
case 1:
(void)snprintf(tmstr_u, sizeof(tmstr_u),
- ".%06ld", (long)now.tv_usec);
+ ".%06ld", (long)now.tv_nsec/1000);
break;
default:
*tmstr_u = '\0';