Commits

fearog committed 4c94df6

Reimplemented nacl as its own platform - everything is stubbed out.

  • Participants
  • Parent commits 6760a1b

Comments (0)

Files changed (36)

File d/druntime/core/runtime.d

 
 private
 {
-    extern (C) bool rt_isHalting();
+	extern (C) bool rt_isHalting();
 
-    alias bool function() ModuleUnitTester;
-    alias bool function(Object) CollectHandler;
-    alias Throwable.TraceInfo function( void* ptr ) TraceHandler;
+	alias bool function() ModuleUnitTester;
+	alias bool function(Object) CollectHandler;
+	alias Throwable.TraceInfo function( void* ptr ) TraceHandler;
 
-    extern (C) void rt_setCollectHandler( CollectHandler h );
-    extern (C) CollectHandler rt_getCollectHandler();
+	extern (C) void rt_setCollectHandler( CollectHandler h );
+	extern (C) CollectHandler rt_getCollectHandler();
 
-    extern (C) void rt_setTraceHandler( TraceHandler h );
-    extern (C) TraceHandler rt_getTraceHandler();
+	extern (C) void rt_setTraceHandler( TraceHandler h );
+	extern (C) TraceHandler rt_getTraceHandler();
 
-    alias void delegate( Throwable ) ExceptionHandler;
-    extern (C) bool rt_init( ExceptionHandler dg = null );
-    extern (C) bool rt_term( ExceptionHandler dg = null );
+	alias void delegate( Throwable ) ExceptionHandler;
+	extern (C) bool rt_init( ExceptionHandler dg = null );
+	extern (C) bool rt_term( ExceptionHandler dg = null );
 
-    extern (C) void* rt_loadLibrary( in char[] name );
-    extern (C) bool  rt_unloadLibrary( void* ptr );
+	extern (C) void* rt_loadLibrary( in char[] name );
+	extern (C) bool  rt_unloadLibrary( void* ptr );
 
-    extern (C) void* thread_stackBottom();
+	extern (C) void* thread_stackBottom();
 
-    extern (C) string[] rt_args();
+	extern (C) string[] rt_args();
 
-    version( linux )
-    {
-        import core.demangle;
-        import core.stdc.stdlib : free;
-        import core.stdc.string : strlen, memchr;
-        extern (C) int    backtrace(void**, int);
-        extern (C) char** backtrace_symbols(void**, 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**, int);
-        extern (C) char** backtrace_symbols(void**, int);
-        extern (C) void   backtrace_symbols_fd(void**, int, int);
-        import core.sys.posix.signal; // segv handler
-    }
-    else version( Windows )
-    {
-        import core.sys.windows.stacktrace;
-    }
+	version( linux )
+	{
+		import core.demangle;
+		import core.stdc.stdlib : free;
+		import core.stdc.string : strlen, memchr;
+		extern (C) int    backtrace(void**, int);
+		extern (C) char** backtrace_symbols(void**, 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**, int);
+		extern (C) char** backtrace_symbols(void**, int);
+		extern (C) void   backtrace_symbols_fd(void**, int, int);
+		import core.sys.posix.signal; // segv handler
+	}
+	else version( Windows )
+	{
+		import core.sys.windows.stacktrace;
+	}
 
-    // For runModuleUnitTests error reporting.
-    version( Windows )
-    {
-        import core.sys.windows.windows;
-    }
-    else version( Posix )
-    {
-        import core.sys.posix.unistd;
-    }
+	// For runModuleUnitTests error reporting.
+	version( Windows )
+	{
+		import core.sys.windows.windows;
+	}
+	else version( Posix )
+	{
+		import core.sys.posix.unistd;
+	}
 }
 
 
 static this()
 {
-    // NOTE: Some module ctors will run before this handler is set, so it's
-    //       still possible the app could exit without a stack trace.  If
-    //       this becomes an issue, the handler could be set in C main
-    //       before the module ctors are run.
-    Runtime.traceHandler = &defaultTraceHandler;
+	// NOTE: Some module ctors will run before this handler is set, so it's
+	//       still possible the app could exit without a stack trace.  If
+	//       this becomes an issue, the handler could be set in C main
+	//       before the module ctors are run.
+	Runtime.traceHandler = &defaultTraceHandler;
 }
 
 
  */
 struct Runtime
 {
-    /**
-     * Initializes the runtime.  This call is to be used in instances where the
-     * standard program initialization process is not executed.  This is most
-     * often in shared libraries or in libraries linked to a C program.
-     *
-     * Params:
-     *  dg = A delegate which will receive any exception thrown during the
-     *       initialization process or null if such exceptions should be
-     *       discarded.
-     *
-     * Returns:
-     *  true if initialization succeeds and false if initialization fails.
-     */
-    static bool initialize( ExceptionHandler dg = null )
-    {
-        return rt_init( dg );
-    }
+	/**
+	 * Initializes the runtime.  This call is to be used in instances where the
+	 * standard program initialization process is not executed.  This is most
+	 * often in shared libraries or in libraries linked to a C program.
+	 *
+	 * Params:
+	 *  dg = A delegate which will receive any exception thrown during the
+	 *       initialization process or null if such exceptions should be
+	 *       discarded.
+	 *
+	 * Returns:
+	 *  true if initialization succeeds and false if initialization fails.
+	 */
+	static bool initialize( ExceptionHandler dg = null )
+	{
+		return rt_init( dg );
+	}
 
 
-    /**
-     * Terminates the runtime.  This call is to be used in instances where the
-     * standard program termination process will not be not executed.  This is
-     * most often in shared libraries or in libraries linked to a C program.
-     *
-     * Params:
-     *  dg = A delegate which will receive any exception thrown during the
-     *       termination process or null if such exceptions should be
-     *       discarded.
-     *
-     * Returns:
-     *  true if termination succeeds and false if termination fails.
-     */
-    static bool terminate( ExceptionHandler dg = null )
-    {
-        return rt_term( dg );
-    }
+	/**
+	 * Terminates the runtime.  This call is to be used in instances where the
+	 * standard program termination process will not be not executed.  This is
+	 * most often in shared libraries or in libraries linked to a C program.
+	 *
+	 * Params:
+	 *  dg = A delegate which will receive any exception thrown during the
+	 *       termination process or null if such exceptions should be
+	 *       discarded.
+	 *
+	 * Returns:
+	 *  true if termination succeeds and false if termination fails.
+	 */
+	static bool terminate( ExceptionHandler dg = null )
+	{
+		return rt_term( dg );
+	}
 
 
-    /**
-     * Returns true if the runtime is halting.  Under normal circumstances,
-     * this will be set between the time that normal application code has
-     * exited and before module dtors are called.
-     *
-     * Returns:
-     *  true if the runtime is halting.
-     */
-    deprecated static @property bool isHalting()
-    {
-        return rt_isHalting();
-    }
+	/**
+	 * Returns true if the runtime is halting.  Under normal circumstances,
+	 * this will be set between the time that normal application code has
+	 * exited and before module dtors are called.
+	 *
+	 * Returns:
+	 *  true if the runtime is halting.
+	 */
+	deprecated static @property bool isHalting()
+	{
+		return rt_isHalting();
+	}
 
 
-    /**
-     * Returns the arguments supplied when the process was started.
-     *
-     * Returns:
-     *  The arguments supplied when this process was started.
-     */
-    static @property string[] args()
-    {
-        return rt_args();
-    }
+	/**
+	 * Returns the arguments supplied when the process was started.
+	 *
+	 * Returns:
+	 *  The arguments supplied when this process was started.
+	 */
+	static @property string[] args()
+	{
+		return rt_args();
+	}
 
 
-    /**
-     * Locates a dynamic library with the supplied library name and dynamically
-     * loads it into the caller's address space.  If the library contains a D
-     * runtime it will be integrated with the current runtime.
-     *
-     * Params:
-     *  name = The name of the dynamic library to load.
-     *
-     * Returns:
-     *  A reference to the library or null on error.
-     */
-    static void* loadLibrary( in char[] name )
-    {
-        return rt_loadLibrary( name );
-    }
+	/**
+	 * Locates a dynamic library with the supplied library name and dynamically
+	 * loads it into the caller's address space.  If the library contains a D
+	 * runtime it will be integrated with the current runtime.
+	 *
+	 * Params:
+	 *  name = The name of the dynamic library to load.
+	 *
+	 * Returns:
+	 *  A reference to the library or null on error.
+	 */
+	static void* loadLibrary( in char[] name )
+	{
+		return rt_loadLibrary( name );
+	}
 
 
-    /**
-     * Unloads the dynamic library referenced by p.  If this library contains a
-     * D runtime then any necessary finalization or cleanup of that runtime
-     * will be performed.
-     *
-     * Params:
-     *  p = A reference to the library to unload.
-     */
-    static bool unloadLibrary( void* p )
-    {
-        return rt_unloadLibrary( p );
-    }
+	/**
+	 * Unloads the dynamic library referenced by p.  If this library contains a
+	 * D runtime then any necessary finalization or cleanup of that runtime
+	 * will be performed.
+	 *
+	 * Params:
+	 *  p = A reference to the library to unload.
+	 */
+	static bool unloadLibrary( void* p )
+	{
+		return rt_unloadLibrary( p );
+	}
 
 
-    /**
-     * Overrides the default trace mechanism with s user-supplied version.  A
-     * trace represents the context from which an exception was thrown, and the
-     * trace handler will be called when this occurs.  The pointer supplied to
-     * this routine indicates the base address from which tracing should occur.
-     * If the supplied pointer is null then the trace routine should determine
-     * an appropriate calling context from which to begin the trace.
-     *
-     * Params:
-     *  h = The new trace handler.  Set to null to use the default handler.
-     */
-    static @property void traceHandler( TraceHandler h )
-    {
-        rt_setTraceHandler( h );
-    }
+	/**
+	 * Overrides the default trace mechanism with s user-supplied version.  A
+	 * trace represents the context from which an exception was thrown, and the
+	 * trace handler will be called when this occurs.  The pointer supplied to
+	 * this routine indicates the base address from which tracing should occur.
+	 * If the supplied pointer is null then the trace routine should determine
+	 * an appropriate calling context from which to begin the trace.
+	 *
+	 * Params:
+	 *  h = The new trace handler.  Set to null to use the default handler.
+	 */
+	static @property void traceHandler( TraceHandler h )
+	{
+		rt_setTraceHandler( h );
+	}
 
-    /**
-     * Gets the current trace handler.
-     *
-     * Returns:
-     *  The current trace handler or null if no trace handler is set.
-     */
-    static @property TraceHandler traceHandler()
-    {
-        return rt_getTraceHandler();
-    }
+	/**
+	 * Gets the current trace handler.
+	 *
+	 * Returns:
+	 *  The current trace handler or null if no trace handler is set.
+	 */
+	static @property TraceHandler traceHandler()
+	{
+		return rt_getTraceHandler();
+	}
 
-    /**
-     * Overrides the default collect hander with a user-supplied version.  This
-     * routine will be called for each resource object that is finalized in a
-     * non-deterministic manner--typically during a garbage collection cycle.
-     * If the supplied routine returns true then the object's dtor will called
-     * as normal, but if the routine returns false than the dtor will not be
-     * called.  The default behavior is for all object dtors to be called.
-     *
-     * Params:
-     *  h = The new collect handler.  Set to null to use the default handler.
-     */
-    static @property void collectHandler( CollectHandler h )
-    {
-        rt_setCollectHandler( h );
-    }
+	/**
+	 * Overrides the default collect hander with a user-supplied version.  This
+	 * routine will be called for each resource object that is finalized in a
+	 * non-deterministic manner--typically during a garbage collection cycle.
+	 * If the supplied routine returns true then the object's dtor will called
+	 * as normal, but if the routine returns false than the dtor will not be
+	 * called.  The default behavior is for all object dtors to be called.
+	 *
+	 * Params:
+	 *  h = The new collect handler.  Set to null to use the default handler.
+	 */
+	static @property void collectHandler( CollectHandler h )
+	{
+		rt_setCollectHandler( h );
+	}
 
 
-    /**
-     * Gets the current collect handler.
-     *
-     * Returns:
-     *  The current collect handler or null if no trace handler is set.
-     */
-    static @property CollectHandler collectHandler()
-    {
-        return rt_getCollectHandler();
-    }
+	/**
+	 * Gets the current collect handler.
+	 *
+	 * Returns:
+	 *  The current collect handler or null if no trace handler is set.
+	 */
+	static @property CollectHandler collectHandler()
+	{
+		return rt_getCollectHandler();
+	}
 
 
-    /**
-     * Overrides the default module unit tester with a user-supplied version.
-     * This routine will be called once on program initialization.  The return
-     * value of this routine indicates to the runtime whether the tests ran
-     * without error.
-     *
-     * Params:
-     *  h = The new unit tester.  Set to null to use the default unit tester.
-     */
-    static @property void moduleUnitTester( ModuleUnitTester h )
-    {
-        sm_moduleUnitTester = h;
-    }
+	/**
+	 * Overrides the default module unit tester with a user-supplied version.
+	 * This routine will be called once on program initialization.  The return
+	 * value of this routine indicates to the runtime whether the tests ran
+	 * without error.
+	 *
+	 * Params:
+	 *  h = The new unit tester.  Set to null to use the default unit tester.
+	 */
+	static @property void moduleUnitTester( ModuleUnitTester h )
+	{
+		sm_moduleUnitTester = h;
+	}
 
 
-    /**
-     * Gets the current module unit tester.
-     *
-     * Returns:
-     *  The current module unit tester handler or null if no trace handler is
-     *  set.
-     */
-    static @property ModuleUnitTester moduleUnitTester()
-    {
-        return sm_moduleUnitTester;
-    }
+	/**
+	 * Gets the current module unit tester.
+	 *
+	 * Returns:
+	 *  The current module unit tester handler or null if no trace handler is
+	 *  set.
+	 */
+	static @property ModuleUnitTester moduleUnitTester()
+	{
+		return sm_moduleUnitTester;
+	}
 
 
 private:
-    // NOTE: This field will only ever be set in a static ctor and should
-    //       never occur within any but the main thread, so it is safe to
-    //       make it __gshared.
-    __gshared ModuleUnitTester sm_moduleUnitTester = null;
+	// NOTE: This field will only ever be set in a static ctor and should
+	//       never occur within any but the main thread, so it is safe to
+	//       make it __gshared.
+	__gshared ModuleUnitTester sm_moduleUnitTester = null;
 }
 
 
  */
 extern (C) bool runModuleUnitTests()
 {
-    static if( __traits( compiles, backtrace ) )
-    {
-        static extern (C) void unittestSegvHandler( int signum, siginfo_t* info, void* ptr )
-        {
-            static enum MAXFRAMES = 128;
-            void*[MAXFRAMES]  callstack;
-            int               numframes;
+	static if( __traits( compiles, backtrace ) )
+	{
+		static extern (C) void unittestSegvHandler( int signum, siginfo_t* info, void* ptr )
+		{
+			static enum MAXFRAMES = 128;
+			void*[MAXFRAMES]  callstack;
+			int               numframes;
 
-            numframes = backtrace( callstack, MAXFRAMES );
-            backtrace_symbols_fd( callstack, numframes, 2 );
-        }
+			numframes = backtrace( callstack, MAXFRAMES );
+			backtrace_symbols_fd( callstack, numframes, 2 );
+		}
 
-        sigaction_t action = void;
-        sigaction_t oldseg = void;
-        sigaction_t oldbus = void;
+		sigaction_t action = void;
+		sigaction_t oldseg = void;
+		sigaction_t oldbus = void;
 
-        (cast(byte*) &action)[0 .. action.sizeof] = 0;
-        sigfillset( &action.sa_mask ); // block other signals
-        action.sa_flags = SA_SIGINFO | SA_RESETHAND;
-        action.sa_sigaction = &unittestSegvHandler;
-        sigaction( SIGSEGV, &action, &oldseg );
-        sigaction( SIGBUS, &action, &oldbus );
-        scope( exit )
-        {
-            sigaction( SIGSEGV, &oldseg, null );
-            sigaction( SIGBUS, &oldbus, null );
-        }
-    }
+		(cast(byte*) &action)[0 .. action.sizeof] = 0;
+		sigfillset( &action.sa_mask ); // block other signals
+		action.sa_flags = SA_SIGINFO | SA_RESETHAND;
+		action.sa_sigaction = &unittestSegvHandler;
+		sigaction( SIGSEGV, &action, &oldseg );
+		sigaction( SIGBUS, &action, &oldbus );
+		scope( exit )
+		{
+			sigaction( SIGSEGV, &oldseg, null );
+			sigaction( SIGBUS, &oldbus, null );
+		}
+	}
 
-    static struct Console
-    {
-        Console opCall( in char[] val )
-        {
-            version( Windows )
-            {
-                DWORD count = void;
-                assert(val.length <= uint.max, "val must be less than or equal to uint.max");
-                WriteFile( GetStdHandle( 0xfffffff5 ), val.ptr, cast(uint)val.length, &count, null );
-            }
-            else version( Posix )
-            {
-                write( 2, val.ptr, val.length );
-            }
-            return this;
-        }
-    }
+	static struct Console
+	{
+		Console opCall( in char[] val )
+		{
+			version( Windows )
+			{
+				DWORD count = void;
+				assert(val.length <= uint.max, "val must be less than or equal to uint.max");
+				WriteFile( GetStdHandle( 0xfffffff5 ), val.ptr, cast(uint)val.length, &count, null );
+			}
+			else version( Posix )
+			{
+				write( 2, val.ptr, val.length );
+			}
+			else version( nacl )
+			{
+				throw new Exception( "Function not yet implemented for nacl." );
+			}
+			return this;
+		}
+	}
 
-    static __gshared Console console;
+	static __gshared Console console;
 
-    if( Runtime.sm_moduleUnitTester is null )
-    {
-        size_t failed = 0;
-        foreach( m; ModuleInfo )
-        {
-            if( m )
-            {
-                auto fp = m.unitTest;
+	if( Runtime.sm_moduleUnitTester is null )
+	{
+		size_t failed = 0;
+		foreach( m; ModuleInfo )
+		{
+			if( m )
+			{
+				auto fp = m.unitTest;
 
-                if( fp )
-                {
-                    try
-                    {
-                        fp();
-                    }
-                    catch( Throwable e )
-                    {
-                        console( e.toString() )( "\n" );
-                        failed++;
-                    }
-                }
-            }
-        }
-        return failed == 0;
-    }
-    return Runtime.sm_moduleUnitTester();
+				if( fp )
+				{
+					try
+					{
+						fp();
+					}
+					catch( Throwable e )
+					{
+						console( e.toString() )( "\n" );
+						failed++;
+					}
+				}
+			}
+		}
+		return failed == 0;
+	}
+	return Runtime.sm_moduleUnitTester();
 }
 
 
  */
 Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
 {
-    static if( __traits( compiles, backtrace ) )
-    {
-        class DefaultTraceInfo : Throwable.TraceInfo
-        {
-            this()
-            {
-                static enum MAXFRAMES = 128;
-                void*[MAXFRAMES]  callstack;
-              version( GNU )
-                numframes = backtrace( callstack, MAXFRAMES );
-              else
-                numframes = 0; //backtrace( callstack, MAXFRAMES );
-                if (numframes < 2) // backtrace() failed, do it ourselves
-                {
-                    static void** getBasePtr()
-                    {
-                        version( D_InlineAsm_X86 )
-                            asm { naked; mov EAX, EBP; ret; }
-                        else
-                        version( D_InlineAsm_X86_64 )
-                            asm { naked; mov RAX, RBP; ret; }
-                        else
-                            return null;
-                    }
+	static if( __traits( compiles, backtrace ) )
+	{
+		class DefaultTraceInfo : Throwable.TraceInfo
+		{
+			this()
+			{
+				static enum MAXFRAMES = 128;
+				void*[MAXFRAMES]  callstack;
+			  version( GNU )
+				numframes = backtrace( callstack, MAXFRAMES );
+			  else
+				numframes = 0; //backtrace( callstack, MAXFRAMES );
+				if (numframes < 2) // backtrace() failed, do it ourselves
+				{
+					static void** getBasePtr()
+					{
+						version( D_InlineAsm_X86 )
+							asm { naked; mov EAX, EBP; ret; }
+						else
+						version( D_InlineAsm_X86_64 )
+							asm { naked; mov RAX, RBP; ret; }
+						else
+							return null;
+					}
 
-                    auto  stackTop    = getBasePtr();
-                    auto  stackBottom = cast(void**) thread_stackBottom();
-                    void* dummy;
+					auto  stackTop    = getBasePtr();
+					auto  stackBottom = cast(void**) thread_stackBottom();
+					void* dummy;
 
-                    if( stackTop && &dummy < stackTop && stackTop < stackBottom )
-                    {
-                        auto stackPtr = stackTop;
+					if( stackTop && &dummy < stackTop && stackTop < stackBottom )
+					{
+						auto stackPtr = stackTop;
 
-                        for( numframes = 0; stackTop <= stackPtr &&
-                                            stackPtr < stackBottom && 
-                                            numframes < MAXFRAMES; )
-                        {
-                            callstack[numframes++] = *(stackPtr + 1);
-                            stackPtr = cast(void**) *stackPtr;
-                        }
-                    }
-                }
-                framelist = backtrace_symbols( callstack, numframes );
-            }
+						for( numframes = 0; stackTop <= stackPtr &&
+											stackPtr < stackBottom && 
+											numframes < MAXFRAMES; )
+						{
+							callstack[numframes++] = *(stackPtr + 1);
+							stackPtr = cast(void**) *stackPtr;
+						}
+					}
+				}
+				framelist = backtrace_symbols( callstack, numframes );
+			}
 
-            ~this()
-            {
-                free( framelist );
-            }
+			~this()
+			{
+				free( framelist );
+			}
 
-            override int opApply( scope int delegate(ref char[]) dg )
-            {
-                return opApply( (ref size_t, ref char[] buf)
-                                {
-                                    return dg( buf );
-                                } );
-            }
+			override int opApply( scope int delegate(ref char[]) dg )
+			{
+				return opApply( (ref size_t, ref char[] buf)
+								{
+									return dg( buf );
+								} );
+			}
 
-            override int opApply( scope int delegate(ref size_t, ref char[]) dg )
-            {
-                version( Posix )
-                {
-                    // NOTE: The first 5 frames with the current implementation are
-                    //       inside core.runtime and the object code, so eliminate
-                    //       these for readability.  The alternative would be to
-                    //       exclude the first N frames that are in a list of
-                    //       mangled function names.
-                    static enum FIRSTFRAME = 5;
-                }
-                else
-                {
-                    // NOTE: On Windows, the number of frames to exclude is based on
-                    //       whether the exception is user or system-generated, so
-                    //       it may be necessary to exclude a list of function names
-                    //       instead.
-                    static enum FIRSTFRAME = 0;
-                }
-                int ret = 0;
+			override int opApply( scope int delegate(ref size_t, ref char[]) dg )
+			{
+				version( Posix )
+				{
+					// NOTE: The first 5 frames with the current implementation are
+					//       inside core.runtime and the object code, so eliminate
+					//       these for readability.  The alternative would be to
+					//       exclude the first N frames that are in a list of
+					//       mangled function names.
+					static enum FIRSTFRAME = 5;
+				}
+				else
+				{
+					// NOTE: On Windows, the number of frames to exclude is based on
+					//       whether the exception is user or system-generated, so
+					//       it may be necessary to exclude a list of function names
+					//       instead.
+					static enum FIRSTFRAME = 0;
+				}
+				int ret = 0;
 
-                for( int i = FIRSTFRAME; i < numframes; ++i )
-                {
-                    auto buf = framelist[i][0 .. strlen(framelist[i])];
-                    auto pos = cast(size_t)(i - FIRSTFRAME);
-                    buf = fixline( buf );
-                    ret = dg( pos, buf );
-                    if( ret )
-                        break;
-                }
-                return ret;
-            }
+				for( int i = FIRSTFRAME; i < numframes; ++i )
+				{
+					auto buf = framelist[i][0 .. strlen(framelist[i])];
+					auto pos = cast(size_t)(i - FIRSTFRAME);
+					buf = fixline( buf );
+					ret = dg( pos, buf );
+					if( ret )
+						break;
+				}
+				return ret;
+			}
 
-            override string toString()
-            {
-                string buf;
-                foreach( i, line; this )
-                    buf ~= i ? "\n" ~ line : line;
-                return buf;
-            }
+			override string toString()
+			{
+				string buf;
+				foreach( i, line; this )
+					buf ~= i ? "\n" ~ line : line;
+				return buf;
+			}
 
-        private:
-            int     numframes;
-            char**  framelist;
+		private:
+			int     numframes;
+			char**  framelist;
 
-        private:
-            char[4096] fixbuf;
-            char[] fixline( char[] buf )
-            {
-                version( OSX )
-                {
-                    // format is:
-                    //  1  module    0x00000000 D6module4funcAFZv + 0
-                    for( size_t i = 0, n = 0; i < buf.length; i++ )
-                    {
-                        if( ' ' == buf[i] )
-                        {
-                            n++;
-                            while( i < buf.length && ' ' == buf[i] )
-                                i++;
-                            if( 3 > n )
-                                continue;
-                            auto bsym = i;
-                            while( i < buf.length && ' ' != buf[i] )
-                                i++;
-                            auto esym = i;
-                            auto tail = buf.length - esym;
-                            fixbuf[0 .. bsym] = buf[0 .. bsym];
-                            auto m = demangle( buf[bsym .. esym], fixbuf[bsym .. $] );
-                            fixbuf[bsym + m.length .. bsym + m.length + tail] = buf[esym .. $];
-                            return fixbuf[0 .. bsym + m.length + tail];
-                        }
-                    }
-                    return buf;
-                }
-                else version( linux )
-                {
-                    // format is:  module(_D6module4funcAFZv) [0x00000000]
-                    // or:         module(_D6module4funcAFZv+0x78) [0x00000000]
-                    auto bptr = cast(char*) memchr( buf.ptr, '(', buf.length );
-                    auto eptr = cast(char*) memchr( buf.ptr, ')', buf.length );
-                    auto pptr = cast(char*) memchr( buf.ptr, '+', buf.length );
+		private:
+			char[4096] fixbuf;
+			char[] fixline( char[] buf )
+			{
+				version( OSX )
+				{
+					// format is:
+					//  1  module    0x00000000 D6module4funcAFZv + 0
+					for( size_t i = 0, n = 0; i < buf.length; i++ )
+					{
+						if( ' ' == buf[i] )
+						{
+							n++;
+							while( i < buf.length && ' ' == buf[i] )
+								i++;
+							if( 3 > n )
+								continue;
+							auto bsym = i;
+							while( i < buf.length && ' ' != buf[i] )
+								i++;
+							auto esym = i;
+							auto tail = buf.length - esym;
+							fixbuf[0 .. bsym] = buf[0 .. bsym];
+							auto m = demangle( buf[bsym .. esym], fixbuf[bsym .. $] );
+							fixbuf[bsym + m.length .. bsym + m.length + tail] = buf[esym .. $];
+							return fixbuf[0 .. bsym + m.length + tail];
+						}
+					}
+					return buf;
+				}
+				else version( linux )
+				{
+					// format is:  module(_D6module4funcAFZv) [0x00000000]
+					// or:         module(_D6module4funcAFZv+0x78) [0x00000000]
+					auto bptr = cast(char*) memchr( buf.ptr, '(', buf.length );
+					auto eptr = cast(char*) memchr( buf.ptr, ')', buf.length );
+					auto pptr = cast(char*) memchr( buf.ptr, '+', buf.length );
 
-                    if (pptr && pptr < eptr)
-                        eptr = pptr;
+					if (pptr && pptr < eptr)
+						eptr = pptr;
 
-                    if( bptr++ && eptr )
-                    {
-                        size_t bsym = bptr - buf.ptr;
-                        size_t esym = eptr - buf.ptr;
-                        auto tail = buf.length - esym;
-                        fixbuf[0 .. bsym] = buf[0 .. bsym];
-                        auto m = demangle( buf[bsym .. esym], fixbuf[bsym .. $] );
-                        fixbuf[bsym + m.length .. bsym + m.length + tail] = buf[esym .. $];
-                        return fixbuf[0 .. bsym + m.length + tail];
-                    }
-                    return buf;
-                }
-                else
-                {
-                    return buf;
-                }
-            }
-        }
+					if( bptr++ && eptr )
+					{
+						size_t bsym = bptr - buf.ptr;
+						size_t esym = eptr - buf.ptr;
+						auto tail = buf.length - esym;
+						fixbuf[0 .. bsym] = buf[0 .. bsym];
+						auto m = demangle( buf[bsym .. esym], fixbuf[bsym .. $] );
+						fixbuf[bsym + m.length .. bsym + m.length + tail] = buf[esym .. $];
+						return fixbuf[0 .. bsym + m.length + tail];
+					}
+					return buf;
+				}
+				else
+				{
+					return buf;
+				}
+			}
+		}
 
-        return new DefaultTraceInfo;
-    }
-    else static if( __traits( compiles, new StackTrace ) )
-    {
-        return new StackTrace;
-    }
-    else
-    {
-        return null;
-    }
+		return new DefaultTraceInfo;
+	}
+	else static if( __traits( compiles, new StackTrace ) )
+	{
+		return new StackTrace;
+	}
+	else
+	{
+		return null;
+	}
 }

