Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Return negative, zero, positive if A < B, A == B, A > B, respectively.
- Assume the nanosecond components are in range, or close to it. */
- static inline int
- timespec_cmp (struct timespec a, struct timespec b)
- {
- int diffadd = a.tv_sec + b.tv_sec;
- int diffsub = a.tv_sec - b.tv_sec;
- if( ((diffsub > 0) && (diffadd > 0)) || ((diffsub < 0) && (diffadd < 0)) ){
- return 1;
- }
- else if( ((diffsub > 0) && (diffadd < 0)) || ((diffsub < 0) && (diffadd > 0)) ){
- return -1;
- }
- return 0;
- //int diff = a.tv_sec - b.tv_sec;
- //return diff ? diff : a.tv_nsec - b.tv_nsec;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement