Permalink
Browse files

add thread.di

 - Strip all implementations and all private stuff
   from thread.d.

 - Without an indirection we need to know the class
   sizes in the header file. As the modules can't import
   each other this has to be kept in sync manually.
  • Loading branch information...
1 parent a39f1b4 commit f047208660eef6361285aab8ceec071f0fb8d709 @MartinNowak MartinNowak committed Jan 22, 2012
Showing with 1,071 additions and 2 deletions.
  1. +7 −0 posix.mak
  2. +63 −0 src/core/thread.d
  3. +998 −0 src/core/thread.di
  4. +3 −2 win32.mak
View
@@ -61,6 +61,7 @@ MANIFEST= \
src/core/runtime.d \
src/core/simd.d \
src/core/thread.d \
+ src/core/thread.di \
src/core/threadasm.S \
src/core/time.d \
src/core/vararg.d \
@@ -501,6 +502,9 @@ doc: $(DOCS)
$(DOCDIR)/object.html : src/object_.d
$(DMD) $(DDOCFLAGS) -Df$@ $(DOCFMT) $<
+$(DOCDIR)/core_%.html : src/core/%.di
+ $(DMD) $(DDOCFLAGS) -Df$@ $(DOCFMT) $<
+
$(DOCDIR)/core_%.html : src/core/%.d
$(DMD) $(DDOCFLAGS) -Df$@ $(DOCFMT) $<
@@ -514,6 +518,9 @@ import: $(IMPORTS)
$(IMPDIR)/core/sys/windows/%.di : src/core/sys/windows/%.d
$(DMD) -m32 -c -d -o- -Isrc -Iimport -Hf$@ $<
+$(IMPDIR)/core/%.di : src/core/%.di
+ $(DMD) -m$(MODEL) -c -d -o- -Isrc -Iimport -Hf$@ $<
+
$(IMPDIR)/core/%.di : src/core/%.d
$(DMD) -m$(MODEL) -c -d -o- -Isrc -Iimport -Hf$@ $<
View
@@ -1823,6 +1823,31 @@ private:
}
}
+// These must be kept in sync with core/thread.di
+version (D_LP64)
+{
+ version (Windows)
+ static assert(__traits(classInstanceSize, Thread) == 304);
+ else version (OSX)
+ static assert(__traits(classInstanceSize, Thread) == 312);
+ else version (Posix)
+ static assert(__traits(classInstanceSize, Thread) == 176);
+ else
+ static assert(0, "Platform not supported.");
+}
+else
+{
+ static assert((void*).sizeof == 4); // 32-bit
+
+ version (Windows)
+ static assert(__traits(classInstanceSize, Thread) == 124);
+ else version (OSX)
+ static assert(__traits(classInstanceSize, Thread) == 124);
+ else version (Posix)
+ static assert(__traits(classInstanceSize, Thread) == 88);
+ else
+ static assert(0, "Platform not supported.");
+}
///////////////////////////////////////////////////////////////////////////////
// GC Support Routines
@@ -2847,6 +2872,17 @@ private:
Thread[Thread] m_all;
}
+// These must be kept in sync with core/thread.di
+version (D_LP64)
+{
+ static assert(__traits(classInstanceSize, ThreadGroup) == 24);
+}
+else
+{
+ static assert((void*).sizeof == 4); // 32-bit
+ static assert(__traits(classInstanceSize, ThreadGroup) == 12);
+}
+
///////////////////////////////////////////////////////////////////////////////
// Fiber Platform Detection and Memory Allocation
@@ -4005,6 +4041,33 @@ private:
}
}
+// These must be kept in sync with core/thread.di
+version (D_LP64)
+{
+ version (Windows)
+ static assert(__traits(classInstanceSize, Fiber) == 88);
+ else version (OSX)
+ static assert(__traits(classInstanceSize, Fiber) == 88);
+ else version (Posix)
+ static assert(__traits(classInstanceSize, Fiber) == 88);
+ else
+ static assert(0, "Platform not supported.");
+}
+else
+{
+ static assert((void*).sizeof == 4); // 32-bit
+
+ version (Windows)
+ static assert(__traits(classInstanceSize, Fiber) == 44);
+ else version (OSX)
+ static assert(__traits(classInstanceSize, Fiber) == 44);
+ else version (Posix)
+ static assert(__traits(classInstanceSize, Fiber) == 44);
+ else
+ static assert(0, "Platform not supported.");
+}
+
+
version( unittest )
{
import core.atomic;
Oops, something went wrong.

0 comments on commit f047208

Please sign in to comment.