File d/druntime/core/sync/condition.d

             if( rc )
                 throw new SyncException( "Unable to initialize condition" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
             int rc = pthread_cond_destroy( &m_hndl );
             assert( !rc, "Unable to destroy condition" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
             if( rc )
                 throw new SyncException( "Unable to wait for condition" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
                 return false;
             throw new SyncException( "Unable to wait for condition" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
             if( rc )
                 throw new SyncException( "Unable to notify condition" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
             if( rc )
                 throw new SyncException( "Unable to notify condition" );
         }
+ 		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 

File d/druntime/core/sync/mutex.d

             if( pthread_mutex_init( &m_hndl, &attr ) )
                 throw new SyncException( "Unable to initialize mutex" );
         }
-        m_proxy.link = this;
+	 	else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
+       m_proxy.link = this;
         this.__monitor = &m_proxy;
     }
 
             int rc = pthread_mutex_destroy( &m_hndl );
             assert( !rc, "Unable to destroy mutex" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
         this.__monitor = null;
     }
 
             if( rc )
                 throw new SyncException( "Unable to lock mutex" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
             if( rc )
                 throw new SyncException( "Unable to unlock mutex" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
         {
             return pthread_mutex_trylock( &m_hndl ) == 0;
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 

File d/druntime/core/sync/semaphore.d

             if( rc )
                 throw new SyncException( "Unable to create semaphore" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
             int rc = sem_destroy( &m_hndl );
             assert( !rc, "Unable to destroy semaphore" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
                     throw new SyncException( "Unable to wait for semaphore" );
             }
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
                     throw new SyncException( "Unable to wait for semaphore" );
             }
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
             if( rc )
                 throw new SyncException( "Unable to notify semaphore" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 
                     throw new SyncException( "Unable to wait for semaphore" );
             }
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
 

File d/druntime/core/sys/nacl/time.d

+/**
+ * D header file for Google Native Client.
+ *
+ * Copyright: Copyright Tristan Williams 2012.
+ * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+ * Authors:   Tristan Williams
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Tristan Williams 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.nacl.time;
+
+public struct timeval
+{
+	uint	tv_sec;
+	uint	tv_usec;
+}
+

File d/druntime/core/sys/nacl/types.d

+/**
+ * D header file for Google Native Client.
+ *
+ * Copyright: Copyright Tristan Williams 2012.
+ * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+ * Authors:   Tristan Williams
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Tristan Williams 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.nacl.types;
+
+alias ulong    ssize_t;

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

  */
 module core.sys.posix.sys.un;
 
-public import core.sys.posix.sys.socket: sa_family_t;
-
 extern(C):
 
 //
 
 version( linux )
 {
+	public import core.sys.posix.sys.socket: sa_family_t;
     struct sockaddr_un
     {
         sa_family_t sun_family;
 }
 else version( OSX )
 {
+	public import core.sys.posix.sys.socket: sa_family_t;
     struct sockaddr_un
     {
         ubyte       sun_len;
 }
 else version( FreeBSD )
 {
+	public import core.sys.posix.sys.socket: sa_family_t;
     struct sockaddr_un
     {
         ubyte       sun_len;

File d/druntime/core/sys/posix/time.d

 {
     pragma(msg, "no Windows support for CLOCK_MONOTONIC");
 }
+else version( nacl )
+{
+	//TWTODO
+    pragma(msg, "no nacl support for CLOCK_MONOTONIC");
+}
 else
 {
     static assert(0);

File d/druntime/core/thread.d

 {
     alias core.sys.windows.windows.GetCurrentProcessId getpid;
 }
+else version( nacl )
+{
+    uint getpid()
+	{
+		throw new Exception( "Function not yet implemented for nacl." );
+	}
+}
 
 
 ///////////////////////////////////////////////////////////////////////////////
         }
     }
 }
+else version( nacl )
+{
+	//TWTODO
+    extern (C)
+    {
+        extern int _tlsstart;
+        extern int _tlsend;
+    }
+}
 else
 {
     // NOTE: This is the only place threading versions are checked.  If a new
             pthread_detach( m_addr );
             m_addr = m_addr.init;
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
         version( OSX )
         {
             m_tmach = m_tmach.init;
             if( pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE ) )
                 throw new ThreadException( "Error setting thread joinable" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
 
         // NOTE: The starting thread must be added to the global thread list
         //       here rather than within thread_entryPoint to prevent a race
                 if( pthread_create( &m_addr, &attr, &thread_entryPoint, cast(void*) this ) != 0 )
                     throw new ThreadException( "Error creating thread" );
             }
+			else version( nacl )
+			{
+				throw new Exception( "not yet implemented for nacl" );
+			}
             version( OSX )
             {
                 m_tmach = pthread_mach_thread_np( m_addr );
             //       on object destruction.
             volatile m_addr = m_addr.init;
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
         if( m_unhandled )
         {
             if( rethrow )
             //       really isn't an issue for boolean values.
             return m_isRunning;
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
     }
 
 
                 throw new ThreadException( "Unable to get thread priority" );
             return param.sched_priority;
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
     }
 
 
             if( pthread_setschedparam( m_addr, policy, &param ) )
                 throw new ThreadException( "Unable to set thread priority" );
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
     }
 
 
                 tin = tout;
             }
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
     }
 
 
         {
             sched_yield();
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
     }
 
 
             //       Windows only, the secondary lookup is pointless anyway.
             return t;
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
     }
 
 
             PRIORITY_MAX = sched_get_priority_max( policy );
             assert( PRIORITY_MAX != -1 );
         }
+		else version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
     }
 
 
         alias pthread_key_t TLSKey;
         alias pthread_t     ThreadAddr;
     }
+    else version( nacl )
+    {
+        alias uint TLSKey;
+        alias uint ThreadAddr;
+    }
 
     //
     // Local storage
         {
             pthread_setspecific( sm_this, cast(void*) t );
         }
+        else version( nacl )
+        {
+            throw new Exception( "Function not yet implemented for nacl." );
+        }
     }
 
 
     {
         __gshared Mutex m = null;
 
-        if( m !is null )
-            return m;
-        else
-        {
-            auto ci = Mutex.classinfo;
-            auto p  = malloc( ci.init.length );
-            (cast(byte*) p)[0 .. ci.init.length] = ci.init[];
-            m = cast(Mutex) p;
-            m.__ctor();
-            return m;
-        }
+		version( nacl )
+		{
+			throw new Exception( "not yet implemented for nacl" );
+		}
+		else
+		{
+		    if( m !is null )
+		        return m;
+		    else
+		    {
+		        auto ci = Mutex.classinfo;
+		        auto p  = malloc( ci.init.length );
+		        (cast(byte*) p)[0 .. ci.init.length] = ci.init[];
+		        m = cast(Mutex) p;
+		        m.__ctor();
+		        return m;
+		    }
+		}
     }
 
 
         status = pthread_key_create( &Thread.sm_this, null );
         assert( status == 0 );
     }
