aboutsummaryrefslogtreecommitdiff
path: root/pfinet/timer-emul.c
diff options
context:
space:
mode:
Diffstat (limited to 'pfinet/timer-emul.c')
-rw-r--r--pfinet/timer-emul.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/pfinet/timer-emul.c b/pfinet/timer-emul.c
index 6a7ab537..6eb20bc4 100644
--- a/pfinet/timer-emul.c
+++ b/pfinet/timer-emul.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,2000,02 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -21,6 +21,7 @@
#include <linux/timer.h>
#include <asm/system.h>
#include <linux/sched.h>
+#include <error.h>
#include <string.h>
#include "pfinet.h"
@@ -40,7 +41,7 @@ timer_function (int this_is_a_pointless_variable_with_a_rather_long_name)
timer_thread = mach_thread_self ();
- mutex_lock (&global_lock);
+ __mutex_lock (&global_lock);
while (1)
{
int jiff = jiffies;
@@ -52,13 +53,13 @@ timer_function (int this_is_a_pointless_variable_with_a_rather_long_name)
else
wait = ((timers->expires - jiff) * 1000) / HZ;
- mutex_unlock (&global_lock);
+ __mutex_unlock (&global_lock);
mach_msg (NULL, (MACH_RCV_MSG | MACH_RCV_INTERRUPT
| (wait == -1 ? 0 : MACH_RCV_TIMEOUT)),
0, 0, recv, wait, MACH_PORT_NULL);
- mutex_lock (&global_lock);
+ __mutex_lock (&global_lock);
while (timers->expires < jiffies)
{
@@ -68,14 +69,16 @@ timer_function (int this_is_a_pointless_variable_with_a_rather_long_name)
timers = timers->next;
if (timers)
- timers->prevp = &timers;
+ timers->prev = &timers;
tp->next = 0;
- tp->prevp = 0;
+ tp->prev = 0;
(*tp->function) (tp->data);
}
}
+
+ return 0;
}
@@ -84,21 +87,19 @@ add_timer (struct timer_list *timer)
{
struct timer_list **tp;
- timer->expires += jiffies;
-
for (tp = &timers; *tp; tp = &(*tp)->next)
if ((*tp)->expires > timer->expires)
{
timer->next = *tp;
- timer->next->prevp = &timer->next;
- timer->prevp = tp;
+ timer->next->prev = &timer->next;
+ timer->prev = tp;
*tp = timer;
break;
}
if (!*tp)
{
timer->next = 0;
- timer->prevp = tp;
+ timer->prev = tp;
*tp = timer;
}
@@ -121,14 +122,14 @@ add_timer (struct timer_list *timer)
int
del_timer (struct timer_list *timer)
{
- if (timer->prevp)
+ if (timer->prev)
{
- *timer->prevp = timer->next;
+ *timer->prev = timer->next;
if (timer->next)
- timer->next->prevp = timer->prevp;
+ timer->next->prev = timer->prev;
timer->next = 0;
- timer->prevp = 0;
+ timer->prev = 0;
return 1;
}
else
@@ -136,6 +137,16 @@ del_timer (struct timer_list *timer)
}
void
+mod_timer (struct timer_list *timer, unsigned long expires)
+{
+ /* Should optimize this. */
+ del_timer (timer);
+ timer->expires = expires;
+ add_timer (timer);
+}
+
+
+void
init_timer (struct timer_list *timer)
{
bzero (timer, sizeof (struct timer_list));
@@ -144,24 +155,17 @@ init_timer (struct timer_list *timer)
void
init_time ()
{
- device_t timedev;
- memory_object_t timeobj;
+ error_t err;
struct timeval tp;
- device_open (master_device, 0, "time", &timedev);
- device_map (timedev, VM_PROT_READ, 0, sizeof (mapped_time_value_t),
- &timeobj, 0);
- vm_map (mach_task_self (), (vm_address_t *)&mapped_time,
- sizeof (mapped_time_value_t), 0, 1, timeobj, 0, 0,
- VM_PROT_READ, VM_PROT_READ, VM_INHERIT_NONE);
- mach_port_deallocate (mach_task_self (), timedev);
- mach_port_deallocate (mach_task_self (), timeobj);
+ err = maptime_map (0, 0, &mapped_time);
+ if (err)
+ error (2, err, "cannot map time device");
- fill_timeval (&tp);
+ maptime_read (mapped_time, &tp);
root_jiffies = (long long) tp.tv_sec * HZ
+ ((long long) tp.tv_usec * HZ) / 1000000;
cthread_detach (cthread_fork ((cthread_fn_t) timer_function, 0));
}
-