diff options
author | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-12-19 19:10:26 +0000 |
---|---|---|
committer | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-12-19 19:10:26 +0000 |
commit | e4f8268d46727a486ccf4868f9caeb93d90309c9 (patch) | |
tree | 63711b581c7f71ba5f764a932841c3f7a401e022 /libobjc | |
parent | 5edfcfbde8d0198a1cb845fbc5e7c6e6173e4ddf (diff) | |
download | gcc-e4f8268d46727a486ccf4868f9caeb93d90309c9.tar.gz |
In libobjc/:
2010-12-19 Nicola Pero <nicola.pero@meta-innovation.com>
PR libobjc/47012
* accessors.m (objc_getProperty): If not atomic, do not
retain/autorelease the returned value. (Problem reported by
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168070 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc')
-rw-r--r-- | libobjc/ChangeLog | 6 | ||||
-rw-r--r-- | libobjc/accessors.m | 12 |
2 files changed, 17 insertions, 1 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index e9bfedb2d3c..55f35dc3989 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,5 +1,11 @@ 2010-12-19 Nicola Pero <nicola.pero@meta-innovation.com> + PR libobjc/47012 + * accessors.m (objc_getProperty): If not atomic, do not + retain/autorelease the returned value. (Problem reported by + +2010-12-19 Nicola Pero <nicola.pero@meta-innovation.com> + * objc-private/runtime.h (__objc_selector_max_index, __objc_init_selector_tables, __objc_register_selectors_from_class, __objc_register_selectors_from_list, diff --git a/libobjc/accessors.m b/libobjc/accessors.m index d6469ea7ce5..a47903a6c87 100644 --- a/libobjc/accessors.m +++ b/libobjc/accessors.m @@ -106,8 +106,18 @@ objc_getProperty (id self, SEL __attribute__((unused)) _cmd, ptrdiff_t offset, B { id *pointer_to_ivar = (id *)((char *)self + offset); + if (is_atomic == NO) - return AUTORELEASE (RETAIN (*pointer_to_ivar)); + { + /* Note that in this case, we do not RETAIN/AUTORELEASE the + returned value. The programmer should do it if it is + needed. Since access is non-atomic, other threads can be + ignored and the caller has full control of what happens + to the object and whether it needs to be RETAINed or not, + so it makes sense to leave the decision to him/her. This + is also what the Apple/NeXT runtime does. */ + return *pointer_to_ivar; + } else { objc_mutex_t lock = accessors_locks[ACCESSORS_HASH (pointer_to_ivar)]; |