Iain Buclaw avatar Iain Buclaw committed 0ada920

Library updated to 1.070/2.055

Comments (0)

Files changed (122)

d/druntime/core/atomic.d

 
 
     HeadUnshared!(T) atomicLoad(msync ms = msync.seq, T)( ref const shared T val )
+    if(!__traits(isFloating, T))
     {
         static if( T.sizeof == byte.sizeof )
         {
         }
     }
 
-
     void atomicStore(msync ms = msync.seq, T, V1)( ref shared T val, V1 newval )
         if( __traits( compiles, mixin( "val = newval" ) ) )
     {
 
 
     HeadUnshared!(T) atomicLoad(msync ms = msync.seq, T)( ref const shared T val )
-    {
+    if(!__traits(isFloating, T)) {
         static if( T.sizeof == byte.sizeof )
         {
             //////////////////////////////////////////////////////////////////
     }
 }
 
+// This is an ABI adapter that works on all architectures.  It type puns
+// floats and doubles to ints and longs, atomically loads them, then puns
+// them back.  This is necessary so that they get returned in floating
+// point instead of integer registers.
+HeadUnshared!(T) atomicLoad(msync ms = msync.seq, T)( ref const shared T val )
+if(__traits(isFloating, T))
+{
+    static if(T.sizeof == int.sizeof)
+    {
+        static assert(is(T : float));
+        auto ptr = cast(int*) &val;
+        auto asInt = atomicLoad!(ms)(*ptr);
+        return *(cast(typeof(return)*) &asInt);
+    }
+    else static if(T.sizeof == long.sizeof)
+    {
+        static assert(is(T : double));
+        auto ptr = cast(long*) &val;
+        auto asLong = atomicLoad!(ms)(*ptr);
+        return *(cast(typeof(return)*) &asLong);
+    }
+    else
+    {
+        static assert(0, "Cannot atomically load 80-bit reals.");
+    }
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 // Unit Tests
 {
     void testCAS(T)( T val = T.init + 1 )
     {
-        T         base;
-        shared(T) atom;
+        T         base = cast(T) 0;
+        shared(T) atom = cast(T) 0;
 
-        assert( base != val );
-        assert( atom == base );
-        assert( cas( &atom, base, val ) );
-        assert( atom == val );
-        assert( !cas( &atom, base, base ) );
-        assert( atom == val );
+        assert( base != val, T.stringof );
+        assert( atom == base, T.stringof );
+        
+        assert( cas( &atom, base, val ), T.stringof );
+        assert( atom == val, T.stringof );
+        assert( !cas( &atom, base, base ), T.stringof );
+        assert( atom == val, T.stringof );
     }
 
-
     void testLoadStore(msync ms = msync.seq, T)( T val = T.init + 1 )
     {
-        T         base;
-        shared(T) atom;
+        T         base = cast(T) 0;
+        shared(T) atom = cast(T) 0;
 
         assert( base != val );
         assert( atom == base );
         atomicStore!(ms)( atom, val );
         base = atomicLoad!(ms)( atom );
-        assert( base == val );
+        
+        assert( base == val, T.stringof );
         assert( atom == val );
     }
 
         testType!(uint)();
 
         testType!(shared int*)();
+        
+        testType!(float)(1.0f);
+        testType!(double)(1.0);
 
         static if( has64BitCAS )
         {
 
         atomicOp!"-="( i, cast(size_t) 1 );
         assert( i == 0 );
+        
+        float f = 0;
+        atomicOp!"+="( f, 1 );
+        assert( f == 1 );
+        
+        double d = 0;
+        atomicOp!"+="( d, 1 );
+        assert( d == 1 );
     }
 }

d/druntime/core/cpuid.d

     /// The data caches. If there are fewer than 5 physical caches levels,
     /// the remaining levels are set to uint.max (== entire memory space)
     __gshared CacheInfo[5] datacache;
+    @property {
     /// Does it have an x87 FPU on-chip?
     bool x87onChip()    {return (features&FPU_BIT)!=0;}
     /// Is MMX supported?
             return false;
         return (features & SYSENTERSYSEXIT_BIT)!=0;
     }
-
+    
 
     /// Is 3DNow prefetch supported?
     bool has3dnowPrefetch()
     bool preferPentium4() { return probablyIntel && family == 0xF; }
     /// Does this CPU perform better on Pentium I code than Pentium Pro code?
     bool preferPentium1() { return family < 6 || (family==6 && model < 0xF && !probablyIntel); }
+    }
 
 __gshared:
     // All these values are set only once, and never subsequently modified.
     uint maxCores = 1;
     uint maxThreads = 1;
     // Note that this may indicate multi-core rather than hyperthreading.
-    bool hyperThreadingBit()    { return (features&HTT_BIT)!=0;}
+    @property bool hyperThreadingBit()    { return (features&HTT_BIT)!=0;}
 
     // feature flags CPUID1_EDX
     enum : uint

d/druntime/core/demangle.d

     //       faster than assembling the result piecemeal.
 
 
-    enum AddType { yes, no }
+    enum AddType { no, yes }
 
 
     this( const(char)[] buf_, char[] dst_ = null )
     {
-        this( buf_, AddType.no, dst_ );
+        this( buf_, AddType.yes, dst_ );
     }
 
 
     char[]          dst     = null;
     size_t          pos     = 0;
     size_t          len     = 0;
-    AddType         addType = AddType.no;
+    AddType         addType = AddType.yes;
 
 
     static class ParseException : Exception
         debug(trace) printf( "decodeNumber+\n" );
         debug(trace) scope(success) printf( "decodeNumber-\n" );
 
-        auto   num = sliceNumber();
+        return decodeNumber( sliceNumber() );
+    }
+
+
+    size_t decodeNumber( const(char)[] num )
+    {
+        debug(trace) printf( "decodeNumber+\n" );
+        debug(trace) scope(success) printf( "decodeNumber-\n" );
+
         size_t val = 0;
 
         foreach( i, e; num )
     {
         debug(trace) printf( "parseType+\n" );
         debug(trace) scope(success) printf( "parseType-\n" );
-
-        enum IsDelegate { yes, no }
-
         auto beg = len;
 
-        /*
-        TypeFunction:
-            CallConvention FuncAttrs Arguments ArgClose Type
-
-        CallConvention:
-            F       // D
-            U       // C
-            W       // Windows
-            V       // Pascal
-            R       // C++
-
-        FuncAttrs:
-            FuncAttr
-            FuncAttr FuncAttrs
-
-        FuncAttr:
-            empty
-            FuncAttrPure
-            FuncAttrNothrow
-            FuncAttrProperty
-            FuncAttrRef
-            FuncAttrTrusted
-            FuncAttrSafe
-
-        FuncAttrPure:
-            Na
-
-        FuncAttrNothrow:
-            Nb
-
-        FuncAttrRef:
-            Nc
-
-        FuncAttrProperty:
-            Nd
-
-        FuncAttrTrusted:
-            Ne
-
-        FuncAttrSafe:
-            Nf
-
-        Arguments:
-            Argument
-            Argument Arguments
-
-        Argument:
-            Argument2
-            M Argument2     // scope
-
-        Argument2:
-            Type
-            J Type     // out
-            K Type     // ref
-            L Type     // lazy
-
-        ArgClose
-            X     // variadic T t,...) style
-            Y     // variadic T t...) style
-            Z     // not variadic
-        */
-        void parseTypeFunction( IsDelegate isdg = IsDelegate.no )
-        {
-            debug(trace) printf( "parseTypeFunction+\n" );
-            debug(trace) scope(success) printf( "parseTypeFunction-\n" );
-
-            // CallConvention
-            switch( tok() )
-            {
-            case 'F': // D
-                next();
-                break;
-            case 'U': // C
-                next();
-                put( "extern (C) " );
-                break;
-            case 'W': // Windows
-                next();
-                put( "extern (Windows) " );
-                break;
-            case 'V': // Pascal
-                next();
-                put( "extern (Pascal) " );
-                break;
-            case 'R': // C++
-                next();
-                put( "extern (C++) " );
-                break;
-            default:
-                error();
-            }
-
-            // FuncAttrs
-            breakFuncAttrs:
-            while( 'N' == tok() )
-            {
-                next();
-                switch( tok() )
-                {
-                case 'a': // FuncAttrPure
-                    next();
-                    put( "pure " );
-                    continue;
-                case 'b': // FuncAttrNoThrow
-                    next();
-                    put( "nothrow " );
-                    continue;
-                case 'c': // FuncAttrRef
-                    next();
-                    put( "ref " );
-                    continue;
-                case 'd': // FuncAttrProperty
-                    next();
-                    put( "@property " );
-                    continue;
-                case 'e': // FuncAttrTrusted
-                    next();
-                    put( "@trusted " );
-                    continue;
-                case 'f': // FuncAttrSafe
-                    next();
-                    put( "@safe " );
-                    continue;
-                case 'g':
-                    // NOTE: The inout parameter type is represented as "Ng",
-                    //       which makes it look like a FuncAttr.  So if we
-                    //       see an "Ng" FuncAttr we know we're really in
-                    //       the parameter list.  Rewind and break.
-                    pos--;
-                    break breakFuncAttrs;
-                default:
-                    error();
-                }
-            }
-
-            beg = len;
-            put( "(" );
-            scope(success)
-            {
-                put( ")" );
-                auto t = len;
-                parseType();
-                put( " " );
-                if( name.length )
-                {
-                    if( !contains( dst[0 .. len], name ) )
-                        put( name );
-                    else if( shift( name ).ptr != name.ptr )
-                    {
-                        beg -= name.length;
-                        t -= name.length;
-                    }
-                }
-                else if( IsDelegate.yes == isdg )
-                    put( "delegate" );
-                else
-                    put( "function" );
-                shift( dst[beg .. t] );
-            }
-
-            // Arguments
-            for( size_t n = 0; true; n++ )
-            {
-                debug(info) printf( "tok (%c)\n", tok() );
-                switch( tok() )
-                {
-                case 'X': // ArgClose (variadic T t,...) style)
-                    next();
-                    put( ", ..." );
-                    return;
-                case 'Y': // ArgClose (variadic T t...) style)
-                    next();
-                    put( "..." );
-                    return;
-                case 'Z': // ArgClose (not variadic)
-                    next();
-                    return;
-                default:
-                    break;
-                }
-                if( n )
-                {
-                    put( ", " );
-                }
-                if( 'M' == tok() )
-                {
-                    next();
-                    put( "scope " );
-                }
-                switch( tok() )
-                {
-                case 'J': // out (J Type)
-                    next();
-                    put( "out " );
-                    parseType();
-                    continue;
-                case 'K': // ref (K Type)
-                    next();
-                    put( "ref " );
-                    parseType();
-                    continue;
-                case 'L': // lazy (L Type)
-                    next();
-                    put( "lazy " );
-                    parseType();
-                    continue;
-                default:
-                    parseType();
-                }
-            }
-        }
-
         switch( tok() )
         {
         case 'O': // Shared (O Type)
             pad( name );
             return dst[beg .. len];
         case 'F': case 'U': case 'W': case 'V': case 'R': // TypeFunction
-            parseTypeFunction();
-            return dst[beg .. len];
+            return parseTypeFunction( name );
         case 'I': // TypeIdent (I LName)
         case 'C': // TypeClass (C LName)
         case 'S': // TypeStruct (S LName)
         case 'T': // TypeTypedef (T LName)
             next();
             parseQualifiedName();
+            pad( name );
             return dst[beg .. len];
         case 'D': // TypeDelegate (D TypeFunction)
             next();
-            parseTypeFunction( IsDelegate.yes );
+            parseTypeFunction( name, IsDelegate.yes );
             return dst[beg .. len];
         case 'n': // TypeNone (n)
             next();
         case 'v': // TypeVoid (v)
             next();
             put( "void" );
+            pad( name );
             return dst[beg .. len];
         case 'g': // TypeByte (g)
             next();
 
 
     /*
+    TypeFunction:
+        CallConvention FuncAttrs Arguments ArgClose Type
+
+    CallConvention:
+        F       // D
+        U       // C
+        W       // Windows
+        V       // Pascal
+        R       // C++
+
+    FuncAttrs:
+        FuncAttr
+        FuncAttr FuncAttrs
+
+    FuncAttr:
+        empty
+        FuncAttrPure
+        FuncAttrNothrow
+        FuncAttrProperty
+        FuncAttrRef
+        FuncAttrTrusted
+        FuncAttrSafe
+
+    FuncAttrPure:
+        Na
+
+    FuncAttrNothrow:
+        Nb
+
+    FuncAttrRef:
+        Nc
+
+    FuncAttrProperty:
+        Nd
+
+    FuncAttrTrusted:
+        Ne
+
+    FuncAttrSafe:
+        Nf
+
+    Arguments:
+        Argument
+        Argument Arguments
+
+    Argument:
+        Argument2
+        M Argument2     // scope
+
+    Argument2:
+        Type
+        J Type     // out
+        K Type     // ref
+        L Type     // lazy
+
+    ArgClose
+        X     // variadic T t,...) style
+        Y     // variadic T t...) style
+        Z     // not variadic
+    */
+    enum IsDelegate { no, yes }
+    char[] parseTypeFunction( char[] name = null, IsDelegate isdg = IsDelegate.no )
+    {
+        debug(trace) printf( "parseTypeFunction+\n" );
+        debug(trace) scope(success) printf( "parseTypeFunction-\n" );
+        auto beg = len;
+
+        // CallConvention
+        switch( tok() )
+        {
+        case 'F': // D
+            next();
+            break;
+        case 'U': // C
+            next();
+            put( "extern (C) " );
+            break;
+        case 'W': // Windows
+            next();
+            put( "extern (Windows) " );
+            break;
+        case 'V': // Pascal
+            next();
+            put( "extern (Pascal) " );
+            break;
+        case 'R': // C++
+            next();
+            put( "extern (C++) " );
+            break;
+        default:
+            error();
+        }
+
+        // FuncAttrs
+        breakFuncAttrs:
+        while( 'N' == tok() )
+        {
+            next();
+            switch( tok() )
+            {
+            case 'a': // FuncAttrPure
+                next();
+                put( "pure " );
+                continue;
+            case 'b': // FuncAttrNoThrow
+                next();
+                put( "nothrow " );
+                continue;
+            case 'c': // FuncAttrRef
+                next();
+                put( "ref " );
+                continue;
+            case 'd': // FuncAttrProperty
+                next();
+                put( "@property " );
+                continue;
+            case 'e': // FuncAttrTrusted
+                next();
+                put( "@trusted " );
+                continue;
+            case 'f': // FuncAttrSafe
+                next();
+                put( "@safe " );
+                continue;
+            case 'g':
+                // NOTE: The inout parameter type is represented as "Ng",
+                //       which makes it look like a FuncAttr.  So if we
+                //       see an "Ng" FuncAttr we know we're really in
+                //       the parameter list.  Rewind and break.
+                pos--;
+                break breakFuncAttrs;
+            default:
+                error();
+            }
+        }
+
+        beg = len;
+        put( "(" );
+        scope(success)
+        {
+            put( ")" );
+            auto t = len;
+            parseType();
+            put( " " );
+            if( name.length )
+            {
+                if( !contains( dst[0 .. len], name ) )
+                    put( name );
+                else if( shift( name ).ptr != name.ptr )
+                {
+                    beg -= name.length;
+                    t -= name.length;
+                }
+            }
+            else if( IsDelegate.yes == isdg )
+                put( "delegate" );
+            else
+                put( "function" );
+            shift( dst[beg .. t] );
+        }
+
+        // Arguments
+        for( size_t n = 0; true; n++ )
+        {
+            debug(info) printf( "tok (%c)\n", tok() );
+            switch( tok() )
+            {
+            case 'X': // ArgClose (variadic T t...) style)
+                next();
+                put( "..." );
+                return dst[beg .. len];
+            case 'Y': // ArgClose (variadic T t,...) style)
+                next();
+                put( ", ..." );
+                return dst[beg .. len];
+            case 'Z': // ArgClose (not variadic)
+                next();
+                return dst[beg .. len];
+            default:
+                break;
+            }
+            if( n )
+            {
+                put( ", " );
+            }
+            if( 'M' == tok() )
+            {
+                next();
+                put( "scope " );
+            }
+            switch( tok() )
+            {
+            case 'J': // out (J Type)
+                next();
+                put( "out " );
+                parseType();
+                continue;
+            case 'K': // ref (K Type)
+                next();
+                put( "ref " );
+                parseType();
+                continue;
+            case 'L': // lazy (L Type)
+                next();
+                put( "lazy " );
+                parseType();
+                continue;
+            default:
+                parseType();
+            }
+        }
+        assert(0);
+    }
+
+
+    /*
     Value:
         n
         Number
         debug(trace) printf( "parseValue+\n" );
         debug(trace) scope(success) printf( "parseValue-\n" );
 
+//        printf( "*** %c\n", tok() );
         switch( tok() )
         {
         case 'n':
                 error( "Number expected" );
             // fall-through intentional
         case '0': .. case '9':
-            put( sliceNumber() );
+            putIntegerValue( name, type );
             return;
         case 'N':
             next();
             put( "-" );
-            put( sliceNumber() );
+            putIntegerValue( name, type );
             return;
         case 'e':
             next();
             next();
             parseReal();
             put( "+" );
+            match( 'c' );
             parseReal();
             put( "i" );
             return;
     }
 
 
+    void putIntegerValue( char[] name = null, char type = '\0' )
+    {
+        debug(trace) printf( "putIntegerValue+\n" );
+        debug(trace) scope(success) printf( "putIntegerValue-\n" );
+
+        switch( type )
+        {
+        case 'a': // char
+        case 'u': // wchar
+        case 'w': // dchar
+        {
+            auto val = sliceNumber();
+            auto num = decodeNumber( val );
+
+            switch( num )
+            {
+            case '\'':
+                put( "'\\''" );
+                return;
+            // \", \?
+            case '\\':
+                put( "'\\\\'" );
+                return;
+            case '\a':
+                put( "'\\a'" );
+                return;
+            case '\b':
+                put( "'\\b'" );
+                return;
+            case '\f':
+                put( "'\\f'" );
+                return;
+            case '\n':
+                put( "'\\n'" );
+                return;
+            case '\r':
+                put( "'\\r'" );
+                return;
+            case '\t':
+                put( "'\\t'" );
+                return;
+            case '\v':
+                put( "'\\v'" );
+                return;
+            default:
+                if( num < 0x20 || num == 0x7F )
+                {
+                    // TODO: Put as hex.
+                    put( val );
+                    return;
+                }
+                else
+                {
+                    // TODO: Handle wchar & dchar.
+                    put( val );
+                    return;
+                }
+            }
+        }
+        case 'b': // bool
+            put( decodeNumber() ? "true" : "false" );
+            return;
+        case 'h', 't', 'k': // ubyte, ushort, uint
+            put( sliceNumber() );
+            put( "u" );
+            return;
+        case 'l': // long
+            put( sliceNumber() );
+            put( "L" );
+            return;
+        case 'm': // ulong
+            put( sliceNumber() );
+            put( "uL" );
+            return;
+        default:
+            put( sliceNumber() );
+            return;
+        }
+    }
+
+
     /*
     TemplateArgs:
         TemplateArg
             debug(info) printf( "name (%.*s)\n", cast(int) name.length, name.ptr );
             if( 'M' == tok() )
                 next(); // has 'this' pointer
-            if( addType )
+            if( AddType.yes == addType )
                 parseType( name );
             if( pos >= buf.length )
                 return;
         ["_D4test3fooAa", "char[] test.foo"],
         ["_D8demangle8demangleFAaZAa", "char[] demangle.demangle(char[])"],
         ["_D6object6Object8opEqualsFC6ObjectZi", "int object.Object.opEquals(Object)"],
-        ["_D4test2dgDFiYd", "double test.dg(int...)"],
+        ["_D4test2dgDFiYd", "double test.dg(int, ...)"],
         //["_D4test58__T9factorialVde67666666666666860140VG5aa5_68656c6c6fVPvnZ9factorialf", ""],
         //["_D4test101__T9factorialVde67666666666666860140Vrc9a999999999999d9014000000000000000c00040VG5aa5_68656c6c6fVPvnZ9factorialf", ""],
         ["_D4test34__T3barVG3uw3_616263VG3wd3_646566Z1xi", "int test.bar!(\"abc\"w, \"def\"d).x"],
         ["_D8demangle4testFLC6ObjectLDFLiZiZi", "int demangle.test(lazy Object, lazy int delegate(lazy int))"],
-        ["_D8demangle4testFAiXi", "int demangle.test(int[], ...)"],
-        ["_D8demangle4testFLAiXi", "int demangle.test(lazy int[], ...)"],
+        ["_D8demangle4testFAiXi", "int demangle.test(int[]...)"],
+        ["_D8demangle4testFAiYi", "int demangle.test(int[], ...)"],
+        ["_D8demangle4testFLAiXi", "int demangle.test(lazy int[]...)"],
+        ["_D8demangle4testFLAiYi", "int demangle.test(lazy int[], ...)"],
         ["_D6plugin8generateFiiZAya", "immutable(char)[] plugin.generate(int, int)"],
         ["_D6plugin8generateFiiZAxa", "const(char)[] plugin.generate(int, int)"],
         ["_D6plugin8generateFiiZAOa", "shared(char)[] plugin.generate(int, int)"],

d/druntime/core/exception.d

 
 private
 {
-    alias void function( string file, size_t line, string msg = null ) errorHandlerType;
+    alias void function( string file, size_t line, string msg ) errorHandlerType;
 
     // NOTE: One assert handler is used for all threads.  Thread-local
     //       behavior should occur within the handler itself.  This delegate
 {
     if( assertHandler is null )
         throw new AssertError( file, line );
-    assertHandler( file, line );
+    assertHandler( file, line, null);
 }
 
 

d/druntime/core/memory.d

         FINALIZE    = 0b0000_0001, /// Finalize the data in this block on collect.
         NO_SCAN     = 0b0000_0010, /// Do not scan through this block on collect.
         NO_MOVE     = 0b0000_0100,  /// Do not move this memory block on collect.
-        APPENDABLE  = 0b0000_1000  /// This block contains the info to allow appending.
+        APPENDABLE  = 0b0000_1000, /// This block contains the info to allow appending.
+        
+        /**
+        This block is guaranteed to have a pointer to its base while it's
+        alive.  Interior pointers can be safely ignored.  This attribute
+        is useful for eliminating false pointers in very large data structures
+        and is only implemented for data structures at least a page in size.
+        */
+        NO_INTERIOR = 0b0001_0000  
+                                   
     }
 
 

d/druntime/core/runtime.d

 
     alias bool function() ModuleUnitTester;
     alias bool function(Object) CollectHandler;
-    alias Throwable.TraceInfo function( void* ptr = null ) TraceHandler;
+    alias Throwable.TraceInfo function( void* ptr ) TraceHandler;
 
     extern (C) void rt_setCollectHandler( CollectHandler h );
     extern (C) CollectHandler rt_getCollectHandler();
         import core.demangle;
         import core.stdc.stdlib : free;
         import core.stdc.string : strlen, memchr;
-        extern (C) int    backtrace(void**, size_t);
+        extern (C) int    backtrace(void**, int);
         extern (C) char** backtrace_symbols(void**, int);
-        extern (C) void   backtrace_symbols_fd(void**,int,int);
+        extern (C) void   backtrace_symbols_fd(void**, int, int);
         import core.sys.posix.signal; // segv handler
     }
     else version( OSX )
         import core.demangle;
         import core.stdc.stdlib : free;
         import core.stdc.string : strlen;
-        extern (C) int    backtrace(void**, size_t);
+        extern (C) int    backtrace(void**, int);
         extern (C) char** backtrace_symbols(void**, int);
-        extern (C) void   backtrace_symbols_fd(void**,int,int);
+        extern (C) void   backtrace_symbols_fd(void**, int, int);
         import core.sys.posix.signal; // segv handler
     }
     else version( Windows )
                     }
                     catch( Throwable e )
                     {
-                        console( e.toString )( "\n" );
+                        console( e.toString() )( "\n" );
                         failed++;
                     }
                 }