+    else version( nacl )
+    {
+        throw new Exception( "Function not yet implemented for nacl." );
+    }
     Thread.sm_main = thread_attachThis();
 }
 
                 t.m_curr.tstack = getStackTop();
             }
         }
+        else version( nacl )
+        {
+            throw new Exception( "Function not yet implemented for nacl." );
+        }        
     }
 
 
                 t.m_curr.tstack = t.m_curr.bstack;
             }
         }
+        else version( nacl )
+        {
+            throw new Exception( "Function not yet implemented for nacl." );
+        }
     }
 
 

File d/druntime/core/time.d

             else
                 ticksPerSec = 1_000_000;
         }
-		else version( nacl )
-		{
-			// HACK
-			ticksPerSec = 0;
-		}
         else version(Posix)
         {
             static if(is(typeof(clock_gettime)))
             else
                 ticksPerSec = 1_000_000;
         }
+        else version( nacl )
+        {
+            // HACK
+            ticksPerSec = 0;
+        }
 
 		version( nacl )
 		{
                                     tv.tv_usec * TickDuration.ticksPerSec / 1000 / 1000);
             }
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
     }
 
     unittest

File d/druntime/object_.d

             }
         }
     }
+    else version( nacl )
+    {
+        int len = 0;
+        ModuleReference *mr;
+
+        for (mr = _Dmodule_ref; mr; mr = mr.next)
+            len++;
+        _moduleinfo_array = new ModuleInfo*[len];
+        len = 0;
+        for (mr = _Dmodule_ref; mr; mr = mr.next)
+        {   _moduleinfo_array[len] = mr.mod;
+            len++;
+        }
+    }
 
     //_moduleinfo_dtors = new ModuleInfo*[_moduleinfo_array.length];
     //debug(PRINTF) printf("_moduleinfo_dtors = x%x\n", cast(void*)_moduleinfo_dtors);

File d/druntime/rt/dmain2.d

         _STI_monitor_staticctor();
         _STI_critical_init();
     }
+    
+	version( nacl )
+	{
+        _STI_monitor_staticctor();
+        _STI_critical_init();
+	}    
 }
 
 alias void delegate(Throwable) ExceptionHandler;
         _STD_critical_term();
         _STD_monitor_staticdtor();
     }
+    
+    version( nacl )
+    {
+        _STD_critical_term();
+        _STD_monitor_staticdtor();
+    }    
 }
 
 extern (C) bool rt_term(ExceptionHandler dg = null)
         _STI_critical_init();
     }
 
+    version( nacl )
+    {
+        _STI_monitor_staticctor();
+        _STI_critical_init();
+    }
+    
     version (Windows)
     {
         wchar_t*  wcbuf = GetCommandLineW();
         _STD_monitor_staticdtor();
     }
 
+    version( nacl )
+    {
+        _STD_critical_term();
+        _STD_monitor_staticdtor();
+    }
+    
     return result;
 }

File d/druntime/rt/memory.d

     }
     else version( nacl )
     {
-		//TODO: STUB!
+		//TWTODO: STUB!
 		throw new Exception("initStaticDataGC not yet implemented for nacl");
     }
     else
         }
         else version( nacl )
         {
-			//TODO: STUB!
+			//TWTODO: STUB!
 			throw new Exception("initStaticDataGC not yet implemented for nacl");
         }
 		else

File d/druntime/rt/util/console.d

         {
             write( 2, val.ptr, val.length );
         }
+		else version( nacl )
+		{
+			throw new Exception( "Function not yet implemented for nacl." );
+		}
         return this;
     }
 

File d/phobos/std/date.d

     }
 
 }
+else version( nacl )
+{
+    d_time getLocalTZA() { throw new Exception( "Function not yet implemented for nacl." ); }
+    int DaylightSavingTA(d_time dt) { throw new Exception( "Function not yet implemented for nacl." ); }
+}
 else version (NoSystem)
 {
     d_time getLocalTZA() { return 0; }

File d/phobos2/Makefile.am

 		core/sys/windows/stacktrace.o core/sys/windows/threadaux.o \
 		core/sys/windows/windows.o
 
+RT_NACL_OBJS=core/sys/nacl/time.o
+
 # This should not be linked into a shared library.
 CMAIN_OBJS= #rt/cmain.o
 
 	     \
 	     core/sys/windows/dbghelp.di core/sys/windows/dll.di \
 	     core/sys/windows/stacktrace.di core/sys/windows/threadaux.di \
-	     core/sys/windows/windows.di
+	     core/sys/windows/windows.di \
+		 \
+		 core/sys/nacl/time.di
 
 ALL_DRUNTIME_OBJS = $(DRUNTIME_OBJS) $(CORE_OBJS) $(D_GC_MODULES) $(GCC_OBJS)
 
 	done
 	for i in core core/stdc core/sync core/sys/osx/mach core/sys/posix \
 		core/sys/posix/arpa core/sys/posix/net core/sys/posix/netinet \
-		core/sys/posix/sys core/sys/windows; do \
+		core/sys/posix/sys core/sys/windows core/sys/nacl; do \
 		$(mkinstalldirs) $(DESTDIR)$(gdc_include_dir)/$(host_alias)/$(MULTISUBDIR)/$$i; \
 		for f in $(IMPORT)/$$i/*.di; do \
 			$(INSTALL_HEADER) $$f $(DESTDIR)$(gdc_include_dir)/$(host_alias)/$(MULTISUBDIR)/$$i; \

File d/phobos2/Makefile.in

 		core/sys/windows/stacktrace.o core/sys/windows/threadaux.o \
 		core/sys/windows/windows.o
 
+RT_NACL_OBJS = core/sys/nacl/time.o
 
 # This should not be linked into a shared library.
 CMAIN_OBJS = #rt/cmain.o
 	     \
 	     core/sys/windows/dbghelp.di core/sys/windows/dll.di \
 	     core/sys/windows/stacktrace.di core/sys/windows/threadaux.di \
-	     core/sys/windows/windows.di
+	     core/sys/windows/windows.di \
+		 \
+		 core/sys/nacl/time.di
 
 ALL_DRUNTIME_OBJS = $(DRUNTIME_OBJS) $(CORE_OBJS) $(D_GC_MODULES) $(GCC_OBJS)
 MAIN_OBJS = std/algorithm.o std/array.o std/ascii.o std/base64.o std/bigint.o \
 frag-math: $(top_builddir)/config.status $(srcdir)/frag-math.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 phobos-ver-syms: $(top_builddir)/config.status $(srcdir)/phobos-ver-syms.in
-	cd $(top_builddir) && $(SHELL) ./config.status $@
+	cd $(top_builddir) && $(SHELL) ./config.status $@posix
 
 # GNU Make needs to see an explicit $(MAKE) variable in the command it
 # runs to enable its job server during parallel builds.  Hence the

File d/phobos2/acinclude.m4

 	    ;;
   nacl*)
 		d_gc_data="$d_gc_data GC_Use_Data_Fixed"
-		DCFG_POSIX="Posix"
 	    ;;
   *)    dnl D_GC_MODULES=gc/gcgcc.o
         ;;

File d/phobos2/configure

 $as_echo "#define PTHREAD_MUTEX_ALREADY_RECURSIVE 1" >>confdefs.h
 
 	     ;;
+    nacl*)	DCFG_UNIX=NoSystem
+
+$as_echo "#define PHOBOS_NO_SYSTEM 1" >>confdefs.h
+
+	     DRUNTIME_OBJS="$DRUNTIME_OBJS gcc/cbridge_stdio.o"
+	     DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_STDC_OBJS)"
+	     DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_NACL_OBJS)"
+	     DCFG_CBRIDGE_STDIO=GNU_CBridge_Stdio
+	     ;;
     *)       if test "$enable_unix" != "yes"; then
 	         DCFG_UNIX=NoSystem
 
 	    ;;
   nacl*)
 		d_gc_data="$d_gc_data GC_Use_Data_Fixed"
-		DCFG_POSIX="Posix"
 	    ;;
   *)            ;;
 esac

File d/phobos2/configure.in

 	     DCFG_CBRIDGE_STDIO=GNU_CBridge_Stdio
 	     AC_DEFINE(PTHREAD_MUTEX_ALREADY_RECURSIVE,1,[Define if mutexes are recursive by default])
 	     ;;
+    nacl*)	DCFG_UNIX=NoSystem
+		 AC_DEFINE(PHOBOS_NO_SYSTEM,1,[Define if there is no file system, synchronization services, etc.])
+	     DRUNTIME_OBJS="$DRUNTIME_OBJS gcc/cbridge_stdio.o"
+	     DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_STDC_OBJS)"
+	     DRUNTIME_OBJS="$DRUNTIME_OBJS \$(RT_NACL_OBJS)"
+	     DCFG_CBRIDGE_STDIO=GNU_CBridge_Stdio
+	     ;;
     *)       if test "$enable_unix" != "yes"; then
 	         DCFG_UNIX=NoSystem
 		 AC_DEFINE(PHOBOS_NO_SYSTEM,1,[Define if there is no file system, synchronization services, etc.])

File d/phobos2/etc/c/curl.d

   enum CURL_SOCKET_BAD = SOCKET_ERROR;
 }
 version(Posix) enum CURL_SOCKET_BAD = -1;
+version(nacl) enum CURL_SOCKET_BAD = -1;
 
 ///
 extern (C) struct curl_httppost

File d/phobos2/std/ascii.d

     /// Newline sequence for this system.
     immutable newline = "\n";
 }
+else version( nacl )
+{
+    /// Newline sequence for this system.
+    immutable newline = "\n";
+}
 else
     static assert(0, "Unsupported OS");
 

File d/phobos2/std/date.d

 
 }
 
+version( nacl )
+{
+    /******
+     * Get current UTC time.
+     */
+    d_time getUTCtime()
+    {
+        throw new Exception( "Function not yet implemented for nacl." );
+    }
+
+    d_time getLocalTZA()
+    {
+        throw new Exception( "Function not yet implemented for nacl." );
+    }
+
+    /*
+     * Get daylight savings time adjust for time dt.
+     */
+
+    int daylightSavingTA(d_time dt)
+    {
+        throw new Exception( "Function not yet implemented for nacl." );
+    }
+}
 
 /+ DOS File Time +/
 

File d/phobos2/std/datetime.d

     import core.sys.posix.time;
     import core.sys.posix.sys.time;
 }
+else version( nacl )
+{
+	import core.sys.nacl.time;
+}
 
 //Comment this out to disable std.datetime's unit tests.
 version = testStdDateTime;
                        hnsecsToUnixEpoch;
             }
         }
+        else version( nacl )
+        {
+            throw new Exception( "Function not yet implemented for nacl." );            
+        }
     }
 
     /++
             return PosixTimeZone.getTimeZone(name);
         else version(Windows)
             return WindowsTimeZone.getTimeZone(tzDatabaseNameToWindowsTZName(name));
+        else version( nacl )
+            throw new Exception( "Function not yet implemented for nacl." );            
     }
 
     //Since reading in the time zone files could be expensive, most unit tests
 
             return retval.data;
         }
+        else version( nacl )
+            throw new Exception( "Function not yet implemented for nacl." );            
     }
 
     unittest
             catch(Exception e)
                 assert(0, "GetTimeZoneInformation() threw.");
         }
+        else version( nacl )
+            assert( 0, "Function not yet implemented for nacl " );
     }
 
     unittest
             catch(Exception e)
                 assert(0, "GetTimeZoneInformation() threw.");
         }
+        else version( nacl )
+            assert( 0, "Function not yet implemented for nacl " );
     }
 
     unittest
             catch(Exception e)
                 assert(0, "GetTimeZoneInformation() threw.");
         }
