Differences From Artifact [badbea4cd4]:
- File src/OFBlock.m — part of check-in [8892ae9fcc] at 2012-07-12 01:28:46 on branch trunk — Don't access isa directly. (user: js, size: 11921) [annotate] [blame] [check-ins using]
To Artifact [a204e2796b]:
- File
src/OFBlock.m
— part of check-in
[417b213d41]
at
2012-07-16 23:49:50
on branch trunk
— Add OF_ENSURE.
This is to be used when the condition includes a statement that needs to
be executed, as with assert, this would not be executed anymore when
NDEBUG is defined. (user: js, size: 11934) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
16 17 18 19 20 21 22 | #include "config.h" #include <stdint.h> #include <stdlib.h> #include <string.h> | < < > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include "config.h" #include <stdint.h> #include <stdlib.h> #include <string.h> #if defined(OF_APPLE_RUNTIME) && !defined(__OBJC2__) # import <objc/runtime.h> #elif defined(OF_OBJFW_RUNTIME) # import "runtime-private.h" #endif #import "OFBlock.h" #import "OFAllocFailedException.h" #import "OFInitializationFailedException.h" #import "OFNotImplementedException.h" #import "macros.h" #ifdef OF_ATOMIC_OPS # import "atomic.h" #endif #ifdef OF_THREADS # import "threading.h" #endif |
︙ | ︙ | |||
197 198 199 200 201 202 203 | if (object_getClass((id)block) == (Class)&_NSConcreteMallocBlock) { #if defined(OF_ATOMIC_OPS) of_atomic_inc_int(&block->flags); #else unsigned hash = SPINLOCK_HASH(block); | | | | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | if (object_getClass((id)block) == (Class)&_NSConcreteMallocBlock) { #if defined(OF_ATOMIC_OPS) of_atomic_inc_int(&block->flags); #else unsigned hash = SPINLOCK_HASH(block); OF_ENSURE(of_spinlock_lock(&spinlocks[hash])); block->flags++; OF_ENSURE(of_spinlock_unlock(&spinlocks[hash])); #endif } return block; } void |
︙ | ︙ | |||
224 225 226 227 228 229 230 | block->descriptor->dispose_helper(block); free(block); } #else unsigned hash = SPINLOCK_HASH(block); | | | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | block->descriptor->dispose_helper(block); free(block); } #else unsigned hash = SPINLOCK_HASH(block); OF_ENSURE(of_spinlock_lock(&spinlocks[hash])); if ((--block->flags & OF_BLOCK_REFCOUNT_MASK) == 0) { OF_ENSURE(of_spinlock_unlock(&spinlocks[hash])); if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE) block->descriptor->dispose_helper(block); free(block); return; } OF_ENSURE(of_spinlock_unlock(&spinlocks[hash])); #endif } void _Block_object_assign(void *dst_, const void *src_, const int flags_) { int flags = flags_ & (OF_BLOCK_FIELD_IS_BLOCK | |
︙ | ︙ |