| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: jiffies.h,v 1.1.2.2 2013/07/24 02:28:22 riastradh Exp $ */ | | 1 | /* $NetBSD: jiffies.h,v 1.1.2.3 2013/07/24 03:03:23 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -27,14 +27,54 @@ | | | @@ -27,14 +27,54 @@ |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #ifndef _LINUX_JIFFIES_H_ | | 32 | #ifndef _LINUX_JIFFIES_H_ |
33 | #define _LINUX_JIFFIES_H_ | | 33 | #define _LINUX_JIFFIES_H_ |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/kernel.h> | | 36 | #include <sys/kernel.h> |
37 | | | 37 | |
38 | #define jiffies hardclock_ticks | | 38 | #define jiffies hardclock_ticks |
39 | | | 39 | |
| | | 40 | static inline unsigned int |
| | | 41 | msecs_to_jiffies(unsigned int msec) |
| | | 42 | { |
| | | 43 | return mstohz(msec); |
| | | 44 | } |
| | | 45 | |
| | | 46 | static inline unsigned int |
| | | 47 | usecs_to_jiffies(unsigned int usec) |
| | | 48 | { |
| | | 49 | return mstohz((usec + (1000 / hz) - 1) / (1000 / hz)); |
| | | 50 | } |
| | | 51 | |
| | | 52 | /* XXX long is the wrong type here times... */ |
| | | 53 | |
| | | 54 | #define __linux_time_compare(A, OP, B) (((long)(A) - (long)(B)) OP 0) |
| | | 55 | |
| | | 56 | static inline bool |
| | | 57 | time_after(unsigned long a, unsigned long b) |
| | | 58 | { |
| | | 59 | return __linux_time_compare(a, >, b); |
| | | 60 | } |
| | | 61 | |
| | | 62 | static inline bool |
| | | 63 | time_after_eq(unsigned long a, unsigned long b) |
| | | 64 | { |
| | | 65 | return __linux_time_compare(a, >=, b); |
| | | 66 | } |
| | | 67 | |
| | | 68 | static inline bool |
| | | 69 | time_before(unsigned long a, unsigned long b) |
| | | 70 | { |
| | | 71 | return __linux_time_compare(a, <, b); |
| | | 72 | } |
| | | 73 | |
| | | 74 | static inline bool |
| | | 75 | time_before_eq(unsigned long a, unsigned long b) |
| | | 76 | { |
| | | 77 | return __linux_time_compare(a, <=, b); |
| | | 78 | } |
| | | 79 | |
40 | #endif /* _LINUX_JIFFIES_H_ */ | | 80 | #endif /* _LINUX_JIFFIES_H_ */ |