d/druntime/core/stdc/errno.d

 extern (C) int getErrno();      // for internal use
 extern (C) int setErrno(int);   // for internal use
 
-alias getErrno errno;
-alias setErrno errno;
+@property int errno() { return getErrno(); }
+@property int errno(int n) { return setErrno(n); }
 
 extern (C):
 nothrow:

d/druntime/core/stdc/string.d

 char*  strtok(char* s1, in char* s2);
 char*  strerror(int errnum);
 pure size_t strlen(in char* s);
+char*  strdup(in char *s);

d/druntime/core/sync/rwmutex.d

                     if( ++numReaders > maxReaders )
                         maxReaders = numReaders;
                 }
-                Thread.sleep( 100_000 ); // 1ms
+                Thread.sleep( dur!"msecs"(1) );
                 synchronized( synInfo )
                 {
                     --numReaders;
                         if( ++numReaders > maxReaders )
                             maxReaders = numReaders;
                     }
-                    Thread.sleep( 100_000 ); // 1ms
+                    Thread.sleep( dur!"msecs"(1) );
                     synchronized( synInfo )
                     {
                         --numReaders;
                         if( ++numWriters > maxWriters )
                             maxWriters = numWriters;
                     }
-                    Thread.sleep( 100_000 ); // 1ms
+                    Thread.sleep( dur!"msecs"(1) );
                     synchronized( synInfo )
                     {
                         --numWriters;

d/druntime/core/sync/semaphore.d

             mach_timespec_t t = void;
             (cast(byte*) &t)[0 .. t.sizeof] = 0;
 
-            if( dur!("nsecs")( 0 ) == val )
+            if( val.total!("seconds")() > t.tv_sec.max )
             {
-                if( val.total!("seconds")() > t.tv_sec.max )
-                {
-                    t.tv_sec  = t.tv_sec.max;
-                    t.tv_nsec = cast(typeof(t.tv_nsec)) val.fracSec.nsecs;
-                }
-                else
-                {
-                    t.tv_sec  = cast(typeof(t.tv_sec)) val.total!("seconds")();
-                    t.tv_nsec = cast(typeof(t.tv_nsec)) val.fracSec.nsecs;
-                }
+                t.tv_sec  = t.tv_sec.max;
+                t.tv_nsec = cast(typeof(t.tv_nsec)) val.fracSec.nsecs;
+            }
+            else
+            {
+                t.tv_sec  = cast(typeof(t.tv_sec)) val.total!("seconds")();
+                t.tv_nsec = cast(typeof(t.tv_nsec)) val.fracSec.nsecs;
             }
             while( true )
             {
                 }
                 Thread.yield();
             }
