Skip to content

Commit

Permalink
use pointer to reference InitializeRuntime method (dotnet#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonerdo committed Nov 11, 2017
1 parent 6575a65 commit 9d7df3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/Native/Bootstrap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ int main(int argc, char* argv[])
return retval;
}

extern "C" int InitializeRuntime()
extern "C" int (*InitializeRuntimePtr)();
int InitializeRuntime()
{
if (RUNTIME_INITIALIZED)
return 0;
Expand Down Expand Up @@ -394,3 +395,9 @@ extern "C" int InitializeRuntime()
return 0;
#endif // CORERT_DLL
}

__attribute__ ((__constructor__))
void Init()
{
InitializeRuntimePtr = &InitializeRuntime;
}
6 changes: 3 additions & 3 deletions src/Native/Runtime/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,13 +1115,13 @@ FORCEINLINE bool Thread::InlineTryFastReversePInvoke(ReversePInvokeFrame * pFram
return true;
}

extern "C" int InitializeRuntime();

EXTERN_C int (*InitializeRuntimePtr)() = NULL;
void Thread::ReversePInvokeAttachOrTrapThread(ReversePInvokeFrame * pFrame)
{
if (!IsStateSet(TSF_Attached))
{
InitializeRuntime();
if (*InitializeRuntimePtr != NULL)
(*InitializeRuntimePtr)();
ThreadStore::AttachCurrentThread();
}

Expand Down

0 comments on commit 9d7df3d

Please sign in to comment.