1 #if __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409
13 #define offsetof(t, f) ((size_t) &((t *)0)->f)
17 #define hsc_line(line, file) \
18 printf ("# %d \"%s\"\n", line, file);
20 #define hsc_line(line, file) \
21 printf ("{-# LINE %d \"%s\" #-}\n", line, file);
24 #define hsc_const(x) \
26 printf ("%ld", (long)(x)); \
28 printf ("%lu", (unsigned long)(x));
30 #define hsc_const_str(x) \
32 const char *s = (x); \
36 if (*s == '"' || *s == '\\') \
37 printf ("\\%c", *s); \
38 else if (*s >= 0x20 && *s <= 0x7E) \
43 s[1] >= '0' && s[1] <= '9' ? "\\&" : ""); \
50 if ((t)(int)(t)1.4 == (t)1.4) \
52 (t)(-1) < (t)0 ? "Int" : "Word", \
56 sizeof (t) > sizeof (double) ? "LDouble" : \
57 sizeof (t) == sizeof (double) ? "Double" : \
60 #define hsc_peek(t, f) \
61 printf ("(\\hsc_ptr -> peekByteOff hsc_ptr %ld)", (long) offsetof (t, f));
63 #define hsc_poke(t, f) \
64 printf ("(\\hsc_ptr -> pokeByteOff hsc_ptr %ld)", (long) offsetof (t, f));
66 #define hsc_ptr(t, f) \
67 printf ("(\\hsc_ptr -> hsc_ptr `plusPtr` %ld)", (long) offsetof (t, f));
69 #define hsc_offset(t, f) \
70 printf("(%ld)", (long) offsetof (t, f));
73 printf("(%ld)", (long) sizeof(t));
75 #define hsc_enum(t, f, print_name, x) \
77 printf (" :: %s\n", #t); \
79 printf (" = %s ", #f); \
81 printf ("(%ld)\n", (long)(x)); \
83 printf ("%lu\n", (unsigned long)(x));
85 #define hsc_haskellize(x) \
87 const char *s = (x); \
91 putchar (tolower (*s)); \
99 putchar (upper ? toupper (*s) : tolower (*s)); \