From a0dae1a2756c0f9a84c3a258f3a4a05e63afc1c6 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Wed, 1 Oct 2008 17:28:07 +0200 Subject: Support %FLET on the GNU runtime and pre-10.5 versions of Mac OS X. --- MLKLLVMCompiler.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'MLKLLVMCompiler.mm') diff --git a/MLKLLVMCompiler.mm b/MLKLLVMCompiler.mm index 51ac0d3..5428927 100644 --- a/MLKLLVMCompiler.mm +++ b/MLKLLVMCompiler.mm @@ -56,7 +56,10 @@ #include #include +#ifdef MACOSX #include +#include +#endif using namespace llvm; using namespace std; @@ -561,9 +564,13 @@ static Constant // the GEP offset in terms of bytes. Value *closure = builder.CreateBitCast ([_compiler insertMethodCall:@"value" onObject:binding], VoidPointerTy); - //offsetof (MLKCompiledClosure, _code); - ptrdiff_t code_offset = ivar_getOffset (class_getInstanceVariable ([MLKCompiledClosure class], "_code")); - ptrdiff_t data_offset = ivar_getOffset (class_getInstanceVariable ([MLKCompiledClosure class], "_data")); +#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 + ptrdiff_t code_offset = ivar_getOffset (class_getInstanceVariable ([MLKCompiledClosure class], "m_code")); + ptrdiff_t data_offset = ivar_getOffset (class_getInstanceVariable ([MLKCompiledClosure class], "m_data")); +#else + ptrdiff_t code_offset = offsetof (MLKCompiledClosure, m_code); + ptrdiff_t data_offset = offsetof (MLKCompiledClosure, m_data); +#endif Constant *code_offset_value = ConstantInt::get (Type::Int32Ty, code_offset, false); Constant *data_offset_value = ConstantInt::get (Type::Int32Ty, data_offset, false); Value *codeptr = builder.CreateGEP (closure, code_offset_value); -- cgit v1.2.3