-            alertedOne = semReady.wait( dur!"msecs"(200) );
-            alertedTwo = semReady.wait( dur!"msecs"(200) );
+            alertedOne = semReady.wait( dur!"msecs"(100) );
+            alertedTwo = semReady.wait( dur!"msecs"(100) );
         }
 
         auto thread = new Thread( &waiter );

d/druntime/core/sys/osx/pthread.d

+/**
+ * D header file for OSX.
+ *
+ * Copyright: Copyright Sean Kelly 2008 - 2009.
+ * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+ * Authors:   Sean Kelly
+ */
+
+/*          Copyright Sean Kelly 2008 - 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)
+ */
+module core.sys.osx.pthread;
+
+version (OSX):
+
+public import core.sys.posix.pthread;
+public import core.sys.osx.mach.port;
+
+extern (C):
+
+int pthread_is_threaded_np();
+int pthread_threadid_np(pthread_t, ulong*);
+// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
+int pthread_rwlock_longrdlock_np(pthread_rwlock_t*);
+int pthread_rwlock_yieldwrlock_np(pthread_rwlock_t*);
+// ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
+int pthread_rwlock_downgrade_np(pthread_rwlock_t*);
+int pthread_rwlock_upgrade_np(pthread_rwlock_t*);
+int pthread_rwlock_tryupgrade_np(pthread_rwlock_t*);
+int pthread_rwlock_held_np(pthread_rwlock_t*);
+int pthread_rwlock_rdheld_np(pthread_rwlock_t*);
+int pthread_rwlock_wrheld_np(pthread_rwlock_t*);
+int pthread_getname_np(pthread_t, char*, size_t);
+int pthread_setname_np(in char*);
+// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
+int pthread_main_np();
+mach_port_t pthread_mach_thread_np(pthread_t);
+size_t pthread_get_stacksize_np(pthread_t);
+void* pthread_get_stackaddr_np(pthread_t);
+int pthread_cond_signal_thread_np(pthread_cond_t*, pthread_t);
+int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, in timespec*);
+int pthread_create_suspended_np(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
+int pthread_kill(pthread_t, int);
+pthread_t pthread_from_mach_thread_np(mach_port_t);
+// ^ __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
+int pthread_sigmask(int, in sigset_t*, sigset_t*);
+// ^ __DARWIN_ALIAS(pthread_sigmask)
+void pthread_yield_np();

d/druntime/core/sys/posix/arpa/inet.d

 // Required
 //
 /*
+NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
+      a circular import: in_port_t, in_addr_t, struct in_addr, INET_ADDRSTRLEN.
+
 in_port_t // from core.sys.posix.netinet.in_
 in_addr_t // from core.sys.posix.netinet.in_
 
 }
 else version( OSX )
 {
-    alias uint16_t in_port_t; // TODO: verify
-    alias uint32_t in_addr_t; // TODO: verify
+    alias uint16_t in_port_t;
+    alias uint32_t in_addr_t;
 
     struct in_addr
     {
 // IPV6 (IP6)
 //
 /*
+NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
+      a circular import: INET6_ADDRSTRLEN.
+
 INET6_ADDRSTRLEN // from core.sys.posix.netinet.in_
 */
 

d/druntime/core/sys/posix/dirent.d

         char[256] d_name;
     }
 
-    typedef void* DIR;
+    alias void* DIR;
 
     dirent* readdir(DIR*);
 }

d/druntime/core/sys/posix/netinet/in_.d

 
 version( linux )
 {
+    //alias uint16_t in_port_t;
+    //alias uint32_t in_addr_t;
+
+    //struct in_addr
+    //{
+    //    in_addr_t s_addr;
+    //}
+    
     private enum __SOCK_SIZE__ = 16;
 
     struct sockaddr_in
     enum uint INADDR_ANY       = 0x00000000;
     enum uint INADDR_BROADCAST = 0xffffffff;
 
-    enum INET_ADDRSTRLEN       = 16;
+    //enum INET_ADDRSTRLEN       = 16;
 }
 else version( OSX )
 {
+    //alias uint16_t in_port_t;
+    //alias uint32_t in_addr_t;
+
+    //struct in_addr
+    //{
+    //    in_addr_t s_addr;
+    //}
+    
     private enum __SOCK_SIZE__ = 16;
 
     struct sockaddr_in
     enum uint INADDR_ANY       = 0x00000000;
     enum uint INADDR_BROADCAST = 0xffffffff;
 
-    enum INET_ADDRSTRLEN       = 16;
+    //enum INET_ADDRSTRLEN       = 16;
 }
 else version( FreeBSD )
 {
+    //alias uint16_t in_port_t;
+    //alias uint32_t in_addr_t;
+
+    //struct in_addr
+    //{
+    //    in_addr_t s_addr;
+    //}
+    
     struct sockaddr_in
     {
         ubyte       sin_len;
 
     enum uint INADDR_ANY       = 0x00000000;
     enum uint INADDR_BROADCAST = 0xffffffff;
+    
+    //enum INET_ADDRSTRLEN       = 16;
 }
 
 
     {
         IPPROTO_IPV6        = 41,
 
-        INET6_ADDRSTRLEN    = 46,
+        //INET6_ADDRSTRLEN    = 46,
 
         IPV6_JOIN_GROUP     = 20,
         IPV6_LEAVE_GROUP    = 21,
     {
         IPPROTO_IPV6        = 41,
 
-        INET6_ADDRSTRLEN    = 46,
+        //INET6_ADDRSTRLEN    = 46,
 
         IPV6_JOIN_GROUP     = 12,
         IPV6_LEAVE_GROUP    = 13,
         in6_addr    ipv6mr_multiaddr;
         uint        ipv6mr_interface;
     }
+    
+    enum : uint
+    {
+        IPPROTO_IPV6        = 41,
 
-    enum INET6_ADDRSTRLEN    = 46;
-    enum IPPROTO_IPV6        = 41; // <netinet/in.h>
-
-    enum
-    {
-        IPV6_SOCKOPT_RESERVED1  = 3,
-        IPV6_UNICAST_HOPS       = 4,
-        IPV6_MULTICAST_IF       = 9,
-        IPV6_MULTICAST_HOPS     = 10,
-        IPV6_MULTICAST_LOOP     = 11,
-        IPV6_JOIN_GROUP         = 12,
-        IPV6_LEAVE_GROUP        = 13,
-        IPV6_PORTRANGE          = 14,
-        ICMP6_FILTER            = 18,
-        IPV6_CHECKSUM           = 26,
-        IPV6_V6ONLY             = 27,
+        //INET6_ADDRSTRLEN    = 46,
+        
+        IPV6_JOIN_GROUP     = 12,
+        IPV6_LEAVE_GROUP    = 13,
+        IPV6_MULTICAST_HOPS = 10,
+        IPV6_MULTICAST_IF   = 9,
+        IPV6_MULTICAST_LOOP = 11,
+        IPV6_UNICAST_HOPS   = 4,
+        IPV6_V6ONLY         = 27,
     }
 
     private enum

d/druntime/core/sys/posix/pthread.d

 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int); (TPP)
 int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int); (TPI|TPP)
 */
+version( OSX )
+{
+    enum
+    {
+        PTHREAD_PRIO_NONE,
+        PTHREAD_PRIO_INHERIT,
+        PTHREAD_PRIO_PROTECT
+    }
+
+    int pthread_mutex_getprioceiling(in pthread_mutex_t*, int*);
+    int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*);
+    int pthread_mutexattr_getprioceiling(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int);
+    int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int);
+}
 
 //
 // Scheduling (TPS)
 int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
 int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 */
