28377efa9069a1ae55e436ee573f1bd291b46670
[ghc.git] / includes / mkDerivedConstants.c
1 /* --------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1992-2012
4 *
5 * mkDerivedConstants.c
6 *
7 * Basically this is a C program that extracts information from the C
8 * declarations in the header files (primarily struct field offsets)
9 * and generates a header file that can be #included into non-C source
10 * containing this information.
11 *
12 * ------------------------------------------------------------------------*/
13
14 #define IN_STG_CODE 0
15
16 /*
17 * We need offsets of profiled things... better be careful that this
18 * doesn't affect the offsets of anything else.
19 */
20
21 #define PROFILING
22 #define THREADED_RTS
23
24 #include "PosixSource.h"
25 #include "Rts.h"
26 #include "Stable.h"
27 #include "Capability.h"
28
29 #include <inttypes.h>
30 #include <stdio.h>
31 #include <string.h>
32
33 enum Mode { Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haskell_Exports, Gen_Header } mode;
34
35 #define str(a,b) #a "_" #b
36
37 #define OFFSET(s_type, field) ((size_t)&(((s_type*)0)->field))
38 #define FIELD_SIZE(s_type, field) ((size_t)sizeof(((s_type*)0)->field))
39 #define TYPE_SIZE(type) (sizeof(type))
40
41 #pragma GCC poison sizeof
42
43 #define def_offset(str, offset) \
44 switch (mode) { \
45 case Gen_Haskell_Type: \
46 printf(" , pc_OFFSET_" str " :: Int\n"); \
47 break; \
48 case Gen_Haskell_Value: \
49 printf(" , pc_OFFSET_" str " = %" PRIdPTR "\n", (intptr_t)offset); \
50 break; \
51 case Gen_Haskell_Wrappers: \
52 printf("oFFSET_" str " :: DynFlags -> Int\n"); \
53 printf("oFFSET_" str " dflags = pc_OFFSET_" str " (sPlatformConstants (settings dflags))\n"); \
54 break; \
55 case Gen_Haskell_Exports: \
56 printf(" oFFSET_" str ",\n"); \
57 break; \
58 case Gen_Header: \
59 printf("#define OFFSET_" str " %" PRIdPTR "\n", (intptr_t)offset); \
60 break; \
61 }
62
63 #define ctype(type) \
64 switch (mode) { \
65 case Gen_Haskell_Type: \
66 case Gen_Haskell_Value: \
67 case Gen_Haskell_Wrappers: \
68 case Gen_Haskell_Exports: \
69 break; \
70 case Gen_Header: \
71 printf("#define SIZEOF_" #type " %" FMT_SizeT "\n", \
72 (size_t)TYPE_SIZE(type)); \
73 break; \
74 }
75
76 /* Defining REP_x to be b32 etc
77 These are both the C-- types used in a load
78 e.g. b32[addr]
79 and the names of the CmmTypes in the compiler
80 b32 :: CmmType
81 */
82 #define field_type_(str, s_type, field) \
83 switch (mode) { \
84 case Gen_Haskell_Type: \
85 case Gen_Haskell_Value: \
86 case Gen_Haskell_Wrappers: \
87 case Gen_Haskell_Exports: \
88 break; \
89 case Gen_Header: \
90 printf("#define REP_" str " b"); \
91 printf("%" FMT_SizeT "\n", FIELD_SIZE(s_type, field) * 8); \
92 break; \
93 }
94
95 #define field_type_gcptr_(str, s_type, field) \
96 switch (mode) { \
97 case Gen_Haskell_Type: \
98 case Gen_Haskell_Value: \
99 case Gen_Haskell_Wrappers: \
100 case Gen_Haskell_Exports: \
101 break; \
102 case Gen_Header: \
103 printf("#define REP_" str " gcptr\n"); \
104 break; \
105 }
106
107 #define field_type(s_type, field) \
108 field_type_(str(s_type,field),s_type,field);
109
110 #define field_offset_(str, s_type, field) \
111 def_offset(str, OFFSET(s_type,field));
112
113 #define field_offset(s_type, field) \
114 field_offset_(str(s_type,field),s_type,field);
115
116 /* An access macro for use in C-- sources. */
117 #define struct_field_macro(str) \
118 switch (mode) { \
119 case Gen_Haskell_Type: \
120 case Gen_Haskell_Value: \
121 case Gen_Haskell_Wrappers: \
122 case Gen_Haskell_Exports: \
123 break; \
124 case Gen_Header: \
125 printf("#define " str "(__ptr__) REP_" str "[__ptr__+OFFSET_" str "]\n"); \
126 break; \
127 }
128
129 /* Outputs the byte offset and MachRep for a field */
130 #define struct_field(s_type, field) \
131 field_offset(s_type, field); \
132 field_type(s_type, field); \
133 struct_field_macro(str(s_type,field))
134
135 #define struct_field_(str, s_type, field) \
136 field_offset_(str, s_type, field); \
137 field_type_(str, s_type, field); \
138 struct_field_macro(str)
139
140 #define def_size(str, size) \
141 switch (mode) { \
142 case Gen_Haskell_Type: \
143 printf(" , pc_SIZEOF_" str " :: Int\n"); \
144 break; \
145 case Gen_Haskell_Value: \
146 printf(" , pc_SIZEOF_" str " = %" FMT_SizeT "\n", (size_t)size); \
147 break; \
148 case Gen_Haskell_Wrappers: \
149 printf("sIZEOF_" str " :: DynFlags -> Int\n"); \
150 printf("sIZEOF_" str " dflags = pc_SIZEOF_" str " (sPlatformConstants (settings dflags))\n"); \
151 break; \
152 case Gen_Haskell_Exports: \
153 printf(" sIZEOF_" str ",\n"); \
154 break; \
155 case Gen_Header: \
156 printf("#define SIZEOF_" str " %" FMT_SizeT "\n", (size_t)size); \
157 break; \
158 }
159
160 #define def_closure_size(str, size) \
161 switch (mode) { \
162 case Gen_Haskell_Type: \
163 case Gen_Haskell_Value: \
164 case Gen_Haskell_Wrappers: \
165 case Gen_Haskell_Exports: \
166 break; \
167 case Gen_Header: \
168 printf("#define SIZEOF_" str " (SIZEOF_StgHeader+%" FMT_SizeT ")\n", (size_t)size); \
169 break; \
170 }
171
172 #define struct_size(s_type) \
173 def_size(#s_type, TYPE_SIZE(s_type));
174
175 /*
176 * Size of a closure type, minus the header, named SIZEOF_<type>_NoHdr
177 * Also, we #define SIZEOF_<type> to be the size of the whole closure for .cmm.
178 */
179 #define closure_size(s_type) \
180 def_size(#s_type "_NoHdr", TYPE_SIZE(s_type) - TYPE_SIZE(StgHeader)); \
181 def_closure_size(#s_type, TYPE_SIZE(s_type) - TYPE_SIZE(StgHeader));
182
183 #define thunk_size(s_type) \
184 def_size(#s_type "_NoThunkHdr", TYPE_SIZE(s_type) - TYPE_SIZE(StgThunkHeader)); \
185 closure_size(s_type)
186
187 /* An access macro for use in C-- sources. */
188 #define closure_field_macro(str) \
189 switch (mode) { \
190 case Gen_Haskell_Type: \
191 case Gen_Haskell_Value: \
192 case Gen_Haskell_Wrappers: \
193 case Gen_Haskell_Exports: \
194 break; \
195 case Gen_Header: \
196 printf("#define " str "(__ptr__) REP_" str "[__ptr__+SIZEOF_StgHeader+OFFSET_" str "]\n"); \
197 break; \
198 }
199
200 #define closure_field_offset_(str, s_type,field) \
201 def_offset(str, OFFSET(s_type,field) - TYPE_SIZE(StgHeader));
202
203 #define closure_field_offset(s_type,field) \
204 closure_field_offset_(str(s_type,field),s_type,field)
205
206 #define closure_payload_macro(str) \
207 switch (mode) { \
208 case Gen_Haskell_Type: \
209 case Gen_Haskell_Value: \
210 case Gen_Haskell_Wrappers: \
211 case Gen_Haskell_Exports: \
212 break; \
213 case Gen_Header: \
214 printf("#define " str "(__ptr__,__ix__) W_[__ptr__+SIZEOF_StgHeader+OFFSET_" str " + WDS(__ix__)]\n"); \
215 break; \
216 }
217
218 #define closure_payload(s_type,field) \
219 closure_field_offset_(str(s_type,field),s_type,field); \
220 closure_payload_macro(str(s_type,field));
221
222 /* Byte offset and MachRep for a closure field, minus the header */
223 #define closure_field_(str, s_type, field) \
224 closure_field_offset_(str,s_type,field) \
225 field_type_(str, s_type, field); \
226 closure_field_macro(str)
227
228 #define closure_field(s_type, field) \
229 closure_field_(str(s_type,field),s_type,field)
230
231 /* Byte offset and MachRep for a closure field, minus the header */
232 #define closure_field_gcptr_(str, s_type, field) \
233 closure_field_offset_(str,s_type,field) \
234 field_type_gcptr_(str, s_type, field); \
235 closure_field_macro(str)
236
237 #define closure_field_gcptr(s_type, field) \
238 closure_field_gcptr_(str(s_type,field),s_type,field)
239
240 /* Byte offset for a TSO field, minus the header and variable prof bit. */
241 #define tso_payload_offset(s_type, field) \
242 def_offset(str(s_type,field), OFFSET(s_type,field) - TYPE_SIZE(StgHeader) - TYPE_SIZE(StgTSOProfInfo));
243
244 /* Full byte offset for a TSO field, for use from Cmm */
245 #define tso_field_offset_macro(str) \
246 switch (mode) { \
247 case Gen_Haskell_Type: \
248 case Gen_Haskell_Value: \
249 case Gen_Haskell_Wrappers: \
250 case Gen_Haskell_Exports: \
251 break; \
252 case Gen_Header: \
253 printf("#define TSO_OFFSET_" str " (SIZEOF_StgHeader+SIZEOF_OPT_StgTSOProfInfo+OFFSET_" str ")\n"); \
254 break; \
255 }
256
257 #define tso_field_offset(s_type, field) \
258 tso_payload_offset(s_type, field); \
259 tso_field_offset_macro(str(s_type,field));
260
261 #define tso_field_macro(str) \
262 switch (mode) { \
263 case Gen_Haskell_Type: \
264 case Gen_Haskell_Value: \
265 case Gen_Haskell_Wrappers: \
266 case Gen_Haskell_Exports: \
267 break; \
268 case Gen_Header: \
269 printf("#define " str "(__ptr__) REP_" str "[__ptr__+TSO_OFFSET_" str "]\n") \
270 break; \
271 }
272
273 #define tso_field(s_type, field) \
274 field_type(s_type, field); \
275 tso_field_offset(s_type,field); \
276 tso_field_macro(str(s_type,field))
277
278 #define opt_struct_size(s_type, option) \
279 switch (mode) { \
280 case Gen_Haskell_Type: \
281 case Gen_Haskell_Value: \
282 case Gen_Haskell_Wrappers: \
283 case Gen_Haskell_Exports: \
284 break; \
285 case Gen_Header: \
286 printf("#ifdef " #option "\n"); \
287 printf("#define SIZEOF_OPT_" #s_type " SIZEOF_" #s_type "\n"); \
288 printf("#else\n"); \
289 printf("#define SIZEOF_OPT_" #s_type " 0\n"); \
290 printf("#endif\n\n"); \
291 break; \
292 }
293
294 #define FUN_OFFSET(sym) (OFFSET(Capability,f.sym) - OFFSET(Capability,r))
295
296 void constantInt(char *name, intptr_t val) {
297 /* If the value is larger than 2^28 or smaller than -2^28, then fail.
298 This test is a bit conservative, but if any constants are roughly
299 maxBoun or minBound then we probably need them to be Integer
300 rather than Int so that cross-compiling between 32bit and 64bit
301 platforms works. */
302 if (val > 268435456) {
303 printf("Value too large for constantInt: %" PRIdPTR "\n", val);
304 exit(1);
305 }
306 if (val < -268435456) {
307 printf("Value too small for constantInt: %" PRIdPTR "\n", val);
308 exit(1);
309 }
310
311 switch (mode) {
312 case Gen_Haskell_Type:
313 printf(" , pc_%s :: Int\n", name);
314 break;
315 case Gen_Haskell_Value:
316 printf(" , pc_%s = %" PRIdPTR "\n", name, val);
317 break;
318 case Gen_Haskell_Wrappers:
319 printf("%s :: DynFlags -> Int\n", name);
320 printf("%s dflags = pc_%s (sPlatformConstants (settings dflags))\n",
321 name, name);
322 break;
323 case Gen_Haskell_Exports:
324 printf(" %s,\n", name);
325 break;
326 case Gen_Header:
327 break;
328 }
329 }
330
331 int
332 main(int argc, char *argv[])
333 {
334 if (argc == 1) {
335 mode = Gen_Header;
336 }
337 else if (argc == 2) {
338 if (0 == strcmp("--gen-haskell-type", argv[1])) {
339 mode = Gen_Haskell_Type;
340 }
341 else if (0 == strcmp("--gen-haskell-value", argv[1])) {
342 mode = Gen_Haskell_Value;
343 }
344 else if (0 == strcmp("--gen-haskell-wrappers", argv[1])) {
345 mode = Gen_Haskell_Wrappers;
346 }
347 else if (0 == strcmp("--gen-haskell-exports", argv[1])) {
348 mode = Gen_Haskell_Exports;
349 }
350 else {
351 printf("Bad args\n");
352 exit(1);
353 }
354 }
355 else {
356 printf("Bad args\n");
357 exit(1);
358 }
359
360 switch (mode) {
361 case Gen_Haskell_Type:
362 printf("data PlatformConstants = PlatformConstants {\n");
363 /* Now a kludge that allows the real entries to all start with a
364 comma, which makes life a little easier */
365 printf(" pc_platformConstants :: ()\n");
366 break;
367 case Gen_Haskell_Value:
368 printf("PlatformConstants {\n");
369 printf(" pc_platformConstants = ()\n");
370 break;
371 case Gen_Haskell_Wrappers:
372 case Gen_Haskell_Exports:
373 break;
374 case Gen_Header:
375 printf("/* This file is created automatically. Do not edit by hand.*/\n\n");
376
377 printf("#define STD_HDR_SIZE %" FMT_SizeT "\n", (size_t)sizeofW(StgHeader) - sizeofW(StgProfHeader));
378 /* grrr.. PROFILING is on so we need to subtract sizeofW(StgProfHeader) */
379 printf("#define PROF_HDR_SIZE %" FMT_SizeT "\n", (size_t)sizeofW(StgProfHeader));
380
381 printf("#define BLOCK_SIZE %u\n", BLOCK_SIZE);
382 printf("#define MBLOCK_SIZE %u\n", MBLOCK_SIZE);
383 printf("#define BLOCKS_PER_MBLOCK %" FMT_Word "\n", (W_)BLOCKS_PER_MBLOCK);
384 // could be derived, but better to save doing the calculation twice
385
386 printf("\n\n");
387 break;
388 }
389
390 field_offset(StgRegTable, rR1);
391 field_offset(StgRegTable, rR2);
392 field_offset(StgRegTable, rR3);
393 field_offset(StgRegTable, rR4);
394 field_offset(StgRegTable, rR5);
395 field_offset(StgRegTable, rR6);
396 field_offset(StgRegTable, rR7);
397 field_offset(StgRegTable, rR8);
398 field_offset(StgRegTable, rR9);
399 field_offset(StgRegTable, rR10);
400 field_offset(StgRegTable, rF1);
401 field_offset(StgRegTable, rF2);
402 field_offset(StgRegTable, rF3);
403 field_offset(StgRegTable, rF4);
404 field_offset(StgRegTable, rD1);
405 field_offset(StgRegTable, rD2);
406 field_offset(StgRegTable, rL1);
407 field_offset(StgRegTable, rSp);
408 field_offset(StgRegTable, rSpLim);
409 field_offset(StgRegTable, rHp);
410 field_offset(StgRegTable, rHpLim);
411 field_offset(StgRegTable, rCCCS);
412 field_offset(StgRegTable, rCurrentTSO);
413 field_offset(StgRegTable, rCurrentNursery);
414 field_offset(StgRegTable, rHpAlloc);
415 struct_field(StgRegTable, rRet);
416 struct_field(StgRegTable, rNursery);
417
418 def_offset("stgEagerBlackholeInfo", FUN_OFFSET(stgEagerBlackholeInfo));
419 def_offset("stgGCEnter1", FUN_OFFSET(stgGCEnter1));
420 def_offset("stgGCFun", FUN_OFFSET(stgGCFun));
421
422 field_offset(Capability, r);
423 field_offset(Capability, lock);
424 struct_field(Capability, no);
425 struct_field(Capability, mut_lists);
426 struct_field(Capability, context_switch);
427 struct_field(Capability, interrupt);
428 struct_field(Capability, sparks);
429
430 struct_field(bdescr, start);
431 struct_field(bdescr, free);
432 struct_field(bdescr, blocks);
433 struct_field(bdescr, gen_no);
434 struct_field(bdescr, link);
435
436 struct_size(generation);
437 struct_field(generation, n_new_large_words);
438
439 struct_size(CostCentreStack);
440 struct_field(CostCentreStack, ccsID);
441 struct_field(CostCentreStack, mem_alloc);
442 struct_field(CostCentreStack, scc_count);
443 struct_field(CostCentreStack, prevStack);
444
445 struct_field(CostCentre, ccID);
446 struct_field(CostCentre, link);
447
448 struct_field(StgHeader, info);
449 struct_field_("StgHeader_ccs", StgHeader, prof.ccs);
450 struct_field_("StgHeader_ldvw", StgHeader, prof.hp.ldvw);
451
452 struct_size(StgSMPThunkHeader);
453
454 closure_payload(StgClosure,payload);
455
456 struct_field(StgEntCounter, allocs);
457 struct_field(StgEntCounter, registeredp);
458 struct_field(StgEntCounter, link);
459 struct_field(StgEntCounter, entry_count);
460
461 closure_size(StgUpdateFrame);
462 closure_size(StgCatchFrame);
463 closure_size(StgStopFrame);
464
465 closure_size(StgMutArrPtrs);
466 closure_field(StgMutArrPtrs, ptrs);
467 closure_field(StgMutArrPtrs, size);
468
469 closure_size(StgArrWords);
470 closure_field(StgArrWords, bytes);
471 closure_payload(StgArrWords, payload);
472
473 closure_field(StgTSO, _link);
474 closure_field(StgTSO, global_link);
475 closure_field(StgTSO, what_next);
476 closure_field(StgTSO, why_blocked);
477 closure_field(StgTSO, block_info);
478 closure_field(StgTSO, blocked_exceptions);
479 closure_field(StgTSO, id);
480 closure_field(StgTSO, cap);
481 closure_field(StgTSO, saved_errno);
482 closure_field(StgTSO, trec);
483 closure_field(StgTSO, flags);
484 closure_field(StgTSO, dirty);
485 closure_field(StgTSO, bq);
486 closure_field_("StgTSO_cccs", StgTSO, prof.cccs);
487 closure_field(StgTSO, stackobj);
488
489 closure_field(StgStack, sp);
490 closure_field_offset(StgStack, stack);
491 closure_field(StgStack, stack_size);
492 closure_field(StgStack, dirty);
493
494 struct_size(StgTSOProfInfo);
495
496 opt_struct_size(StgTSOProfInfo,PROFILING);
497
498 closure_field(StgUpdateFrame, updatee);
499
500 closure_field(StgCatchFrame, handler);
501 closure_field(StgCatchFrame, exceptions_blocked);
502
503 closure_size(StgPAP);
504 closure_field(StgPAP, n_args);
505 closure_field_gcptr(StgPAP, fun);
506 closure_field(StgPAP, arity);
507 closure_payload(StgPAP, payload);
508
509 thunk_size(StgAP);
510 closure_field(StgAP, n_args);
511 closure_field_gcptr(StgAP, fun);
512 closure_payload(StgAP, payload);
513
514 thunk_size(StgAP_STACK);
515 closure_field(StgAP_STACK, size);
516 closure_field_gcptr(StgAP_STACK, fun);
517 closure_payload(StgAP_STACK, payload);
518
519 thunk_size(StgSelector);
520
521 closure_field_gcptr(StgInd, indirectee);
522
523 closure_size(StgMutVar);
524 closure_field(StgMutVar, var);
525
526 closure_size(StgAtomicallyFrame);
527 closure_field(StgAtomicallyFrame, code);
528 closure_field(StgAtomicallyFrame, next_invariant_to_check);
529 closure_field(StgAtomicallyFrame, result);
530
531 closure_field(StgInvariantCheckQueue, invariant);
532 closure_field(StgInvariantCheckQueue, my_execution);
533 closure_field(StgInvariantCheckQueue, next_queue_entry);
534
535 closure_field(StgAtomicInvariant, code);
536
537 closure_field(StgTRecHeader, enclosing_trec);
538
539 closure_size(StgCatchSTMFrame);
540 closure_field(StgCatchSTMFrame, handler);
541 closure_field(StgCatchSTMFrame, code);
542
543 closure_size(StgCatchRetryFrame);
544 closure_field(StgCatchRetryFrame, running_alt_code);
545 closure_field(StgCatchRetryFrame, first_code);
546 closure_field(StgCatchRetryFrame, alt_code);
547
548 closure_field(StgTVarWatchQueue, closure);
549 closure_field(StgTVarWatchQueue, next_queue_entry);
550 closure_field(StgTVarWatchQueue, prev_queue_entry);
551
552 closure_field(StgTVar, current_value);
553
554 closure_size(StgWeak);
555 closure_field(StgWeak,link);
556 closure_field(StgWeak,key);
557 closure_field(StgWeak,value);
558 closure_field(StgWeak,finalizer);
559 closure_field(StgWeak,cfinalizer);
560
561 closure_size(StgDeadWeak);
562 closure_field(StgDeadWeak,link);
563
564 closure_size(StgMVar);
565 closure_field(StgMVar,head);
566 closure_field(StgMVar,tail);
567 closure_field(StgMVar,value);
568
569 closure_size(StgMVarTSOQueue);
570 closure_field(StgMVarTSOQueue, link);
571 closure_field(StgMVarTSOQueue, tso);
572
573 closure_size(StgBCO);
574 closure_field(StgBCO, instrs);
575 closure_field(StgBCO, literals);
576 closure_field(StgBCO, ptrs);
577 closure_field(StgBCO, arity);
578 closure_field(StgBCO, size);
579 closure_payload(StgBCO, bitmap);
580
581 closure_size(StgStableName);
582 closure_field(StgStableName,sn);
583
584 closure_size(StgBlockingQueue);
585 closure_field(StgBlockingQueue, bh);
586 closure_field(StgBlockingQueue, owner);
587 closure_field(StgBlockingQueue, queue);
588 closure_field(StgBlockingQueue, link);
589
590 closure_size(MessageBlackHole);
591 closure_field(MessageBlackHole, link);
592 closure_field(MessageBlackHole, tso);
593 closure_field(MessageBlackHole, bh);
594
595 struct_field_("RtsFlags_ProfFlags_showCCSOnException",
596 RTS_FLAGS, ProfFlags.showCCSOnException);
597 struct_field_("RtsFlags_DebugFlags_apply",
598 RTS_FLAGS, DebugFlags.apply);
599 struct_field_("RtsFlags_DebugFlags_sanity",
600 RTS_FLAGS, DebugFlags.sanity);
601 struct_field_("RtsFlags_DebugFlags_weak",
602 RTS_FLAGS, DebugFlags.weak);
603 struct_field_("RtsFlags_GcFlags_initialStkSize",
604 RTS_FLAGS, GcFlags.initialStkSize);
605 struct_field_("RtsFlags_MiscFlags_tickInterval",
606 RTS_FLAGS, MiscFlags.tickInterval);
607
608 struct_size(StgFunInfoExtraFwd);
609 struct_field(StgFunInfoExtraFwd, slow_apply);
610 struct_field(StgFunInfoExtraFwd, fun_type);
611 struct_field(StgFunInfoExtraFwd, arity);
612 struct_field_("StgFunInfoExtraFwd_bitmap", StgFunInfoExtraFwd, b.bitmap);
613
614 struct_size(StgFunInfoExtraRev);
615 struct_field(StgFunInfoExtraRev, slow_apply_offset);
616 struct_field(StgFunInfoExtraRev, fun_type);
617 struct_field(StgFunInfoExtraRev, arity);
618 struct_field_("StgFunInfoExtraRev_bitmap", StgFunInfoExtraRev, b.bitmap);
619
620 struct_field(StgLargeBitmap, size);
621 field_offset(StgLargeBitmap, bitmap);
622
623 struct_size(snEntry);
624 struct_field(snEntry,sn_obj);
625 struct_field(snEntry,addr);
626
627 #ifdef mingw32_HOST_OS
628 /* Note that this conditional part only affects the C headers.
629 That's important, as it means we get the same PlatformConstants
630 type on all platforms. */
631 if (mode == Gen_Header) {
632 struct_size(StgAsyncIOResult);
633 struct_field(StgAsyncIOResult, reqID);
634 struct_field(StgAsyncIOResult, len);
635 struct_field(StgAsyncIOResult, errCode);
636 }
637 #endif
638
639 // pre-compiled thunk types
640 constantInt("mAX_SPEC_SELECTEE_SIZE", MAX_SPEC_SELECTEE_SIZE);
641 constantInt("mAX_SPEC_AP_SIZE", MAX_SPEC_AP_SIZE);
642
643 switch (mode) {
644 case Gen_Haskell_Type:
645 printf(" } deriving (Read, Show)\n");
646 break;
647 case Gen_Haskell_Value:
648 printf(" }\n");
649 break;
650 case Gen_Haskell_Wrappers:
651 case Gen_Haskell_Exports:
652 case Gen_Header:
653 break;
654 }
655
656 return 0;
657 }