- eliminate dependency on linking order for autosegs registration

This commit is contained in:
alexey.lysiuk 2020-11-13 11:03:16 +02:00
commit 18b5928f49
14 changed files with 218 additions and 235 deletions

View file

@ -194,17 +194,14 @@ void InitImports()
AFTable.Clear();
if (AFTable.Size() == 0)
{
FAutoSegIterator probe(ARegHead, ARegTail);
while (*++probe != NULL)
AutoSegs::ActionFunctons.ForEach([](AFuncDesc *afunc)
{
AFuncDesc *afunc = (AFuncDesc *)*probe;
assert(afunc->VMPointer != NULL);
*(afunc->VMPointer) = new VMNativeFunction(afunc->Function, afunc->FuncName);
(*(afunc->VMPointer))->PrintableName.Format("%s.%s [Native]", afunc->ClassName+1, afunc->FuncName);
(*(afunc->VMPointer))->DirectNativeCall = afunc->DirectNative;
AFTable.Push(*afunc);
}
});
AFTable.ShrinkToFit();
qsort(&AFTable[0], AFTable.Size(), sizeof(AFTable[0]), funccmp);
}
@ -212,13 +209,10 @@ void InitImports()
FieldTable.Clear();
if (FieldTable.Size() == 0)
{
FAutoSegIterator probe(FRegHead, FRegTail);
while (*++probe != NULL)
AutoSegs::ClassFields.ForEach([](FieldDesc *afield)
{
FieldDesc *afield = (FieldDesc *)*probe;
FieldTable.Push(*afield);
}
});
FieldTable.ShrinkToFit();
qsort(&FieldTable[0], FieldTable.Size(), sizeof(FieldTable[0]), fieldcmp);
}

View file

@ -620,11 +620,11 @@ struct AFuncDesc
};
#if defined(_MSC_VER)
#pragma section(".areg$u",read)
#pragma section(".freg$u",read)
#pragma section(SECTION_AREG,read)
#pragma section(SECTION_FREG,read)
#define MSVC_ASEG __declspec(allocate(".areg$u"))
#define MSVC_FSEG __declspec(allocate(".freg$u"))
#define MSVC_ASEG __declspec(allocate(SECTION_AREG))
#define MSVC_FSEG __declspec(allocate(SECTION_FREG))
#define GCC_ASEG
#define GCC_FSEG
#else