[added rts/rts_support, cleaned up rts code.
John Meacham <john@repetae.net>**20120213070644
 Ignore-this: 79533860331fbd02057748e3d1b81666
] move ./rts/profile.c ./rts/rts/profile.c
hunk ./Makefile.am 115
-	   rts/rts/gc_jgc.c
+	   rts/rts/gc_jgc.c rts/rts/profile.c rts/rts/profile.h rts/rts/cdefs.h rts/rts/rts_support.c \
+	   rts/rts/rts_support.h rts/rts/gc.h
hunk ./Makefile.am 119
-	   rts/debug.c rts/jhc_rts_alloc.c rts/jhc_rts.c rts/profile.c rts/jhc_rts2.c \
+	   rts/jhc_rts_alloc.c rts/jhc_rts.c rts/jhc_rts2.c \
hunk ./docs/unboxed.mkd 32
+# Explicit namespaces in import/export lists
+
+jhc allows explicit namespaces in import export lists. In haskell 98, a name
+such as 'Foo' in an export list will indicate that all of a class named Foo, a
+type named 'Foo' and a data constructor named 'Foo' shoud be exported. Jhc
+allows finer grained control by prefixing exports with a namespace indicator.
+The valid namespace indicators are
+
+    * 'type' - The name is a type, as in something defined by 'type', 'newtype',
+       or 'data', or the constructors of a kind declaration.
+    * 'class' - Specifies that the name is that of a class.
+    * 'data'  - Specifies that the name is a data constructor.
+    * 'kind'  - specifies that the name is a user defined kind.
+
+In addition, classes and types are in independent namespaces, so a type and a
+class of the same name may be in scope and not conflict.
+
+When an unqualified name is given in a import/export list then all names that
+match it that are in scope are matched. The only exception is a holdover from
+haskell 98 where in hiding lists data constructors are not matched. This
+behavior may change in the future when explicit namespaces are used, so it
+should not be relied upon when using explicit namespaces.
+
hunk ./rts/jhc_rts.c 1
-static jmp_buf jhc_uncaught;
-
-#ifdef __WIN32__
-A_UNUSED static char *jhc_options_os =  "mingw32";
-A_UNUSED static char *jhc_options_arch = "i386";
-#elif defined(__ARM_EABI__)
-A_UNUSED static char *jhc_options_os =  "nds";
-A_UNUSED static char *jhc_options_arch = "ARM";
-#else
-A_UNUSED struct utsname jhc_utsname;
-A_UNUSED static char *jhc_options_os = "(unknown os)";
-A_UNUSED static char *jhc_options_arch = "(unknown arch)";
-#endif
-
-static void A_NORETURN A_UNUSED A_COLD
-jhc_exit(int n) {
-        fflush(stdout);
-        jhc_print_profile();
-        exit(n);
-}
-
-static void  A_NORETURN A_UNUSED  A_COLD
-jhc_error(char *s) {
-        fflush(stdout);
-        fputs(s,stderr);
-        fputs("\n",stderr);
-        jhc_exit(1);
-}
-
-static void  A_NORETURN A_UNUSED  A_COLD
-jhc_case_fell_off(int n) {
-        fflush(stdout);
-        fprintf(stderr, "\n%s:%i: case fell off\n", __FILE__, n);
-        abort();
-}
-
-#define jhc_setjmp(jb) setjmp(*(jb))
-#define jhc_longjmp(jb) longjmp(*(jb),1)
-
-struct jhc_continuation {
-    void *argument;
-    jmp_buf jump_buf;
-};
-
-#define prim_umaxbound(t) ((t)~((t)0))
-#define prim_maxbound(t) ((t)(~((t)1 << (sizeof(t)*8 - 1))))
-#define prim_minbound(t) ((t)(((t)1 << (sizeof(t)*8 - 1))))
-
-void
-hs_set_argv(int argc, char *argv[])
-{
-        jhc_argc = argc - 1;
-        jhc_argv = argv + 1;
-        jhc_progname = argv[0];
-}
-
-static int hs_init_count;
-
-static void jhc_hs_init(void);
-
-void
-hs_init(int *argc, char **argv[])
-{
-
-        if(!hs_init_count++) {
-                /* A few random assertions about the architecture that the compiler
-                 * assumes. should be true of any but the oddest of beasts. */
-                assert(sizeof(HsPtr) == sizeof(HsFunPtr));
-                assert(sizeof(HsPtr) == sizeof(intptr_t));
-                assert(sizeof(HsPtr) == sizeof(uintptr_t));
-                assert(CHAR_BIT == 8);
-                assert(EOF == -1);
-
-                jhc_alloc_init();
-                jhc_hs_init();
-                hs_set_argv(*argc,*argv);
-#if JHC_isPosix
-                if(!uname(&jhc_utsname)) {
-                        jhc_options_arch = jhc_utsname.machine;
-                        jhc_options_os   = jhc_utsname.sysname;
-                }
-#endif
-                setlocale(LC_ALL,"");
-        }
-}
-
-void
-hs_exit(void)
-{
-        if(!hs_init_count) {
-                fprintf(stderr, "hs_exit() called before hs_init()\n");
-                abort();
-        }
-        if(!--hs_init_count) {
-                jhc_alloc_fini();
-                jhc_exit(0);
-        }
-}
-
hunk ./rts/jhc_rts_alloc.c 6
-#define _JHC_GC_CONTEXT 0
hunk ./rts/jhc_rts_alloc.c 13
-#if _JHC_PROFILE
-
-#define BUCKETS 7
-
-static unsigned alloced[BUCKETS];
-static unsigned alloced_atomic[BUCKETS];
-
-static void
-alloc_count(int n,int atomic)
-{
-        n = n ? ((n - 1)/sizeof(void *)) + 1 : 0;
-        n = n > BUCKETS - 1 ? BUCKETS - 1 : n;
-        (atomic ? alloced_atomic : alloced)[n]++;
-}
-
-static void
-print_alloc_size_stats(void) {
-        char fmt[] = "%10s %10s %10s %10s %10s\n";
-        char fmt2[] = "%10u %10u %10u %10u %10u\n";
-        fprintf(stderr,fmt,"Size","Normal","Atomic","Total","Accum");
-        fprintf(stderr,fmt,"----","------","------","-----","-----");
-        unsigned accum = 0;
-        for(int i = 0; i < BUCKETS; i++) {
-                accum += alloced[i] + alloced_atomic[i];
-                fprintf(stderr,fmt2,i,alloced[i],alloced_atomic[i],alloced_atomic[i] + alloced[i], accum);
-        }
-}
-
-#else
-
-#define alloc_count(x,y)
-#define print_alloc_size_stats()
-
-#endif
-
hunk ./rts/jhc_rts_header.h 30
-
-// #define our options
+#include "rts/cdefs.h"
hunk ./rts/jhc_rts_header.h 41
-#ifndef _JHC_PROFILE
-#define _JHC_PROFILE 0
-#endif
-
hunk ./rts/jhc_rts_header.h 49
-#ifndef JHC_VALGRIND
-#define JHC_VALGRIND 0
-#endif
-
-#ifndef JHC_MEM_ANNOTATE
-#define JHC_MEM_ANNOTATE 0
-#endif
-
hunk ./rts/jhc_rts_header.h 57
-// GNU attributes
-#ifdef __GNUC__
-#  define __predict_true(exp)     __builtin_expect(!!(exp), 1)
-#  define __predict_false(exp)    __builtin_expect(!!(exp), 0)
-#else
-#  define __predict_true(exp)     (exp)
-#  define __predict_false(exp)    (exp)
-#endif
-
-#ifdef __GNUC__
-#define A_ALIGNED  __attribute__ ((aligned))
-#define A_CONST    __attribute__ ((const))
-#define A_MALLOC   __attribute__ ((malloc))
-#define A_MAYALIAS __attribute__ ((__may_alias__))
-#define A_NORETURN __attribute__ ((noreturn))
-#define A_PURE     __attribute__ ((pure))
-#define A_UNUSED   __attribute__ ((unused))
-#ifdef __i386__
-#define A_REGPARM __attribute__ ((fastcall))
-#else
-#define A_REGPARM
-#endif
-#define A_STD    A_REGPARM
-
-#else
-#define A_ALIGNED
-#define A_CONST
-#define A_MALLOC
-#define A_MAYALIAS
-#define A_NORETURN
-#define A_PURE
-#define A_UNUSED
-#define A_STD
-#endif
-
-// these should be enabled with newer versions of gcc
-#define A_HOT
-#define A_COLD
-#define A_FALIGNED
-
hunk ./rts/jhc_rts_header.h 71
-static void jhc_alloc_init(void);
-static void jhc_alloc_fini(void);
-static void jhc_alloc_print_stats(void);
-static void jhc_print_profile(void);
-
-static int jhc_argc;
-static char **jhc_argv;
-static char *jhc_progname;
-
-#if JHC_STATUS > 1
-#define debugf(...) fprintf(stderr,__VA_ARGS__)
-#else
-#define debugf(...) do { } while (0)
-#endif
-
-
+#include "rts/profile.h"
+#include "rts/rts_support.h"
+#include "rts/gc.h"
addfile ./rts/rts/gc.h
hunk ./rts/rts/gc.h 1
+#ifndef JHC_GC_H
+#define JHC_GC_H
+
+void jhc_alloc_init(void);
+void jhc_alloc_fini(void);
+void jhc_alloc_print_stats(void);
+
+#endif
hunk ./rts/rts/gc_jgc.c 236
-static void jhc_alloc_print_stats(void) { }
+void jhc_alloc_print_stats(void) { }
hunk ./rts/rts/gc_jgc.c 239
-static void
+void
hunk ./rts/rts/gc_jgc.c 257
-static void
+void
hunk ./rts/rts/profile.c 1
-static void A_UNUSED
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/times.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "rts/gc.h"
+#include "rts/cdefs.h"
+#include "rts/profile.h"
+#include "rts/rts_support.h"
+
+void A_UNUSED
hunk ./rts/rts/profile.c 24
-#if _JHC_PROFILE
-
hunk ./rts/rts/profile.c 33
-profile_push(struct profile_stack *ps)
+jhc_profile_push(struct profile_stack *ps)
hunk ./rts/rts/profile.c 39
-profile_pop(struct profile_stack *ps)
+jhc_profile_pop(struct profile_stack *ps)
hunk ./rts/rts/profile.c 47
-#else
-
-#define profile_push(x) do { } while(0)
-#define profile_pop(x) do { } while(0)
-
-#endif
-
-#ifndef __WIN32__
-#ifndef __ARM_EABI__
hunk ./rts/rts/profile.c 48
+#if  !defined(__WIN32__) && !defined(__ARM_EABI__)
hunk ./rts/rts/profile.c 53
-}
-#endif
hunk ./rts/rts/profile.c 54
+    return;
+}
hunk ./rts/rts/profile.c 57
-static void A_COLD
+void A_COLD
hunk ./rts/rts/profile.c 71
-#ifndef __WIN32__
-#ifndef __ARM_EABI__
hunk ./rts/rts/profile.c 76
-#endif
-#endif
hunk ./rts/rts/profile.c 78
+
+#if _JHC_PROFILE
+
+#define BUCKETS 7
+static unsigned alloced[BUCKETS];
+static unsigned alloced_atomic[BUCKETS];
+
+static void
+alloc_count(int n,int atomic)
+{
+        n = n ? ((n - 1)/sizeof(void *)) + 1 : 0;
+        n = n > BUCKETS - 1 ? BUCKETS - 1 : n;
+        (atomic ? alloced_atomic : alloced)[n]++;
+}
+
+static void
+print_alloc_size_stats(void) {
+        char fmt[] = "%10s %10s %10s %10s %10s\n";
+        char fmt2[] = "%10u %10u %10u %10u %10u\n";
+        fprintf(stderr,fmt,"Size","Normal","Atomic","Total","Accum");
+        fprintf(stderr,fmt,"----","------","------","-----","-----");
+        unsigned accum = 0;
+        for(int i = 0; i < BUCKETS; i++) {
+                accum += alloced[i] + alloced_atomic[i];
+                fprintf(stderr,fmt2,i,alloced[i],alloced_atomic[i],alloced_atomic[i] + alloced[i], accum);
+        }
+}
+#endif
addfile ./rts/rts/rts_support.c
hunk ./rts/rts/rts_support.c 1
+#include <stdio.h>
+#include <stdlib.h>
+#include <locale.h>
+
+#include "HsFFI.h"
+#include "rts/rts_support.h"
+#include "rts/profile.h"
+#include "rts/gc.h"
+
+jmp_buf jhc_uncaught;
+int jhc_argc;
+char **jhc_argv;
+char *jhc_progname;
+
+#ifdef __WIN32__
+A_UNUSED char *jhc_options_os =  "mingw32";
+A_UNUSED char *jhc_options_arch = "i386";
+#elif defined(__ARM_EABI__)
+A_UNUSED char *jhc_options_os =  "nds";
+A_UNUSED char *jhc_options_arch = "ARM";
+#else
+A_UNUSED char *jhc_options_os = "(unknown os)";
+A_UNUSED char *jhc_options_arch = "(unknown arch)";
+#endif
+
+void
+hs_set_argv(int argc, char *argv[])
+{
+        jhc_argc = argc - 1;
+        jhc_argv = argv + 1;
+        jhc_progname = argv[0];
+}
+
+void A_NORETURN A_UNUSED A_COLD
+jhc_exit(int n) {
+        fflush(stdout);
+        jhc_print_profile();
+        exit(n);
+}
+
+void  A_NORETURN A_UNUSED  A_COLD
+jhc_error(char *s) {
+        fflush(stdout);
+        fputs(s,stderr);
+        fputs("\n",stderr);
+        jhc_exit(1);
+}
+
+void  A_NORETURN A_UNUSED  A_COLD
+jhc_case_fell_off(int n) {
+        fflush(stdout);
+        fprintf(stderr, "\n%s:%i: case fell off\n", __FILE__, n);
+        abort();
+}
+
+void jhc_hs_init(void);
+
+static int hs_init_count;
+void
+hs_init(int *argc, char **argv[])
+{
+
+        if(!hs_init_count++) {
+                jhc_alloc_init();
+                jhc_hs_init();
+                hs_set_argv(*argc,*argv);
+#if JHC_isPosix
+
+                struct utsname jhc_utsname;
+                if(!uname(&jhc_utsname)) {
+                        jhc_options_arch = jhc_utsname.machine;
+                        jhc_options_os   = jhc_utsname.sysname;
+                }
+#endif
+                setlocale(LC_ALL,"");
+        }
+}
+
+void
+hs_exit(void)
+{
+        if(!hs_init_count) {
+                fprintf(stderr, "hs_exit() called before hs_init()\n");
+                abort();
+        }
+        if(!--hs_init_count) {
+                jhc_alloc_fini();
+                jhc_exit(0);
+        }
+}
addfile ./rts/rts/rts_support.h
hunk ./rts/rts/rts_support.h 1
+#ifndef RTS_SUPPORT_H
+#define RTS_SUPPORT_H
+
+#include <setjmp.h>
+#include "rts/cdefs.h"
+
+extern jmp_buf jhc_uncaught;
+A_UNUSED extern char *jhc_options_os;
+A_UNUSED extern char *jhc_options_arch;
+extern int jhc_argc;
+extern char **jhc_argv;
+extern char *jhc_progname;
+
+extern char jhc_c_compile[];
+extern char jhc_command[];
+extern char jhc_version[];
+
+void A_NORETURN A_UNUSED A_COLD jhc_exit(int n);
+void A_NORETURN A_UNUSED A_COLD jhc_error(char *s);
+void A_NORETURN A_UNUSED A_COLD jhc_case_fell_off(int n);
+
+#define jhc_setjmp(jb) setjmp(*(jb))
+#define jhc_longjmp(jb) longjmp(*(jb),1)
+
+#define prim_umaxbound(t) ((t)~((t)0))
+#define prim_maxbound(t) ((t)(~((t)1 << (sizeof(t)*CHAR_BIT - 1))))
+#define prim_minbound(t) ((t)(((t)1 << (sizeof(t)*CHAR_BIT - 1))))
+
+#endif
hunk ./src/C/FromGrin2.hs 155
-    (header,body) = generateC (function (name "jhc_hs_init") voidType [] [] icaches:Map.elems fm) (Map.elems sm)
+    (header,body) = generateC (function (name "jhc_hs_init") voidType [] [Public] icaches:Map.elems fm) (Map.elems sm)
hunk ./src/C/FromGrin2.hs 664
-        PrimTypeInfo { primArgTy = arg, primTypeInfo = PrimSizeOf } -> 
+        PrimTypeInfo { primArgTy = arg, primTypeInfo = PrimSizeOf } ->
hunk ./src/C/FromGrin2.hs 666
-        PrimTypeInfo { primArgTy = arg, primTypeInfo = PrimMinBound } -> 
+        PrimTypeInfo { primArgTy = arg, primTypeInfo = PrimMinBound } ->
hunk ./src/C/FromGrin2.hs 668
-        PrimTypeInfo { primArgTy = arg, primTypeInfo = PrimMaxBound } -> 
+        PrimTypeInfo { primArgTy = arg, primTypeInfo = PrimMaxBound } ->
hunk ./src/C/FromGrin2.hs 670
-        PrimTypeInfo { primArgTy = arg, primTypeInfo = PrimUMaxBound } -> 
+        PrimTypeInfo { primArgTy = arg, primTypeInfo = PrimUMaxBound } ->
hunk ./src/E/E.hs 1
-{-# OPTIONS -fglasgow-exts #-}
hunk ./src/E/FreeVars.hs 1
-{-# OPTIONS -fglasgow-exts #-}
hunk ./src/Grin/Main.hs 102
+           ("rts/profile.c",profile_c),
+           ("rts/profile.h",profile_h),
+           ("rts/gc.h",gc_h),
+           ("rts/rts_support.c",rts_support_c),
+           ("rts/rts_support.h",rts_support_h),
+           ("rts/cdefs.h",cdefs_h),
hunk ./src/Grin/Main.hs 114
+    let cFiles = ["rts/profile.c","rts/rts_support.c"]
hunk ./src/Grin/Main.hs 118
-    let extraCFiles = ["-I" ++ tdir ++ "/cbits", "-I" ++ tdir ] ++ [ tdir FP.</> "cbits" FP.</> fn | fn@(reverse -> 'c':'.':_) <- ds ]
+    let extraCFiles = map (tdir FP.</>) cFiles ++ ["-I" ++ tdir ++ "/cbits", "-I" ++ tdir ] ++ [ tdir FP.</> "cbits" FP.</> fn | fn@(reverse -> 'c':'.':_) <- ds ]
hunk ./src/Support/IniParse.hs 1
-{-# OPTIONS_GHC -fglasgow-exts #-}
hunk ./src/Util/ReaderWriter.hs 1
-{-# OPTIONS_GHC -fglasgow-exts #-}
-
+{-# LANGUAGE UnboxedTuples #-}
hunk ./src/Util/ReaderWriter.hs 9
-
hunk ./src/Util/ReaderWriter.hs 11
-
hunk ./src/Util/ReaderWriter.hs 29
-
hunk ./src/Util/ReaderWriter.hs 39
-
-