[move jhc_rts_alloc to gc_none
John Meacham <john@repetae.net>**20120213100906
 Ignore-this: 1c2e9028d72127acd5a448971266f627
] move ./rts/jhc_rts_alloc.c ./rts/rts/gc_none.c
hunk ./Makefile.am 116
-	   rts/rts/rts_support.h rts/rts/gc.h
+	   rts/rts/rts_support.h rts/rts/gc.h rts/rts/gc_none.c rts/rts/gc_none.h
hunk ./Makefile.am 118
-RTSFILES = rts/jhc_rts_header.h \
-	   rts/jhc_rts_alloc.c rts/jhc_rts.c rts/jhc_rts2.c \
-	   rts/lib/lib_cbits.c
+RTSFILES = rts/jhc_rts_header.h rts/jhc_rts2.c rts/lib/lib_cbits.c
hunk ./rts/HsFFI.h 10
-
hunk ./rts/debug.c 1
-#if JHC_VALGRIND
-#include <valgrind/valgrind.h>
-#include <valgrind/memcheck.h>
-#else
-#define VALGRIND_MAKE_MEM_UNDEFINED(x,y) \
-    do { } while (0)
-#define VALGRIND_MAKE_MEM_DEFINED(x,y) \
-    do { } while (0)
-#define VALGRIND_MAKE_MEM_NOACCESS(x,y) \
-    do { } while (0)
-#define VALGRIND_PRINTF(...) \
-    do { } while (0)
-#endif
-
-#if JHC_MEM_ANNOTATE && _JHC_GC == _JHC_GC_JGC
-#include <Judy.h>
-
-static Pvoid_t mem_annotate = NULL;
-
-#define XSTR(x) #x
-#define STR(x) XSTR(x)
-#define gc_alloc(gc,sc,c,nptrs) \
-    gc_alloc_annot(gc,sc,c,nptrs,(__FILE__ ":" STR(__LINE__)))
-
-A_UNUSED static void *
-gc_alloc_annot(gc_t gc,struct s_cache **sc, unsigned count, unsigned nptrs, char *str)
-{
-        void *ret = (gc_alloc)(gc,sc,count,nptrs);
-        PWord_t pval;
-        JLI(pval,mem_annotate,(Word_t)ret);
-        *pval = (Word_t)str;
-        return ret;
-}
-
-char *
-gc_lookup(void *ptr)
-{
-        PWord_t pval;
-        JLG(pval,mem_annotate,(Word_t)ptr & ~(Word_t)3);
-        return pval ? (char *)*pval : "(none)";
-}
-
-#endif
rmfile ./rts/debug.c
hunk ./rts/jhc_rts.c 1
-#if _JHC_STANDALONE
-int
-main(int argc, char *argv[])
-{
-        hs_init(&argc,&argv);
-        if (jhc_setjmp(&jhc_uncaught))
-                jhc_error("Uncaught Exception");
-        else
-                _amain();
-        hs_exit();
-        return 0;
-}
-#endif
rmfile ./rts/jhc_rts.c
hunk ./rts/jhc_rts2.c 293
+#if _JHC_STANDALONE
+int
+main(int argc, char *argv[])
+{
+        hs_init(&argc,&argv);
+        if (jhc_setjmp(&jhc_uncaught))
+                jhc_error("Uncaught Exception");
+        else
+                _amain();
+        hs_exit();
+        return 0;
+}
+#endif
+
hunk ./rts/jhc_rts_header.h 32
-#define _JHC_GC_NONE   0
-#define _JHC_GC_JGC    1
-#define _JHC_GC_BOEHM  2
-#define _JHC_GC_REGION 3
-
-#ifndef _JHC_GC
-#define _JHC_GC _JHC_GC_NONE
-#endif
-
hunk ./rts/jhc_rts_header.h 48
-#define M_ALIGN(a,n) ((n) - 1 + ((a) - ((n) - 1) % (a)))
-
hunk ./rts/rts/gc.h 4
+#define _JHC_GC_NONE   0
+#define _JHC_GC_JGC    1
+#define _JHC_GC_BOEHM  2
+#define _JHC_GC_REGION 3
+
+#ifndef _JHC_GC
+#define _JHC_GC _JHC_GC_NONE
+#endif
+
hunk ./rts/rts/gc.h 17
+#include "rts/gc_none.h"
+
hunk ./rts/rts/gc_jgc.c 270
+A_UNUSED static void *
+(gc_alloc)(gc_t gc,struct s_cache **sc, unsigned count, unsigned nptrs)
+{
+        profile_push(&gc_alloc_time);
+        if (JHC_STATUS)
+                number_allocs++;
+        assert(nptrs <= count);
+        entry_t *e = s_alloc(gc, find_cache(sc, arena, count, nptrs));
+        VALGRIND_MAKE_MEM_UNDEFINED(e,sizeof(uintptr_t)*count);
+        debugf("allocated: %p %i %i\n",(void *)e, count, nptrs);
+        profile_pop(&gc_alloc_time);
+        return (void *)e;
+}
+
hunk ./rts/rts/gc_none.c 1
-#define jhc_malloc_whnf jhc_malloc
-#define jhc_malloc_suspension jhc_malloc
-#define jhc_malloc_atomic jhc_malloc
-#define jhc_malloc_atomic_whnf jhc_malloc_atomic
-#define jhc_malloc_sanity(p,t) (1)
-
-#ifdef JHC_ALLOC_NEEDS_STUBS
-void hs_perform_gc(void) {}
-void hs_free_stable_ptr(HsStablePtr sp) {}
-void hs_free_fun_ptr(HsFunPtr fp) {}
-#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include "rts/gc.h"
+#include "rts/profile.h"
hunk ./rts/rts/gc_none.c 8
-#include <gc/gc.h>
-
-#define jhc_malloc GC_malloc
-#undef  jhc_malloc_atomic
-#define jhc_malloc_atomic GC_malloc_atomic
-#define jhc_free GC_free
+void hs_perform_gc(void) {
+        GC_gcollect();
+}
hunk ./rts/rts/gc_none.c 12
-static void jhc_alloc_init(void) { GC_INIT(); }
-static void jhc_alloc_fini(void) { }
-static void jhc_alloc_print_stats(void) { }
+void jhc_alloc_init(void) { GC_INIT(); }
+void jhc_alloc_fini(void) { }
+void jhc_alloc_print_stats(void) { }
hunk ./rts/rts/gc_none.c 26
-static void jhc_alloc_init(void) {}
-static void jhc_alloc_fini(void) {}
+void jhc_alloc_init(void) {}
+void jhc_alloc_fini(void) {}
hunk ./rts/rts/gc_none.c 29
-static void
+void
hunk ./rts/rts/gc_none.c 47
+#define M_ALIGN(a,n) ((n) - 1 + ((a) - ((n) - 1) % (a)))
+
hunk ./rts/rts/gc_none.c 61
-#define jhc_malloc(n) jhc_malloc_debug(n,__LINE__,0)
-#undef jhc_malloc_atomic
-#define jhc_malloc_atomic(n) jhc_malloc_debug(n,__LINE__,1)
-
-static void * A_MALLOC
+void * A_MALLOC
hunk ./rts/rts/gc_none.c 71
-static inline void * A_MALLOC
+void * A_MALLOC
hunk ./rts/rts/gc_none.c 78
-static inline void * A_MALLOC
+void * A_MALLOC
addfile ./rts/rts/gc_none.h
hunk ./rts/rts/gc_none.h 1
+#ifndef GC_NONE_H
+#define GC_NONE_H
+
+#include <stddef.h>
+#include "rts/cdefs.h"
+
+#define jhc_malloc_sanity(p,t) (1)
+
+#if _JHC_GC == _JHC_GC_BOEHM
+
+#include "rts/profile.h"
+
+#include <gc/gc.h>
+
+#define jhc_malloc GC_malloc
+#define jhc_malloc_atomic GC_malloc_atomic
+
+#elif _JHC_GC == _JHC_GC_NONE
+
+#if _JHC_DEBUG
+void * A_MALLOC jhc_malloc_debug(size_t n,int line,int atomic);
+#define jhc_malloc(n) jhc_malloc_debug(n,__LINE__,0)
+#define jhc_malloc_atomic(n) jhc_malloc_debug(n,__LINE__,1)
+#else
+void * A_MALLOC jhc_malloc(size_t n);
+void * A_MALLOC jhc_malloc_atomic(size_t n);
+#endif
+
+#endif
+
+#endif
hunk ./rts/rts/profile.c 23
+#if  defined(__WIN32__) || defined(__ARM_EABI__)
+struct tms {};
+#endif
hunk ./rts/rts/profile.c 62
-#ifndef __WIN32__
-        struct tms tm;
-        times(&tm);
-#endif
hunk ./rts/rts/profile.c 63
-
hunk ./rts/rts/profile.c 69
+#ifndef __WIN32__
+        struct tms tm;
+        times(&tm);
hunk ./rts/rts/profile.c 73
+#endif
hunk ./rts/rts/profile.c 107
+#endif
+
+#if JHC_MEM_ANNOTATE && _JHC_GC == _JHC_GC_JGC
+#include <Judy.h>
+
+static Pvoid_t mem_annotate = NULL;
+
+#define XSTR(x) #x
+#define STR(x) XSTR(x)
+#define gc_alloc(gc,sc,c,nptrs) \
+    gc_alloc_annot(gc,sc,c,nptrs,(__FILE__ ":" STR(__LINE__)))
+
+A_UNUSED static void *
+gc_alloc_annot(gc_t gc,struct s_cache **sc, unsigned count, unsigned nptrs, char *str)
+{
+        void *ret = (gc_alloc)(gc,sc,count,nptrs);
+        PWord_t pval;
+        JLI(pval,mem_annotate,(Word_t)ret);
+        *pval = (Word_t)str;
+        return ret;
+}
+
+char *
+gc_lookup(void *ptr)
+{
+        PWord_t pval;
+        JLG(pval,mem_annotate,(Word_t)ptr & ~(Word_t)3);
+        return pval ? (char *)*pval : "(none)";
+}
+
hunk ./rts/rts/slub.c 7
-static void *s_alloc(gc_t gc, struct s_cache *sc);
+static void *s_alloc(gc_t gc, struct s_cache *sc) A_UNUSED;
hunk ./rts/rts/slub.c 9
-                                  unsigned short size, unsigned short num_ptrs);
-static bool s_set_used_bit(void *val);
-static void clear_used_bits(struct s_arena *arena);
+                                  unsigned short size, unsigned short num_ptrs) A_UNUSED;
+static bool s_set_used_bit(void *val) A_UNUSED;
+static void clear_used_bits(struct s_arena *arena) A_UNUSED;
hunk ./rts/rts/stableptr.c 29
+void hs_free_stable_ptr(HsStablePtr sp) {
+        c_freeStablePtr((HsStablePtr)sp);
+}
+void hs_free_fun_ptr(HsFunPtr fp) {}
+
hunk ./rts/sys/queue.h 146
-
hunk ./rts/sys/queue.h 206
-
hunk ./rts/sys/queue.h 287
-
hunk ./rts/sys/queue.h 360
-
hunk ./rts/sys/queue.h 462
-
hunk ./rts/test/seatest.c 21
-
-
hunk ./rts/test/seatest.c 94
-
hunk ./rts/test/seatest.c 177
-
hunk ./rts/test/seatest.c 203
-
hunk ./rts/test/seatest.c 208
-
hunk ./rts/test/seatest.c 242
-
hunk ./src/C/FromGrin2.hs 645
-            _ -> [text ".what =" <+> text "SET_RAW_TAG(" <> tshow (nodeTagName a) <> text ")"]
+            _ -> [text ".what =" <+> text "(what_t)SET_RAW_TAG(" <> tshow (nodeTagName a) <> text ")"]
hunk ./src/Grin/Main.hs 112
+           ("rts/gc_none.c",gc_none_c),
+           ("rts/gc_none.h",gc_none_h),
hunk ./src/Grin/Main.hs 116
-    let cFiles = ["rts/profile.c","rts/rts_support.c"]
+    let cFiles = ["rts/profile.c","rts/rts_support.c", "rts/gc_none.c"]
hunk ./src/Grin/Main.hs 121
-    let comm = shellQuote $ [cc] ++ ["-o", fn, cf] ++ args ++ rls ++ extraCFiles
+    let comm = shellQuote $ [cc] ++ extraCFiles ++ [cf, "-o", fn] ++ args ++ rls