mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01: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()
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
// TODO Check size
|
||||
return 68;
|
||||
// Return sizeof(RTL_CRITICAL_SECTION)
|
||||
return global.params.is64bit ? 40 : 24;
|
||||
#else
|
||||
if (global.params.os == OSWindows)
|
||||
return 68;
|
||||
return global.params.is64bit ? 40 : 24;
|
||||
else if (global.params.os == OSFreeBSD)
|
||||
return sizeof(size_t);
|
||||
else
|
||||
|
||||
@@ -41,11 +41,11 @@
|
||||
int os_critsecsize()
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
// TODO Check size
|
||||
return 68;
|
||||
// Return sizeof(RTL_CRITICAL_SECTION)
|
||||
return global.params.is64bit ? 40 : 24;
|
||||
#else
|
||||
if (global.params.os == OSWindows)
|
||||
return 68;
|
||||
return global.params.is64bit ? 40 : 24;
|
||||
else if (global.params.os == OSFreeBSD)
|
||||
return sizeof(size_t);
|
||||
else
|
||||
|
||||
@@ -917,12 +917,35 @@ LLStructType* DtoMutexType()
|
||||
if (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)
|
||||
{
|
||||
// CRITICAL_SECTION.sizeof == 68
|
||||
std::vector<LLType*> types(17, LLType::getInt32Ty(gIR->context()));
|
||||
return LLStructType::get(gIR->context(), types);
|
||||
llvm::Type *VoidPtrTy = llvm::Type::getInt8PtrTy(gIR->context());
|
||||
llvm::Type *Int32Ty = llvm::Type::getInt32Ty(gIR->context());
|
||||
|
||||
// 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
|
||||
@@ -952,6 +975,8 @@ LLStructType* DtoMutexType()
|
||||
types.push_back(getPtrToType(mutex));
|
||||
types.push_back(pmutex);
|
||||
mutex->setBody(types);
|
||||
|
||||
// Cache type
|
||||
gIR->mutexType = mutex;
|
||||
|
||||
return pmutex;
|
||||
|
||||
Reference in New Issue
Block a user