Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | /* Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh |
2 | * Jagannathan, and Stephen Weeks. | |
3 | * Copyright (C) 1997-2000 NEC Research Institute. | |
4 | * | |
5 | * MLton is released under a BSD-style license. | |
6 | * See the file MLton-LICENSE for details. | |
7 | */ | |
8 | ||
9 | #if (defined (MLTON_GC_INTERNAL_TYPES)) | |
10 | ||
11 | /* | |
12 | * Thread objects are normal objects with the following layout: | |
13 | * | |
14 | * header :: | |
15 | * padding :: | |
16 | * bytesNeeded (size_t) :: | |
17 | * exnStack (size_t) :: | |
18 | * stack (object-pointer) | |
19 | * | |
20 | * There may be zero or more bytes of padding for alignment purposes. | |
21 | * | |
22 | * The bytesNeeded size_t is the number of bytes needed when returning | |
23 | * to this thread. | |
24 | * | |
25 | * The exnStack size_t is an offset added to stackBottom that | |
26 | * specifies the top of the exnStack. | |
27 | * | |
28 | * The final component is the stack object-pointer. | |
29 | * | |
30 | * Note that the order of the fields is important. The non-objptr | |
31 | * fields must be first, because a thread object must appear to be a | |
32 | * normal object. | |
33 | */ | |
34 | typedef struct GC_thread { | |
35 | size_t bytesNeeded; | |
36 | size_t exnStack; | |
37 | objptr stack; | |
38 | } __attribute__ ((packed)) *GC_thread; | |
39 | ||
40 | COMPILE_TIME_ASSERT(GC_thread__packed, | |
41 | sizeof(struct GC_thread) == | |
42 | sizeof(size_t) | |
43 | + sizeof(size_t) | |
44 | + sizeof(objptr)); | |
45 | ||
46 | #define BOGUS_EXN_STACK ((size_t)(-1)) | |
47 | ||
48 | #else | |
49 | ||
50 | struct GC_thread; | |
51 | typedef struct GC_thread *GC_thread; | |
52 | ||
53 | #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */ | |
54 | ||
55 | #if (defined (MLTON_GC_INTERNAL_FUNCS)) | |
56 | ||
57 | static void displayThread (GC_state s, GC_thread thread, FILE *stream); | |
58 | static inline size_t sizeofThread (GC_state s); | |
59 | static inline size_t offsetofThread (GC_state s); | |
60 | ||
61 | #endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */ |