From: sean Date: Wed, 15 Oct 2008 21:33:55 +0000 (+0000) Subject: * Changed top-level exception class name from 'Exception' to 'Throwable'. X-Git-Url: https://git.llucax.com/software/druntime.git/commitdiff_plain/4926e6ef8c37680c8e5ce47d9cddd03819ae84af?ds=sidebyside * Changed top-level exception class name from 'Exception' to 'Throwable'. * Created a new class 'Exception' which derives from 'Throwable'. * Created a new class 'Error' which derives from 'Throwable'. * Moved core modules from the top level into a package named 'core'. * Added onHiddenFuncError() routine to pass hidden function error handling from the runtime to core.exception. * Renamed _d_getErrno to getErrno and moved it to src/common/stdc. The idea is that druntime may eventually generate a lib for the stdc modules, and this definition is necessary. The comparable function will have to be removed from Phobos as well. * Moved the GC code into a package named 'gc', which is in accordance with the spec defined for druntime library integration (as yet unpublished). git-svn-id: http://svn.dsource.org/projects/druntime/trunk@29 4a9d5153-6564-4b3f-b5e1-7e8e9dac548f --- diff --git a/import/bitmanip.di b/import/core/bitmanip.di similarity index 95% rename from import/bitmanip.di rename to import/core/bitmanip.di index 2e1496d..ab2c3ec 100644 --- a/import/bitmanip.di +++ b/import/core/bitmanip.di @@ -1,262 +1,262 @@ -/** - * This module contains a collection of bit-level operations. - * - * Copyright: Copyright (c) 2005-2008, The D Runtime Project - * License: BSD Style, see LICENSE - * Authors: Walter Bright, Don Clugston, Sean Kelly - */ -module bitmanip; - - -version( DDoc ) -{ - /** - * Scans the bits in v starting with bit 0, looking - * for the first set bit. - * Returns: - * The bit number of the first bit set. - * The return value is undefined if v is zero. - */ - int bsf( uint v ); - - - /** - * Scans the bits in v from the most significant bit - * to the least significant bit, looking - * for the first set bit. - * Returns: - * The bit number of the first bit set. - * The return value is undefined if v is zero. - * Example: - * --- - * import bitmanip; - * - * int main() - * { - * uint v; - * int x; - * - * v = 0x21; - * x = bsf(v); - * printf("bsf(x%x) = %d\n", v, x); - * x = bsr(v); - * printf("bsr(x%x) = %d\n", v, x); - * return 0; - * } - * --- - * Output: - * bsf(x21) = 0
- * bsr(x21) = 5 - */ - int bsr( uint v ); - - - /** - * Tests the bit. - */ - int bt( uint* p, uint bitnum ); - - - /** - * Tests and complements the bit. - */ - int btc( uint* p, uint bitnum ); - - - /** - * Tests and resets (sets to 0) the bit. - */ - int btr( uint* p, uint bitnum ); - - - /** - * Tests and sets the bit. - * Params: - * p = a non-NULL pointer to an array of uints. - * index = a bit number, starting with bit 0 of p[0], - * and progressing. It addresses bits like the expression: - --- - p[index / (uint.sizeof*8)] & (1 << (index & ((uint.sizeof*8) - 1))) - --- - * Returns: - * A non-zero value if the bit was set, and a zero - * if it was clear. - * - * Example: - * --- - import bitmanip; - - int main() - { - uint array[2]; - - array[0] = 2; - array[1] = 0x100; - - printf("btc(array, 35) = %d\n", btc(array, 35)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); - - printf("btc(array, 35) = %d\n", btc(array, 35)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); - - printf("bts(array, 35) = %d\n", bts(array, 35)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); - - printf("btr(array, 35) = %d\n", btr(array, 35)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); - - printf("bt(array, 1) = %d\n", bt(array, 1)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); - - return 0; - } - * --- - * Output: -
-    btc(array, 35) = 0
-    array = [0]:x2, [1]:x108
-    btc(array, 35) = -1
-    array = [0]:x2, [1]:x100
-    bts(array, 35) = 0
-    array = [0]:x2, [1]:x108
-    btr(array, 35) = -1
-    array = [0]:x2, [1]:x100
-    bt(array, 1) = -1
-    array = [0]:x2, [1]:x100
-    
- */ - int bts( uint* p, uint bitnum ); - - - /** - * Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes - * byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3 - * becomes byte 0. - */ - uint bswap( uint v ); - - - /** - * Reads I/O port at port_address. - */ - ubyte inp( uint port_address ); - - - /** - * ditto - */ - ushort inpw( uint port_address ); - - - /** - * ditto - */ - uint inpl( uint port_address ); - - - /** - * Writes and returns value to I/O port at port_address. - */ - ubyte outp( uint port_address, ubyte value ); - - - /** - * ditto - */ - ushort outpw( uint port_address, ushort value ); - - - /** - * ditto - */ - uint outpl( uint port_address, uint value ); -} -else -{ - public import std.intrinsic; -} - - -/** - * Calculates the number of set bits in a 32-bit integer. - */ -int popcnt( uint x ) -{ - // Avoid branches, and the potential for cache misses which - // could be incurred with a table lookup. - - // We need to mask alternate bits to prevent the - // sum from overflowing. - // add neighbouring bits. Each bit is 0 or 1. - x = x - ((x>>1) & 0x5555_5555); - // now each two bits of x is a number 00,01 or 10. - // now add neighbouring pairs - x = ((x&0xCCCC_CCCC)>>2) + (x&0x3333_3333); - // now each nibble holds 0000-0100. Adding them won't - // overflow any more, so we don't need to mask any more - - // Now add the nibbles, then the bytes, then the words - // We still need to mask to prevent double-counting. - // Note that if we used a rotate instead of a shift, we - // wouldn't need the masks, and could just divide the sum - // by 8 to account for the double-counting. - // On some CPUs, it may be faster to perform a multiply. - - x += (x>>4); - x &= 0x0F0F_0F0F; - x += (x>>8); - x &= 0x00FF_00FF; - x += (x>>16); - x &= 0xFFFF; - return x; -} - - -/** - * Reverses the order of bits in a 32-bit integer. - */ -uint bitswap( uint x ) -{ - - version( D_InlineAsm_X86 ) - { - asm - { - // Author: Tiago Gasiba. - mov EDX, EAX; - shr EAX, 1; - and EDX, 0x5555_5555; - and EAX, 0x5555_5555; - shl EDX, 1; - or EAX, EDX; - mov EDX, EAX; - shr EAX, 2; - and EDX, 0x3333_3333; - and EAX, 0x3333_3333; - shl EDX, 2; - or EAX, EDX; - mov EDX, EAX; - shr EAX, 4; - and EDX, 0x0f0f_0f0f; - and EAX, 0x0f0f_0f0f; - shl EDX, 4; - or EAX, EDX; - bswap EAX; - } - } - else - { - // swap odd and even bits - x = ((x >> 1) & 0x5555_5555) | ((x & 0x5555_5555) << 1); - // swap consecutive pairs - x = ((x >> 2) & 0x3333_3333) | ((x & 0x3333_3333) << 2); - // swap nibbles - x = ((x >> 4) & 0x0F0F_0F0F) | ((x & 0x0F0F_0F0F) << 4); - // swap bytes - x = ((x >> 8) & 0x00FF_00FF) | ((x & 0x00FF_00FF) << 8); - // swap 2-byte long pairs - x = ( x >> 16 ) | ( x << 16); - return x; - - } -} +/** + * This module contains a collection of bit-level operations. + * + * Copyright: Copyright (c) 2005-2008, The D Runtime Project + * License: BSD Style, see LICENSE + * Authors: Walter Bright, Don Clugston, Sean Kelly + */ +module bitmanip; + + +version( DDoc ) +{ + /** + * Scans the bits in v starting with bit 0, looking + * for the first set bit. + * Returns: + * The bit number of the first bit set. + * The return value is undefined if v is zero. + */ + int bsf( uint v ); + + + /** + * Scans the bits in v from the most significant bit + * to the least significant bit, looking + * for the first set bit. + * Returns: + * The bit number of the first bit set. + * The return value is undefined if v is zero. + * Example: + * --- + * import bitmanip; + * + * int main() + * { + * uint v; + * int x; + * + * v = 0x21; + * x = bsf(v); + * printf("bsf(x%x) = %d\n", v, x); + * x = bsr(v); + * printf("bsr(x%x) = %d\n", v, x); + * return 0; + * } + * --- + * Output: + * bsf(x21) = 0
+ * bsr(x21) = 5 + */ + int bsr( uint v ); + + + /** + * Tests the bit. + */ + int bt( uint* p, uint bitnum ); + + + /** + * Tests and complements the bit. + */ + int btc( uint* p, uint bitnum ); + + + /** + * Tests and resets (sets to 0) the bit. + */ + int btr( uint* p, uint bitnum ); + + + /** + * Tests and sets the bit. + * Params: + * p = a non-NULL pointer to an array of uints. + * index = a bit number, starting with bit 0 of p[0], + * and progressing. It addresses bits like the expression: + --- + p[index / (uint.sizeof*8)] & (1 << (index & ((uint.sizeof*8) - 1))) + --- + * Returns: + * A non-zero value if the bit was set, and a zero + * if it was clear. + * + * Example: + * --- + import bitmanip; + + int main() + { + uint array[2]; + + array[0] = 2; + array[1] = 0x100; + + printf("btc(array, 35) = %d\n", btc(array, 35)); + printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); + + printf("btc(array, 35) = %d\n", btc(array, 35)); + printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); + + printf("bts(array, 35) = %d\n", bts(array, 35)); + printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); + + printf("btr(array, 35) = %d\n", btr(array, 35)); + printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); + + printf("bt(array, 1) = %d\n", bt(array, 1)); + printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); + + return 0; + } + * --- + * Output: +
+    btc(array, 35) = 0
+    array = [0]:x2, [1]:x108
+    btc(array, 35) = -1
+    array = [0]:x2, [1]:x100
+    bts(array, 35) = 0
+    array = [0]:x2, [1]:x108
+    btr(array, 35) = -1
+    array = [0]:x2, [1]:x100
+    bt(array, 1) = -1
+    array = [0]:x2, [1]:x100
+    
+ */ + int bts( uint* p, uint bitnum ); + + + /** + * Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes + * byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3 + * becomes byte 0. + */ + uint bswap( uint v ); + + + /** + * Reads I/O port at port_address. + */ + ubyte inp( uint port_address ); + + + /** + * ditto + */ + ushort inpw( uint port_address ); + + + /** + * ditto + */ + uint inpl( uint port_address ); + + + /** + * Writes and returns value to I/O port at port_address. + */ + ubyte outp( uint port_address, ubyte value ); + + + /** + * ditto + */ + ushort outpw( uint port_address, ushort value ); + + + /** + * ditto + */ + uint outpl( uint port_address, uint value ); +} +else +{ + public import std.intrinsic; +} + + +/** + * Calculates the number of set bits in a 32-bit integer. + */ +int popcnt( uint x ) +{ + // Avoid branches, and the potential for cache misses which + // could be incurred with a table lookup. + + // We need to mask alternate bits to prevent the + // sum from overflowing. + // add neighbouring bits. Each bit is 0 or 1. + x = x - ((x>>1) & 0x5555_5555); + // now each two bits of x is a number 00,01 or 10. + // now add neighbouring pairs + x = ((x&0xCCCC_CCCC)>>2) + (x&0x3333_3333); + // now each nibble holds 0000-0100. Adding them won't + // overflow any more, so we don't need to mask any more + + // Now add the nibbles, then the bytes, then the words + // We still need to mask to prevent double-counting. + // Note that if we used a rotate instead of a shift, we + // wouldn't need the masks, and could just divide the sum + // by 8 to account for the double-counting. + // On some CPUs, it may be faster to perform a multiply. + + x += (x>>4); + x &= 0x0F0F_0F0F; + x += (x>>8); + x &= 0x00FF_00FF; + x += (x>>16); + x &= 0xFFFF; + return x; +} + + +/** + * Reverses the order of bits in a 32-bit integer. + */ +uint bitswap( uint x ) +{ + + version( D_InlineAsm_X86 ) + { + asm + { + // Author: Tiago Gasiba. + mov EDX, EAX; + shr EAX, 1; + and EDX, 0x5555_5555; + and EAX, 0x5555_5555; + shl EDX, 1; + or EAX, EDX; + mov EDX, EAX; + shr EAX, 2; + and EDX, 0x3333_3333; + and EAX, 0x3333_3333; + shl EDX, 2; + or EAX, EDX; + mov EDX, EAX; + shr EAX, 4; + and EDX, 0x0f0f_0f0f; + and EAX, 0x0f0f_0f0f; + shl EDX, 4; + or EAX, EDX; + bswap EAX; + } + } + else + { + // swap odd and even bits + x = ((x >> 1) & 0x5555_5555) | ((x & 0x5555_5555) << 1); + // swap consecutive pairs + x = ((x >> 2) & 0x3333_3333) | ((x & 0x3333_3333) << 2); + // swap nibbles + x = ((x >> 4) & 0x0F0F_0F0F) | ((x & 0x0F0F_0F0F) << 4); + // swap bytes + x = ((x >> 8) & 0x00FF_00FF) | ((x & 0x00FF_00FF) << 8); + // swap 2-byte long pairs + x = ( x >> 16 ) | ( x << 16); + return x; + + } +} diff --git a/import/object.di b/import/object.di index ff7ad8d..065af6b 100644 --- a/import/object.di +++ b/import/object.di @@ -208,14 +208,14 @@ class ModuleInfo void function() dtor; void function() unitTest; - static int opApply( int delegate( inout ModuleInfo ) ); + static int opApply(int delegate(inout ModuleInfo)); } -class Exception : Object +class Throwable : Object { interface TraceInfo { - int opApply( int delegate(inout char[]) ); + int opApply(int delegate(inout char[])); string toString(); } @@ -223,12 +223,23 @@ class Exception : Object string file; size_t line; TraceInfo info; - Exception next; + Throwable next; - this(string msg, Exception next = null); - this(string msg, string file, size_t line, Exception next = null); + this(string msg, Throwable next = null); + this(string msg, string file, size_t line, Throwable next = null); override string toString(); } -alias Exception Error; +class Exception : Throwable +{ + this(string msg, Throwable next = null); + this(string msg, string file, size_t line, Throwable next = null); +} + + +class Error : Throwable +{ + this(string msg, Throwable next = null); + this(string msg, string file, size_t line, Throwable next = null); +} diff --git a/src/core/bitmanip.d b/src/common/core/bitmanip.d similarity index 98% rename from src/core/bitmanip.d rename to src/common/core/bitmanip.d index 11397c9..ad1ac4e 100644 --- a/src/core/bitmanip.d +++ b/src/common/core/bitmanip.d @@ -5,7 +5,7 @@ * License: BSD Style, see LICENSE * Authors: Walter Bright, Don Clugston, Sean Kelly */ -module bitmanip; +module core.bitmanip; version( DDoc ) @@ -29,7 +29,7 @@ version( DDoc ) * The return value is undefined if v is zero. * Example: * --- - * import bitmanip; + * import core.bitmanip; * * int main() * { @@ -84,7 +84,7 @@ version( DDoc ) * * Example: * --- - import bitmanip; + import core.bitmanip; int main() { diff --git a/src/core/exception.d b/src/common/core/exception.d similarity index 93% rename from src/core/exception.d rename to src/common/core/exception.d index e44392a..a9178cf 100644 --- a/src/core/exception.d +++ b/src/common/core/exception.d @@ -6,7 +6,7 @@ * License: BSD Style, see LICENSE * Authors: Sean Kelly */ -module exception; +module core.exception; private @@ -29,18 +29,6 @@ class ArrayBoundsException : Exception } -/** - * Thrown on hidden function error. - */ -class HiddenFuncException : Exception -{ - this(ClassInfo ci) - { - super("hidden method called for " ~ ci.name); - } -} - - /** * Thrown on an assert error. */ @@ -78,6 +66,18 @@ class FinalizeException : Exception } +/** + * Thrown on hidden function error. + */ +class HiddenFuncException : Exception +{ + this( ClassInfo ci ) + { + super( "Hidden method called for " ~ ci.name ); + } +} + + /** * Thrown on an out of memory error. */ @@ -216,6 +216,19 @@ extern (C) void onFinalizeError( ClassInfo info, Exception ex ) } +/** + * A callback for hidden function errors in D. A HiddenFuncException will be + * thrown. + * + * Throws: + * HiddenFuncException. + */ +extern (C) void onHiddenFuncError( Object o ) +{ + throw new HiddenFuncException( o.classinfo ); +} + + /** * A callback for out of memory errors in D. An OutOfMemoryException will be * thrown. @@ -261,20 +274,3 @@ extern (C) void onUnicodeError( string msg, size_t idx ) { throw new UnicodeException( msg, idx ); } - -/******************************************** - * Called by the compiler generated code. - */ - -extern (C) void _d_hidden_func() -{ Object o; - asm - { - mov o, EAX; - } - - //printf("_d_hidden_func()\n"); - auto a = new HiddenFuncException(o.classinfo); - //printf("assertion %p created\n", a); - throw a; -} diff --git a/src/core/memory.d b/src/common/core/memory.d similarity index 99% rename from src/core/memory.d rename to src/common/core/memory.d index 9bdd3d6..65c35c8 100644 --- a/src/core/memory.d +++ b/src/common/core/memory.d @@ -6,7 +6,7 @@ * License: BSD Style, see LICENSE * Authors: Sean Kelly */ -module memory; +module core.memory; private diff --git a/src/core/runtime.d b/src/common/core/runtime.d similarity index 99% rename from src/core/runtime.d rename to src/common/core/runtime.d index 5263374..76a9438 100644 --- a/src/core/runtime.d +++ b/src/common/core/runtime.d @@ -5,7 +5,7 @@ * License: BSD Style, see LICENSE * Authors: Sean Kelly */ -module runtime; +module core.runtime; private diff --git a/src/core/thread.d b/src/common/core/thread.d similarity index 99% rename from src/core/thread.d rename to src/common/core/thread.d index 846f249..d359b20 100644 --- a/src/core/thread.d +++ b/src/common/core/thread.d @@ -5,7 +5,7 @@ * License: BSD Style, see LICENSE * Authors: Sean Kelly */ -module thread; +module core.thread; // this should be true for most architectures @@ -157,9 +157,6 @@ else version( Posix ) import stdc.posix.time; import stdc.errno; - extern (C) int _d_getErrno(); - alias _d_getErrno getErrno; - version( GNU ) { import gcc.builtins; diff --git a/src/core/posix.mak b/src/common/posix.mak similarity index 83% rename from src/core/posix.mak rename to src/common/posix.mak index adf6763..c2e8e8a 100644 --- a/src/core/posix.mak +++ b/src/common/posix.mak @@ -1,134 +1,134 @@ -# Makefile to build the D runtime library core components for Posix -# Designed to work with GNU make -# Targets: -# make -# Same as make all -# make lib -# Build the common library -# make doc -# Generate documentation -# make clean -# Delete unneeded files created by build process - -LIB_TARGET=libdruntime-core.a -LIB_MASK=libdruntime-core*.a - -CP=cp -f -RM=rm -f -MD=mkdir -p - -ADD_CFLAGS= -ADD_DFLAGS= - -CFLAGS=-O $(ADD_CFLAGS) -#CFLAGS=-g $(ADD_CFLAGS) - -DFLAGS=-release -O -inline -w -nofloat -version=Posix $(ADD_DFLAGS) -#DFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS) - -TFLAGS=-O -inline -w -nofloat -version=Posix $(ADD_DFLAGS) -#TFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS) - -DOCFLAGS=-version=DDoc -version=Posix - -CC=gcc -LC=$(AR) -qsv -DC=dmd - -INC_DEST=../../import -LIB_DEST=../../lib -DOC_DEST=../../doc - -.SUFFIXES: .s .S .c .cpp .d .html .o - -.s.o: - $(CC) -c $(CFLAGS) $< -o$@ - -.S.o: - $(CC) -c $(CFLAGS) $< -o$@ - -.c.o: - $(CC) -c $(CFLAGS) $< -o$@ - -.cpp.o: - g++ -c $(CFLAGS) $< -o$@ - -.d.o: - $(DC) -c $(DFLAGS) -Hf$*.di $< -of$@ -# $(DC) -c $(DFLAGS) $< -of$@ - -.d.html: - $(DC) -c -o- $(DOCFLAGS) -Df$*.html $< - -targets : lib doc -all : lib doc -core : lib -lib : core.lib -doc : core.doc - -###################################################### - -OBJ_CORE= \ - bitmanip.o \ - exception.o \ - memory.o \ - runtime.o \ - thread.o - -OBJ_STDC= \ - stdc.o - -ALL_OBJS= \ - $(OBJ_CORE) \ - $(OBJ_STDC) - -###################################################### - -DOC_CORE= \ - bitmanip.html \ - exception.html \ - memory.html \ - runtime.html \ - thread.html - - -ALL_DOCS= - -###################################################### - -core.lib : $(LIB_TARGET) - -$(LIB_TARGET) : $(ALL_OBJS) - $(RM) $@ - $(LC) $@ $(ALL_OBJS) - -core.doc : $(ALL_DOCS) - echo Documentation generated. - -###################################################### - -### bitmanip - -bitmanip.o : bitmanip.d - $(DC) -c $(DFLAGS) bitmanip.d -of$@ - -### thread - -thread.o : thread.d - $(DC) -c $(DFLAGS) -d -Hf$*.di thread.d -of$@ - -###################################################### - -clean : - find . -name "*.di" | xargs $(RM) - $(RM) $(ALL_OBJS) - $(RM) $(ALL_DOCS) - find . -name "$(LIB_MASK)" | xargs $(RM) - -install : - $(MD) $(INC_DEST) - find . -name "*.di" -exec cp -f {} $(INC_DEST)/{} \; - $(MD) $(DOC_DEST) - find . -name "*.html" -exec cp -f {} $(DOC_DEST)/{} \; - $(MD) $(LIB_DEST) - find . -name "$(LIB_MASK)" -exec cp -f {} $(LIB_DEST)/{} \; +# Makefile to build the D runtime library core components for Posix +# Designed to work with GNU make +# Targets: +# make +# Same as make all +# make lib +# Build the common library +# make doc +# Generate documentation +# make clean +# Delete unneeded files created by build process + +LIB_TARGET=libdruntime-core.a +LIB_MASK=libdruntime-core*.a + +CP=cp -f +RM=rm -f +MD=mkdir -p + +ADD_CFLAGS= +ADD_DFLAGS= + +CFLAGS=-O $(ADD_CFLAGS) +#CFLAGS=-g $(ADD_CFLAGS) + +DFLAGS=-release -O -inline -w -nofloat -version=Posix $(ADD_DFLAGS) +#DFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS) + +TFLAGS=-O -inline -w -nofloat -version=Posix $(ADD_DFLAGS) +#TFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS) + +DOCFLAGS=-version=DDoc -version=Posix + +CC=gcc +LC=$(AR) -qsv +DC=dmd + +INC_DEST=../../import +LIB_DEST=../../lib +DOC_DEST=../../doc + +.SUFFIXES: .s .S .c .cpp .d .html .o + +.s.o: + $(CC) -c $(CFLAGS) $< -o$@ + +.S.o: + $(CC) -c $(CFLAGS) $< -o$@ + +.c.o: + $(CC) -c $(CFLAGS) $< -o$@ + +.cpp.o: + g++ -c $(CFLAGS) $< -o$@ + +.d.o: + $(DC) -c $(DFLAGS) -Hf$*.di $< -of$@ +# $(DC) -c $(DFLAGS) $< -of$@ + +.d.html: + $(DC) -c -o- $(DOCFLAGS) -Df$*.html $< + +targets : lib doc +all : lib doc +core : lib +lib : core.lib +doc : core.doc + +###################################################### + +OBJ_CORE= \ + core/bitmanip.o \ + core/exception.o \ + core/memory.o \ + core/runtime.o \ + core/thread.o + +OBJ_STDC= \ + stdc/errno.o + +ALL_OBJS= \ + $(OBJ_CORE) \ + $(OBJ_STDC) + +###################################################### + +DOC_CORE= \ + core/bitmanip.html \ + core/exception.html \ + core/memory.html \ + core/runtime.html \ + core/thread.html + + +ALL_DOCS= + +###################################################### + +core.lib : $(LIB_TARGET) + +$(LIB_TARGET) : $(ALL_OBJS) + $(RM) $@ + $(LC) $@ $(ALL_OBJS) + +core.doc : $(ALL_DOCS) + echo Documentation generated. + +###################################################### + +### bitmanip + +core/bitmanip.o : core/bitmanip.d + $(DC) -c $(DFLAGS) bitmanip.d -of$@ + +### thread + +core/thread.o : core/thread.d + $(DC) -c $(DFLAGS) -d -Hf$*.di thread.d -of$@ + +###################################################### + +clean : + find . -name "*.di" | xargs $(RM) + $(RM) $(ALL_OBJS) + $(RM) $(ALL_DOCS) + find . -name "$(LIB_MASK)" | xargs $(RM) + +install : + $(MD) $(INC_DEST) + find . -name "*.di" -exec cp -f {} $(INC_DEST)/{} \; + $(MD) $(DOC_DEST) + find . -name "*.html" -exec cp -f {} $(DOC_DEST)/{} \; + $(MD) $(LIB_DEST) + find . -name "$(LIB_MASK)" -exec cp -f {} $(LIB_DEST)/{} \; diff --git a/src/core/stdc.c b/src/common/stdc/errno.c similarity index 86% rename from src/core/stdc.c rename to src/common/stdc/errno.c index 6e4ac64..10ca015 100644 --- a/src/core/stdc.c +++ b/src/common/stdc/errno.c @@ -8,13 +8,13 @@ #include -int _d_getErrno() +int getErrno() { return errno; } -int _d_setErrno( int val ) +int setErrno( int val ) { errno = val; return val; diff --git a/src/core/win32.mak b/src/common/win32.mak similarity index 76% rename from src/core/win32.mak rename to src/common/win32.mak index 3e80307..fefcb93 100644 --- a/src/core/win32.mak +++ b/src/common/win32.mak @@ -1,130 +1,130 @@ -# Makefile to build the D runtime library core components for Win32 -# Designed to work with DigitalMars make -# Targets: -# make -# Same as make all -# make lib -# Build the common library -# make doc -# Generate documentation -# make clean -# Delete unneeded files created by build process - -LIB_TARGET=druntime-core.lib -LIB_MASK=druntime-core*.lib - -CP=xcopy /y -RM=del /f -MD=mkdir - -ADD_CFLAGS= -ADD_DFLAGS= - -CFLAGS=-mn -6 -r $(ADD_CFLAGS) -#CFLAGS=-g -mn -6 -r $(ADD_CFLAGS) - -DFLAGS=-release -O -inline -w -nofloat $(ADD_DFLAGS) -#DFLAGS=-g -w -nofloat $(ADD_DFLAGS) - -TFLAGS=-O -inline -w -nofloat $(ADD_DFLAGS) -#TFLAGS=-g -w -nofloat $(ADD_DFLAGS) - -DOCFLAGS=-version=DDoc - -CC=dmc -LC=lib -DC=dmd - -INC_DEST=..\..\import -LIB_DEST=..\..\lib -DOC_DEST=..\..\doc - -.DEFAULT: .asm .c .cpp .d .html .obj - -.asm.obj: - $(CC) -c $< - -.c.obj: - $(CC) -c $(CFLAGS) $< -o$@ - -.cpp.obj: - $(CC) -c $(CFLAGS) $< -o$@ - -.d.obj: - $(DC) -c $(DFLAGS) -Hf$*.di $< -of$@ -# $(DC) -c $(DFLAGS) $< -of$@ - -.d.html: - $(DC) -c -o- $(DOCFLAGS) -Df$*.html $< - -targets : lib doc -all : lib doc -core : lib -lib : core.lib -doc : core.doc - -###################################################### - -OBJ_CORE= \ - bitmanip.obj \ - exception.obj \ - memory.obj \ - runtime.obj \ - thread.obj - -OBJ_STDC= \ - stdc.obj - -ALL_OBJS= \ - $(OBJ_CORE) \ - $(OBJ_STDC) - -###################################################### - -DOC_CORE= \ - bitmanip.html \ - exception.html \ - memory.html \ - runtime.html \ - thread.html - -ALL_DOCS= - -###################################################### - -core.lib : $(LIB_TARGET) - -$(LIB_TARGET) : $(ALL_OBJS) - $(RM) $@ - $(LC) -c -n $@ $(ALL_OBJS) - -core.doc : $(ALL_DOCS) - @echo Documentation generated. - -###################################################### - -### bitmanip - -bitmanip.obj : bitmanip.d - $(DC) -c $(DFLAGS) bitmanip.d -of$@ - -### thread - -thread.obj : thread.d - $(DC) -c $(DFLAGS) -d -Hf$*.di thread.d -of$@ - -###################################################### - -clean : - $(RM) /s .\*.di - $(RM) $(ALL_OBJS) - $(RM) $(ALL_DOCS) - $(RM) $(LIB_MASK) - -install : - $(MD) $(INC_DEST) - $(CP) /s *.di $(INC_DEST)\. - $(MD) $(DOC_DEST) - $(CP) /s *.html $(DOC_DEST)\. - $(MD) $(LIB_DEST) - $(CP) $(LIB_MASK) $(LIB_DEST)\. +# Makefile to build the D runtime library core components for Win32 +# Designed to work with DigitalMars make +# Targets: +# make +# Same as make all +# make lib +# Build the common library +# make doc +# Generate documentation +# make clean +# Delete unneeded files created by build process + +LIB_TARGET=druntime-core.lib +LIB_MASK=druntime-core*.lib + +CP=xcopy /y +RM=del /f +MD=mkdir + +ADD_CFLAGS= +ADD_DFLAGS= + +CFLAGS=-mn -6 -r $(ADD_CFLAGS) +#CFLAGS=-g -mn -6 -r $(ADD_CFLAGS) + +DFLAGS=-release -O -inline -w -nofloat $(ADD_DFLAGS) +#DFLAGS=-g -w -nofloat $(ADD_DFLAGS) + +TFLAGS=-O -inline -w -nofloat $(ADD_DFLAGS) +#TFLAGS=-g -w -nofloat $(ADD_DFLAGS) + +DOCFLAGS=-version=DDoc + +CC=dmc +LC=lib +DC=dmd + +INC_DEST=..\..\import +LIB_DEST=..\..\lib +DOC_DEST=..\..\doc + +.DEFAULT: .asm .c .cpp .d .html .obj + +.asm.obj: + $(CC) -c $< + +.c.obj: + $(CC) -c $(CFLAGS) $< -o$@ + +.cpp.obj: + $(CC) -c $(CFLAGS) $< -o$@ + +.d.obj: + $(DC) -c $(DFLAGS) -Hf$*.di $< -of$@ +# $(DC) -c $(DFLAGS) $< -of$@ + +.d.html: + $(DC) -c -o- $(DOCFLAGS) -Df$*.html $< + +targets : lib doc +all : lib doc +core : lib +lib : core.lib +doc : core.doc + +###################################################### + +OBJ_CORE= \ + core\bitmanip.obj \ + core\exception.obj \ + core\memory.obj \ + core\runtime.obj \ + core\thread.obj + +OBJ_STDC= \ + stdc\errno.obj + +ALL_OBJS= \ + $(OBJ_CORE) \ + $(OBJ_STDC) + +###################################################### + +DOC_CORE= \ + core\bitmanip.html \ + core\exception.html \ + core\memory.html \ + core\runtime.html \ + core\thread.html + +ALL_DOCS= + +###################################################### + +core.lib : $(LIB_TARGET) + +$(LIB_TARGET) : $(ALL_OBJS) + $(RM) $@ + $(LC) -c -n $@ $(ALL_OBJS) + +core.doc : $(ALL_DOCS) + @echo Documentation generated. + +###################################################### + +### bitmanip + +core\bitmanip.obj : core\bitmanip.d + $(DC) -c $(DFLAGS) core\bitmanip.d -of$@ + +### thread + +core\thread.obj : core\thread.d + $(DC) -c $(DFLAGS) -d -Hf$*.di core\thread.d -of$@ + +###################################################### + +clean : + $(RM) /s .\*.di + $(RM) $(ALL_OBJS) + $(RM) $(ALL_DOCS) + $(RM) $(LIB_MASK) + +install : + $(MD) $(INC_DEST)\. + $(CP) /s *.di $(INC_DEST)\. + $(MD) $(DOC_DEST) + $(CP) /s *.html $(DOC_DEST)\. + $(MD) $(LIB_DEST) + $(CP) $(LIB_MASK) $(LIB_DEST)\. diff --git a/src/compiler/dmd/cover.d b/src/compiler/dmd/cover.d index ca8381f..111f3bf 100644 --- a/src/compiler/dmd/cover.d +++ b/src/compiler/dmd/cover.d @@ -23,7 +23,7 @@ private import stdc.posix.fcntl; import stdc.posix.unistd; } - import bitmanip; + import core.bitmanip; import stdc.stdio; import util.utf; diff --git a/src/compiler/dmd/deh.c b/src/compiler/dmd/deh.c index 12c2fd9..40f921e 100644 --- a/src/compiler/dmd/deh.c +++ b/src/compiler/dmd/deh.c @@ -33,9 +33,11 @@ extern DWORD _except_list; #include "mars.h" -extern ClassInfo D9Exception7__ClassZ; +extern ClassInfo D6object9Throwable7__ClassZ; +#define _Class_9Throwable D6object9Throwable7__ClassZ; -#define _Class_9Exception D9Exception7__ClassZ +extern ClassInfo D6object5Error7__ClassZ; +#define _Class_5Error D6object5Error7__ClassZ typedef int (__pascal *fp_t)(); // function pointer in ambient memory model @@ -151,11 +153,12 @@ EXCEPTION_DISPOSITION _d_framehandler( ci = **(ClassInfo ***)(exception_record->ExceptionInformation[0]); } else - ci = &_Class_9Exception; + ci = &_Class_9Throwable; } if (_d_isbaseof(ci, pcb->type)) - { // Matched the catch type, so we've found the handler. + { + // Matched the catch type, so we've found the handler. int regebp; pti = _d_translate_se_to_d_exception(exception_record); @@ -229,9 +232,9 @@ void __stdcall _d_throw(Object *h) Object *_d_create_exception_object(ClassInfo *ci, char *msg) { - Exception *exc; + Throwable *exc; - exc = (Exception *)_d_newclass(ci); + exc = (Throwable *)_d_newclass(ci); // BUG: what if _d_newclass() throws an out of memory exception? if (msg) @@ -257,24 +260,24 @@ Object *_d_translate_se_to_d_exception(EXCEPTION_RECORD *exception_record) break; case STATUS_INTEGER_DIVIDE_BY_ZERO: - pti = _d_create_exception_object(&_Class_9Exception, "Integer Divide by Zero"); + pti = _d_create_exception_object(&_Class_5Error, "Integer Divide by Zero"); break; case STATUS_FLOAT_DIVIDE_BY_ZERO: - pti = _d_create_exception_object(&_Class_9Exception, "Float Divide by Zero"); + pti = _d_create_exception_object(&_Class_5Error, "Float Divide by Zero"); break; case STATUS_ACCESS_VIOLATION: - pti = _d_create_exception_object(&_Class_9Exception, "Access Violation"); + pti = _d_create_exception_object(&_Class_5Error, "Access Violation"); break; case STATUS_STACK_OVERFLOW: - pti = _d_create_exception_object(&_Class_9Exception, "Stack Overflow"); + pti = _d_create_exception_object(&_Class_5Error, "Stack Overflow"); break; // convert all other exception codes into a Win32Exception default: - pti = _d_create_exception_object(&_Class_9Exception, "Win32 Exception"); + pti = _d_create_exception_object(&_Class_5Error, "Win32 Exception"); break; } @@ -413,9 +416,11 @@ void _d_monitor_epilog(void *x, void *y, Object *h) #include "mars.h" -extern ClassInfo D9Exception7__ClassZ; +extern ClassInfo D6object9Throwable7__ClassZ; +#define _Class_9Throwable D6object9Throwable7__ClassZ; -#define _Class_9Exception D9Exception7__ClassZ +extern ClassInfo D6object5Error7__ClassZ; +#define _Class_5Error D6object5Error7__ClassZ typedef int (*fp_t)(); // function pointer in ambient memory model diff --git a/src/compiler/dmd/dmain2.d b/src/compiler/dmd/dmain2.d index 8c22052..14b6950 100644 --- a/src/compiler/dmd/dmain2.d +++ b/src/compiler/dmd/dmain2.d @@ -18,7 +18,7 @@ private import stdc.string; } -version( Windows ) +version(Windows) { extern (Windows) void* LocalFree(void*); extern (Windows) wchar_t* GetCommandLineW(); @@ -42,45 +42,48 @@ extern (C) void thread_joinAll(); * These functions must be defined for any D program linked * against this library. */ -extern (C) void onAssertError( string file, size_t line ); -extern (C) void onAssertErrorMsg( string file, size_t line, string msg ); -extern (C) void onArrayBoundsError( string file, size_t line ); -extern (C) void onSwitchError( string file, size_t line ); +extern (C) void onAssertError(string file, size_t line); +extern (C) void onAssertErrorMsg(string file, size_t line, string msg); +extern (C) void onArrayBoundsError(string file, size_t line); +extern (C) void onHiddenFuncError(Object o); +extern (C) void onSwitchError(string file, size_t line); extern (C) bool runModuleUnitTests(); // this function is called from the utf module -//extern (C) void onUnicodeError( string msg, size_t idx ); +//extern (C) void onUnicodeError(string msg, size_t idx); /*********************************** * These are internal callbacks for various language errors. */ -extern (C) void _d_assert( string file, uint line ) +extern (C) void _d_assert(string file, uint line) { - onAssertError( file, line ); + onAssertError(file, line); } -extern (C) static void _d_assert_msg( string msg, string file, uint line ) +extern (C) static void _d_assert_msg(string msg, string file, uint line) { - onAssertErrorMsg( file, line, msg ); + onAssertErrorMsg(file, line, msg); } -extern (C) void _d_array_bounds( string file, uint line ) +extern (C) void _d_array_bounds(string file, uint line) { - onArrayBoundsError( file, line ); + onArrayBoundsError(file, line); } -extern (C) void _d_switch_error( string file, uint line ) +extern (C) void _d_switch_error(string file, uint line) { - onSwitchError( file, line ); + onSwitchError(file, line); } -/+ extern (C) void _d_hidden_func() { - // TODO: Figure out what to do with this routine - // it's in exception.d for the moment + Object o; + asm + { + mov o, EAX; + } + onHiddenFuncError(o); } -+/ bool _d_isHalting = false; @@ -100,9 +103,9 @@ void _d_criticalInit() } } -alias void delegate( Exception ) ExceptionHandler; +alias void delegate(Throwable) ExceptionHandler; -extern (C) bool rt_init( ExceptionHandler dg = null ) +extern (C) bool rt_init(ExceptionHandler dg = null) { _d_criticalInit(); @@ -114,10 +117,10 @@ extern (C) bool rt_init( ExceptionHandler dg = null ) _moduleCtor(); return true; } - catch( Exception e ) + catch (Throwable e) { - if( dg ) - dg( e ); + if (dg) + dg(e); } catch { @@ -136,7 +139,7 @@ void _d_criticalTerm() } } -extern (C) bool rt_term( ExceptionHandler dg = null ) +extern (C) bool rt_term(ExceptionHandler dg = null) { try { @@ -146,10 +149,10 @@ extern (C) bool rt_term( ExceptionHandler dg = null ) gc_term(); return true; } - catch( Exception e ) + catch (Throwable e) { - if( dg ) - dg( e ); + if (dg) + dg(e); } catch { @@ -200,7 +203,7 @@ extern (C) int main(int argc, char **argv) for (size_t i = 0, p = 0; i < wargc; i++) { - int wlen = wcslen( wargs[i] ); + int wlen = wcslen(wargs[i]); int clen = WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, null, 0, null, 0); args[i] = cargp[p .. p+clen]; p += clen; assert(p <= cargl); @@ -234,19 +237,19 @@ extern (C) int main(int argc, char **argv) { dg(); } - catch (Exception e) + catch (Throwable e) { while (e) { if (e.file) { - // fprintf(stderr, "%.*s(%u): %.*s\n", e.file, e.line, e.msg); - console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.msg)("\n"); + // fprintf(stderr, "%.*s(%u): %.*s\n", e.file, e.line, e.msg); + console (e.classinfo.name)("@")(e.file)("(")(e.line)("): ")(e.msg)("\n"); } else { - // fprintf(stderr, "%.*s\n", e.toString()); - console (e.classinfo.name)(": ")(e.toString)("\n"); + // fprintf(stderr, "%.*s\n", e.toString()); + console (e.toString)("\n"); } if (e.info) { diff --git a/src/compiler/dmd/lifetime.d b/src/compiler/dmd/lifetime.d index e5ef60f..adb9f2a 100644 --- a/src/compiler/dmd/lifetime.d +++ b/src/compiler/dmd/lifetime.d @@ -66,7 +66,7 @@ private extern (C) size_t gc_sizeOf( void* p ); extern (C) BlkInfo gc_query( void* p ); - extern (C) void onFinalizeError( ClassInfo c, Exception e ); + extern (C) void onFinalizeError( ClassInfo c, Throwable e ); extern (C) void onOutOfMemoryError(); extern (C) void _d_monitordelete(Object h, bool det = true); @@ -529,7 +529,7 @@ extern (C) void rt_finalize(void* p, bool det = true) if ((cast(void**)p)[1]) // if monitor is not null _d_monitordelete(cast(Object)p, det); } - catch (Exception e) + catch (Throwable e) { onFinalizeError(**pc, e); } diff --git a/src/compiler/dmd/mars.h b/src/compiler/dmd/mars.h index 9990fff..f05d73f 100644 --- a/src/compiler/dmd/mars.h +++ b/src/compiler/dmd/mars.h @@ -60,7 +60,7 @@ typedef struct ClassInfo int flags; } ClassInfo; -typedef struct Exception +typedef struct Throwable { Object object; @@ -73,8 +73,8 @@ typedef struct Exception size_t line; struct Interface *info; - struct Exception *next; -} Exception; + struct Throwable *next; +} Throwable; typedef struct Array { diff --git a/src/compiler/dmd/object_.d b/src/compiler/dmd/object_.d index 8c5115f..8cdcd21 100644 --- a/src/compiler/dmd/object_.d +++ b/src/compiler/dmd/object_.d @@ -54,7 +54,7 @@ private //alias typeof(int.sizeof) size_t; //alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t; -version( X86_64 ) +version(X86_64) { alias ulong size_t; alias long ptrdiff_t; @@ -126,7 +126,7 @@ class Object void unlock(); } - /****** + /** * Create instance of class specified by classname. * The class must either have no constructors or have * a default constructor. @@ -216,6 +216,7 @@ class ClassInfo : Object } return o; } + /** * Search for all members with the name 'name'. * If name[] is null, return all members. @@ -246,7 +247,8 @@ struct OffsetTypeInfo class TypeInfo { override hash_t toHash() - { hash_t hash; + { + hash_t hash; foreach (char c; this.toString()) hash = hash * 9 + c; @@ -1048,32 +1050,31 @@ class MemberInfo_function : MemberInfo /////////////////////////////////////////////////////////////////////////////// -// Exception +// Throwable /////////////////////////////////////////////////////////////////////////////// -class Exception : Object +class Throwable : Object { interface TraceInfo { - int opApply( int delegate(inout char[]) ); + int opApply(int delegate(inout char[])); } string msg; string file; size_t line; TraceInfo info; - Exception next; - char[] buffer; + Throwable next; - this( string msg, Exception next = null ) + this(string msg, Throwable next = null) { this.msg = msg; this.next = next; this.info = traceContext(); } - this( string msg, string file, size_t line, Exception next = null ) + this(string msg, string file, size_t line, Throwable next = null) { this(msg, next); this.file = file; @@ -1083,40 +1084,34 @@ class Exception : Object override string toString() { - if (file.length == 0 && line == 0) - return msg; - if (buffer.length == 0) + char[10] tmp; + char[] buf; + + for (Throwable e = this; e !is null; e = e.next) { - // Write into buffer[] the following: "file(line): msg" - buffer.length = 4 + file.length + line.sizeof * 3 + msg.length; - auto i = file.length; - buffer[0 .. i] = file[]; - buffer[i] = '('; - i++; - - auto n = line; - auto j = i; - do - { - buffer[i] = cast(char)((n % 10) + '0'); - n /= 10; - i++; - } while (n); - buffer[j .. i].reverse; - buffer[i..i+3] = "): "[]; - i += 3; - - buffer[i .. i + msg.length] = msg[]; - i += msg.length; - - buffer = buffer[0 .. i]; - } - return cast(invariant)buffer; + if (e.file) + { + buf ~= e.classinfo.name ~ "@" ~ e.file ~ "(" ~ tmp.intToString(e.line) ~ "): " ~ e.msg; + } + else + { + buf ~= e.classinfo.name ~ ": " ~ e.msg; + } + if (e.info) + { + buf ~= "\n----------------"; + foreach (t; e.info) + buf ~= "\n" ~ t; + } + if (e.next) + buf ~= "\n"; + } + return cast(string) buf; } } -alias Exception.TraceInfo function( void* ptr = null ) TraceHandler; +alias Throwable.TraceInfo function(void* ptr = null) TraceHandler; private TraceHandler traceHandler = null; @@ -1126,14 +1121,14 @@ private TraceHandler traceHandler = null; * Params: * h = The new trace handler. Set to null to use the default handler. */ -extern (C) void rt_setTraceHandler( TraceHandler h ) +extern (C) void rt_setTraceHandler(TraceHandler h) { traceHandler = h; } /** - * This function will be called when an Exception is constructed. The + * This function will be called when an exception is constructed. The * user-supplied trace handler will be called if one has been supplied, * otherwise no trace will be generated. * @@ -1146,11 +1141,39 @@ extern (C) void rt_setTraceHandler( TraceHandler h ) * An object describing the current calling context or null if no handler is * supplied. */ -Exception.TraceInfo traceContext( void* ptr = null ) +Throwable.TraceInfo traceContext(void* ptr = null) { - if( traceHandler is null ) + if (traceHandler is null) return null; - return traceHandler( ptr ); + return traceHandler(ptr); +} + + +class Exception : Throwable +{ + this(string msg, Throwable next = null) + { + super(msg, next); + } + + this(string msg, string file, size_t line, Throwable next = null) + { + super(msg, file, line, next); + } +} + + +class Error : Throwable +{ + this(string msg, Throwable next = null) + { + super(msg, next); + } + + this(string msg, string file, size_t line, Throwable next = null) + { + super(msg, file, line, next); + } } @@ -1184,14 +1207,14 @@ class ModuleInfo void function() ictor; // module static constructor (order independent) - static int opApply( int delegate(inout ModuleInfo) dg ) + static int opApply(int delegate(inout ModuleInfo) dg) { int ret = 0; - foreach( m; _moduleinfo_array ) + foreach (m; _moduleinfo_array) { - ret = dg( m ); - if( ret ) + ret = dg(m); + if (ret) break; } return ret; @@ -1289,7 +1312,7 @@ void _moduleCtor2(ModuleInfo[] mi, int skip) if (m.flags & MIctorstart) { if (skip || m.flags & MIstandalone) continue; - throw new Exception( "Cyclic dependency in module " ~ m.name ); + throw new Exception("Cyclic dependency in module " ~ m.name); } m.flags |= MIctorstart; diff --git a/src/dmd-posix.mak b/src/dmd-posix.mak index dce94e2..6b567c8 100644 --- a/src/dmd-posix.mak +++ b/src/dmd-posix.mak @@ -11,11 +11,12 @@ # Delete unneeded files created by build process LIB_TARGET=libdruntime-dmd.a -LIB_MASK=libdruntime-dmd*.a +DUP_TARGET=libdruntime.a +LIB_MASK=libdruntime*.a -DIR_CC=../src/core -DIR_RT=../src/compiler/dmd -DIR_GC=../src/gc/basic +DIR_CC=common +DIR_RT=compiler/dmd +DIR_GC=gc/basic CP=cp -f RM=rm -f @@ -47,10 +48,12 @@ lib : $(ALL_OBJS) make -C $(DIR_CC) -fposix.mak lib DC=$(DC) ADD_DFLAGS="$(ADD_DFLAGS)" ADD_CFLAGS="$(ADD_CFLAGS)" make -C $(DIR_RT) -fposix.mak lib DC=$(DC) ADD_DFLAGS="$(ADD_DFLAGS)" ADD_CFLAGS="$(ADD_CFLAGS)" make -C $(DIR_GC) -fposix.mak lib DC=$(DC) ADD_DFLAGS="$(ADD_DFLAGS)" ADD_CFLAGS="$(ADD_CFLAGS)" - find . -name "libphobos*.a" | xargs $(RM) + $(RM) $(LIB_TARGET) $(LC) $(LIB_TARGET) `find $(DIR_CC) -name "*.o" | xargs echo` $(LC) $(LIB_TARGET) `find $(DIR_RT) -name "*.o" | xargs echo` $(LC) $(LIB_TARGET) `find $(DIR_GC) -name "*.o" | xargs echo` + $(RM) $(DUP_TARGET) + $(CP) $(LIB_TARGET) $(DUP_TARGET) doc : $(ALL_DOCS) make -C $(DIR_CC) -fposix.mak doc DC=$(DC) diff --git a/src/dmd-win32.mak b/src/dmd-win32.mak index 50fe360..d7c83b1 100644 --- a/src/dmd-win32.mak +++ b/src/dmd-win32.mak @@ -10,10 +10,11 @@ # make clean # Delete unneeded files created by build process -LIB_TARGET=druntime.lib -LIB_MASK=druntime.lib +LIB_TARGET=druntime-dmd.lib +DUP_TARGET=druntime.lib +LIB_MASK=druntime*.lib -DIR_CC=core +DIR_CC=common DIR_RT=compiler\dmd DIR_GC=gc\basic @@ -59,6 +60,8 @@ lib : $(ALL_OBJS) cd ..\.. $(RM) $(LIB_TARGET) $(LC) -c -n $(LIB_TARGET) $(LIB_CC) $(LIB_RT) $(LIB_GC) + $(RM) $(DUP_TARGET) + copy $(LIB_TARGET) $(DUP_TARGET) doc : $(ALL_DOCS) cd $(DIR_CC) diff --git a/src/dmd.conf b/src/dmd.conf index 181b8a9..67d282a 100644 --- a/src/dmd.conf +++ b/src/dmd.conf @@ -1,2 +1,2 @@ [Environment] -DFLAGS=-version=Posix "-I%HOME%/core" "-I%HOME%/../import" +DFLAGS=-version=Posix "-I%HOME%/common" "-I%HOME%/../import" diff --git a/src/gc/basic/gc.d b/src/gc/basic/gc.d index b078959..4dd2d9f 100644 --- a/src/gc/basic/gc.d +++ b/src/gc/basic/gc.d @@ -24,6 +24,8 @@ * Authors: Walter Bright, Sean Kelly */ +module gc.gc; + private import gcx; private import gcstats; private import stdc.stdlib; diff --git a/src/gc/basic/gcalloc.d b/src/gc/basic/gcalloc.d index 5c47f69..62d5d47 100644 --- a/src/gc/basic/gcalloc.d +++ b/src/gc/basic/gcalloc.d @@ -24,6 +24,8 @@ * Authors: Walter Bright, David Friedman, Sean Kelly */ +module gc.gcalloc; + version (Windows) { diff --git a/src/gc/basic/gcbits.d b/src/gc/basic/gcbits.d index a3c3e96..b6cc1fb 100644 --- a/src/gc/basic/gcbits.d +++ b/src/gc/basic/gcbits.d @@ -24,10 +24,12 @@ * Authors: Walter Bright, David Friedman, Sean Kelly */ +module gc.gcbits; + private { - import bitmanip; + import core.bitmanip; import stdc.string; import stdc.stdlib; extern (C) void onOutOfMemoryError(); diff --git a/src/gc/basic/gcstats.d b/src/gc/basic/gcstats.d index 18f21ab..641b3e0 100644 --- a/src/gc/basic/gcstats.d +++ b/src/gc/basic/gcstats.d @@ -24,6 +24,8 @@ * Authors: Walter Bright, Sean Kelly */ +module gc.gcstats; + /** * diff --git a/src/gc/basic/gcx.d b/src/gc/basic/gcx.d index 15296ac..5145839 100644 --- a/src/gc/basic/gcx.d +++ b/src/gc/basic/gcx.d @@ -24,6 +24,8 @@ * Authors: Walter Bright, David Friedman, Sean Kelly */ +module gc.gcx; + // D Programming Language Garbage Collector implementation /************** Debugging ***************************/ diff --git a/src/gc/stub/gc.d b/src/gc/stub/gc.d index 29e2686..7232588 100644 --- a/src/gc/stub/gc.d +++ b/src/gc/stub/gc.d @@ -18,6 +18,8 @@ * Authors: Sean Kelly */ +module gc.gc; + private import stdc.stdlib; private diff --git a/src/sc.ini b/src/sc.ini index 0ba028c..534dc28 100644 --- a/src/sc.ini +++ b/src/sc.ini @@ -3,5 +3,5 @@ version=7.51 Build 020 [Environment] LIB=%@P%\..\lib;\dm\lib -DFLAGS="-I%HOME%\core" "-I%HOME%\..\import" +DFLAGS="-I%HOME%\common" "-I%HOME%\..\import" LINKCMD=%@P%\..\..\dm\bin\link.exe