/* License: GPLv2 */
/*******************************************************************************/
+#define _GNU_SOURCE
#include <ctype.h>
#include <errno.h>
#include <error.h>
tstamp->tv_sec, tstamp->tv_nsec/1000);
}
+int timespec_subtract (struct timespec *result, struct timespec *x, struct timespec *yy);
+
void msg_info_print(FILE *f, struct msg_info *mi)
{
struct timespec diff;
return ifr.ifr_ifindex;
}
-static inline get_tstamp(struct timespec *ts)
+static inline void get_tstamp(struct timespec *ts)
{
clock_gettime(CLOCK_REALTIME, ts);
}
int trace_fd = -1;
int marker_fd = -1;
-int init_ftrace()
+void init_ftrace()
{
#ifdef FTRACE
char *debugfs;
return ret;
}
-static inline send_and_check(int s)
+static inline void send_and_check(int s)
{
int ret;
ret = send_frame(s);
cmsg && (cmsg->cmsg_level == SOL_SOCKET);
cmsg = CMSG_NXTHDR(&msg,cmsg)) {
if (cmsg->cmsg_type == SO_TIMESTAMPNS)
- *ts_kern = *(struct timespec *)CMSG_DATA(cmsg);
- else if (cmsg->cmsg_type == SO_RXQ_OVFL)
- dropcnt += *(__u32 *)CMSG_DATA(cmsg);
+ memcpy(ts_kern, CMSG_DATA(cmsg), sizeof(struct timespec));
+ else if (cmsg->cmsg_type == SO_RXQ_OVFL) {
+ uint32_t ovfl;
+ memcpy(&ovfl, CMSG_DATA(cmsg), sizeof(ovfl));
+ dropcnt += ovfl;
+ }
}
}
void process_on_wire_rx(int s)
{
- struct timespec ts_kern, ts_user, ts_diff;
+ struct timespec ts_kern, ts_user;
struct can_frame frame;
struct msg_info *mi;
receive(s, &frame, &ts_kern, &ts_user);
void process_final_rx(int s)
{
- struct timespec ts_kern, ts_user, ts_diff;
+ struct timespec ts_kern, ts_user;
struct can_frame frame;
struct msg_info *mi;
int ret;
struct pollfd pfd[3];
struct timespec timeout;
struct sockaddr_can addr;
- sigset_t set;
int consecutive_timeouts = 0;
MEMSET_ZERO(pfd);
}
}
if (pfd[i].revents & ~POLLIN)
- error(1, 0, "Unexpected pfd[%d].revents: 0x%04x\n", pfd[i].revents);
+ error(1, 0, "Unexpected pfd[%d].revents: 0x%04x\n", i, pfd[i].revents);
}
}
int main(int argc, const char *argv[])
{
pthread_t thread;
- sigset_t set;
int ret, i;
parse_options(argc, argv);