Mercurial > projects > ldc
changeset 1582:d8e558087001
Fixed a segfault in ldc2 when compiling synchronized{} blocks.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Sat, 19 Sep 2009 13:05:10 +0100 |
parents | f4421c81398f |
children | 593f99fddd2f |
files | dmd2/statement.c gen/tollvm.cpp |
diffstat | 2 files changed, 13 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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; }