Index: src/rt/adi.d
===================================================================
--- src/rt/adi.d	(revision 429)
+++ src/rt/adi.d	(working copy)
@@ -572,14 +572,11 @@
   }
   else
   {
-    int len;
-    int c;
-
     debug(adi) printf("adCmpChar()\n");
-    len = a1.length;
+    auto len = a1.length;
     if (a2.length < len)
         len = a2.length;
-    c = memcmp(cast(char *)a1.ptr, cast(char *)a2.ptr, len);
+    auto c = memcmp(cast(char *)a1.ptr, cast(char *)a2.ptr, len);
     if (!c)
         c = cast(int)a1.length - cast(int)a2.length;
     return c;
Index: src/rt/lifetime.d
===================================================================
--- src/rt/lifetime.d	(revision 429)
+++ src/rt/lifetime.d	(working copy)
@@ -663,6 +663,7 @@
 
 Loverflow:
     onOutOfMemoryError();
+    assert(0);
 }
 
 /**
@@ -690,8 +691,19 @@
                 jc      Loverflow       ;
             }
         }
+        else version(D_InlineAsm_X86_64)
+        {
+            asm
+            {
+                mov     RAX,size        ;
+                mul     RAX,length      ;
+                mov     size,RAX        ;
+                jc      Loverflow       ;
+            }
+        }
         else
             size *= length;
+
         // increase the size by the array pad.
         auto info = gc_qalloc(size + __arrayPad(size), !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN | BlkAttr.APPENDABLE : BlkAttr.APPENDABLE);
         debug(PRINTF) printf(" p = %p\n", info.base);
@@ -706,6 +718,7 @@
 
 Loverflow:
     onOutOfMemoryError();
+    assert(0);
 }
 
 /**
@@ -735,6 +748,16 @@
                 jc      Loverflow       ;
             }
         }
+        else version (D_InlineAsm_X86_64)
+        {
+            asm
+            {
+                mov     RAX,size        ;
+                mul     RAX,length      ;
+                mov     size,RAX        ;
+                jc      Loverflow       ;
+            }
+        }
         else
             size *= length;
 
@@ -759,7 +782,6 @@
                 memcpy(arrstart + u, q, isize);
             }
         }
-        va_end(q);
         auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
         __setArrayAllocLength(info, size, isshared);
 	result = arrstart[0..length];
@@ -768,6 +790,7 @@
 
 Loverflow:
     onOutOfMemoryError();
+    assert(0);
 }
 
 /**
@@ -782,11 +805,13 @@
         result = null;
     else
     {   va_list q;
-        va_start!(size_t)(q, ndims);
+        version(X86_64) va_start(q, __va_argsave); else va_start(q, ndims);
 
-        void[] foo(TypeInfo ti, size_t* pdim, size_t ndims)
+        void[] foo(TypeInfo ti, va_list ap, size_t ndims)
         {
-            auto dim = *pdim;
+            size_t dim;
+	    pragma(msg, "broken");
+            //va_arg(ap, dim);
             void[] p;
 
             debug(PRINTF) printf("foo(ti = %p, ti.next = %p, dim = %d, ndims = %d\n", ti, ti.next, dim, ndims);
@@ -802,16 +827,26 @@
                 auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
                 __setArrayAllocLength(info, allocsize, isshared);
                 p = __arrayStart(info)[0 .. dim];
+
+                version(X86)
+                {
+                    va_list ap2;
+                    va_copy(ap2, ap);
+                }
                 for (size_t i = 0; i < dim; i++)
                 {
-                    (cast(void[]*)p.ptr)[i] = foo(ti.next, pdim + 1, ndims - 1);
+                    version(X86_64)
+                    {
+                        __va_list argsave = *cast(__va_list*)ap;
+                        va_list ap2 = &argsave;
+                    }
+                    (cast(void[]*)p.ptr)[i] = foo(ti.next, ap2, ndims - 1);
                 }
             }
             return p;
         }
 
-        auto pdim = cast(size_t *)q;
-        result = foo(ti, pdim, ndims);
+        result = foo(ti, q, ndims);
         debug(PRINTF) printf("result = %llx\n", result);
 
         version (none)
@@ -840,11 +875,13 @@
     else
     {
         va_list q;
-        va_start!(size_t)(q, ndims);
+        version(X86_64) va_start(q, __va_argsave); else va_start(q, ndims);
 
-        void[] foo(TypeInfo ti, size_t* pdim, size_t ndims)
+        void[] foo(TypeInfo ti, va_list ap, size_t ndims)
         {
-            size_t dim = *pdim;
+            size_t dim;
+	    pragma(msg, "broken");
+            //va_arg(ap, dim);
             void[] p;
 
             if (ndims == 1)
@@ -859,16 +896,26 @@
                 auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
                 __setArrayAllocLength(info, allocsize, isshared);
                 p = __arrayStart(info)[0 .. dim];
+
+                version(X86)
+                {
+                    va_list ap2;
+                    va_copy(ap2, q);
+                }
                 for (size_t i = 0; i < dim; i++)
                 {
-                    (cast(void[]*)p.ptr)[i] = foo(ti.next, pdim + 1, ndims - 1);
+                    version(X86_64)
+                    {
+                        __va_list argsave = *cast(__va_list*)ap;
+                        va_list ap2 = &argsave;
+                    }
+                    (cast(void[]*)p.ptr)[i] = foo(ti.next, ap2, ndims - 1);
                 }
             }
             return p;
         }
 
-        size_t* pdim = cast(size_t *)q;
-        result = foo(ti, pdim, ndims);
+        result = foo(ti, q, ndims);
         debug(PRINTF) printf("result = %llx\n", result);
 
         version (none)
@@ -1083,6 +1130,18 @@
                 jc  Loverflow;
             }
         }
+        else version (D_InlineAsm_X86_64)
+        {
+            size_t newsize = void;
+
+            asm
+            {
+                mov RAX, newlength;
+                mul RAX, sizeelem;
+                mov newsize, RAX;
+                jc  Loverflow;
+            }
+        }
         else
         {
             size_t newsize = sizeelem * newlength;
@@ -1195,6 +1254,7 @@
 
 Loverflow:
     onOutOfMemoryError();
+    assert(0);
 }
 
 
@@ -1244,6 +1304,18 @@
                 jc      Loverflow       ;
             }
         }
+        else version (D_InlineAsm_X86_64)
+        {
+            size_t newsize = void;
+
+            asm
+            {
+                mov     RAX,newlength   ;
+                mul     RAX,sizeelem    ;
+                mov     newsize,RAX     ;
+                jc      Loverflow       ;
+            }
+        }
         else
         {
             size_t newsize = sizeelem * newlength;
@@ -1374,6 +1446,7 @@
 
 Loverflow:
     onOutOfMemoryError();
+    assert(0);
 }
 
 
@@ -1381,7 +1454,7 @@
  * Append y[] to array pointed to by px
  * size is size of each array element.
  */
