10 #define BUFFSIZE 65536
13 #define Mbit (Kbit*Kbit)
15 #define SEC_TO_USEC 1000000LL
16 #define MSEC_TO_USEC 1000LL
17 #define USEC_TO_NSEC 1000LL
27 /* unsigned int tos; */
28 struct timespec send_timestamp;
29 struct timespec sendback_timestamp;
30 /* unsigned long int seqn; */
39 char nonsense[BUFFSIZE];
43 extern const int prio_to_ac[8];
44 extern const unsigned int ac_to_tos[4];
45 extern const char *ac_to_text[4];
47 void block_signals(void);
48 void set_rt_prio(int priority);
49 char *bandwidth_to_text(char *buf, unsigned bandwidth_bps);
50 char *usec_to_text(char *buf, unsigned usec);
53 void timespec_add (struct timespec *sum, const struct timespec *left,
54 const struct timespec *right)
56 sum->tv_sec = left->tv_sec + right->tv_sec;
57 sum->tv_nsec = left->tv_nsec + right->tv_nsec;
59 if (sum->tv_nsec >= 1000000000){
61 sum->tv_nsec -= 1000000000;
66 void timespec_sub (struct timespec *diff, const struct timespec *left,
67 const struct timespec *right)
69 diff->tv_sec = left->tv_sec - right->tv_sec;
70 diff->tv_nsec = left->tv_nsec - right->tv_nsec;
72 if (diff->tv_nsec < 0){
74 diff->tv_nsec += 1000000000;
78 static inline long long timespec_sub_usec(const struct timespec *left,
79 const struct timespec *right)
81 struct timespec result;
82 timespec_sub(&result, left, right);
83 return (long long)result.tv_sec * SEC_TO_USEC +
84 result.tv_nsec / USEC_TO_NSEC;
87 static inline long long timespec2usec(const struct timespec *ts)
89 return ts->tv_sec * SEC_TO_USEC + ts->tv_nsec / USEC_TO_NSEC;