Merge origin/master into newabi (using imerge)

main
David Chisnall 8 years ago
commit a54272c1ab

@ -1,9 +1,13 @@
cmake_minimum_required(VERSION 2.8)
project(libobjc)
enable_language(ASM)
macro(install_symlink filepath sympath)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${filepath} ${sympath})")
install(CODE "message(\"-- Symlinking: ${sympath} -> ${filepath}\")")
endmacro(install_symlink)
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -fno-inline ${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "-O3 ${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
@ -61,6 +65,8 @@ set(libobjc_HDRS
objc/objc-api.h
objc/objc-arc.h
objc/objc-auto.h
objc/objc-class.h
objc/objc-runtime.h
objc/objc.h
objc/runtime-deprecated.h
objc/runtime.h
@ -309,7 +315,8 @@ install(TARGETS ${INSTALL_TARGETS}
install(FILES ${libobjc_HDRS}
DESTINATION "${HEADER_INSTALL_PATH}/${INCLUDE_DIRECTORY}")
install_symlink(${HEADER_INSTALL_PATH}/${INCLUDE_DIRECTORY}/blocks_runtime.h ${HEADER_INSTALL_PATH}/Block.h)
install_symlink(${HEADER_INSTALL_PATH}/${INCLUDE_DIRECTORY}/blocks_private.h ${HEADER_INSTALL_PATH}/Block_private.h)
set(CPACK_GENERATOR TGZ CACHE STRING
"Installer types to generate. Sensible options include TGZ, RPM and DEB")

@ -31,6 +31,8 @@ set(TESTS
msgInterpose.m
NilException.m
MethodArguments.m
zeroSizedIVar.m
exchange.m
)
# Function for adding a test. This takes the name of the test and the list of

@ -1,7 +1,5 @@
#import <stdio.h>
#import "../objc/objc.h"
#import "../objc/runtime.h"
#import "../objc/Object.h"
#include "Test.h"
#import <sys/types.h>

@ -0,0 +1,23 @@
#include "Test.h"
@interface Exchange : Test
+ (int)test1;
+ (int)test2;
@end
@implementation Exchange
+ (void)noop { }
+ (int)test1 { return 1024; }
+ (int)test2 { return 2048; }
@end
int main(int argc, char** argv) {
[Exchange noop];
Class i32meta = object_getClass(objc_getClass("Exchange"));
Method m1 = class_getInstanceMethod(i32meta, @selector(test1));
Method m2 = class_getInstanceMethod(i32meta, @selector(test2));
method_exchangeImplementations(m1, m2);
assert(2048 == [Exchange test1]);
}

@ -0,0 +1,69 @@
#include <stdio.h>
#include <stdlib.h>
#include "Test.h"
typedef uintptr_t NSUInteger;
@interface NSArray : Test
{
NSUInteger count;
id objects[0];
}
@end
@implementation NSArray @end
@interface BitfieldTest : Test
{
BOOL flag1:1;
BOOL flag2:1;
BOOL flag3:1;
}
@end
@implementation BitfieldTest @end
@interface BitfieldTest2 : Test
{
BOOL flag1:1;
BOOL flag2:1;
BOOL flag3:1;
int x;
}
@end
@implementation BitfieldTest2 @end
int main()
{
Class nsarray = objc_getClass("NSArray");
assert(nsarray);
assert(class_getInstanceSize(nsarray) == (sizeof(Class) + sizeof(NSUInteger)));
Ivar count = class_getInstanceVariable(nsarray, "count");
assert(ivar_getOffset(count) == sizeof(id));
Ivar objects = class_getInstanceVariable(nsarray, "objects");
Class bitfield = objc_getClass("BitfieldTest");
assert(bitfield);
Ivar flag1 = class_getInstanceVariable(bitfield, "flag1");
assert(flag1);
assert(ivar_getOffset(flag1) == sizeof(id));
Ivar flag2 = class_getInstanceVariable(bitfield, "flag2");
assert(flag2);
assert(ivar_getOffset(flag2) == sizeof(id));
Ivar flag3 = class_getInstanceVariable(bitfield, "flag3");
assert(flag3);
assert(ivar_getOffset(flag3) == sizeof(id));
assert(ivar_getOffset(flag3) + sizeof(int) <= class_getInstanceSize(bitfield));
bitfield = objc_getClass("BitfieldTest2");
flag1 = class_getInstanceVariable(bitfield, "flag1");
flag3 = class_getInstanceVariable(bitfield, "flag3");
Ivar x = class_getInstanceVariable(bitfield, "x");
assert(ivar_getOffset(flag1) == ivar_getOffset(flag3));
assert(ivar_getOffset(x) > ivar_getOffset(flag3));
assert(ivar_getOffset(x) + sizeof(int) <= class_getInstanceSize(bitfield));
}

@ -81,7 +81,6 @@ PRIVATE void objc_compute_ivar_offsets(Class class)
long ivar_size = (i+1 == class->ivars->count)
? (class_size - ivar->offset)
: class->ivars->ivar_list[i+1].offset - ivar->offset ;
assert(ivar_size > 0);
// FIXME: use alignment
ivar->offset += cumulative_fudge;
// We only need to do the realignment for things that are

@ -0,0 +1,2 @@
#include <objc/runtime.h>
#include <objc/message.h>

@ -0,0 +1,2 @@
#include <objc/runtime.h>
#include <objc/message.h>

@ -103,6 +103,12 @@ static void objc_updateDtableForClassContainingMethod(Method m)
objc_update_dtable_for_class(nextClass);
return;
}
Class meta = object_getClass((id)nextClass);
if (class_getInstanceMethodNonrecursive(meta, sel) == m)
{
objc_update_dtable_for_class(meta);
return;
}
}
}

Loading…
Cancel
Save