Update blocks_runtime.h (#45)

Update blocks_runtime.h to be compatible with Apple / LLVM version.
main
Zenny Chen 8 years ago committed by davidchisnall
parent ee12b2362a
commit 5f01917a49

@ -42,9 +42,9 @@ static void *_HeapBlockByRef = (void*)1;
/** /**
* Returns the Objective-C type encoding for the block. * Returns the Objective-C type encoding for the block.
*/ */
const char *block_getType_np(void *b) const char *block_getType_np(const void *b)
{ {
struct Block_layout *block = b; const struct Block_layout *block = b;
if ((NULL == block) || !(block->flags & BLOCK_HAS_SIGNATURE)) if ((NULL == block) || !(block->flags & BLOCK_HAS_SIGNATURE))
{ {
return NULL; return NULL;
@ -231,10 +231,10 @@ void _Block_object_dispose(const void *object, const int flags)
// Copy a block to the heap if it's still on the stack or increments its retain count. // Copy a block to the heap if it's still on the stack or increments its retain count.
void *_Block_copy(void *src) void *_Block_copy(const void *src)
{ {
if (NULL == src) { return NULL; } if (NULL == src) { return NULL; }
struct Block_layout *self = src; struct Block_layout *self = (struct Block_layout*)src;
struct Block_layout *ret = self; struct Block_layout *ret = self;
extern void _NSConcreteStackBlock; extern void _NSConcreteStackBlock;
@ -265,10 +265,10 @@ void *_Block_copy(void *src)
} }
// Release a block and frees the memory when the retain count hits zero. // Release a block and frees the memory when the retain count hits zero.
void _Block_release(void *src) void _Block_release(const void *src)
{ {
if (NULL == src) { return; } if (NULL == src) { return; }
struct Block_layout *self = src; struct Block_layout *self = (struct Block_layout*)src;
extern void _NSConcreteStackBlock; extern void _NSConcreteStackBlock;
extern void _NSConcreteMallocBlock; extern void _NSConcreteMallocBlock;

@ -13,9 +13,9 @@
#define BLOCKS_EXPORT extern #define BLOCKS_EXPORT extern
#endif #endif
BLOCKS_EXPORT void *_Block_copy(void *); BLOCKS_EXPORT void *_Block_copy(const void *);
BLOCKS_EXPORT void _Block_release(void *); BLOCKS_EXPORT void _Block_release(const void *);
BLOCKS_EXPORT const char *block_getType_np(void *b) OBJC_NONPORTABLE; BLOCKS_EXPORT const char *block_getType_np(const void *b) OBJC_NONPORTABLE;
#define Block_copy(x) ((__typeof(x))_Block_copy((void *)(x))) #define Block_copy(x) ((__typeof(x))_Block_copy((const void *)(x)))
#define Block_release(x) _Block_release((void *)(x)) #define Block_release(x) _Block_release((const void *)(x))

Loading…
Cancel
Save