+        else version( nacl )
+            assert( 0, "Function not yet implemented for nacl " );
     }
 
     unittest
 
             return WindowsTimeZone._dstInEffect(&tzInfo, stdTime);
         }
+        else version( nacl )
+            assert( 0, "Function not yet implemented for nacl " );
     }
 
     unittest
 
             return WindowsTimeZone._utcToTZ(&tzInfo, stdTime, hasDST);
         }
+        else version( nacl )
+            assert( 0, "Function not yet implemented for nacl " );
     }
 
     unittest
 
             return WindowsTimeZone._tzToUTC(&tzInfo, adjTime, hasDST);
         }
+        else version( nacl )
+            assert( 0, "Function not yet implemented for nacl " );
     }
 
     unittest
           +/
         enum defaultTZDatabaseDir = "";
     }
+    else version( nacl )
+    {
+        /++ NaCl also does not have them
+		  +/
+        enum defaultTZDatabaseDir = "";
+    }
 
 
     /++
             auto file = tzDatabaseDir ~ name;
         else version(Windows)
             auto file = tzDatabaseDir ~ replace(strip(name), "/", sep);
+        else version( nacl )
+        {
+            throw new Exception( "Function not yet implemented for nacl." );
+            string file = "";
+        }
 
         enforce(file.exists, new DateTimeException(format("File %s does not exist.", file)));
         enforce(file.isFile, new DateTimeException(format("%s is not a file.", file)));
             subName = strip(subName);
         else version(Windows)
             subName = replace(strip(subName), "/", sep);
