# HG changeset patch # User Robert Clipsham # Date 1253361910 -3600 # Node ID d8e55808700166e7164d1362e55ef86223089c94 # Parent f4421c81398f42cfc69e6e36ac9bdb0db0d49af1 Fixed a segfault in ldc2 when compiling synchronized{} blocks. diff -r f4421c81398f -r d8e558087001 dmd2/statement.c --- a/dmd2/statement.c Sat Sep 19 00:44:35 2009 +0100 +++ b/dmd2/statement.c Sat Sep 19 13:05:10 2009 +0100 @@ -30,7 +30,16 @@ #include "attrib.h" #if IN_LLVM -#include "gen/tollvm.h" +// sizes based on those from tollvm.cpp:DtoMutexType() +int os_critsecsize() +{ + if (global.params.os == OSWindows) + return 68; + else if (global.params.os == OSFreeBSD) + return sizeof(size_t); + else + return sizeof(pthread_mutex_t); +} #elif IN_DMD extern int os_critsecsize(); #endif @@ -3869,7 +3878,7 @@ #if IN_LLVM FuncDeclaration *fdexit = FuncDeclaration::genCfunc(args, Type::tvoid, Id::monitorexit); #else - FuncDeclaration *fdexit = FuncDeclaration::genCfunc(args, Type::tvoid, Id::monitorexit); + FuncDeclaration *fdexit = FuncDeclaration::genCfunc(Type::tvoid, Id::monitorexit); #endif e = new CallExp(loc, new VarExp(loc, fdexit), new VarExp(loc, tmp)); e->type = Type::tvoid; // do not run semantic on e @@ -3889,11 +3898,7 @@ * try { body } finally { _d_criticalexit(critsec.ptr); } */ Identifier *id = Lexer::uniqueId("__critsec"); -#if IN_LLVM - Type *t = new TypeSArray(Type::tint8, new IntegerExp(PTRSIZE + getTypePaddedSize(DtoMutexType()))); -#elif IN_DMD Type *t = new TypeSArray(Type::tint8, new IntegerExp(PTRSIZE + os_critsecsize())); -#endif VarDeclaration *tmp = new VarDeclaration(loc, t, id, NULL); tmp->storage_class |= STCgshared | STCstatic; diff -r f4421c81398f -r d8e558087001 gen/tollvm.cpp --- a/gen/tollvm.cpp Sat Sep 19 00:44:35 2009 +0100 +++ b/gen/tollvm.cpp Sat Sep 19 13:05:10 2009 +0100 @@ -874,11 +874,8 @@ opaque->refineAbstractTypeTo(pa.get()); pmutex = isaStruct(pa.get()); - if (gIR->module != NULL) - { - gIR->mutexType = pmutex; - gIR->module->addTypeName("D_CRITICAL_SECTION", pmutex); - } + gIR->mutexType = pmutex; + gIR->module->addTypeName("D_CRITICAL_SECTION", pmutex); return pmutex; }