+
 version( FreeBSD )
 {
     int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
     int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 }
-
+else version( OSX )
+{
+    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_setpshared(pthread_condattr_t*, int);
+    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
+    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+}

d/druntime/core/sys/posix/sys/un.d

+/**
+ * D header file for POSIX.
+ *
+ * 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: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          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)
+ */
+module core.sys.posix.sys.un;
+
+public import core.sys.posix.sys.socket: sa_family_t;
+
+extern(C):
+
+//
+// Required
+//
+/*
+struct sockaddr_un
+{
+    sa_family_t sun_family;
+    char        sa_data[];
+}
+
+sa_family_t    // From core.sys.posix.sys.socket
+*/
+
+version( linux )
+{
+    struct sockaddr_un
+    {
+        sa_family_t sun_family;
+        byte[108]   sun_path;
+    }
+}
+else version( OSX )
+{
+    struct sockaddr_un
+    {
+        ubyte       sun_len;
+        sa_family_t sun_family;
+        byte[104]   sun_path;
+    }
+}
+else version( FreeBSD )
+{
+    struct sockaddr_un
+    {
+        ubyte       sun_len;
+        sa_family_t sun_family;
+        byte[104]   sun_path;
+    }
+}

d/druntime/core/sys/windows/dbghelp.d

 
 extern(System)
 {
-    typedef BOOL    function(HANDLE hProcess, DWORD64 lpBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead) ReadProcessMemoryProc64;
-    typedef PVOID   function(HANDLE hProcess, DWORD64 AddrBase) FunctionTableAccessProc64;
-    typedef DWORD64 function(HANDLE hProcess, DWORD64 Address) GetModuleBaseProc64;
-    typedef DWORD64 function(HANDLE hProcess, HANDLE hThread, ADDRESS64 *lpaddr) TranslateAddressProc64;
+    alias BOOL    function(HANDLE hProcess, DWORD64 lpBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead) ReadProcessMemoryProc64;
+    alias PVOID   function(HANDLE hProcess, DWORD64 AddrBase) FunctionTableAccessProc64;
+    alias DWORD64 function(HANDLE hProcess, DWORD64 Address) GetModuleBaseProc64;
+    alias DWORD64 function(HANDLE hProcess, HANDLE hThread, ADDRESS64 *lpaddr) TranslateAddressProc64;
 
-    typedef BOOL    function(HANDLE hProcess, PCSTR UserSearchPath, bool fInvadeProcess) SymInitializeFunc;
-    typedef BOOL    function(HANDLE hProcess) SymCleanupFunc;
-    typedef DWORD   function(DWORD SymOptions) SymSetOptionsFunc;
-    typedef DWORD   function() SymGetOptionsFunc;
-    typedef PVOID   function(HANDLE hProcess, DWORD64 AddrBase) SymFunctionTableAccess64Func;
-    typedef BOOL    function(DWORD MachineType, HANDLE hProcess, HANDLE hThread, STACKFRAME64 *StackFrame, PVOID ContextRecord,
+    alias BOOL    function(HANDLE hProcess, PCSTR UserSearchPath, bool fInvadeProcess) SymInitializeFunc;
+    alias BOOL    function(HANDLE hProcess) SymCleanupFunc;
+    alias DWORD   function(DWORD SymOptions) SymSetOptionsFunc;
+    alias DWORD   function() SymGetOptionsFunc;
+    alias PVOID   function(HANDLE hProcess, DWORD64 AddrBase) SymFunctionTableAccess64Func;
+    alias BOOL    function(DWORD MachineType, HANDLE hProcess, HANDLE hThread, STACKFRAME64 *StackFrame, PVOID ContextRecord,
                              ReadProcessMemoryProc64 ReadMemoryRoutine, FunctionTableAccessProc64 FunctoinTableAccess,
                              GetModuleBaseProc64 GetModuleBaseRoutine, TranslateAddressProc64 TranslateAddress) StackWalk64Func;
-    typedef BOOL    function(HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, IMAGEHLP_LINE64 *line) SymGetLineFromAddr64Func;
-    typedef DWORD64 function(HANDLE hProcess, DWORD64 dwAddr) SymGetModuleBase64Func;
-    typedef BOOL    function(HANDLE hProcess, DWORD64 dwAddr, IMAGEHLP_MODULE64 *ModuleInfo) SymGetModuleInfo64Func;
-    typedef BOOL    function(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, IMAGEHLP_SYMBOL64 *Symbol) SymGetSymFromAddr64Func;
-    typedef DWORD   function(PCTSTR DecoratedName, PTSTR UnDecoratedName, DWORD UndecoratedLength, DWORD Flags) UnDecorateSymbolNameFunc;
-    typedef DWORD64 function(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll) SymLoadModule64Func;
-    typedef BOOL    function(HANDLE HProcess, PTSTR SearchPath, DWORD SearchPathLength) SymGetSearchPathFunc;
-    typedef BOOL    function(HANDLE hProcess, DWORD64 Address) SymUnloadModule64Func;
+    alias BOOL    function(HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, IMAGEHLP_LINE64 *line) SymGetLineFromAddr64Func;
+    alias DWORD64 function(HANDLE hProcess, DWORD64 dwAddr) SymGetModuleBase64Func;
+    alias BOOL    function(HANDLE hProcess, DWORD64 dwAddr, IMAGEHLP_MODULE64 *ModuleInfo) SymGetModuleInfo64Func;
+    alias BOOL    function(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, IMAGEHLP_SYMBOL64 *Symbol) SymGetSymFromAddr64Func;
+    alias DWORD   function(PCTSTR DecoratedName, PTSTR UnDecoratedName, DWORD UndecoratedLength, DWORD Flags) UnDecorateSymbolNameFunc;
+    alias DWORD64 function(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll) SymLoadModule64Func;
+    alias BOOL    function(HANDLE HProcess, PTSTR SearchPath, DWORD SearchPathLength) SymGetSearchPathFunc;
+    alias BOOL    function(HANDLE hProcess, DWORD64 Address) SymUnloadModule64Func;
 }
 
 struct DbgHelp

d/druntime/core/sys/windows/stacktrace.d

     DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR pBuffer, DWORD nSize);
     void  RtlCaptureContext(CONTEXT* ContextRecord);
 
-    typedef LONG function(void*) UnhandeledExceptionFilterFunc;
+    alias LONG function(void*) UnhandeledExceptionFilterFunc;
     void* SetUnhandledExceptionFilter(void* handler);
 }
 
 
 extern(System)
 {
-    typedef HANDLE function(DWORD dwFlags, DWORD th32ProcessID) CreateToolhelp32SnapshotFunc;
-    typedef BOOL   function(HANDLE hSnapshot, MODULEENTRY32 *lpme) Module32FirstFunc;
-    typedef BOOL   function(HANDLE hSnapshot, MODULEENTRY32 *lpme) Module32NextFunc;
+    alias HANDLE function(DWORD dwFlags, DWORD th32ProcessID) CreateToolhelp32SnapshotFunc;
+    alias BOOL   function(HANDLE hSnapshot, MODULEENTRY32 *lpme) Module32FirstFunc;
+    alias BOOL   function(HANDLE hSnapshot, MODULEENTRY32 *lpme) Module32NextFunc;
 }
 
 
         auto symbolSize = IMAGEHLP_SYMBOL64.sizeof + MAX_NAMELEN;
         auto symbol     = cast(IMAGEHLP_SYMBOL64*) calloc( symbolSize, 1 );
 
-        static assert((IMAGEHLP_SYMBOL64.sizeof + MAX_NAMELEN) < uint.max, "symbolSize should never exceed uint.max");
-        
-        symbol.SizeOfStruct  = cast(DWORD) symbolSize;
+        version( GNU )
+        {
+            static assert((IMAGEHLP_SYMBOL64.sizeof + MAX_NAMELEN) < uint.max, "symbolSize should never exceed uint.max");
+            symbol.SizeOfStruct  = cast(DWORD) symbolSize;
+        }
+        else
+        symbol.SizeOfStruct  = symbolSize;
         symbol.MaxNameLength = MAX_NAMELEN;
 
         IMAGEHLP_LINE64 line;

d/druntime/core/sys/windows/threadaux.d

         }
 
         // execute function on the TLS for the given thread
-        static void impersonate_thread( uint id, void function() fn )
+        alias extern(C) void function() externCVoidFunc;
+        static void impersonate_thread( uint id, externCVoidFunc fn )
         {
             if( id == GetCurrentThreadId() )
             {

d/druntime/core/sys/windows/windows.d

     alias uint * PULONG_PTR;
 }
 
-    typedef void *HANDLE;
+    alias void *HANDLE;
     alias void *PVOID;
     alias HANDLE HGLOBAL;
     alias HANDLE HLOCAL;
     REG_LEGAL_OPTION = (REG_OPTION_RESERVED | REG_OPTION_NON_VOLATILE | REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK | REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK),
 }
 
