linux内核和linux系统时间戳,Linux内核初探 之 系统时间(一) —— 内核时间的基本概念...

内核提供一组比较接口能正确处理回绕/*

* These inlines deal with timer wrapping correctly. You are

* strongly encouraged to use them

* 1. Because people otherwise forget

* 2. Because if the timer wrap changes in future you won't have to

* alter your driver code.

*

* time_after(a,b) returns true if the time a is after time b.

*

* Do this with "<0" and ">=0" to only test the sign of the result. A

* good compiler would generate better code (and a really good compiler

* wouldn't care). Gcc is currently neither.

*/

#define time_after(a,b)

(typecheck(unsigned long, a) &&

typecheck(unsigned long, b) &&

((long)(b) - (long)(a) < 0))

#define time_before(a,b) time_after(b,a)

#define time_after_eq(a,b)

(typecheck(unsigned long, a) &&

typecheck(unsigned long, b) &&

((long)(a) - (long)(b) >= 0))

#define time_before_eq(a,b) time_after_eq(b,a)

/*

* Calculate whether a is in the range of [b, c].

*/

#define time_in_range(a,b,c)

(time_after_eq(a,b) &&

time_before_eq(a,c))

/*

* Calculate whether a is in the range of [b, c).

*/

#define time_in_range_open(a,b,c)

(time_after_eq(a,b) &&

time_before(a,c))

/* Same as above, but does so with platform independent 64bit types.

* These must be used when utilizing jiffies_64 (i.e. return value of

* get_jiffies_64() */

#define time_after64(a,b)

(typecheck(__u64, a) &&

typecheck(__u64, b) &&

((__s64)(b) - (__s64)(a) < 0))

#define time_before64(a,b) time_after64(b,a)

#define time_after_eq64(a,b)

(typecheck(__u64, a) &&

typecheck(__u64, b) &&

((__s64)(a) - (__s64)(b) >= 0))

#define time_before_eq64(a,b) time_after_eq64(b,a)

/*

* These four macros compare jiffies and 'a' for convenience.

*/

/* time_is_before_jiffies(a) return true if a is before jiffies */

#define time_is_before_jiffies(a) time_after(jiffies, a)

/* time_is_after_jiffies(a) return true if a is after jiffies */

#define time_is_after_jiffies(a) time_before(jiffies, a)

/* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/

#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a)

/* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/

#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值