137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
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
|
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
|
}
return page;
}
}
page = of_malloc(1, sizeof(*page));
@try {
page->map = of_calloc(1, mapSize);
page->page = mapPages(1);
page->map = of_calloc(1, mapSize);
} @catch (id e) {
of_free(page);
@throw e;
}
@try {
page->page = mapPages(1);
} @catch (id e) {
of_free(page->map);
of_free(page);
@throw e;
}
of_explicit_memset(page->page, 0, pageSize);
# if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS)
lastPage = of_tlskey_get(lastPageKey);
# endif
page->previous = lastPage;
|
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
|
#if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON)
size_t pageSize = [OFSystemInfo pageSize];
size_t numPages = OF_ROUND_UP_POW2(pageSize, size) / pageSize;
# if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS)
struct page **preallocatedPages = of_tlskey_get(preallocatedPagesKey);
size_t numPreallocatedPages;
# endif
size_t i;
if (preallocatedPages != NULL)
@throw [OFInvalidArgumentException exception];
preallocatedPages = of_calloc(numPages, sizeof(struct page));
# if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS)
of_tlskey_set(preallocatedPagesKey, preallocatedPages);
# endif
@try {
for (size_t i = 0; i < numPages; i++)
preallocatedPages[i] = addPage(false);
for (i = 0; i < numPages; i++)
preallocatedPages[i] = addPage(false);
} @catch (id e) {
for (size_t j = 0; j < i; j++)
removePageIfEmpty(preallocatedPages[j]);
of_free(preallocatedPages);
preallocatedPages = NULL;
@throw e;
}
numPreallocatedPages = numPages;
# if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS)
of_tlskey_set(numPreallocatedPagesKey,
(void *)(uintptr_t)numPreallocatedPages);
# endif
#else
|