[add support for determining type sizes for optional arch-specific optimizations
John Meacham <john@repetae.net>**20051019010926] adddir ./arch
addfile ./arch/arch_hs.prl
addfile ./arch/arch.c
addfile ./arch/generic.arch
addfile ./arch/i686.arch
addfile ./arch/x86_64.arch
hunk ./arch/arch.c 1
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <float.h>
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/utsname.h>
+
+#include "../data/HsFFI.h"
+
+#define SIZE(x) fprintf(FP, "  (\"%s\", %i),\n", #x , sizeof(x))
+#define CONST(x) printf("const %19s  0x%llx\n", #x , (long long)x)
+
+int
+main(int argc, char *argv[])
+{
+        struct utsname utsname;
+        char *str;
+        FILE *FP;
+        uname(&utsname);
+
+        str = malloc(strlen(utsname.machine) + 20);
+        strcpy(str, utsname.machine);
+        strcat(str, ".arch");
+
+        FP = fopen(str,"w");
+
+        fprintf(FP, "arch_%s = [\n", utsname.machine);
+
+        SIZE(uint32_t);
+        SIZE(int);
+        SIZE(intmax_t);
+        SIZE(int8_t);
+        SIZE(int16_t);
+        SIZE(int32_t);
+        SIZE(int64_t);
+        SIZE(intmax_t);
+        SIZE(intptr_t);
+        SIZE(unsigned int);
+        SIZE(uint8_t);
+        SIZE(uint16_t);
+        SIZE(uint32_t);
+        SIZE(uint64_t);
+        SIZE(uintmax_t);
+        SIZE(uintptr_t);
+        SIZE(float);
+        SIZE(double);
+        SIZE(HsPtr);
+        SIZE(HsFunPtr);
+        SIZE(char);
+        SIZE(short);
+        SIZE(int);
+        SIZE(unsigned int);
+        SIZE(size_t);
+        SIZE(wchar_t);
+        SIZE(wint_t);
+        fprintf(FP, "  (\"void\",0)\n ]\n");
+
+        fclose(FP);
+
+        return 0;
+}
+
+
hunk ./arch/arch_hs.prl 1
+
+my @x = `find arch -name \\*.arch`;
+
+
+print @x;
+
+my $body;
+my @a;
+
+foreach (@x) {
+    $body .= "\n";
+    $body .= `cat $_`;
+    s/^arch\///;
+    /^(.*)\.arch$/;
+    my $a = $1;
+    if( $a =~ /i\d86/) {
+
+        push @a,"(\"i386\",Map.fromList arch_${a})";
+        push @a,"(\"i486\",Map.fromList arch_${a})";
+        push @a,"(\"i586\",Map.fromList arch_${a})";
+        push @a,"(\"i686\",Map.fromList arch_${a})";
+
+    }
+    push @a,"(\"$a\",Map.fromList arch_${a})";
+
+}
+
+print "-- This file is generated.\n";
+print "Module Arch(arch_map) where\n\n";
+print "import Data.Map as Map\n\n";
+
+print "arch_map = Map.fromList [" . join(", ",@a) . "]\n\n";
+
+
+
+print $body;
+
+print "\n";
hunk ./arch/generic.arch 1
+
+arch_generic = [
+  ("uint32_t", 4),
+  ("int8_t", 1),
+  ("int16_t", 2),
+  ("int32_t", 4),
+  ("int64_t", 8),
+  ("uint8_t", 1),
+  ("uint16_t", 2),
+  ("uint32_t", 4),
+  ("uint64_t", 8),
+  ("char", 1),
+  ("void",0)
+ ]
hunk ./arch/i686.arch 1
+arch_i686 = [
+  ("uint32_t", 4),
+  ("int", 4),
+  ("intmax_t", 8),
+  ("int8_t", 1),
+  ("int16_t", 2),
+  ("int32_t", 4),
+  ("int64_t", 8),
+  ("intmax_t", 8),
+  ("intptr_t", 4),
+  ("unsigned int", 4),
+  ("uint8_t", 1),
+  ("uint16_t", 2),
+  ("uint32_t", 4),
+  ("uint64_t", 8),
+  ("uintmax_t", 8),
+  ("uintptr_t", 4),
+  ("float", 4),
+  ("double", 8),
+  ("HsPtr", 4),
+  ("HsFunPtr", 4),
+  ("char", 1),
+  ("short", 2),
+  ("int", 4),
+  ("unsigned int", 4),
+  ("size_t", 4),
+  ("wchar_t", 4),
+  ("wint_t", 4),
+  ("void",0)
+ ]
hunk ./arch/x86_64.arch 1
+arch_x86_64 = [
+  ("uint32_t", 4),
+  ("int", 4),
+  ("intmax_t", 8),
+  ("int8_t", 1),
+  ("int16_t", 2),
+  ("int32_t", 4),
+  ("int64_t", 8),
+  ("intmax_t", 8),
+  ("intptr_t", 8),
+  ("unsigned int", 4),
+  ("uint8_t", 1),
+  ("uint16_t", 2),
+  ("uint32_t", 4),
+  ("uint64_t", 8),
+  ("uintmax_t", 8),
+  ("uintptr_t", 8),
+  ("float", 4),
+  ("double", 8),
+  ("HsPtr", 8),
+  ("HsFunPtr", 8),
+  ("char", 1),
+  ("short", 2),
+  ("int", 4),
+  ("unsigned int", 4),
+  ("size_t", 8),
+  ("wchar_t", 4),
+  ("wint_t", 4),
+  ("void",0)
+ ]