ObjFW  Diff

Differences From Artifact [bf4537c728]:

To Artifact [54e2ae018c]:


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#else
static of_tlskey_t objectsKey, topKey, sizeKey;

static void __attribute__((constructor))
init(void)
{
	OF_ENSURE(of_tlskey_new(&objectsKey));
	OF_ENSURE(of_tlskey_new(&sizeKey));
	OF_ENSURE(of_tlskey_new(&topKey));
}
#endif

void*
objc_autoreleasePoolPush()
{
#ifndef OF_COMPILER_TLS







|
|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#else
static of_tlskey_t objectsKey, topKey, sizeKey;

static void __attribute__((constructor))
init(void)
{
	OF_ENSURE(of_tlskey_new(&objectsKey));
	OF_ENSURE(of_tlskey_new(&topKey));
	OF_ENSURE(of_tlskey_new(&sizeKey));
}
#endif

void*
objc_autoreleasePoolPush()
{
#ifndef OF_COMPILER_TLS
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
		free(objects);

		objects = NULL;
		top = NULL;
	}

#ifndef OF_COMPILER_TLS
	OF_ENSURE(of_tlskey_set(objectsKey, objects));
	OF_ENSURE(of_tlskey_set(topKey, top));
#endif
}

id
_objc_rootAutorelease(id object)
{
#ifndef OF_COMPILER_TLS
	id *top = of_tlskey_get(topKey);
	id *objects = of_tlskey_get(objectsKey);
	size_t size = (size_t)(uintptr_t)of_tlskey_get(sizeKey);
#endif

	if (objects == NULL) {
		OF_ENSURE((objects = malloc(of_pagesize)) != NULL);




#ifndef OF_COMPILER_TLS
		OF_ENSURE(of_tlskey_set(objectsKey, objects));
		OF_ENSURE(of_tlskey_set(sizeKey,
			(void*)(uintptr_t)of_pagesize));
#endif

		top = objects;
		size = of_pagesize;
	}

	if ((uintptr_t)top >= (uintptr_t)objects + size) {
		ptrdiff_t diff = top - objects;

		size += of_pagesize;
		OF_ENSURE((objects = realloc(objects, size)) != NULL);

#ifndef OF_COMPILER_TLS
		OF_ENSURE(of_tlskey_set(objectsKey, objects));
		OF_ENSURE(of_tlskey_set(sizeKey, (void*)(uintptr_t)size));
#endif

		top = objects + diff;
	}

	*top = object;
	top++;

#ifndef OF_COMPILER_TLS
	OF_ENSURE(of_tlskey_set(topKey, objects));
#endif

	return object;
}







|
|















>
>
>


|
<

<
<
<




















|




75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

105



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
		free(objects);

		objects = NULL;
		top = NULL;
	}

#ifndef OF_COMPILER_TLS
	OF_ENSURE(of_tlskey_set(topKey, top));
	OF_ENSURE(of_tlskey_set(objectsKey, objects));
#endif
}

id
_objc_rootAutorelease(id object)
{
#ifndef OF_COMPILER_TLS
	id *top = of_tlskey_get(topKey);
	id *objects = of_tlskey_get(objectsKey);
	size_t size = (size_t)(uintptr_t)of_tlskey_get(sizeKey);
#endif

	if (objects == NULL) {
		OF_ENSURE((objects = malloc(of_pagesize)) != NULL);

		top = objects;
		size = of_pagesize;

#ifndef OF_COMPILER_TLS
		OF_ENSURE(of_tlskey_set(objectsKey, objects));
		OF_ENSURE(of_tlskey_set(sizeKey, (void*)(uintptr_t)size));

#endif



	}

	if ((uintptr_t)top >= (uintptr_t)objects + size) {
		ptrdiff_t diff = top - objects;

		size += of_pagesize;
		OF_ENSURE((objects = realloc(objects, size)) != NULL);

#ifndef OF_COMPILER_TLS
		OF_ENSURE(of_tlskey_set(objectsKey, objects));
		OF_ENSURE(of_tlskey_set(sizeKey, (void*)(uintptr_t)size));
#endif

		top = objects + diff;
	}

	*top = object;
	top++;

#ifndef OF_COMPILER_TLS
	OF_ENSURE(of_tlskey_set(topKey, top));
#endif

	return object;
}