posix-timers: Introduce clock_posix_cpu
authorThomas Gleixner <tglx@linutronix.de>
Tue, 1 Feb 2011 13:51:06 +0000 (13:51 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 2 Feb 2011 14:28:12 +0000 (15:28 +0100)
The CLOCK_DISPATCH() macro is a horrible magic. We call common
functions if a function pointer is not set. That's just backwards.

To support dynamic file decriptor based clocks we need to cleanup that
dispatch logic.

Create a k_clock struct clock_posix_cpu which has all the
posix-cpu-timer functions filled in. After the cleanup the functions
can be made static.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <johnstul@us.ibm.com>
Tested-by: Richard Cochran <richard.cochran@omicron.at>
LKML-Reference: <20110201134417.841974553@linutronix.de>

include/linux/posix-timers.h
kernel/posix-cpu-timers.c

index b2c14cbd47a6f09e9a72394fc3700d58809087d0..1330ff33152629ee24a6d47445e18fe71d72a090 100644 (file)
@@ -85,6 +85,8 @@ struct k_clock {
                           struct itimerspec * cur_setting);
 };
 
+extern struct k_clock clock_posix_cpu;
+
 void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock);
 
 /* error handlers for timer_create, nanosleep and settime */
index 11b91dc0992b4fbb9200dafcafe975311a76c257..816cd49a5ad9bb20d8a221c8453147f2624c0113 100644 (file)
@@ -1604,6 +1604,18 @@ static long thread_cpu_nsleep_restart(struct restart_block *restart_block)
        return -EINVAL;
 }
 
+struct k_clock clock_posix_cpu = {
+       .clock_getres   = posix_cpu_clock_getres,
+       .clock_set      = posix_cpu_clock_set,
+       .clock_get      = posix_cpu_clock_get,
+       .timer_create   = posix_cpu_timer_create,
+       .nsleep         = posix_cpu_nsleep,
+       .nsleep_restart = posix_cpu_nsleep_restart,
+       .timer_set      = posix_cpu_timer_set,
+       .timer_del      = posix_cpu_timer_del,
+       .timer_get      = posix_cpu_timer_get,
+};
+
 static __init int init_posix_cpu_timers(void)
 {
        struct k_clock process = {