mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Use clock_gettime(CLOCK_MONOTONIC) if available.
Should fix #759 except on OSX versions below 10.12, which don't have clock_gettime.
This commit is contained in:
parent
46bdc20c26
commit
f40ea9d461
@ -53,6 +53,7 @@
|
|||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -59,7 +59,14 @@ static enum sp_return set_config(struct sp_port *port, struct port_data *data,
|
|||||||
|
|
||||||
static void get_time(struct timeval *time)
|
static void get_time(struct timeval *time)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_CLOCK_GETTIME
|
||||||
|
struct timespec ts;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
time->tv_sec = ts.tv_sec;
|
||||||
|
time->tv_usec = ts.tv_nsec / 1000;
|
||||||
|
#else
|
||||||
gettimeofday(time, NULL);
|
gettimeofday(time, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SP_API enum sp_return sp_get_port_by_name(const char *portname, struct sp_port **port_ptr)
|
SP_API enum sp_return sp_get_port_by_name(const char *portname, struct sp_port **port_ptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user