-
+        else version( nacl )
+        {
+            throw new Exception( "Function not yet implemented for nacl." );
+            string  sep="";
+        }
+        
         if(!tzDatabaseDir.endsWith(sep))
             tzDatabaseDir ~= sep;
 

File d/phobos2/std/file.d

     import core.sys.posix.dirent, core.sys.posix.fcntl, core.sys.posix.sys.stat,
         core.sys.posix.sys.time, core.sys.posix.unistd, core.sys.posix.utime;
 }
+else version( nacl )
+{
+    // TODO
+}
 else
     static assert(false, "Module " ~ .stringof ~ " not implemented for this OS.");
 
       {
         throw new FileException(name, .getErrno(), file, line);
       }
+      else version( nacl )
+      {
+		throw new Exception( "Function not yet implemented for nacl." );
+      }
     }
     return condition;
 }
             ? GC.realloc(result.ptr, size, GC.BlkAttr.NO_SCAN)[0 .. size]
             : result[0 .. size];
     }
+	else version( nacl )
+	{
+		throw new Exception( "Function not yet implemented for nacl." );
+	}
 }
 
 unittest
                 name);
     }
     else version(Posix)
+	{
         return writeImpl(name, buffer, O_CREAT | O_WRONLY | O_TRUNC);
+	}
+	else version( nacl )
+	{
+		throw new Exception( "Function not yet implemented for nacl." );
+	}
 }
 
 /*********************************************
                 name);
     }
     else version(Posix)
+	{
         return writeImpl(name, buffer, O_APPEND | O_WRONLY | O_CREAT);
+	}
+	else version( nacl )
+	{
+		throw new Exception( "Function not yet implemented for nacl." );
+	}
 }
 
 // Posix implementation helper for write and append
                             to)));
     }
     else version(Posix)
+	{
         cenforce(core.stdc.stdio.rename(toStringz(from), toStringz(to)) == 0, to);
+	}
+	else version( nacl )
+	{
+		throw new Exception( "Function not yet implemented for nacl." );
+	}
 }
 
 /***************************************************