-extern (C) long _d_arrayappendT(TypeInfo ti, Array *px, byte[] y)
+extern (C) void[] _d_arrayappendT(TypeInfo ti, Array *px, byte[] y)
 {
     // only optimize array append where ti is not a shared type
     auto sizeelem = ti.next.tsize();            // array element size
@@ -1408,7 +1481,7 @@
                 if(*(cast(size_t*)info.base) == size + offset)
                 {
                     // not enough space, try extending
-                    int extendoffset = offset + LARGEPAD - info.size;
+                    auto extendoffset = offset + LARGEPAD - info.size;
                     auto u = gc_extend(px.data, newsize + extendoffset, newcap + extendoffset);
                     if(u)
                     {
@@ -1468,7 +1541,7 @@
   L1:
     px.length = newlength;
     memcpy(px.data + length * sizeelem, y.ptr, y.length * sizeelem);
-    return *cast(long*)px;
+    return *cast(void[]*)px;
 }
 
 
@@ -1556,17 +1629,21 @@
 /**
  *
  */
-extern (C) long _d_arrayappendcT(TypeInfo ti, Array *x, ...)
+extern (C) void[] _d_arrayappendcT(TypeInfo ti, Array *x, ...)
 {
+    version(X86_64)
+        assert(0); // needs to have its vararg handling fixed
+    else {
     byte *argp = cast(byte*)(&ti + 2);
     return _d_arrayappendT(ti, x, argp[0..1]);
+    }
 }
 
 
 /**
  * Append dchar to char[]
  */
-extern (C) long _d_arrayappendcd(ref char[] x, dchar c)
+extern (C) void[] _d_arrayappendcd(ref char[] x, dchar c)
 {
     // c could encode into from 1 to 4 characters
     char[4] buf = void;
@@ -1612,7 +1689,7 @@
 /**
  * Append dchar to wchar[]
  */
-extern (C) long _d_arrayappendwd(ref wchar[] x, dchar c)
+extern (C) void[] _d_arrayappendwd(ref wchar[] x, dchar c)
 {
     // c could encode into from 1 to 2 w characters
     wchar[2] buf = void;
@@ -1700,19 +1777,33 @@
  *
  */
 extern (C) byte[] _d_arraycatnT(TypeInfo ti, uint n, ...)
-{   void* a;
+{
     size_t length;
-    byte[]* p;
-    uint i;
-    byte[] b;
     auto size = ti.next.tsize(); // array element size
 
-    p = cast(byte[]*)(&n + 1);
+    version(X86)
+    {
+	byte[]* p = cast(byte[]*)(&n + 1);
 
-    for (i = 0; i < n; i++)
+	for (auto i = 0; i < n; i++)
+	{
+	    byte[] b = *p++;
+	    length += b.length;
+	}
+    }
+    else
     {
-        b = *p++;
-        length += b.length;
+        __va_list argsave = __va_argsave.va;
+	va_list ap;
+	va_start(ap, __va_argsave);
+	for (auto i = 0; i < n; i++)
+	{
+	    byte[] b;
+	    pragma(msg, "broken");
+	    //va_arg(ap, b);
+	    length += b.length;
+        }
+	va_end(ap);
     }
     if (!length)
         return null;
@@ -1721,24 +1812,45 @@
     auto info = gc_qalloc(allocsize + __arrayPad(allocsize), !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN | BlkAttr.APPENDABLE : BlkAttr.APPENDABLE);
     auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
     __setArrayAllocLength(info, allocsize, isshared);
-    a = __arrayStart(info);
-    p = cast(byte[]*)(&n + 1);
+    void *a = __arrayStart (info);
 
-    uint j = 0;
-    for (i = 0; i < n; i++)
+    version(X86)
     {
-        b = *p++;
-        if (b.length)
-        {
-            memcpy(a + j, b.ptr, b.length * size);
-            j += b.length * size;
-        }
+        p = cast(byte[]*)(&n + 1);
+
+	size_t j = 0;
+	for (auto i = 0; i < n; i++)
+	{
+	    byte[] b = *p++;
+	    if (b.length)
+	    {
+		memcpy(a + j, b.ptr, b.length * size);
+		j += b.length * size;
+	    }
+	}
     }
+    else
+    {
+        va_list ap2 = &argsave;
+	size_t j = 0;
+	for (auto i = 0; i < n; i++)
+	{
+	    byte[] b;
+	    pragma(msg, "broken");
+	    //va_arg(ap2, b);
+	    if (b.length)
+	    {
+		memcpy(a + j, b.ptr, b.length * size);
+		j += b.length * size;
+	    }
+	}
+	va_end(ap2);
+    }
 
-    byte[] result;
-    *cast(int *)&result = length;       // jam length
-    (cast(void **)&result)[1] = a;      // jam ptr
-    return result;
+    Array2 result;
+    result.length = length;
+    result.ptr = a;
+    return *cast(byte[]*)&result;
 }
 
 
@@ -1761,25 +1873,38 @@
         __setArrayAllocLength(info, allocsize, isshared);
         result = __arrayStart(info);
 
-        va_list q;
-        va_start!(size_t)(q, length);
+	version(X86)
+	{
+	    va_list q;
+	    va_start(q, length);
 
-        size_t stacksize = (sizeelem + int.sizeof - 1) & ~(int.sizeof - 1);
+            size_t stacksize = (sizeelem + int.sizeof - 1) & ~(int.sizeof - 1);
 
-        if (stacksize == sizeelem)
-        {
-            memcpy(result, q, length * sizeelem);
-        }
-        else
-        {
-            for (size_t i = 0; i < length; i++)
-            {
-                memcpy(result + i * sizeelem, q, sizeelem);
-                q += stacksize;
+	    if (stacksize == sizeelem)
+	    {
+		memcpy(result, q, length * sizeelem);
+	    }
+	    else
+	    {
+		for (size_t i = 0; i < length; i++)
+		{
+		    memcpy(result + i * sizeelem, q, sizeelem);
+		    q += stacksize;
+		}
+	    }
+
+	    va_end(q);
+	}
+	else
+	{
+	    va_list q;
+	    va_start(q, __va_argsave);
+	    for (size_t i = 0; i < length; i++)
+	    {
+	        va_arg(q, ti.next, result + i * sizeelem);
             }
-        }
-
-        va_end(q);
+	    va_end(q);
+	}
     }
     return result;
 }
@@ -1798,7 +1923,7 @@
 /**
  *
  */
-extern (C) long _adDupT(TypeInfo ti, Array2 a)
+extern (C) void[] _adDupT(TypeInfo ti, Array2 a)
 out (result)
 {
     auto sizeelem = ti.next.tsize();            // array element size
@@ -1819,7 +1944,7 @@
         r.length = a.length;
         memcpy(r.ptr, a.ptr, size);
     }
-    return *cast(long*)(&r);
+    return *cast(void[]*)(&r);
 }
 
 
Index: src/rt/trace.d
===================================================================
--- src/rt/trace.d	(revision 429)
+++ src/rt/trace.d	(working copy)
@@ -686,7 +686,7 @@
                     goto L1;
                 case ' ':
                 case '\t':              // fan in or fan out line
-                    count = strtoul(buf,&p,10);
+                    count = cast(int)strtoul(buf,&p,10);
                     if (p == buf)       // if invalid conversion
                         continue;
                     p = skipspace(p);
@@ -731,7 +731,7 @@
                     {   timer_t t;
 
                         p++;
-                        count = strtoul(p,&p,10);
+                        count = cast(int)strtoul(p,&p,10);
                         t = cast(long)strtoull(p,&p,10);
                         s.totaltime += t;
                         t = cast(long)strtoull(p,&p,10);
Index: src/rt/typeinfo/ti_AC.d
===================================================================
--- src/rt/typeinfo/ti_AC.d	(revision 429)
+++ src/rt/typeinfo/ti_AC.d	(working copy)
@@ -54,9 +54,9 @@
     {
         Object[] s1 = *cast(Object[]*)p1;
         Object[] s2 = *cast(Object[]*)p2;
-        ptrdiff_t c;
+        int c;
 
-        c = cast(ptrdiff_t)s1.length - cast(ptrdiff_t)s2.length;
+        c = cast(int)s1.length - cast(int)s2.length;
         if (c == 0)
         {
             for (size_t u = 0; u < s1.length; u++)
Index: src/rt/switch_.d
===================================================================
--- src/rt/switch_.d	(revision 429)
+++ src/rt/switch_.d	(working copy)
@@ -38,8 +38,8 @@
 
     for (j = 1; j < table.length; j++)
     {
-        int len1 = table[j - 1].length;
-        int len2 = table[j].length;
+        auto len1 = table[j - 1].length;
+        auto len2 = table[j].length;
 
         assert(len1 <= len2);
         if (len1 == len2)
@@ -89,23 +89,17 @@
 body
 {
     //printf("body _d_switch_string(%.*s)\n", ca);
-    int low;
-    int high;
-    int mid;
-    int c;
-    char[] pca;
+    size_t low = 0;
+    auto high = table.length;
 
-    low = 0;
-    high = table.length;
-
     version (none)
     {
         // Print table
         printf("ca[] = '%s'\n", cast(char *)ca);
-        for (mid = 0; mid < high; mid++)
+        for (auto i = 0; i < high; i++)
         {
-            pca = table[mid];
-            printf("table[%d] = %d, '%.*s'\n", mid, pca.length, pca);
+            auto pca = table[i];
+            printf("table[%d] = %d, '%.*s'\n", i, pca.length, pca);
         }
     }
     if (high &&
@@ -121,9 +115,9 @@
         // Do binary search
         while (low < high)
         {
-            mid = (low + high) >> 1;
-            pca = table[mid];
-            c = ca.length - pca.length;
+            auto mid = (low + high) >> 1;
+            auto pca = table[mid];
+            auto c = ca.length - pca.length;
             if (c == 0)
             {
                 c = cast(ubyte)c1 - cast(ubyte)pca[0];
@@ -132,7 +126,7 @@
                     c = memcmp(ca.ptr, pca.ptr, ca.length);
                     if (c == 0)
                     {   //printf("found %d\n", mid);
-                        return mid;
+                        return cast(int)mid;
                     }
                 }
             }
@@ -177,8 +171,8 @@
 
     for (j = 1; j < table.length; j++)
     {
-        int len1 = table[j - 1].length;
-        int len2 = table[j].length;
+        auto len1 = table[j - 1].length;
+        auto len2 = table[j].length;
 
         assert(len1 <= len2);
         if (len1 == len2)
@@ -228,37 +222,31 @@
 body
 {
     //printf("body _d_switch_ustring()\n");
-    int low;
-    int high;
-    int mid;
-    int c;
-    wchar[] pca;
+    size_t low = 0;
+    auto high = table.length;
 
-    low = 0;
-    high = table.length;
-
 /*
     // Print table
     wprintf("ca[] = '%.*s'\n", ca);
-    for (mid = 0; mid < high; mid++)
+    for (auto i = 0; i < high; i++)
     {
-        pca = table[mid];
-        wprintf("table[%d] = %d, '%.*s'\n", mid, pca.length, pca);
+        auto pca = table[i];
+        wprintf("table[%d] = %d, '%.*s'\n", i, pca.length, pca);
     }
 */
 
     // Do binary search
     while (low < high)
     {
-        mid = (low + high) >> 1;
-        pca = table[mid];
-        c = ca.length - pca.length;
+        auto mid = (low + high) >> 1;
+        auto pca = table[mid];
+        auto c = ca.length - pca.length;
         if (c == 0)
         {
             c = memcmp(ca.ptr, pca.ptr, ca.length * wchar.sizeof);
             if (c == 0)
             {   //printf("found %d\n", mid);
-                return mid;
+                return cast(int)mid;
             }
         }
         if (c < 0)
@@ -298,36 +286,29 @@
     assert(ca.length >= 0);
 
     // Make sure table[] is sorted correctly
-    int j;
-
-    for (j = 1; j < table.length; j++)
+    for (auto j = 1; j < table.length; j++)
     {
-        int len1 = table[j - 1].length;
-        int len2 = table[j].length;
+        auto len1 = table[j - 1].length;
+        auto len2 = table[j].length;
 
         assert(len1 <= len2);
         if (len1 == len2)
         {
-            int c;
-
-            c = memcmp(table[j - 1].ptr, table[j].ptr, len1 * dchar.sizeof);
+            auto c = memcmp(table[j - 1].ptr, table[j].ptr, len1 * dchar.sizeof);
             assert(c < 0);  // c==0 means a duplicate
         }
     }
 }
 out (result)
 {
-    int i;
-    int c;
-
     //printf("out _d_switch_string()\n");
     if (result == -1)
     {
         // Not found
-        for (i = 0; i < table.length; i++)
+        for (auto i = 0; i < table.length; i++)
         {
             if (table[i].length == ca.length)
-            {   c = memcmp(table[i].ptr, ca.ptr, ca.length * dchar.sizeof);
+            {   auto c = memcmp(table[i].ptr, ca.ptr, ca.length * dchar.sizeof);
                 assert(c != 0);
             }
         }
@@ -335,12 +316,12 @@
     else
     {
         assert(0 <= result && result < table.length);
-        for (i = 0; 1; i++)
+        for (auto i = 0; 1; i++)
         {
             assert(i < table.length);
             if (table[i].length == ca.length)
             {
-                c = memcmp(table[i].ptr, ca.ptr, ca.length * dchar.sizeof);
+                auto c = memcmp(table[i].ptr, ca.ptr, ca.length * dchar.sizeof);
                 if (c == 0)
                 {
                     assert(i == result);
@@ -353,37 +334,31 @@
 body
 {
     //printf("body _d_switch_ustring()\n");
-    int low;
-    int high;
-    int mid;
-    int c;
-    dchar[] pca;
+    size_t low = 0;
+    auto high = table.length;
 
-    low = 0;
-    high = table.length;
-
 /*
     // Print table
     wprintf("ca[] = '%.*s'\n", ca);
-    for (mid = 0; mid < high; mid++)
+    for (auto i = 0; i < high; i++)
     {
-        pca = table[mid];
-        wprintf("table[%d] = %d, '%.*s'\n", mid, pca.length, pca);
+        auto pca = table[i];
+        wprintf("table[%d] = %d, '%.*s'\n", i, pca.length, pca);
     }
 */
 
     // Do binary search
     while (low < high)
     {
-        mid = (low + high) >> 1;
-        pca = table[mid];
-        c = ca.length - pca.length;
+        auto mid = (low + high) >> 1;
+        auto pca = table[mid];
+        auto c = ca.length - pca.length;
         if (c == 0)
         {
             c = memcmp(ca.ptr, pca.ptr, ca.length * dchar.sizeof);
             if (c == 0)
             {   //printf("found %d\n", mid);
-                return mid;
+                return cast(int)mid;
             }
         }
         if (c < 0)
Index: src/rt/memory.d
===================================================================
--- src/rt/memory.d	(revision 429)
+++ src/rt/memory.d	(working copy)
@@ -133,6 +133,15 @@
             ret;
         }
     }
+    else version (D_InlineAsm_X86_64)
+    {
+        asm
+	{
+	    naked;
+	    mov RAX, RSP;
+	    ret;
+	}
+    }
     else
     {
         static assert( false, "Architecture not supported." );
Index: src/rt/qsort.d
===================================================================
--- src/rt/qsort.d	(revision 429)
+++ src/rt/qsort.d	(working copy)
@@ -46,17 +46,14 @@
 
 extern (C) long _adSort(Array a, TypeInfo ti)
 {
-  byte* base;
   byte*[40] stack;              // stack
-  byte** sp;                    // stack pointer
-  byte* i, j, limit;            // scan and limit pointers
-  uint thresh;                  // size of _maxspan elements in bytes
-  uint width = ti.tsize();
+  byte* i, j;            // scan and limit pointers
+  auto width = ti.tsize();
 
-  base = cast(byte *)a.ptr;
-  thresh = _maxspan * width;             // init threshold
-  sp = stack.ptr;                        // init stack pointer
-  limit = base + a.length * width;       // pointer past end of array
+  auto base = cast(byte *)a.ptr;
+  auto thresh = _maxspan * width;        // size of _maxspan elements in bytes
+  auto sp = stack.ptr;                   // stack pointer
+  auto limit = base + a.length * width;  // pointer past end of array
   while (1)                              // repeat until done then return
   {
     while (limit - base > thresh)        // if more than _maxspan elements
Index: src/rt/dmain2.d
===================================================================
--- src/rt/dmain2.d	(revision 429)
+++ src/rt/dmain2.d	(working copy)
@@ -211,10 +211,19 @@
 extern (C) void _d_hidden_func()
 {
     Object o;
-    asm
-    {
-        mov o, EAX;
-    }
+    version(X86)
+	asm
+	{
+	    mov o, EAX;
+	}
+    else version(X86_64)
+        asm
+        {
+            mov o, RAX;
+        }
+    else
+        static assert(0, "unknown os");
+
     onHiddenFuncError(o);
 }
 
Index: src/rt/cover.d
===================================================================
--- src/rt/cover.d	(revision 429)
+++ src/rt/cover.d	(working copy)
@@ -28,7 +28,7 @@
     struct BitArray
     {
         size_t  len;
-        uint*   ptr;
+        size_t* ptr;
 
         bool opIndex( size_t i )
         in
@@ -358,13 +358,12 @@
             return false;
         scope( exit ) close( file );
 
-        int     num = 0;
-        uint    pos = 0;
+        uint pos = 0;
 
         buf.length = 4096;
         while( true )
         {
-            num = read( file, &buf[pos], cast(uint)( buf.length - pos ) );
+            auto num = read( file, &buf[pos], cast(uint)( buf.length - pos ) );
             if( num == -1 )
                 return false;
             if( !num )
@@ -433,7 +432,7 @@
                     result[i .. i + nspaces] = ' ';
                 }
                 else
-                {   int j = result.length;
+                {   auto j = result.length;
                     result.length = j + nspaces;
                     result[j .. j + nspaces] = ' ';
                 }
Index: src/rt/aaA.d
===================================================================
--- src/rt/aaA.d	(revision 429)
+++ src/rt/aaA.d	(working copy)
@@ -597,7 +597,7 @@
     else
     {
         va_list q;
-        va_start!(size_t)(q, length);
+        version(X86_64) va_start(q, __va_argsave); else va_start(q, length);
 
         result = new BB();
         result.keyti = keyti;
Index: src/rt/arrayassign.d
===================================================================
--- src/rt/arrayassign.d	(revision 429)
+++ src/rt/arrayassign.d	(working copy)
@@ -64,7 +64,7 @@
     }
     else
     {
-        for (int i = to.length; i--; )
+        for (auto i = to.length; i--; )
         {
             void* pto   = to.ptr   + i * element_size;
             void* pfrom = from.ptr + i * element_size;
Index: src/rt/util/hash.d
===================================================================
--- src/rt/util/hash.d	(revision 429)
+++ src/rt/util/hash.d	(working copy)
@@ -47,8 +47,7 @@
     // NOTE: SuperFastHash normally starts with a zero hash value.  The seed
     //       value was incorporated to allow chaining.
     auto data = cast(const (ubyte)*) buf;
-    uint hash = seed;
-    uint tmp;
+    auto hash = seed;
     int  rem;
 
     if( len <= 0 || data is null )
@@ -60,7 +59,7 @@
     for( ; len > 0; len-- )
     {
         hash += get16bits( data );
-        tmp   = (get16bits( data + 2 ) << 11) ^ hash;
+        auto tmp = (get16bits( data + 2 ) << 11) ^ hash;
         hash  = (hash << 16) ^ tmp;
         data += 2 * ushort.sizeof;
         hash += hash >> 11;
Index: src/rt/util/string.d
===================================================================
--- src/rt/util/string.d	(revision 429)
+++ src/rt/util/string.d	(working copy)
@@ -29,7 +29,7 @@
     return buf[p - buf.ptr .. $];
 }
 
-char[] ulongToString( char[] buf, ulong val )
+char[] intToString( char[] buf, ulong val )
 {
     assert( buf.length >= 20 );
     auto p = buf.ptr + buf.length;
Index: src/object_.d
===================================================================
--- src/object_.d	(revision 429)
+++ src/object_.d	(working copy)
@@ -487,7 +487,7 @@
     override string toString()
     {
         char[20] tmp = void;
-        return cast(string)(value.toString() ~ "[" ~ tmp.ulongToString(len) ~ "]");
+        return cast(string)(value.toString() ~ "[" ~ tmp.intToString(len) ~ "]");
     }
 
     override equals_t opEquals(Object o)
@@ -1255,7 +1255,7 @@
         {
             if (e.file)
             {
-               buf ~= e.classinfo.name ~ "@" ~ e.file ~ "(" ~ tmp.ulongToString(e.line) ~ "): " ~ e.msg;
+               buf ~= e.classinfo.name ~ "@" ~ e.file ~ "(" ~ tmp.intToString(e.line) ~ "): " ~ e.msg;
             }
             else
             {
@@ -1745,10 +1745,10 @@
 }
 
 __gshared ModuleInfo*[] _moduleinfo_dtors;
-__gshared uint          _moduleinfo_dtors_i;
+__gshared size_t        _moduleinfo_dtors_i;
 
 __gshared ModuleInfo*[] _moduleinfo_tlsdtors;
-__gshared uint          _moduleinfo_tlsdtors_i;
+__gshared size_t        _moduleinfo_tlsdtors_i;
 
 // Register termination function pointers
 extern (C) int _fatexit(void*);
@@ -1958,7 +1958,7 @@
         // check that.  First, determine what non-trivial elements are
         // reachable.
         reachable[] = 0;
-        uint nmodules = _findDependencies(current);
+        auto nmodules = _findDependencies(current);
 
         // allocate the dependencies on the stack
         ModuleInfo **p = cast(ModuleInfo **)alloca(nmodules * (ModuleInfo*).sizeof);
@@ -2055,7 +2055,7 @@
     }
 
     // ok, now we need to assign indexes, and also initialize the flags
-    foreach(i, m; _moduleinfo_array)
+    foreach(uint i, m; _moduleinfo_array)
     {
         // TODO: Should null ModuleInfo be allowed?
         if (m is null) continue;
@@ -2126,7 +2126,7 @@
 
     // NOTE: _moduleTlsDtor is now called manually by dmain2
     //_moduleTlsDtor();
-    for (uint i = _moduleinfo_dtors_i; i-- != 0;)
+    for (auto i = _moduleinfo_dtors_i; i-- != 0;)
     {
         ModuleInfo* m = _moduleinfo_dtors[i];
 
@@ -2149,7 +2149,7 @@
             printf("[%d] = %p\n", i, m);
     }
 
-    for (uint i = _moduleinfo_tlsdtors_i; i-- != 0;)
+    for (auto i = _moduleinfo_tlsdtors_i; i-- != 0;)
     {
         ModuleInfo* m = _moduleinfo_tlsdtors[i];
 
Index: src/core/stdc/stdarg.d
===================================================================
--- src/core/stdc/stdarg.d	(revision 429)
+++ src/core/stdc/stdarg.d	(working copy)
@@ -1,46 +1,335 @@
+
 /**
- * D header file for C99.
- *
- * Copyright: Copyright Sean Kelly 2005 - 2009.
- * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
- * Authors:   Sean Kelly
- * Standards: ISO/IEC 9899:1999 (E)
- *
- *          Copyright Sean Kelly 2005 - 2009.
- * Distributed under the Boost Software License, Version 1.0.
- *    (See accompanying file LICENSE_1_0.txt or copy at
- *          http://www.boost.org/LICENSE_1_0.txt)
+ * C's &lt;stdarg.h&gt;
+ * This is for use with extern(C) variable argument lists.
+ * Authors: Hauke Duden and Walter Bright, Digital Mars, http://www.digitalmars.com
+ * License: Public Domain
+ * Source: $(PHOBOSSRC std/c/_stdarg.d)
+ * Macros:
+ *      WIKI=Phobos/StdCStdarg
  */
-module core.stdc.stdarg;
 
-@system:
 
-alias void* va_list;
+module core.stdc.stdarg;
 
-template va_start( T )
+version (X86)
 {
-    void va_start( out va_list ap, ref T parmn )
+    /*********************
+     * The argument pointer type.
+     */
+    alias void* va_list;
+
+    /**********
+     * Initialize ap.
+     * For 32 bit code, parmn should be the last named parameter.
+     * For 64 bit code, parmn should be __va_argsave.
+     */
+    void va_start(T)(out va_list ap, inout T parmn)
     {
-        ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
+        ap = cast(va_list)(cast(void*)&parmn + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)));
     }
-}
 
-template va_arg( T )
-{
-    T va_arg( ref va_list ap )
+    /************
+     * Retrieve and return the next value that is type T.
+     * Should use the other va_arg instead, as this won't work for 64 bit code.
+     */
+    T va_arg(T)(inout va_list ap)
     {
-        T arg = *cast(T*) ap;
-        ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
+        T arg = *cast(T*)ap;
+        ap = cast(va_list)(cast(void*)ap + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)));
         return arg;
     }
+
+    /************
+     * Retrieve and return the next value that is type T.
+     * This is the preferred version.
+     */
+    void va_arg(T)(inout va_list ap, inout T parmn)
+    {
+        parmn = *cast(T*)ap;
+        ap = cast(va_list)(cast(void*)ap + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)));
+    }
+
+    /*************
+     * Retrieve and store through parmn the next value that is of TypeInfo ti.
+     * Used when the static type is not known.
+     */
+    void va_arg()(inout va_list ap, TypeInfo ti, void* parmn)
+    {
+        // Wait until everyone updates to get TypeInfo.talign()
+        //auto talign = ti.talign();
+        //auto p = cast(void*)(cast(size_t)ap + talign - 1) & ~(talign - 1);
+        auto p = ap;
+        auto tsize = ti.tsize();
+        ap = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+        parmn[0..tsize] = p[0..tsize];
+    }
+
+    /***********************
+     * End use of ap.
+     */
+    void va_end(va_list ap)
+    {
+    }
+
+    void va_copy(out va_list dest, va_list src)
+    {
+        dest = src;
+    }
 }
-
-void va_end( va_list ap )
+else version (X86_64)
 {
+    // Layout of this struct must match __gnuc_va_list for C ABI compatibility
+    struct __va_list
+    {
+        uint offset_regs = 6 * 8;            // no regs
+        uint offset_fpregs = 6 * 8 + 8 * 16; // no fp regs
+        void* stack_args;
+        void* reg_args;
+    }
 
+    struct __va_argsave_t
+    {
+        size_t[6] regs;   // RDI,RSI,RDX,RCX,R8,R9
+        real[8] fpregs;   // XMM0..XMM7
+        __va_list va;
+    }
+
+    /*
+     * Making it an array of 1 causes va_list to be passed as a pointer in
+     * function argument lists
+     */
+    alias void* va_list;
+
+    void va_start(T)(out va_list ap, ref T parmn)
+    {
+        ap = &parmn.va;
+    }
+
+    T va_arg(T)(va_list ap)
+    {   T a;
+        va_arg(ap, a);
+        return a;
+    }
+
+    void va_arg(T)(va_list apx, ref T parmn)
+    {
+        __va_list* ap = cast(__va_list*)apx;
+        static if (is(T U == __argTypes))
+        {
+            static if (U.length == 0 || T.sizeof > 16 || U[0].sizeof > 8)
+            {   // Always passed in memory
+                // The arg may have more strict alignment than the stack
+                auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1);
+                ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+                parmn = *cast(T*)p;
+            }
+            else static if (U.length == 1)
+            {   // Arg is passed in one register
+                alias U[0] T1;
+                static if (is(T1 == double) || is(T1 == float))
+                {   // Passed in XMM register
+                    if (ap.offset_fpregs < (6 * 8 + 16 * 8))
+                    {
+                        parmn = *cast(T*)(ap.reg_args + ap.offset_fpregs);
+                        ap.offset_fpregs += 16;
+                    }
+                    else
+                    {
+                        parmn = *cast(T*)ap.stack_args;
+                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                    }
+                }
+                else
+                {   // Passed in regular register
+                    if (ap.offset_regs < 6 * 8 && T.sizeof <= 8)
+                    {
+                        parmn = *cast(T*)(ap.reg_args + ap.offset_regs);
+                        ap.offset_regs += 8;
+                    }
+                    else
+                    {
+                        auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1);
+                        ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+                        parmn = *cast(T*)p;
+                    }
+                }
+            }
+            else static if (U.length == 2)
+            {   // Arg is passed in two registers
+                alias U[0] T1;
+                alias U[1] T2;
+
+                static if (is(T1 == double) || is(T1 == float))
+                {
+                    if (ap.offset_fpregs < (6 * 8 + 16 * 8))
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_fpregs);
+                        ap.offset_fpregs += 16;
+                    }
+                    else
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
+                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                    }
+                }
+                else
+                {
+                    if (ap.offset_regs < 6 * 8 && T1.sizeof <= 8)
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_regs);
+                        ap.offset_regs += 8;
+                    }
+                    else
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
+                        ap.stack_args += 8;
+                    }
+                }
+
+                auto p = cast(void*)&parmn + 8;
+                static if (is(T2 == double) || is(T2 == float))
+                {
+                    if (ap.offset_fpregs < (6 * 8 + 16 * 8))
+                    {
+                        *cast(T2*)p = *cast(T2*)(ap.reg_args + ap.offset_fpregs);
+                        ap.offset_fpregs += 16;
+                    }
+                    else
+                    {
+                        *cast(T2*)p = *cast(T2*)ap.stack_args;
+                        ap.stack_args += (T2.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                    }
+                }
+                else
+                {
+                    void* a = void;
+                    if (ap.offset_regs < 6 * 8 && T2.sizeof <= 8)
+                    {
+                        a = ap.reg_args + ap.offset_regs;
+                        ap.offset_regs += 8;
+                    }
+                    else
+                    {
+                        a = ap.stack_args;
+                        ap.stack_args += 8;
+                    }
+                    // Be careful not to go past the size of the actual argument
+                    const sz2 = T.sizeof - 8;
+                    p[0..sz2] = a[0..sz2];
+                }
+            }
+            else
+            {
+                static assert(0);
+            }
+        }
+        else
+        {
+            static assert(0, "not a valid argument type for va_arg");
+        }
+    }
+
+    void va_arg()(va_list apx, TypeInfo ti, void* parmn)
+    {
+        __va_list* ap = cast(__va_list*)apx;
+        TypeInfo arg1, arg2;
+        if (!ti.argTypes(arg1, arg2))
+        {
+            if (arg1 && arg1.tsize() <= 8)
+            {   // Arg is passed in one register
+                auto tsize = arg1.tsize();
+                void* p;
+                auto s = arg1.toString();
+                if (s == "double" || s == "float")
+                {   // Passed in XMM register
+                    if (ap.offset_fpregs < (6 * 8 + 16 * 8))
+                    {
+                        p = ap.reg_args + ap.offset_fpregs;
+                        ap.offset_fpregs += 16;
+                    }
+                    else
+                    {
+                        p = ap.stack_args;
+                        ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                    }
+                }
+                else
+                {   // Passed in regular register
+                    if (ap.offset_regs < 6 * 8)
+                    {
+                        p = ap.reg_args + ap.offset_regs;
+                        ap.offset_regs += 8;
+                    }
+                    else
+                    {
+                        p = ap.stack_args;
+                        ap.stack_args += 8;
+                    }
+                }
+                parmn[0..tsize] = p[0..tsize];
+
+                if (arg2)
+                {
+                    parmn += 8;
+                    tsize = arg2.tsize();
+                    s = arg2.toString();
+                    if (s == "double" || s == "float")
+                    {   // Passed in XMM register
+                        if (ap.offset_fpregs < (6 * 8 + 16 * 8))
+                        {
+                            p = ap.reg_args + ap.offset_fpregs;
+                            ap.offset_fpregs += 16;
+                        }
+                        else
+                        {
+                            p = ap.stack_args;
+                            ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                        }
+                    }
+                    else
+                    {   // Passed in regular register
+                        if (ap.offset_regs < 6 * 8)
+                        {
+                            p = ap.reg_args + ap.offset_regs;
+                            ap.offset_regs += 8;
+                        }
+                        else
+                        {
+                            p = ap.stack_args;
+                            ap.stack_args += 8;
+                        }
+                    }
+                    tsize = ti.tsize() - 8;
+                    parmn[0..tsize] = p[0..tsize];
+                }
+            }
+            else
+            {   // Always passed in memory
+                // The arg may have more strict alignment than the stack
+                auto talign = ti.talign();
+                auto tsize = ti.tsize();
+                auto p = cast(void*)((cast(size_t)ap.stack_args + talign - 1) & ~(talign - 1));
+                ap.stack_args = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+                parmn[0..tsize] = p[0..tsize];
+            }
+        }
+        else
+        {
+            assert(0, "not a valid argument type for va_arg");
+        }
+    }
+
+    void va_end(va_list ap)
+    {
+    }
+
+    void va_copy(out va_list dest, va_list src)
+    {
+        dest = src;
+    }
 }
-
-void va_copy( out va_list dest, va_list src )
+else
 {
-    dest = src;
+    static assert(0);
 }
Index: src/core/vararg.d
===================================================================
--- src/core/vararg.d	(revision 429)
+++ src/core/vararg.d	(working copy)
@@ -1,83 +1,28 @@
-/**
- * The vararg module is intended to facilitate vararg manipulation in D.
- * It should be interface compatible with the C module "stdarg," and the
- * two modules may share a common implementation if possible (as is done
- * here). 
- * Copyright: Copyright Digital Mars 2000 - 2009.
- * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
- * Authors:   Walter Bright, Hauke Duden
- * Source:    $(DRUNTIMESRC core/_vararg.d)
- */
 
-/*          Copyright Digital Mars 2000 - 2009.
- * Distributed under the Boost Software License, Version 1.0.
- *    (See accompanying file LICENSE_1_0.txt or copy at
- *          http://www.boost.org/LICENSE_1_0.txt)
+/*
+ * Placed in public domain.
+ * Written by Hauke Duden and Walter Bright
  */
-module core.vararg;
 
+/* This is for use with variable argument lists with extern(D) linkage. */
 
-/**
- * The base vararg list type.
- */
-alias void* va_list;
+module core.vararg;
 
-
-/**
- * This function initializes the supplied argument pointer for subsequent
- * use by va_arg and va_end.
- *
- * Params:
- *  ap      = The argument pointer to initialize.
- *  paramn  = The identifier of the rightmost parameter in the function
- *            parameter list.
- */
-void va_start(T) ( out va_list ap, ref T parmn )
+version (X86)
 {
-    ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
-}
+    alias void* va_list;
 
-/**
- * This function returns the next argument in the sequence referenced by
- * the supplied argument pointer.  The argument pointer will be adjusted
- * to point to the next arggument in the sequence.
- *
- * Params:
- *  ap  = The argument pointer.
- *
- * Returns:
- *  The next argument in the sequence.  The result is undefined if ap
- *  does not point to a valid argument.
- */
-T va_arg(T) ( ref va_list ap )
-{
-    T arg = *cast(T*) ap;
-    ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
-    return arg;
+    template va_arg(T)
+    {
+        T va_arg(inout va_list _argptr)
+        {
+            T arg = *cast(T*)_argptr;
+            _argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1));
+            return arg;
+        }
+    }
 }
-
-/**
- * This function cleans up any resources allocated by va_start.  It is
- * currently a no-op and exists mostly for syntax compatibility with
- * the variadric argument functions for C.
- *
- * Params:
- *  ap  = The argument pointer.
- */
-void va_end( va_list ap )
+else
 {
-
+    public import core.stdc.stdarg;
 }
-
-
-/**
- * This function copied the argument pointer src to dst.
- *
- * Params:
- *  src = The source pointer.
- *  dst = The destination pointer.
- */
-void va_copy( out va_list dst, va_list src )
-{
-    dst = src;
-}
Index: src/core/sys/posix/sys/select.d
===================================================================
--- src/core/sys/posix/sys/select.d	(revision 429)
+++ src/core/sys/posix/sys/select.d	(working copy)
@@ -73,9 +73,9 @@
         fdset.fds_bits[__FDELT( fd )] &= ~__FDMASK( fd );
     }
 
-    extern (D) int FD_ISSET( int fd, fd_set* fdset )
+    extern (D) bool FD_ISSET( int fd, fd_set* fdset )
     {
-        return fdset.fds_bits[__FDELT( fd )] & __FDMASK( fd );
+        return (fdset.fds_bits[__FDELT( fd )] & __FDMASK( fd )) == 0;
     }
 
     extern (D) void FD_SET( int fd, fd_set* fdset )
