From: sean Date: Tue, 30 Sep 2008 19:50:33 +0000 (+0000) Subject: Added "invariant" module to fix link issues because DMD generates references to an... X-Git-Url: https://git.llucax.com/software/druntime.git/commitdiff_plain/fd5d6cdebfefde3785c583794885106c42ba705f Added "invariant" module to fix link issues because DMD generates references to an extern (D) function it contains. Hopefully, this is only temporary and the routine will be made extern (C), thus allowing the use of "invariant_" instead. The rationale being that it's not a good thing to have modules with the same name as reserved words. git-svn-id: http://svn.dsource.org/projects/druntime/trunk@12 4a9d5153-6564-4b3f-b5e1-7e8e9dac548f --- diff --git a/src/compiler/dmd/invariant.d b/src/compiler/dmd/invariant.d new file mode 100644 index 0000000..aad22db --- /dev/null +++ b/src/compiler/dmd/invariant.d @@ -0,0 +1,24 @@ +/* + * Placed into the Public Domain + * written by Walter Bright + * www.digitalmars.com + */ + +void _d_invariant(Object o) +{ ClassInfo c; + + //printf("__d_invariant(%p)\n", o); + + // BUG: needs to be filename/line of caller, not library routine + assert(o !is null); // just do null check, not invariant check + + c = o.classinfo; + do + { + if (c.classInvariant) + { + (*c.classInvariant)(o); + } + c = c.base; + } while (c); +} diff --git a/src/compiler/dmd/invariant_.d b/src/compiler/dmd/invariant_.d index f5a3c50..77b12f3 100644 --- a/src/compiler/dmd/invariant_.d +++ b/src/compiler/dmd/invariant_.d @@ -5,7 +5,7 @@ */ module rt.invariant_; -void _d_invariant(Object o) +extern (C) void _d_invariant(Object o) { ClassInfo c; //printf("__d_invariant(%p)\n", o); diff --git a/src/compiler/dmd/posix.mak b/src/compiler/dmd/posix.mak index 51762be..7d3f660 100644 --- a/src/compiler/dmd/posix.mak +++ b/src/compiler/dmd/posix.mak @@ -83,6 +83,7 @@ OBJ_BASE= \ critical.o \ deh2.o \ dmain2.o \ + invariant.o \ invariant_.o \ lifetime.o \ llmath.o \ diff --git a/src/compiler/dmd/win32.mak b/src/compiler/dmd/win32.mak index 0314474..0c2ea1e 100644 --- a/src/compiler/dmd/win32.mak +++ b/src/compiler/dmd/win32.mak @@ -78,6 +78,7 @@ OBJ_BASE= \ critical.obj \ deh.obj \ dmain2.obj \ + invariant.obj \ invariant_.obj \ lifetime.obj \ memory.obj \