1280bad5ff71165aa4483572906cb694dcbfcbb3
[ghc-hetmet.git] / ghc / includes / InfoMacros.h
1 /* ----------------------------------------------------------------------------
2  * $Id: InfoMacros.h,v 1.19 2002/06/03 12:56:41 matthewc Exp $
3  * 
4  * (c) The GHC Team, 1998-1999
5  *
6  * Macros for building and deconstructing info tables.
7  *
8  * -------------------------------------------------------------------------- */
9
10 #ifndef INFOMACROS_H
11 #define INFOMACROS_H
12
13 #define STD_INFO(type_)                         \
14                 srt : 0,                        \
15                 srt_len : 0,                    \
16                 type : type_
17
18 #define SRT_INFO(type_,srt_,srt_off_,srt_len_)                  \
19                 srt : (StgSRT *)((StgClosure **)srt_+srt_off_), \
20                 srt_len : srt_len_,                             \
21                 type : type_
22
23 #define CONSTR_INFO(type_,tag_)                 \
24                 srt : 0,                        \
25                 srt_len : tag_,                 \
26                 type : type_
27
28 #ifdef PROFILING
29 #define PROF_INFO(type_str, desc_str)           \
30                 prof: {                         \
31                    closure_type: type_str,      \
32                    closure_desc: desc_str,      \
33                 },
34 #else
35 #define PROF_INFO(type_str, desc_str)
36 #endif
37
38 /*
39   On the GranSim/GUM specific parts of the InfoTables (GRAN/PAR):
40
41   In both GranSim and GUM we use revertible black holes (RBH) when putting
42   an updatable closure into a packet for communication. The entry code for
43   an RBH performs standard blocking (as with any kind of BH). The info
44   table for the RBH resides just before the one for the std info
45   table. (NB: there is one RBH ITBL for every ITBL of an updatable
46   closure.) The @rbh_infoptr@ field in the ITBL points from the std ITBL to
47   the RBH ITBL and vice versa. This is used by the RBH_INFOPTR and
48   REVERT_INFOPTR macros to turn an updatable node into an RBH and vice
49   versa. Note, that the only case where we have to revert the RBH in its
50   original form is when a packet is sent back because of garbage collection
51   on another PE. In the RTS for GdH we will use this reversion mechanism in 
52   order to deal with faults in the system. 
53   ToDo: Check that RBHs are needed for all the info tables below. From a quick
54   check of the macros generated in the libs it seems that all of them are used
55   for generating THUNKs.
56   Possible optimisation: Note that any RBH ITBL is a fixed distance away from 
57   the actual ITBL. We could inline this offset as a constant into the RTS and
58   avoid the rbh_infoptr fields altogether (Jim did that in the old RTS).
59   -- HWL
60 */
61
62
63 /* function/thunk info tables --------------------------------------------- */
64
65 #if defined(GRAN) || defined(PAR)
66
67 #define \
68 INFO_TABLE_SRT(info,                            /* info-table label */  \
69                entry,                           /* entry code label */  \
70                ptrs, nptrs,                     /* closure layout info */\
71                srt_, srt_off_, srt_len_,        /* SRT info */          \
72                type,                            /* closure type */      \
73                info_class, entry_class,         /* C storage classes */ \
74                prof_descr, prof_type)           /* profiling info */    \
75         entry_class(stg_RBH_##entry);                                           \
76         entry_class(entry);                                             \
77         ED_RO_ StgInfoTable info;                                       \
78         info_class INFO_TBL_CONST StgInfoTable stg_RBH_##info = {               \
79                 layout : { payload : {ptrs,nptrs} },                    \
80                 PROF_INFO(prof_type, prof_descr)                        \
81                 SRT_INFO(RBH,srt_,srt_off_,srt_len_),                   \
82                 INCLUDE_RBH_INFO(info),                                 \
83                 INIT_ENTRY(stg_RBH_##entry),                            \
84         } ;                                                             \
85         StgFunPtr stg_RBH_##entry (void) {                                  \
86           FB_                                                           \
87             JMP_(stg_RBH_entry);                                            \
88           FE_                                                           \
89         } ;                                                             \
90         info_class INFO_TBL_CONST StgInfoTable info = {                 \
91                 layout : { payload : {ptrs,nptrs} },                    \
92                 PROF_INFO(prof_type, prof_descr)                        \
93                 SRT_INFO(type,srt_,srt_off_,srt_len_),                  \
94                 INCLUDE_RBH_INFO(stg_RBH_##info),                               \
95                 INIT_ENTRY(entry),                                      \
96         }
97
98 #else
99
100 #define \
101 INFO_TABLE_SRT(info,                            /* info-table label */  \
102                entry,                           /* entry code label */  \
103                ptrs, nptrs,                     /* closure layout info */\
104                srt_, srt_off_, srt_len_,        /* SRT info */          \
105                type,                            /* closure type */      \
106                info_class, entry_class,         /* C storage classes */ \
107                prof_descr, prof_type)           /* profiling info */    \
108         entry_class(entry);                                             \
109         info_class INFO_TBL_CONST StgInfoTable info = {                 \
110                 layout : { payload : {ptrs,nptrs} },                    \
111                 PROF_INFO(prof_type, prof_descr)                        \
112                 SRT_INFO(type,srt_,srt_off_,srt_len_),                  \
113                 INIT_ENTRY(entry),                                      \
114         }
115
116 #endif
117
118 /* direct-return address info tables  --------------------------------------*/
119
120 #if defined(GRAN) || defined(PAR)
121
122 #define                                                                 \
123 INFO_TABLE_SRT_BITMAP(info, entry, bitmap_, srt_, srt_off_, srt_len_,   \
124                       type, info_class, entry_class,                    \
125                       prof_descr, prof_type)                            \
126         entry_class(stg_RBH_##entry);                                   \
127         entry_class(entry);                                             \
128         ED_RO_ StgInfoTable info;                                       \
129         info_class INFO_TBL_CONST StgInfoTable stg_RBH_##info = {       \
130                 layout : { bitmap : (StgWord)bitmap_ },                 \
131                 PROF_INFO(prof_type, prof_descr)                        \
132                 SRT_INFO(RBH,srt_,srt_off_,srt_len_),                   \
133                 INCLUDE_RBH_INFO(info),                                 \
134                 INIT_ENTRY(stg_RBH_##entry),                            \
135         };                                                              \
136         StgFunPtr stg_RBH_##entry (void) {                              \
137           FB_                                                           \
138             JMP_(stg_RBH_entry);                                        \
139           FE_                                                           \
140         } ;                                                             \
141         info_class INFO_TBL_CONST StgInfoTable info = {                 \
142                 layout : { bitmap : (StgWord)bitmap_ },                 \
143                 PROF_INFO(prof_type, prof_descr)                        \
144                 SRT_INFO(type,srt_,srt_off_,srt_len_),                  \
145                 INCLUDE_RBH_INFO(stg_RBH_##info),                       \
146                 INIT_ENTRY(entry),                                      \
147         }
148
149 #else
150
151 #define                                                                 \
152 INFO_TABLE_SRT_BITMAP(info, entry, bitmap_, srt_, srt_off_, srt_len_,   \
153                       type, info_class, entry_class,                    \
154                       prof_descr, prof_type)                            \
155         entry_class(entry);                                             \
156         info_class INFO_TBL_CONST StgInfoTable info = {                 \
157                 layout : { bitmap : (StgWord)bitmap_ },                 \
158                 PROF_INFO(prof_type, prof_descr)                        \
159                 SRT_INFO(type,srt_,srt_off_,srt_len_),                  \
160                 INIT_ENTRY(entry),                                      \
161         }
162 #endif
163
164 /* info-table without an SRT -----------------------------------------------*/
165
166 #if defined(GRAN) || defined(PAR)
167
168 #define                                                         \
169 INFO_TABLE(info, entry, ptrs, nptrs, type, info_class,          \
170            entry_class, prof_descr, prof_type)                  \
171         entry_class(stg_RBH_##entry);                           \
172         entry_class(entry);                                     \
173         ED_ StgInfoTable info;                          \
174         info_class INFO_TBL_CONST StgInfoTable stg_RBH_##info = {       \
175                 layout : { payload : {ptrs,nptrs} },            \
176                 PROF_INFO(prof_type, prof_descr)                \
177                 STD_INFO(RBH),                                  \
178                 INCLUDE_RBH_INFO(info),                         \
179                 INIT_ENTRY(stg_RBH_##entry),                    \
180         } ;                                                     \
181         StgFunPtr stg_RBH_##entry (void) {                          \
182           FB_                                                   \
183             JMP_(stg_RBH_entry);                                    \
184           FE_                                                   \
185         } ;                                                     \
186         info_class INFO_TBL_CONST StgInfoTable info = { \
187                 layout : { payload : {ptrs,nptrs} },            \
188                 PROF_INFO(prof_type, prof_descr)                \
189                 STD_INFO(type),                                 \
190                 INCLUDE_RBH_INFO(stg_RBH_##info),                       \
191                 INIT_ENTRY(entry),                              \
192         }
193
194 #else
195
196 #define                                                 \
197 INFO_TABLE(info, entry, ptrs, nptrs, type, info_class,  \
198            entry_class, prof_descr, prof_type)          \
199         entry_class(entry);                             \
200         info_class INFO_TBL_CONST StgInfoTable info = { \
201                 layout : { payload : {ptrs,nptrs} },    \
202                 PROF_INFO(prof_type, prof_descr)        \
203                 STD_INFO(type),                         \
204                 INIT_ENTRY(entry),                      \
205         }
206
207 #endif
208
209 /* special selector-thunk info table ---------------------------------------*/
210
211 #if defined(GRAN) || defined(PAR)
212
213 #define                                                         \
214 INFO_TABLE_SELECTOR(info, entry, offset, info_class,            \
215                     entry_class, prof_descr, prof_type)         \
216         entry_class(stg_RBH_##entry);                           \
217         entry_class(entry);                                     \
218         ED_RO_ StgInfoTable info;                               \
219         info_class INFO_TBL_CONST StgInfoTable stg_RBH_##info = {       \
220                 layout : { selector_offset : offset },          \
221                 PROF_INFO(prof_type, prof_descr)                \
222                 STD_INFO(RBH),                                  \
223                 INCLUDE_RBH_INFO(info),                         \
224                 INIT_ENTRY(stg_RBH_##entry),                    \
225         };                                                      \
226         StgFunPtr stg_RBH_##entry (void) {                          \
227           FB_                                                   \
228             JMP_(stg_RBH_entry);                                    \
229           FE_                                                   \
230         } ;                                                     \
231         info_class INFO_TBL_CONST StgInfoTable info = {         \
232                 layout : { selector_offset : offset },          \
233                 PROF_INFO(prof_type, prof_descr)                \
234                 STD_INFO(THUNK_SELECTOR),                       \
235                 INCLUDE_RBH_INFO(stg_RBH_##info),                       \
236                 INIT_ENTRY(entry),                              \
237         }
238
239 #else
240
241 #define                                                 \
242 INFO_TABLE_SELECTOR(info, entry, offset, info_class,    \
243                     entry_class, prof_descr, prof_type) \
244         entry_class(entry);                             \
245         info_class INFO_TBL_CONST StgInfoTable info = { \
246                 layout : { selector_offset : offset },  \
247                 PROF_INFO(prof_type, prof_descr)        \
248                 STD_INFO(THUNK_SELECTOR),               \
249                 INIT_ENTRY(entry),                      \
250         }
251
252 #endif
253
254 /* constructor info table --------------------------------------------------*/
255
256 #define                                                                 \
257 INFO_TABLE_CONSTR(info, entry, ptrs, nptrs, tag_,type_,info_class,      \
258                   entry_class, prof_descr, prof_type)                   \
259         entry_class(entry);                                             \
260         info_class INFO_TBL_CONST StgInfoTable info = {                 \
261                 layout : { payload : {ptrs,nptrs} },                    \
262                 PROF_INFO(prof_type, prof_descr)                        \
263                 CONSTR_INFO(type_,tag_),                                \
264                 INIT_ENTRY(entry),                                      \
265         }
266
267 #define constrTag(con) (get_itbl(con)->srt_len)
268
269 /* return-vectors ----------------------------------------------------------*/
270
271 /* vectored-return info tables have the vector slammed up against the
272  * start of the info table.
273  *
274  * A vectored-return address always has an SRT and a bitmap-style
275  * layout field, so we only need one macro for these.
276  */
277
278 #ifdef TABLES_NEXT_TO_CODE
279
280 typedef struct {
281   StgFunPtr vec[2];
282   StgInfoTable i;
283 } vec_info_2;
284
285 typedef struct {
286   StgFunPtr vec[3];
287   StgInfoTable i;
288 } vec_info_3;
289
290 typedef struct {
291   StgFunPtr vec[4];
292   StgInfoTable i;
293 } vec_info_4;
294
295 typedef struct {
296   StgFunPtr vec[5];
297   StgInfoTable i;
298 } vec_info_5;
299
300 typedef struct {
301   StgFunPtr vec[6];
302   StgInfoTable i;
303 } vec_info_6;
304
305 typedef struct {
306   StgFunPtr vec[7];
307   StgInfoTable i;
308 } vec_info_7;
309
310 typedef struct {
311   StgFunPtr vec[8];
312   StgInfoTable i;
313 } vec_info_8;
314
315 #define VEC_INFO_2(info,bitmap_,srt_,srt_off_,srt_len_,         \
316                    type, info_class,                            \
317                    alt_1, alt_2)                                \
318         info_class INFO_TBL_CONST vec_info_2 info = {           \
319                 { alt_2, alt_1 },                               \
320                 i : {                                           \
321                    layout : { bitmap : (StgWord)bitmap_ },      \
322                    SRT_INFO(type,srt_,srt_off_,srt_len_)        \
323                 }                                               \
324         }
325
326 #define VEC_INFO_3(info,bitmap_,srt_,srt_off_,srt_len_,         \
327                    type, info_class,                            \
328                    alt_1, alt_2, alt_3                          \
329                   )                                             \
330         info_class INFO_TBL_CONST vec_info_3 info = {           \
331                 { alt_3, alt_2, alt_1 },                        \
332                 i : {                                           \
333                    layout : { bitmap : (StgWord)bitmap_ },      \
334                    SRT_INFO(type,srt_,srt_off_,srt_len_)        \
335                 }                                               \
336         }
337
338 #define VEC_INFO_4(info,bitmap_,srt_,srt_off_,srt_len_,         \
339                    type, info_class,                            \
340                    alt_1, alt_2, alt_3, alt_4                   \
341                   )                                             \
342         info_class INFO_TBL_CONST vec_info_4 info = {           \
343                 { alt_4, alt_3, alt_2, alt_1 },                 \
344                 i : {                                           \
345                    layout : { bitmap : (StgWord)bitmap_ },      \
346                    SRT_INFO(type,srt_,srt_off_,srt_len_)        \
347                 }                                               \
348         }
349
350 #define VEC_INFO_5(info,bitmap_,srt_,srt_off_,srt_len_,         \
351                    type, info_class,                            \
352                    alt_1, alt_2, alt_3, alt_4,                  \
353                    alt_5                                        \
354                   )                                             \
355         info_class INFO_TBL_CONST vec_info_5 info = {           \
356                 { alt_5, alt_4, alt_3, alt_2,                   \
357                   alt_1 },                                      \
358                 i : {                                           \
359                    layout : { bitmap : (StgWord)bitmap_ },      \
360                    SRT_INFO(type,srt_,srt_off_,srt_len_)        \
361                 }                                               \
362         }
363
364 #define VEC_INFO_6(info,bitmap_,srt_,srt_off_,srt_len_,         \
365                    type, info_class,                            \
366                    alt_1, alt_2, alt_3, alt_4,                  \
367                    alt_5, alt_6                                 \
368                   )                                             \
369         info_class INFO_TBL_CONST vec_info_6 info = {           \
370                 { alt_6, alt_5, alt_4, alt_3,                   \
371                   alt_2, alt_1 },                               \
372                 i : {                                           \
373                    layout : { bitmap : (StgWord)bitmap_ },      \
374                    SRT_INFO(type,srt_,srt_off_,srt_len_)        \
375                 }                                               \
376         }
377
378 #define VEC_INFO_7(info,bitmap_,srt_,srt_off_,srt_len_,         \
379                    type, info_class,                            \
380                    alt_1, alt_2, alt_3, alt_4,                  \
381                    alt_5, alt_6, alt_7                          \
382                   )                                             \
383         info_class INFO_TBL_CONST vec_info_7 info = {           \
384                 { alt_7, alt_6, alt_5, alt_4,                   \
385                   alt_3, alt_2, alt_1 },                        \
386                 i : {                                           \
387                    layout : { bitmap : (StgWord)bitmap_ },      \
388                    SRT_INFO(type,srt_,srt_off_,srt_len_)        \
389                 }                                               \
390         }
391
392 #define VEC_INFO_8(info,bitmap_,srt_,srt_off_,srt_len_,         \
393                    type, info_class,                            \
394                    alt_1, alt_2, alt_3, alt_4,                  \
395                    alt_5, alt_6, alt_7, alt_8                   \
396                   )                                             \
397         info_class INFO_TBL_CONST vec_info_8 info = {           \
398                 { alt_8, alt_7, alt_6, alt_5,                   \
399                   alt_4, alt_3, alt_2, alt_1 },                 \
400                 i : {                                           \
401                    layout : { bitmap : (StgWord)bitmap_ },      \
402                    SRT_INFO(type,srt_,srt_off_,srt_len_)        \
403                 }                                               \
404         }
405
406
407 #else
408
409 /* We have to define these structure to work around a bug in gcc: if we
410  * try to initialise the vector directly (it's defined as a zero-length
411  * array tacked on the end of the info table structor), then gcc silently
412  * throws away our vector table sometimes.
413  */
414
415 typedef struct {
416   StgInfoTable i;
417   StgFunPtr vec[2];
418 } vec_info_2;
419
420 typedef struct {
421   StgInfoTable i;
422   StgFunPtr vec[3];
423 } vec_info_3;
424
425 typedef struct {
426   StgInfoTable i;
427   StgFunPtr vec[4];
428 } vec_info_4;
429
430 typedef struct {
431   StgInfoTable i;
432   StgFunPtr vec[5];
433 } vec_info_5;
434
435 typedef struct {
436   StgInfoTable i;
437   StgFunPtr vec[6];
438 } vec_info_6;
439
440 typedef struct {
441   StgInfoTable i;
442   StgFunPtr vec[7];
443 } vec_info_7;
444
445 typedef struct {
446   StgInfoTable i;
447   StgFunPtr vec[8];
448 } vec_info_8;
449
450 #define VEC_INFO_2(info,bitmap_,srt_,srt_off_,srt_len_,         \
451                    type, info_class,                            \
452                    alt_1, alt_2)                                \
453         info_class INFO_TBL_CONST vec_info_2 info = {           \
454                 i : { layout : { bitmap : (StgWord)bitmap_ },   \
455                       SRT_INFO(type,srt_,srt_off_,srt_len_),    \
456                       INIT_ENTRY(NULL),                         \
457                 },                                              \
458                 vec : { alt_1, alt_2 }                          \
459         }
460
461 #define VEC_INFO_3(info,bitmap_,srt_,srt_off_,srt_len_,         \
462                    type, info_class,                            \
463                    alt_1, alt_2, alt_3                          \
464                   )                                             \
465         info_class INFO_TBL_CONST vec_info_3 info = {           \
466                 i : { layout : { bitmap : (StgWord)bitmap_ },   \
467                       SRT_INFO(type,srt_,srt_off_,srt_len_),    \
468                       INIT_ENTRY(NULL),                         \
469                 },                                              \
470                 vec : { alt_1, alt_2, alt_3 }                   \
471         }
472
473 #define VEC_INFO_4(info,bitmap_,srt_,srt_off_,srt_len_,         \
474                    type, info_class,                            \
475                    alt_1, alt_2, alt_3, alt_4                   \
476                   )                                             \
477         info_class INFO_TBL_CONST vec_info_4 info = {           \
478                 i : { layout : { bitmap : (StgWord)bitmap_ },   \
479                       SRT_INFO(type,srt_,srt_off_,srt_len_),    \
480                       INIT_ENTRY(NULL),                         \
481                 },                                              \
482                 vec : { alt_1, alt_2, alt_3, alt_4 }            \
483         }
484
485 #define VEC_INFO_5(info,bitmap_,srt_,srt_off_,srt_len_,         \
486                    type, info_class,                            \
487                    alt_1, alt_2, alt_3, alt_4,                  \
488                    alt_5                                        \
489                   )                                             \
490         info_class INFO_TBL_CONST vec_info_5 info = {           \
491                 i : { layout : { bitmap : (StgWord)bitmap_ },   \
492                       SRT_INFO(type,srt_,srt_off_,srt_len_),    \
493                       INIT_ENTRY(NULL),                         \
494                 },                                              \
495                 vec : { alt_1, alt_2, alt_3, alt_4,             \
496                         alt_5 }                                 \
497         }
498
499 #define VEC_INFO_6(info,bitmap_,srt_,srt_off_,srt_len_,         \
500                    type, info_class,                            \
501                    alt_1, alt_2, alt_3, alt_4,                  \
502                    alt_5, alt_6                                 \
503                   )                                             \
504         info_class INFO_TBL_CONST vec_info_6 info = {           \
505                 i : { layout : { bitmap : (StgWord)bitmap_ },   \
506                       SRT_INFO(type,srt_,srt_off_,srt_len_),    \
507                       INIT_ENTRY(NULL),                         \
508                 },                                              \
509                 vec : { alt_1, alt_2, alt_3, alt_4,             \
510                         alt_5, alt_6 }                          \
511         }
512
513 #define VEC_INFO_7(info,bitmap_,srt_,srt_off_,srt_len_,         \
514                    type, info_class,                            \
515                    alt_1, alt_2, alt_3, alt_4,                  \
516                    alt_5, alt_6, alt_7                          \
517                   )                                             \
518         info_class INFO_TBL_CONST vec_info_7 info = {           \
519                 i : { layout : { bitmap : (StgWord)bitmap_ },   \
520                       SRT_INFO(type,srt_,srt_off_,srt_len_),    \
521                       INIT_ENTRY(NULL),                         \
522                 },                                              \
523                 vec : { alt_1, alt_2, alt_3, alt_4,             \
524                         alt_5, alt_6, alt_7 }                   \
525         }
526
527 #define VEC_INFO_8(info,bitmap_,srt_,srt_off_,srt_len_,         \
528                    type, info_class,                            \
529                    alt_1, alt_2, alt_3, alt_4,                  \
530                    alt_5, alt_6, alt_7, alt_8                   \
531                   )                                             \
532         info_class INFO_TBL_CONST vec_info_8 info = {           \
533                 i : { layout : { bitmap : (StgWord)bitmap_ },   \
534                       SRT_INFO(type,srt_,srt_off_,srt_len_),    \
535                       INIT_ENTRY(NULL),                         \
536                 },                                              \
537                 vec : { alt_1, alt_2, alt_3, alt_4,             \
538                         alt_5, alt_6, alt_7, alt_8 }            \
539         }
540
541 #endif /* TABLES_NEXT_TO_CODE */
542
543 /* For polymorphic activation records, we need both a direct return
544  * address and a return vector:
545  */
546
547 typedef vec_info_8 StgPolyInfoTable;
548
549 #ifndef TABLES_NEXT_TO_CODE
550
551 #define VEC_POLY_INFO_TABLE(nm, bitmap_,                        \
552                            srt_, srt_off_, srt_len_,            \
553                            type, info_class, entry_class        \
554                            )                                    \
555   info_class INFO_TBL_CONST vec_info_8 nm##_info = {            \
556                 i : { layout : { bitmap : (StgWord)bitmap_ },   \
557                       SRT_INFO(type,srt_,srt_off_,srt_len_),    \
558                       INIT_ENTRY(nm##_entry),                   \
559                 },                                              \
560                 vec : {                                         \
561                         (F_) nm##_0_entry,                      \
562                         (F_) nm##_1_entry,                      \
563                         (F_) nm##_2_entry,                      \
564                         (F_) nm##_3_entry,                      \
565                         (F_) nm##_4_entry,                      \
566                         (F_) nm##_5_entry,                      \
567                         (F_) nm##_6_entry,                      \
568                         (F_) nm##_7_entry                       \
569                 }                                               \
570             }
571 #else
572
573 #define VEC_POLY_INFO_TABLE(nm, bitmap_,                        \
574                            srt_, srt_off_, srt_len_,            \
575                            type, info_class, entry_class        \
576                            )                                    \
577         info_class INFO_TBL_CONST vec_info_8 nm##_info = {      \
578                 {                                               \
579                         (F_) nm##_7_entry,                      \
580                         (F_) nm##_6_entry,                      \
581                         (F_) nm##_5_entry,                      \
582                         (F_) nm##_4_entry,                      \
583                         (F_) nm##_3_entry,                      \
584                         (F_) nm##_2_entry,                      \
585                         (F_) nm##_1_entry,                      \
586                         (F_) nm##_0_entry                       \
587                 },                                              \
588                 i : {                                           \
589                    layout : { bitmap : (StgWord)bitmap_ },      \
590                    SRT_INFO(type,srt_,srt_off_,srt_len_),       \
591                    INIT_ENTRY(nm##_entry)                       \
592                 }                                               \
593         }
594
595 #endif
596
597 #define SRT(lbl) \
598   static const StgSRT lbl = {
599
600 #define BITMAP(lbl,size,contents) \
601   static const StgLargeBitmap lbl = { \
602       (size*4+SIZEOF_VOID_P-1)/SIZEOF_VOID_P, { contents } };
603
604 #if SIZEOF_VOID_P == 8
605 #define BITMAP_SWITCH64(small, large)   small
606 #define BITMAP64(first, second)         \
607   (((StgWord32)(first)) | ((StgWord)(StgWord32)(second) << 32))
608 #else
609 #define BITMAP_SWITCH64(small, large)   large
610 #define BITMAP64(first, second)         first, second
611 #endif
612 #define BITMAP32(x)                     ((StgWord32)(x))
613 #define COMMA                           ,
614
615 /* DLL_SRT_ENTRY is used on the Win32 side when filling initialising
616    an entry in an SRT table with a reference to a closure that's
617    living in a DLL. See elsewhere for reasons as to why we need
618    to distinguish these kinds of references.
619    (ToDo: fill in a more precise href.)
620 */
621 #ifdef ENABLE_WIN32_DLL_SUPPORT /* mingw DietHEP doesn't seem to care either way */
622 #define DLL_SRT_ENTRY(x) ((StgClosure*)(((char*)&DLL_IMPORT_DATA_VAR(x)) + 1))
623 #else
624 #define DLL_SRT_ENTRY(x) no-can-do
625 #endif
626
627 #endif /* INFOMACROS_H */