summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsof <unknown>2003-03-29 00:27:11 +0000
committersof <unknown>2003-03-29 00:27:11 +0000
commitff54eadfb873ca938ea16b3861e751cba499c34d (patch)
tree931e0bc74e7d995acaeef69b0a5e9aeae55abd86
parent47e6674f14f0b414bbb3f37ffff8749302e0f4b2 (diff)
downloadhaskell-ff54eadfb873ca938ea16b3861e751cba499c34d.tar.gz
[project @ 2003-03-29 00:27:11 by sof]
startTicker(): pass in the tick handler as an arg
-rw-r--r--ghc/rts/Itimer.c8
-rw-r--r--ghc/rts/Itimer.h4
-rw-r--r--ghc/rts/Timer.c3
-rw-r--r--ghc/rts/Timer.h3
-rw-r--r--ghc/rts/win32/Ticker.c8
-rw-r--r--ghc/rts/win32/Ticker.h2
6 files changed, 17 insertions, 11 deletions
diff --git a/ghc/rts/Itimer.c b/ghc/rts/Itimer.c
index 4c94232e10..74801dba54 100644
--- a/ghc/rts/Itimer.c
+++ b/ghc/rts/Itimer.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $Id: Itimer.c,v 1.34 2003/03/29 00:00:41 sof Exp $
+ * $Id: Itimer.c,v 1.35 2003/03/29 00:27:11 sof Exp $
*
* (c) The GHC Team, 1995-1999
*
@@ -42,7 +42,7 @@
static
int
-install_vtalrm_handler(void)
+install_vtalrm_handler(TickProc handle_tick)
{
struct sigaction action;
@@ -55,7 +55,7 @@ install_vtalrm_handler(void)
}
int
-startTicker(nat ms)
+startTicker(nat ms, TickProc handle_tick)
{
# ifndef HAVE_SETITIMER
/* fprintf(stderr, "No virtual timer on this system\n"); */
@@ -63,7 +63,7 @@ startTicker(nat ms)
# else
struct itimerval it;
- install_vtalrm_handler();
+ install_vtalrm_handler(handle_tick);
timestamp = getourtimeofday();
diff --git a/ghc/rts/Itimer.h b/ghc/rts/Itimer.h
index e473ad5047..adfe12a397 100644
--- a/ghc/rts/Itimer.h
+++ b/ghc/rts/Itimer.h
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $Id: Itimer.h,v 1.12 2003/03/28 23:46:40 sof Exp $
+ * $Id: Itimer.h,v 1.13 2003/03/29 00:27:11 sof Exp $
*
* (c) The GHC Team 1998-2001
*
@@ -9,7 +9,7 @@
#ifndef __ITIMER_H__
#define __ITIMER_H__
-extern int startTicker( nat ms );
+extern int startTicker( nat ms, TickProc handle_tick);
extern int stopTicker ( void );
extern unsigned int getourtimeofday ( void );
diff --git a/ghc/rts/Timer.c b/ghc/rts/Timer.c
index 5425116ec7..013fd06594 100644
--- a/ghc/rts/Timer.c
+++ b/ghc/rts/Timer.c
@@ -35,6 +35,7 @@ static int ticks_to_ctxt_switch = 0;
* At each occurrence of a tick, the OS timer will invoke
* handle_tick().
*/
+static
void
handle_tick(int unused STG_UNUSED)
{
@@ -57,7 +58,7 @@ startTimer(nat ms)
initProfTimer();
#endif
- return startTicker(ms);
+ return startTicker(ms, handle_tick);
}
int
diff --git a/ghc/rts/Timer.h b/ghc/rts/Timer.h
index e13570fa11..1c4696e25c 100644
--- a/ghc/rts/Timer.h
+++ b/ghc/rts/Timer.h
@@ -16,7 +16,8 @@
*/
#define CS_MIN_MILLISECS TICK_MILLISECS /* milliseconds per slice */
-extern void handle_tick(int unused);
+typedef void (*TickProc)(int);
+
extern int startTimer(nat ms);
extern int stopTimer(void);
#endif /* __TIMER_H__ */
diff --git a/ghc/rts/win32/Ticker.c b/ghc/rts/win32/Ticker.c
index 194ec8d2a8..124cbc8187 100644
--- a/ghc/rts/win32/Ticker.c
+++ b/ghc/rts/win32/Ticker.c
@@ -21,6 +21,8 @@
*/
static HANDLE hStopEvent = INVALID_HANDLE_VALUE;
+static TickProc tickProc = NULL;
+
/*
* Ticking is done by a separate thread which periodically
* wakes up to handle a tick.
@@ -48,11 +50,12 @@ TimerProc(PVOID param)
switch (waitRes) {
case WAIT_OBJECT_0:
/* event has become signalled */
+ tickProc = NULL;
CloseHandle(hStopEvent);
return 0;
case WAIT_TIMEOUT:
/* tick */
- handle_tick(0);
+ tickProc(0);
break;
default:
fprintf(stderr, "timer: unexpected result %lu\n", waitRes); fflush(stderr);
@@ -64,7 +67,7 @@ TimerProc(PVOID param)
int
-startTicker(nat ms)
+startTicker(nat ms, TickProc handle_tick)
{
unsigned threadId;
/* 'hStopEvent' is a manual-reset event that's signalled upon
@@ -77,6 +80,7 @@ startTicker(nat ms)
if (hStopEvent == INVALID_HANDLE_VALUE) {
return 0;
}
+ tickProc = handle_tick;
return ( 0 != _beginthreadex(NULL,
0,
TimerProc,
diff --git a/ghc/rts/win32/Ticker.h b/ghc/rts/win32/Ticker.h
index 669a0a193e..6104f93a04 100644
--- a/ghc/rts/win32/Ticker.h
+++ b/ghc/rts/win32/Ticker.h
@@ -3,7 +3,7 @@
*/
#ifndef __TICKER_H__
#define __TICKER_H__
-extern int startTicker( nat ms );
+extern int startTicker( nat ms, TickProc handle_tick );
extern int stopTicker ( void );
#endif /* __TICKER_H__ */