Skip to content

Commit

Permalink
Merge pull request #107 from dawgfoto/RefactorModuleInfo
Browse files Browse the repository at this point in the history
Refactor module info - Nice work!
  • Loading branch information
complexmath committed Dec 19, 2011
2 parents 09cde86 + e345258 commit 3159f6f
Show file tree
Hide file tree
Showing 8 changed files with 637 additions and 495 deletions.
6 changes: 0 additions & 6 deletions import/object.di
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,6 @@ struct ModuleInfo
static int opApply(scope int delegate(ref ModuleInfo*) dg);
}

ModuleInfo*[] _moduleinfo_tlsdtors;
uint _moduleinfo_tlsdtors_i;

extern (C) void _moduleTlsCtor();
extern (C) void _moduleTlsDtor();

class Throwable : Object
{
interface TraceInfo
Expand Down
2 changes: 2 additions & 0 deletions posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ MANIFEST= \
src/rt/memory.d \
src/rt/memory_osx.d \
src/rt/memset.d \
src/rt/minfo.d \
src/rt/minit.asm \
src/rt/monitor_.d \
src/rt/obj.d \
Expand Down Expand Up @@ -313,6 +314,7 @@ SRC_D_MODULES = \
rt/memory \
rt/memory_osx \
rt/memset \
rt/minfo \
rt/monitor_ \
rt/obj \
rt/qsort \
Expand Down
10 changes: 8 additions & 2 deletions src/core/sys/windows/dll.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ version( Windows )
extern __gshared void* _tls_callbacks_a;
}

extern (C) // rt.minfo
{
void rt_moduleTlsCtor();
void rt_moduleTlsDtor();
}

private:
struct dll_aux
{
Expand Down Expand Up @@ -424,7 +430,7 @@ public:
if( attach_thread )
thread_attachThis();
if( initTls && !tlsCtorRun ) // avoid duplicate calls
_moduleTlsCtor();
rt_moduleTlsCtor();
}
return true;
}
Expand All @@ -438,7 +444,7 @@ public:
if( thread_findByAddr( GetCurrentThreadId() ) )
{
if( exitTls && tlsCtorRun ) // avoid dtors to be run twice
_moduleTlsDtor();
rt_moduleTlsDtor();
if( detach_thread )
thread_detachThis();
}
Expand Down
14 changes: 10 additions & 4 deletions src/core/sys/windows/threadaux.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ version( Windows )

extern (C) extern __gshared int _tls_index;

extern (C) // rt.minfo
{
void rt_moduleTlsCtor();
void rt_moduleTlsDtor();
}

private:
///////////////////////////////////////////////////////////////////
struct thread_aux
Expand Down Expand Up @@ -246,17 +252,17 @@ public:
}

///////////////////////////////////////////////////////////////////
// run _moduleTlsCtor in the context of the given thread
// run rt_moduleTlsCtor in the context of the given thread
void thread_moduleTlsCtor( uint id )
{
thread_aux.impersonate_thread(id, &_moduleTlsCtor);
thread_aux.impersonate_thread(id, &rt_moduleTlsCtor);
}

///////////////////////////////////////////////////////////////////
// run _moduleTlsDtor in the context of the given thread
// run rt_moduleTlsDtor in the context of the given thread
void thread_moduleTlsDtor( uint id )
{
thread_aux.impersonate_thread(id, &_moduleTlsDtor);
thread_aux.impersonate_thread(id, &rt_moduleTlsDtor);
}
}

Loading

0 comments on commit 3159f6f

Please sign in to comment.