ObjFW  Check-in [08f1d13520]

Overview
Comment:Add objc_{get,set}PropertyStruct() for GCC >= 4.6.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | runtime
Files: files | file ages | folders
SHA3-256: 08f1d135204ceb930bdb4da343723617d17107350331ffe4a60c0f9d2c021f28
User & Date: js on 2012-03-23 12:42:05
Other Links: branch diff | manifest | tags
Context
2012-03-23
12:59
Move objc_{properties,sync} to runtime. check-in: adbce6d8f4 user: js tags: runtime
12:42
Add objc_{get,set}PropertyStruct() for GCC >= 4.6. check-in: 08f1d13520 user: js tags: runtime
12:04
Merge branch 'master' into runtime check-in: 3719e10281 user: js tags: runtime
Changes

Modified src/objc_properties.m from [d2cf97ab35] to [343585f1c5].

12
13
14
15
16
17
18


19
20
21
22
23
24
25
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"



#include <assert.h>

#import "OFObject.h"

#ifdef OF_THREADS
# import "threading.h"
# define NUM_SPINLOCKS 8	/* needs to be a power of 2 */







>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <string.h>

#include <assert.h>

#import "OFObject.h"

#ifdef OF_THREADS
# import "threading.h"
# define NUM_SPINLOCKS 8	/* needs to be a power of 2 */
116
117
118
119
120
121
122















































		break;
	default:
		*ptr = [value copy];
	}

	[old release];
}






















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
		break;
	default:
		*ptr = [value copy];
	}

	[old release];
}

/* The following methods are only required for GCC >= 4.6 */
void
objc_getPropertyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic,
    BOOL strong)
{
	if (atomic) {
#ifdef OF_THREADS
		unsigned hash = SPINLOCK_HASH(src);

		assert(of_spinlock_lock(&spinlocks[hash]));
#endif

		memcpy(dest, src, size);

#ifdef OF_THREADS
		assert(of_spinlock_unlock(&spinlocks[hash]));
#endif

		return;
	}

	memcpy(dest, src, size);
}

void
objc_setPropertyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic,
    BOOL strong)
{
	if (atomic) {
#ifdef OF_THREADS
		unsigned hash = SPINLOCK_HASH(src);

		assert(of_spinlock_lock(&spinlocks[hash]));
#endif

		memcpy(dest, src, size);

#ifdef OF_THREADS
		assert(of_spinlock_unlock(&spinlocks[hash]));
#endif

		return;
	}

	memcpy(dest, src, size);
}