mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-08-02 04:20:05 +02:00
Fix size returned by os_critsecsize() and construct type for D_CRITIAL_SECTION on Windows.
This commit is contained in:
@@ -44,11 +44,11 @@
|
|||||||
int os_critsecsize()
|
int os_critsecsize()
|
||||||
{
|
{
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
// TODO Check size
|
// Return sizeof(RTL_CRITICAL_SECTION)
|
||||||
return 68;
|
return global.params.is64bit ? 40 : 24;
|
||||||
#else
|
#else
|
||||||
if (global.params.os == OSWindows)
|
if (global.params.os == OSWindows)
|
||||||
return 68;
|
return global.params.is64bit ? 40 : 24;
|
||||||
else if (global.params.os == OSFreeBSD)
|
else if (global.params.os == OSFreeBSD)
|
||||||
return sizeof(size_t);
|
return sizeof(size_t);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -41,11 +41,11 @@
|
|||||||
int os_critsecsize()
|
int os_critsecsize()
|
||||||
{
|
{
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
// TODO Check size
|
// Return sizeof(RTL_CRITICAL_SECTION)
|
||||||
return 68;
|
return global.params.is64bit ? 40 : 24;
|
||||||
#else
|
#else
|
||||||
if (global.params.os == OSWindows)
|
if (global.params.os == OSWindows)
|
||||||
return 68;
|
return global.params.is64bit ? 40 : 24;
|
||||||
else if (global.params.os == OSFreeBSD)
|
else if (global.params.os == OSFreeBSD)
|
||||||
return sizeof(size_t);
|
return sizeof(size_t);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -917,12 +917,35 @@ LLStructType* DtoMutexType()
|
|||||||
if (gIR->mutexType)
|
if (gIR->mutexType)
|
||||||
return gIR->mutexType;
|
return gIR->mutexType;
|
||||||
|
|
||||||
// win32
|
// The structures defined here must be the same as in druntime/src/rt/critical.c
|
||||||
|
|
||||||
|
// Windows
|
||||||
if (global.params.os == OSWindows)
|
if (global.params.os == OSWindows)
|
||||||
{
|
{
|
||||||
// CRITICAL_SECTION.sizeof == 68
|
llvm::Type *VoidPtrTy = llvm::Type::getInt8PtrTy(gIR->context());
|
||||||
std::vector<LLType*> types(17, LLType::getInt32Ty(gIR->context()));
|
llvm::Type *Int32Ty = llvm::Type::getInt32Ty(gIR->context());
|
||||||
return LLStructType::get(gIR->context(), types);
|
|
||||||
|
// Build RTL_CRITICAL_SECTION; size is 24 (32bit) or 40 (64bit)
|
||||||
|
std::vector<LLType*> rtl_types;
|
||||||
|
rtl_types.push_back(VoidPtrTy); // Pointer to DebugInfo
|
||||||
|
rtl_types.push_back(Int32Ty); // LockCount
|
||||||
|
rtl_types.push_back(Int32Ty); // RecursionCount
|
||||||
|
rtl_types.push_back(VoidPtrTy); // Handle of OwningThread
|
||||||
|
rtl_types.push_back(VoidPtrTy); // Handle of LockSemaphore
|
||||||
|
rtl_types.push_back(VoidPtrTy); // SpinCount
|
||||||
|
LLStructType* rtl = LLStructType::create(gIR->context(), rtl_types, "RTL_CRITICAL_SECTION");
|
||||||
|
|
||||||
|
// Build D_CRITICAL_SECTION; size is 28 (32bit) or 48 (64bit)
|
||||||
|
LLStructType* mutex = LLStructType::create(gIR->context(), "D_CRITICAL_SECTION");
|
||||||
|
std::vector<LLType*> types;
|
||||||
|
types.push_back(getPtrToType(mutex));
|
||||||
|
types.push_back(rtl);
|
||||||
|
mutex->setBody(types);
|
||||||
|
|
||||||
|
// Cache type
|
||||||
|
gIR->mutexType = mutex;
|
||||||
|
|
||||||
|
return mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FreeBSD
|
// FreeBSD
|
||||||
@@ -952,6 +975,8 @@ LLStructType* DtoMutexType()
|
|||||||
types.push_back(getPtrToType(mutex));
|
types.push_back(getPtrToType(mutex));
|
||||||
types.push_back(pmutex);
|
types.push_back(pmutex);
|
||||||
mutex->setBody(types);
|
mutex->setBody(types);
|
||||||
|
|
||||||
|
// Cache type
|
||||||
gIR->mutexType = mutex;
|
gIR->mutexType = mutex;
|
||||||
|
|
||||||
return pmutex;
|
return pmutex;
|
||||||
|
|||||||
Reference in New Issue
Block a user