File: Thread.c

package info (click to toggle)
mlton 20041109-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 18,212 kB
  • ctags: 58,085
  • sloc: ansic: 10,386; makefile: 1,178; sh: 1,139; pascal: 256; asm: 97
file content (55 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "platform.h"

extern struct GC_state gcState;

enum {
	DEBUG_THREAD = FALSE,
};

Thread Thread_current () {
	Thread t;

	t = (Thread)gcState.currentThread;
	if (DEBUG_THREAD)
		fprintf (stderr, "0x%08x = Thread_current ()\n", (uint)t);
	return t;
}

void Thread_finishHandler () {
	GC_finishHandler (&gcState);
}

Thread Thread_saved () {
	Thread t;

	t = (Thread)gcState.savedThread;
	gcState.savedThread = (GC_thread)0x1;
	if (DEBUG_THREAD)
		fprintf (stderr, "0x%08x = Thread_saved ()\n", (uint)t);
	return t;
}

void Thread_setCallFromCHandler (Thread t) {
	gcState.callFromCHandler = (GC_thread)t;
}

void Thread_setSaved (Thread t) {
	if (DEBUG_THREAD)
		fprintf (stderr, "Thread_setSaved (0x%08x)\n", (uint)t);
	gcState.savedThread = (GC_thread)t;
}

void Thread_setHandler (Thread t) {
	gcState.signalHandler = (GC_thread)t;
}

void Thread_startHandler () {
	GC_startHandler (&gcState);
}

void Thread_switchTo (Thread thread, Word ensureBytesFree) {
	if (DEBUG_THREAD)
		fprintf (stderr, "Thread_switchTo (0x%08x, %u)\n",
				(uint)thread, (uint)ensureBytesFree);
	GC_switchToThread (&gcState, (GC_thread)thread, ensureBytesFree);
}