From 8e95b6f6370ec617983247724742be9cdaf4a160 Mon Sep 17 00:00:00 2001 From: theraven Date: Sat, 25 Sep 2010 10:52:01 +0000 Subject: [PATCH] Fix warnings with GCC. Patch by TOM, tweaked to not introduce errors with clang. --- blocks_runtime.m | 4 ++-- encoding2.c | 5 +++-- sync.m | 14 ++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/blocks_runtime.m b/blocks_runtime.m index 7e194c5..8290ac1 100644 --- a/blocks_runtime.m +++ b/blocks_runtime.m @@ -132,7 +132,7 @@ void _Block_object_assign(void *destAddr, const void *object, const int flags) } else if((flags & BLOCK_FIELD_IS_OBJECT) == BLOCK_FIELD_IS_OBJECT) { - id src = object; + id src = (id)object; id *dst = destAddr; *dst = [src retain]; } @@ -174,7 +174,7 @@ void _Block_object_dispose(const void *object, const int flags) } else if((flags & ~BLOCK_BYREF_CALLER) == BLOCK_FIELD_IS_OBJECT) { - id src = object; + id src = (id)object; [src release]; } } diff --git a/encoding2.c b/encoding2.c index 9696e4c..06368a6 100644 --- a/encoding2.c +++ b/encoding2.c @@ -458,8 +458,9 @@ static const char *layout_structure_callback(const char *type, struct objc_struc } else { - round_up((size_t*)&layout->record_size, align); - layout->record_size += size; + size_t rsize = (size_t)layout->record_size; + round_up(&rsize, align); + layout->record_size = rsize + size; } return end; } diff --git a/sync.m b/sync.m index ffdc065..88f0aee 100644 --- a/sync.m +++ b/sync.m @@ -4,6 +4,12 @@ #include #include +#ifdef __clang__ +#define SELECTOR(x) @selector(x) +#else +#define SELECTOR(x) (SEL)@selector(x) +#endif + int snprintf(char *restrict s, size_t n, const char *restrict format, ...); @interface Fake @@ -25,7 +31,7 @@ static void deallocLockClass(id obj, SEL _cmd); static inline Class findLockClass(id obj) { struct objc_object object = { obj->isa }; - SEL dealloc = @selector(dealloc); + SEL dealloc = SELECTOR(dealloc); // Find the first class where this lookup is correct if (objc_msg_lookup((id)&object, dealloc) != (IMP)deallocLockClass) { @@ -62,8 +68,8 @@ static inline Class initLockObject(id obj) } const char *types = method_getTypeEncoding(class_getInstanceMethod(obj->isa, - @selector(dealloc))); - class_addMethod(lockClass, @selector(dealloc), (IMP)deallocLockClass, + SELECTOR(dealloc))); + class_addMethod(lockClass, SELECTOR(dealloc), (IMP)deallocLockClass, types); if (!class_isMetaClass(obj->isa)) { @@ -83,7 +89,7 @@ static void deallocLockClass(id obj, SEL _cmd) Class realClass = class_getSuperclass(lockClass); // Call the real -dealloc method struct objc_super super = {obj, realClass }; - objc_msgSendSuper(&super, @selector(dealloc)); + objc_msgSendSuper(&super, SELECTOR(dealloc)); // After calling [super dealloc], the object will no longer exist. // Free the lock mutex_t *lock = object_getIndexedIvars(lockClass);