12 #define Mbit (Kbit*Kbit)
14 #define SEC_TO_USEC 1000000LL
15 #define MSEC_TO_USEC 1000LL
16 #define USEC_TO_NSEC 1000LL
26 /* unsigned int tos; */
27 struct timespec send_timestamp;
28 struct timespec sendback_timestamp;
29 /* unsigned long int seqn; */
35 char nonsense[BUFFSIZE];
39 extern const int prio_to_ac[8];
40 extern const unsigned int ac_to_tos[4];
41 extern const char *ac_to_text[4];
43 void block_signals(void);
44 void set_rt_prio(int priority);
45 char *bandwidth_to_text(char *buf, unsigned bandwidth_bps);
46 char *usec_to_text(char *buf, unsigned usec);
49 void timespec_add (struct timespec *sum, const struct timespec *left,
50 const struct timespec *right)
52 sum->tv_sec = left->tv_sec + right->tv_sec;
53 sum->tv_nsec = left->tv_nsec + right->tv_nsec;
55 if (sum->tv_nsec >= 1000000000){
57 sum->tv_nsec -= 1000000000;
62 void timespec_sub (struct timespec *diff, const struct timespec *left,
63 const struct timespec *right)
65 diff->tv_sec = left->tv_sec - right->tv_sec;
66 diff->tv_nsec = left->tv_nsec - right->tv_nsec;
68 if (diff->tv_nsec < 0){
70 diff->tv_nsec += 1000000000;
74 static inline long long timespec_sub_usec(const struct timespec *left,
75 const struct timespec *right)
77 struct timespec result;
78 timespec_sub(&result, left, right);
79 return (long long)result.tv_sec * SEC_TO_USEC +
80 result.tv_nsec / USEC_TO_NSEC;
83 static inline long long timespec2usec(const struct timespec *ts)
85 return ts->tv_sec * SEC_TO_USEC + ts->tv_nsec / USEC_TO_NSEC;