]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/mk_timer.c
xnu-517.12.7.tar.gz
[apple/xnu.git] / osfmk / kern / mk_timer.c
index 0f6850a134290b560e7507f8286ca8c9f2505d17..dfa26e3532df7bae9ca3dc73df8faa4313578056 100644 (file)
@@ -122,7 +122,7 @@ mk_timer_port_destroy(
 }
 
 void
-mk_timer_initialize(void)
+mk_timer_init(void)
 {
        int                     s = sizeof (mk_timer_data_t);
 
@@ -136,12 +136,9 @@ mk_timer_expire(
        void                    *p0,
        void                    *p1)
 {
-       AbsoluteTime            time_of_posting;
        mk_timer_t                      timer = p0;
        ipc_port_t                      port;
 
-       clock_get_uptime(&time_of_posting);
-
        simple_lock(&timer->lock);
 
        if (timer->active > 1) {
@@ -152,17 +149,12 @@ mk_timer_expire(
 
        port = timer->port;
        assert(port != IP_NULL);
+       assert(timer->active == 1);
 
-       while (         timer->is_armed                                                                         &&
-                               !thread_call_is_delayed(&timer->call_entry, NULL)               ) {
+       while (timer->is_armed && timer->active == 1) {
                mk_timer_expire_msg_t           msg;
 
                timer->is_armed = FALSE;
-
-               msg.time_of_arming = timer->time_of_arming;
-               msg.armed_time = timer->call_entry.deadline;
-               msg.time_of_posting = time_of_posting;
-
                simple_unlock(&timer->lock);
 
                msg.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0);
@@ -170,6 +162,8 @@ mk_timer_expire(
                msg.header.msgh_local_port = MACH_PORT_NULL;
                msg.header.msgh_reserved = msg.header.msgh_id = 0;
 
+               msg.unused[0] = msg.unused[1] = msg.unused[2] = 0;
+
                (void) mach_msg_send_from_kernel(&msg.header, sizeof (msg));
 
                simple_lock(&timer->lock);
@@ -213,9 +207,9 @@ mk_timer_destroy(
 kern_return_t
 mk_timer_arm(
        mach_port_name_t        name,
-       AbsoluteTime            expire_time)
+       uint64_t                        expire_time)
 {
-       AbsoluteTime            time_of_arming;
+       uint64_t                        time_of_arming;
        mk_timer_t                      timer;
        ipc_space_t                     myspace = current_space();
        ipc_port_t                      port;
@@ -234,11 +228,14 @@ mk_timer_arm(
                assert(timer->port == port);
                ip_unlock(port);
 
-               timer->time_of_arming = time_of_arming;
-               timer->is_armed = TRUE;
+               if (!timer->is_dead) {
+                       timer->time_of_arming = time_of_arming;
+                       timer->is_armed = TRUE;
+
+                       if (!thread_call_enter_delayed(&timer->call_entry, expire_time))
+                               timer->active++;
+               }
 
-               if (!thread_call_enter_delayed(&timer->call_entry, expire_time))
-                       timer->active++;
                simple_unlock(&timer->lock);
        }
        else {
@@ -252,9 +249,9 @@ mk_timer_arm(
 kern_return_t
 mk_timer_cancel(
        mach_port_name_t        name,
-       AbsoluteTime            *result_time)
+       uint64_t                        *result_time)
 {
-       AbsoluteTime            armed_time = { 0, 0 };
+       uint64_t                        armed_time = 0;
        mk_timer_t                      timer;
        ipc_space_t                     myspace = current_space();
        ipc_port_t                      port;