-export LONG RegDeleteKeyA(HKEY hKey, LPCSTR lpSubKey);
-export LONG RegDeleteKeyW(HKEY hKey, LPCWSTR lpSubKey);
-export LONG RegDeleteValueA(HKEY hKey, LPCSTR lpValueName);
-export LONG RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName);
-
-export LONG  RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName, LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass, FILETIME* lpftLastWriteTime);
-export LONG  RegEnumKeyExW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, LPDWORD lpcbName, LPDWORD lpReserved, LPWSTR lpClass, LPDWORD lpcbClass, FILETIME* lpftLastWriteTime);
-export LONG RegEnumValueA(HKEY hKey, DWORD dwIndex, LPSTR lpValueName, LPDWORD lpcbValueName, LPDWORD lpReserved,
+export LONG RegDeleteKeyA(in HKEY hKey, LPCSTR lpSubKey);
+export LONG RegDeleteKeyW(in HKEY hKey, LPCWSTR lpSubKey);
+export LONG RegDeleteValueA(in HKEY hKey, LPCSTR lpValueName);
+export LONG RegDeleteValueW(in HKEY hKey, LPCWSTR lpValueName);
+
+export LONG  RegEnumKeyExA(in HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName, LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass, FILETIME* lpftLastWriteTime);
+export LONG  RegEnumKeyExW(in HKEY hKey, DWORD dwIndex, LPWSTR lpName, LPDWORD lpcbName, LPDWORD lpReserved, LPWSTR lpClass, LPDWORD lpcbClass, FILETIME* lpftLastWriteTime);
+export LONG RegEnumValueA(in HKEY hKey, DWORD dwIndex, LPSTR lpValueName, LPDWORD lpcbValueName, LPDWORD lpReserved,
     LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
-export LONG RegEnumValueW(HKEY hKey, DWORD dwIndex, LPWSTR lpValueName, LPDWORD lpcbValueName, LPDWORD lpReserved,
+export LONG RegEnumValueW(in HKEY hKey, DWORD dwIndex, LPWSTR lpValueName, LPDWORD lpcbValueName, LPDWORD lpReserved,
     LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
 
-export LONG RegCloseKey(HKEY hKey);
-export LONG RegFlushKey(HKEY hKey);
-
-export LONG RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult);
-export LONG RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult);
-export LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
-export LONG RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
-
-export LONG RegQueryInfoKeyA(HKEY hKey, LPSTR lpClass, LPDWORD lpcbClass,
+export LONG RegCloseKey(in HKEY hKey);
+export LONG RegFlushKey(in HKEY hKey);
+
+export LONG RegOpenKeyA(in HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult);
+export LONG RegOpenKeyW(in HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult);
+export LONG RegOpenKeyExA(in HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
+export LONG RegOpenKeyExW(in HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
+
+export LONG RegQueryInfoKeyA(in HKEY hKey, LPSTR lpClass, LPDWORD lpcbClass,
     LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcbMaxSubKeyLen, LPDWORD lpcbMaxClassLen,
     LPDWORD lpcValues, LPDWORD lpcbMaxValueNameLen, LPDWORD lpcbMaxValueLen, LPDWORD lpcbSecurityDescriptor,
     PFILETIME lpftLastWriteTime);
-export LONG RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcbClass,
+export LONG RegQueryInfoKeyW(in HKEY hKey, LPWSTR lpClass, LPDWORD lpcbClass,
     LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcbMaxSubKeyLen, LPDWORD lpcbMaxClassLen,
     LPDWORD lpcValues, LPDWORD lpcbMaxValueNameLen, LPDWORD lpcbMaxValueLen, LPDWORD lpcbSecurityDescriptor,
     PFILETIME lpftLastWriteTime);
 
-export LONG RegQueryValueA(HKEY hKey, LPCSTR lpSubKey, LPSTR lpValue, LPLONG lpcbValue);
-export LONG RegQueryValueW(HKEY hKey, LPCWSTR lpSubKey, LPWSTR lpValue, LPLONG lpcbValue);
-export LONG RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPVOID lpData, LPDWORD lpcbData);
-export LONG RegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPVOID lpData, LPDWORD lpcbData);
-
-export LONG RegCreateKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass,
+export LONG RegQueryValueA(in HKEY hKey, LPCSTR lpSubKey, LPSTR lpValue, LPLONG lpcbValue);
+export LONG RegQueryValueW(in HKEY hKey, LPCWSTR lpSubKey, LPWSTR lpValue, LPLONG lpcbValue);
+export LONG RegQueryValueExA(in HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPVOID lpData, LPDWORD lpcbData);
+export LONG RegQueryValueExW(in HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPVOID lpData, LPDWORD lpcbData);
+
+export LONG RegCreateKeyExA(in HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass,
    DWORD dwOptions, REGSAM samDesired, SECURITY_ATTRIBUTES* lpSecurityAttributes,
     PHKEY phkResult, LPDWORD lpdwDisposition);
-export LONG RegCreateKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass,
+export LONG RegCreateKeyExW(in HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass,
    DWORD dwOptions, REGSAM samDesired, SECURITY_ATTRIBUTES* lpSecurityAttributes,
     PHKEY phkResult, LPDWORD lpdwDisposition);
 
-export LONG RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData);
-export LONG RegSetValueExW(HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData);
+export LONG RegSetValueExA(in HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData);
+export LONG RegSetValueExW(in HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData);
 
 export LONG RegOpenCurrentUser(REGSAM samDesired, PHKEY phkResult);
 
 BOOL TlsSetValue(DWORD, LPVOID);
 BOOL TlsFree(DWORD);
 
+// shellapi.h
+HINSTANCE ShellExecuteA(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd);
+HINSTANCE ShellExecuteW(HWND hwnd, LPCWSTR lpOperation, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
 }

d/druntime/core/thread.d

 
 
 // this should be true for most architectures
-version( GNU_StackGrowsDown )
-    version = StackGrowsDown;
+version = StackGrowsDown;
 
 
 ///////////////////////////////////////////////////////////////////////////////
             assert( obj.m_curr is &obj.m_main );
             // NOTE: For some reason this does not always work for threads.
             //obj.m_main.bstack = getStackBottom();
-            version( GNU )
-            {
-                version( StackGrowsDown )
-                    obj.m_main.bstack = &obj + 1;
-                else
-                    obj.m_main.bstack = &obj;
-            }
-            else version( D_InlineAsm_X86 )
+            version( D_InlineAsm_X86 )
             {
                 static void* getBasePtr()
                 {
 
 
     /**
-     * $(RED Scheduled for deprecation in January 2012. Please use the version
-     *       which takes a $(D Duration) instead.)
-     *
      * Suspends the calling thread for at least the supplied period.  This may
      * result in multiple OS calls if period is greater than the maximum sleep
      * duration supported by the operating system.
 
 
     /**
+     * $(RED Scheduled for deprecation in January 2012. Please use the version
+     *       which takes a $(D Duration) instead.)
+     *
      * Suspends the calling thread for at least the supplied period.  This may
      * result in multiple OS calls if period is greater than the maximum sleep
      * duration supported by the operating system.
     //
     // All use of the global lists should synchronize on this lock.
     //
-    static Mutex slock()
+    @property static Mutex slock()
     {
         __gshared Mutex m = null;
 
     }
     else version(FreeBSD)
     {
-        return _tlsstart[0..(_tlsend-_tlsstart)];
+        return (cast(void*)&_tlsstart)[0..(&_tlsend)-(&_tlsstart)];
     }
     else
     {

d/druntime/core/time.d

     Copyright: Copyright 2010 - 2011
     License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
     Authors:   Jonathan M Davis and Kato Shoichi
-    Source:    $(PHOBOSSRC std/_datetime.d)
+    Source:    $(DRUNTIMESRC core/_time.d)
  +/
 module core.time;
 
     (e.g. 22 days or 700 seconds).
 
     It is used when representing a duration of time - such as how long to
-    sleep with Thread.sleep().
+    sleep with $(CXREF Thread, sleep).
 
     In std.datetime, it is also used as the result of various arithmetic
     operations on time points.
 
-    Use the $(D dur!()) function to create Durations.
+    Use the $(D dur) function to create Durations.
 
     You cannot create a duration of months or years because the variable number
     of days in a month or a year makes it so that you cannot convert between
     months or years and smaller units without a specific date. Any type or
-    function which handles months or years has other functions for handling those
-    rather than using durations. For instance, $(D std.datetime.Date) has
-    $(D addYears()) and $(D addMonths()) for adding years and months, rather than
+    function which handles months or years has other functions for handling
+    those rather than using durations. For instance, $(XREF datetime, Date) has
+    $(D addYears) and $(D addMonths) for adding years and months, rather than
     creating a duration of years or months and adding that to a
-    $(D std.datetime.Date). If you're dealing with weeks or smaller, however,
+    $(XREF datetime, Date). If you're dealing with weeks or smaller, however,
     durations are what you use.
 
     Examples:
 --------------------
 assert(dur!"days"(12) == Duration(10_368_000_000_000L));
 assert(dur!"hnsecs"(27) == Duration(27));
-assert(std.datetime.Date(2010, 9, 7) + dur!"days"(5) == std.datetime.Date(2010, 9, 12));
+assert(std.datetime.Date(2010, 9, 7) + dur!"days"(5) ==
+       std.datetime.Date(2010, 9, 12));
+
+assert(dur!"days"(-12) == Duration(-10_368_000_000_000L));
+assert(dur!"hnsecs"(-27) == Duration(-27));
+assert(std.datetime.Date(2010, 9, 7) - std.datetime.Date(2010, 10, 3) ==
+       dur!"days"(-26));
 --------------------
  +/
 struct Duration
 {
+    //Verify Examples.
     unittest
     {
-        //Verify Examples.
         assert(dur!"days"(12) == Duration(10_368_000_000_000L));
         assert(dur!"hnsecs"(27) == Duration(27));
+        assert(dur!"days"(-12) == Duration(-10_368_000_000_000L));
+        assert(dur!"hnsecs"(-27) == Duration(-27));
     }
 
 public:
 
         Params:
             duration = The duration to add to or subtract from this duration.
-
-        Note:
-            TUnqual is just a local copy of std.traits' Unqual, since core does
-            not have access to std.traits, and naming it Unqual as well would
-            result in a name clash, so it's TUnqual.
       +/
     Duration opBinary(string op, D)(in D rhs) const pure nothrow
         if((op == "+" || op == "-") &&
-           (is(TUnqual!D == Duration) ||
-           is(TUnqual!D == TickDuration)))
+           (is(_Unqual!D == Duration) ||
+           is(_Unqual!D == TickDuration)))
     {
-        static if(is(TUnqual!D == Duration))
+        static if(is(_Unqual!D == Duration))
             return Duration(mixin("_hnsecs " ~ op ~ " rhs._hnsecs"));
-        else if(is(TUnqual!D == TickDuration))
+        else if(is(_Unqual!D == TickDuration))
             return Duration(mixin("_hnsecs " ~ op ~ " rhs.hnsecs"));
     }
 
 
         Params:
             rhs = The duration to add to or subtract from this DateTime.
-
-        Note:
-            TUnqual is just a local copy of std.traits' Unqual, since core does
-            not have access to std.traits, and naming it Unqual as well would
-            result in a name clash, so it's TUnqual.
       +/
     /+ref+/ Duration opOpAssign(string op, D)(in D rhs) pure nothrow
         if((op == "+" || op == "-") &&
-           (is(TUnqual!D == Duration) ||
-            is(TUnqual!D == TickDuration)))
+           (is(_Unqual!D == Duration) ||
+            is(_Unqual!D == TickDuration)))
     {
-        static if(is(TUnqual!D == Duration))
+        static if(is(_Unqual!D == Duration))
             mixin("_hnsecs " ~ op ~ "= rhs._hnsecs;");
-        else if(is(TUnqual!D == TickDuration))
+        else if(is(_Unqual!D == TickDuration))
             mixin("_hnsecs " ~ op ~ "= rhs.hnsecs;");
 
         return this;
 
     unittest
     {
-        tAssertExThrown!TimeException((){Duration(5) / 0;}());
-        tAssertExThrown!TimeException((){Duration(-5) / 0;}());
+        _assertThrown!TimeException((){Duration(5) / 0;}());
+        _assertThrown!TimeException((){Duration(-5) / 0;}());
 
         assert(Duration(5) / 7 == Duration(0));
         assert(Duration(7) / 5 == Duration(1));
 
     unittest
     {
-        tAssertExThrown!TimeException((){Duration(5) /= 0;}());
-        tAssertExThrown!TimeException((){Duration(-5) /= 0;}());
+        _assertThrown!TimeException((){Duration(5) /= 0;}());
+        _assertThrown!TimeException((){Duration(-5) /= 0;}());
 
         static void testDur(Duration dur, long value, in Duration expected, size_t line = __LINE__)
         {
 assert(dur!"days"(13).weeks == 1);
 --------------------
       +/
-    @property alias get!"weeks" weeks;
+    @property long weeks() const pure nothrow { return get!"weeks"(); }
 
     unittest
     {
 assert(dur!"hours"(49).days == 2);
 --------------------
       +/
-    @property alias get!"days" days;
+    @property long days() const pure nothrow { return get!"days"(); }
 
     unittest
     {
 assert(dur!"minutes"(121).hours == 2);
 --------------------
       +/
-    @property alias get!"hours" hours;
+    @property long hours() const pure nothrow { return get!"hours"(); }
 
     unittest
     {
 assert(dur!"seconds"(121).minutes == 2);
 --------------------
       +/
-    @property alias get!"minutes" minutes;
+    @property long minutes() const pure nothrow { return get!"minutes"(); }
 
     unittest
     {
 assert(dur!"msecs"(1217).seconds == 1);
 --------------------
       +/
-    @property alias get!"seconds" seconds;
+    @property long seconds() const pure nothrow { return get!"seconds"(); }
 
     unittest
     {
 assert(dur!"usecs"(43).fracSec == FracSec.from!"usecs"(43));
 assert(dur!"hnsecs"(50_007).fracSec == FracSec.from!"hnsecs"(50_007));
 assert(dur!"nsecs"(62_127).fracSec == FracSec.from!"nsecs"(62_100));
+
+assert(dur!"msecs"(-1000).fracSec == FracSec.from!"msecs"(-0));
+assert(dur!"msecs"(-1217).fracSec == FracSec.from!"msecs"(-217));
+assert(dur!"usecs"(-43).fracSec == FracSec.from!"usecs"(-43));
+assert(dur!"hnsecs"(-50_007).fracSec == FracSec.from!"hnsecs"(-50_007));
+assert(dur!"nsecs"(-62_127).fracSec == FracSec.from!"nsecs"(-62_100));
 --------------------
      +/
     @property FracSec fracSec() const pure nothrow
     {
         try
         {
-            long hnsecs = _hnsecs;
-            auto days = splitUnitsFromHNSecs!"days"(hnsecs) + 1;
-
-            if(hnsecs < 0)
-            {
-                hnsecs += convert!("hours", "hnsecs")(24);
-                --days;
-            }
-
-            hnsecs = removeUnitsFromHNSecs!"hours"(hnsecs);
-            hnsecs = removeUnitsFromHNSecs!"minutes"(hnsecs);
-            hnsecs = removeUnitsFromHNSecs!"seconds"(hnsecs);
-
-            return FracSec.from!"hnsecs"(cast(int)hnsecs);
+            immutable hnsecs = removeUnitsFromHNSecs!("seconds")(_hnsecs);
+
+            return FracSec.from!"hnsecs"(hnsecs);
         }
         catch(Exception e)
             assert(0, "FracSec.from!\"hnsecs\"() threw.");
     }
 
+    //Verify Examples.
     unittest
     {
-        //Verify Examples.
         assert(dur!"msecs"(1000).fracSec == FracSec.from!"msecs"(0));
         assert(dur!"msecs"(1217).fracSec == FracSec.from!"msecs"(217));
         assert(dur!"usecs"(43).fracSec == FracSec.from!"usecs"(43));
         assert(dur!"hnsecs"(50_007).fracSec == FracSec.from!"hnsecs"(50_007));
         assert(dur!"nsecs"(62_127).fracSec == FracSec.from!"nsecs"(62_100));
 
-        const dur = Duration(12);
-        const cdur = Duration(12);
-        immutable idur = Duration(12);
-        static assert(__traits(compiles, dur.fracSec));
-        static assert(__traits(compiles, cdur.fracSec));
-        static assert(__traits(compiles, idur.fracSec));
+        assert(dur!"msecs"(-1000).fracSec == FracSec.from!"msecs"(-0));
+        assert(dur!"msecs"(-1217).fracSec == FracSec.from!"msecs"(-217));
+        assert(dur!"usecs"(-43).fracSec == FracSec.from!"usecs"(-43));
+        assert(dur!"hnsecs"(-50_007).fracSec == FracSec.from!"hnsecs"(-50_007));
+        assert(dur!"nsecs"(-62_127).fracSec == FracSec.from!"nsecs"(-62_100));
+    }
+
+    unittest
+    {
+        auto mdur = dur!"hnsecs"(12);
+        const cdur = dur!"hnsecs"(12);
+        immutable idur = dur!"hnsecs"(12);
+
+        assert(mdur.fracSec == FracSec.from!"hnsecs"(12));
+        assert(cdur.fracSec == FracSec.from!"hnsecs"(12));
+        assert(idur.fracSec == FracSec.from!"hnsecs"(12));
     }
 
 
 assert(dur!"nsecs"(2007).total!"nsecs"() == 2000);
 --------------------
       +/
-    long total(string units)() const pure nothrow
+    @property long total(string units)() const pure nothrow
         if(units == "weeks" ||
            units == "days" ||
            units == "hours" ||
     unittest
     {
         //Verify Examples.
-        assert(dur!"weeks"(12).total!"weeks"() == 12);
-        assert(dur!"weeks"(12).total!"days"() == 84);
-
-        assert(dur!"days"(13).total!"weeks"() == 1);
-        assert(dur!"days"(13).total!"days"() == 13);
-
-        assert(dur!"hours"(49).total!"days"() == 2);
-        assert(dur!"hours"(49).total!"hours"() == 49);
-
-        assert(dur!"nsecs"(2007).total!"hnsecs"() == 20);
-        assert(dur!"nsecs"(2007).total!"nsecs"() == 2000);
+        assert(dur!"weeks"(12).total!"weeks" == 12);
+        assert(dur!"weeks"(12).total!"days" == 84);
+
+        assert(dur!"days"(13).total!"weeks" == 1);
+        assert(dur!"days"(13).total!"days" == 13);
+
+        assert(dur!"hours"(49).total!"days" == 2);
+        assert(dur!"hours"(49).total!"hours" == 49);
+
+        assert(dur!"nsecs"(2007).total!"hnsecs" == 20);
+        assert(dur!"nsecs"(2007).total!"nsecs" == 2000);
 
         const dur = Duration(12);
         const cdur = Duration(12);
         immutable idur = Duration(12);
-        static assert(__traits(compiles, dur.total!"days"()));
-        static assert(__traits(compiles, cdur.total!"days"()));
-        static assert(__traits(compiles, idur.total!"days"()));
+        dur.total!"days"; // just check that it compiles
+        cdur.total!"days"; // just check that it compiles
+        idur.total!"days"; // just check that it compiles
     }
 
 
     /++
         Alias for converting TickDuration to seconds.
       +/
-    @property alias to!("seconds", long) seconds;
+    @property long seconds() const pure nothrow { return to!("seconds", long)(); }
 
     unittest
     {
     /++
         Alias for converting TickDuration to milliseconds.
       +/
-    @property alias to!("msecs", long) msecs;
+    @property long msecs() const pure nothrow { return to!("msecs", long)(); }
 
 
     /++
       +/
 
 
-    @property alias to!("usecs", long) usecs;
+    @property long usecs() const pure nothrow { return to!("usecs", long)(); }
 
 
     /++
         Alias for converting TickDuration to hecto-nanoseconds (100 ns).
       +/
-    @property alias to!("hnsecs", long) hnsecs;
+    @property long hnsecs() const pure nothrow { return to!("hnsecs", long)(); }
 
 
     /++
         Alias for converting TickDuration to nanoseconds.
       +/
-    @property alias to!("nsecs", long) nsecs;
+    @property long nsecs() const pure nothrow { return to!("nsecs", long)(); }
 
 
     /++
     {
         auto a = TickDuration.currSystemTick;
         auto b = TickDuration.currSystemTick;
-        assert((a + b).to!("seconds", real) > 0);
-        assert((a - b).to!("seconds", real) <= 0);
+        assert((a + b).to!("seconds", real)() > 0);
+        assert((a - b).to!("seconds", real)() <= 0);
     }
 
 
     Represents fractional seconds.
 
     This is the portion of the time which is smaller than a second and cannot
-    hold values which would equal or exceed a second.
+    hold values which would greater than or equal to a second (or less than or
+    equal to a negative second).
 
     It holds hnsecs internally, but you can create it using either milliseconds,
-    microseconds, or hnsecs. What it does is allow for a simple way to set or adjust
-    the fractional seconds portion of a Duration or a std.datetime.SysTime without
-    having to worry about whether you're dealing with milliseconds, microseconds,
-    or hnsecs.
-
-    FracSec's functions which take time unit strings do accept "nsecs", but the
-    because the resolution for Duration and std.datetime.SysTime is hnsecs, you
-    don't actually get precision higher than hnsecs. "nsecs" is accepted merely
-    for convenience. Any values given as nsecs will be converted to hnsecs using
-    convert!() (which uses truncation when converting to smaller units).
+    microseconds, or hnsecs. What it does is allow for a simple way to set or
+    adjust the fractional seconds portion of a $(D Duration) or a
+    $(XREF datetime, SysTime) without having to worry about whether you're
+    dealing with milliseconds, microseconds, or hnsecs.
+
+    $(D FracSec)'s functions which take time unit strings do accept
+    $(D "nsecs"), but the because the resolution for $(D Duration) and
+    $(XREF datetime, SysTime) is hnsecs, you don't actually get precision higher
+    than hnsecs. $(D "nsecs") is accepted merely for convenience. Any values
+    given as nsecs will be converted to hnsecs using $(D convert) (which uses
+    truncation when converting to smaller units).
   +/
 struct FracSec
 {
 public:
 
     /++