]> git.donarmstrong.com Git - lilypond.git/blob - guile18/qt/md/i386.h
Import guile-1.8 as multiple upstream tarball component
[lilypond.git] / guile18 / qt / md / i386.h
1 /*
2  * QuickThreads -- Threads-building toolkit.
3  * Copyright (c) 1993 by David Keppel
4  *
5  * Permission to use, copy, modify and distribute this software and
6  * its documentation for any purpose and without fee is hereby
7  * granted, provided that the above copyright notice and this notice
8  * appear in all copies.  This software is provided as a
9  * proof-of-concept and for demonstration purposes; there is no
10  * representation about the suitability of this software for any
11  * purpose.
12  */
13
14 #ifndef QT_386_H
15 #define QT_386_H
16
17 typedef unsigned long qt_word_t;
18
19 /* Thread's initial stack layout on the i386:
20
21    non-varargs:
22
23    +---
24    | arg[2]     === `userf' on startup
25    | arg[1]     === `pt' on startup
26    | arg[0]     === `pu' on startup
27    +---
28    | ret pc === qt_error
29    +---
30    | ret pc     === `only' on startup
31    +---
32    | %ebp
33    | %esi
34    | %edi
35    | %ebx                               <--- qt_t.sp
36    +---
37
38    When a non-varargs thread is started, it ``returns'' directly to
39    the client's `only' function.
40
41    varargs:
42
43    +---
44    | arg[n-1]
45    | ..
46    | arg[0]
47    +---
48    | ret pc     === `qt_vstart'
49    +---
50    | %ebp       === `startup'
51    | %esi       === `cleanup'
52    | %edi       === `pt'
53    | %ebx       === `vuserf'            <--- qt_t.sp
54    +---
55
56    When a varargs thread is started, it ``returns'' to the `qt_vstart'
57    startup code.  The startup code calls the appropriate functions. */
58
59
60 /* What to do to start a varargs thread running. */
61 QT_API void qt_vstart (void);
62
63
64 /* Hold 4 saved regs plus two return pcs (qt_error, qt_start) plus
65    three args. */
66 #define QT_STKBASE      (9 * 4)
67
68 /* Hold 4 saved regs plus one return pc (qt_vstart). */
69 #define QT_VSTKBASE     (5 * 4)
70
71
72 /* Stack must be 4-byte aligned. */
73 #define QT_STKALIGN     (4)
74
75
76 /* Where to place various arguments. */
77 #define QT_ONLY_INDEX   (QT_PC)
78 #define QT_USER_INDEX   (QT_ARG2)
79 #define QT_ARGT_INDEX   (QT_ARG1)
80 #define QT_ARGU_INDEX   (QT_ARG0)
81
82 #define QT_VSTARTUP_INDEX       (QT_EBP)
83 #define QT_VUSERF_INDEX         (QT_EBX)
84 #define QT_VCLEANUP_INDEX       (QT_ESI)
85 #define QT_VARGT_INDEX          (QT_EDI)
86
87
88 #define QT_EBX  0
89 #define QT_EDI  1
90 #define QT_ESI  2
91 #define QT_EBP  3
92 #define QT_PC   4
93 /* The following are defined only for non-varargs. */
94 #define QT_RPC  5
95 #define QT_ARG0 6
96 #define QT_ARG1 7
97 #define QT_ARG2 8
98
99
100 /* Stack grows down.  The top of the stack is the first thing to
101    pop off (preincrement, postdecrement). */
102 #define QT_GROW_DOWN
103
104 QT_API void qt_error (void);
105
106 /* Push on the error return address. */
107 #define QT_ARGS_MD(sto) \
108   (QT_SPUT (sto, QT_RPC, qt_error))
109
110
111 /* When varargs are pushed, allocate space for all the args. */
112 #define QT_VARGS_MD0(sto, nbytes) \
113   ((qt_t *)(((char *)(sto)) - QT_STKROUNDUP(nbytes)))
114
115 #define QT_VARGS_MD1(sto) \
116   (QT_SPUT (sto, QT_PC, qt_vstart))
117
118 #define QT_VARGS_DEFAULT
119
120 #endif /* QT_386_H */