diff options
-rw-r--r-- | include/linux/posix-timers.h | 13 | ||||
-rw-r--r-- | kernel/posix-timers.c | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 79a1cea7f6ed..88b9256169f8 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h | |||
@@ -18,6 +18,17 @@ struct cpu_timer_list { | |||
18 | int firing; | 18 | int firing; |
19 | }; | 19 | }; |
20 | 20 | ||
21 | /* | ||
22 | * Bit fields within a clockid: | ||
23 | * | ||
24 | * The most significant 29 bits hold either a pid or a file descriptor. | ||
25 | * | ||
26 | * Bit 2 indicates whether a cpu clock refers to a thread or a process. | ||
27 | * | ||
28 | * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3. | ||
29 | * | ||
30 | * A clockid is invalid if bits 2, 1, and 0 are all set. | ||
31 | */ | ||
21 | #define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3)) | 32 | #define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3)) |
22 | #define CPUCLOCK_PERTHREAD(clock) \ | 33 | #define CPUCLOCK_PERTHREAD(clock) \ |
23 | (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0) | 34 | (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0) |
@@ -29,6 +40,8 @@ struct cpu_timer_list { | |||
29 | #define CPUCLOCK_VIRT 1 | 40 | #define CPUCLOCK_VIRT 1 |
30 | #define CPUCLOCK_SCHED 2 | 41 | #define CPUCLOCK_SCHED 2 |
31 | #define CPUCLOCK_MAX 3 | 42 | #define CPUCLOCK_MAX 3 |
43 | #define CLOCKFD CPUCLOCK_MAX | ||
44 | #define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK) | ||
32 | 45 | ||
33 | #define MAKE_PROCESS_CPUCLOCK(pid, clock) \ | 46 | #define MAKE_PROCESS_CPUCLOCK(pid, clock) \ |
34 | ((~(clockid_t) (pid) << 3) | (clockid_t) (clock)) | 47 | ((~(clockid_t) (pid) << 3) | (clockid_t) (clock)) |
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 5a5a4f1c0971..df629d853a81 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -488,7 +488,7 @@ static void release_posix_timer(struct k_itimer *tmr, int it_id_set) | |||
488 | static struct k_clock *clockid_to_kclock(const clockid_t id) | 488 | static struct k_clock *clockid_to_kclock(const clockid_t id) |
489 | { | 489 | { |
490 | if (id < 0) | 490 | if (id < 0) |
491 | return &clock_posix_cpu; | 491 | return (id & CLOCKFD_MASK) == CLOCKFD ? NULL : &clock_posix_cpu; |
492 | 492 | ||
493 | if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres) | 493 | if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres) |
494 | return NULL; | 494 | return NULL; |