[add code to support JGC on windows and OSX
John Meacham <john@repetae.net>**20100719023921
 Ignore-this: ab480a43d9ba2e845782680ab51ec6ae
] hunk ./src/C/FromGrin2.hs 11
-import Text.PrettyPrint.HughesPJ(nest,($$))
+import Text.PrettyPrint.HughesPJ(nest,($$),fsep)
hunk ./src/C/FromGrin2.hs 131
-        --hsffi_h,
-        --wsize_h,
-        --jhc_rts_header_h,
-        --jhc_jgc_h,
-        --jhc_rts_alloc_c,
-        --jhc_rts_c,
-        --jhc_rts2_c,
-        --bitarray_h,
-        --slub_c,
-        --jhc_jgc_c,
hunk ./src/C/FromGrin2.hs 135
-    ans = vcat $ includes ++ jgcs ++ [text "", enum_tag_t, header,cafs, buildConstants cpr grin finalHcHash, body]
-    jgcs = [ text "struct s_cache *" <> tshow (nodeCacheName m) <> char ';' | m <- Set.toList wAllocs]
+    ans = vcat [
+        vcat includes,
+        vcat jgcs,
+        text "",
+        enum_tag_t,
+        header,
+        cafs,
+        buildConstants cpr grin finalHcHash,
+        text "",
+        nh_stuff,
+        text "",
+        body
+        ]
+    jgcs = [ text "static struct s_cache *" <> tshow (nodeCacheName m) <> char ';' | m <- Set.toList wAllocs]
+    nh_stuff = text "static const void *nh_stuff[] = {" $$ fsep (punctuate (char ',') (cafnames ++ constnames ++ [text "NULL"]))  $$ text "};"
hunk ./src/C/FromGrin2.hs 153
+    cafnames = [ text "&_" <> tshow (varName v) | (v,_) <- grinCafs grin ]
+    constnames =  map (\n -> text "&_c" <> tshow n) [ 1 .. length $ Grin.HashConst.toList finalHcHash]
hunk ./src/rts/jhc_jgc.c 28
-static bool
+static void *nh_start, *nh_end;
hunk ./src/rts/jhc_jgc.c 31
-        return (s < &_start || s > &_end);
+        return (s < nh_start || s > nh_end);
hunk ./src/rts/jhc_jgc.c 47
-        s->stack = realloc(s->stack, sizeof(uintptr_t)*s->size);
+        s->stack = realloc(s->stack, sizeof(s->stack[0])*s->size);
hunk ./src/rts/jhc_jgc.c 65
-static void
+A_UNUSED static void
hunk ./src/rts/jhc_jgc.c 205
-static void *
+A_UNUSED static void *
hunk ./src/rts/jhc_jgc.c 218
+static const void *nh_stuff[];
hunk ./src/rts/jhc_jgc.c 220
-#ifdef JHC_JGC_STACK
-static void jhc_alloc_init(void) { }
-#else
hunk ./src/rts/jhc_jgc.c 222
+#ifndef JHC_JGC_STACK
hunk ./src/rts/jhc_jgc.c 224
+#endif
hunk ./src/rts/jhc_jgc.c 226
+        if(nh_stuff[0]) {
+                nh_end = nh_start = nh_stuff[0];
+        }
+        for(int i = 0; nh_stuff[i]; i++) {
+                if(nh_stuff[i] < nh_start)
+                        nh_start = nh_stuff[i];
+                if(nh_stuff[i] > nh_end)
+                        nh_end = nh_stuff[i];
+        }
hunk ./src/rts/jhc_jgc.c 236
-#endif
hunk ./src/rts/jhc_rts2.c 202
-                assert((void *)dhead >= &_start && (void *)dhead < &_end);
+                //assert((void *)dhead >= &_start && (void *)dhead < &_end);
hunk ./src/rts/jhc_rts_header.h 13
+#include <setjmp.h>
hunk ./src/rts/jhc_rts_header.h 20
+#else
+#include <malloc.h>
hunk ./src/rts/jhc_rts_header.h 23
-#include <setjmp.h>
hunk ./src/rts/slub.c 100
-        int ret = posix_memalign(&mb->base,MEGABLOCK_SIZE,MEGABLOCK_SIZE);
+#if defined(__WIN32__)
+        mb->base = _aligned_malloc(MEGABLOCK_SIZE, BLOCK_SIZE);
+        int ret = !mb->base;
+#elif (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <  1060)
+        assert(sysconf(_SC_PAGESIZE) == BLOCK_SIZE);
+        mb->base = valloc(MEGABLOCK_SIZE);
+        int ret = !mb->base;
+#else
+        int ret = posix_memalign(&mb->base,BLOCK_SIZE,MEGABLOCK_SIZE);
+#endif
hunk ./src/rts/slub.c 111
-                fprintf(stderr,"Unable to allocate memory with posix_memalign for megablock\n");
+                fprintf(stderr,"Unable to allocate memory for megablock\n");
hunk ./src/rts/slub.c 248
-
hunk ./src/rts/slub.c 262
-
hunk ./src/rts/slub.c 265
-        struct s_cache *sc = malloc(sizeof(struct s_cache));
+        struct s_cache *sc = malloc(sizeof(*sc));