ObjFW  Diff

Differences From Artifact [3fbabbb84b]:

To Artifact [47f623ac86]:


251
252
253
254
255
256
257
258

259
260
261
262

263
264

265
266
267
268
269
270
271
272
273
274
275

276
277
278
279
280
281
282
283
284
285
251
252
253
254
255
256
257

258
259
260
261

262
263

264
265






266
267
268

269
270


271
272
273
274
275
276
277







-
+



-
+

-
+

-
-
-
-
-
-



-
+

-
-







#if defined(OF_HAVE_PTHREADS)
	return !pthread_key_create(key, NULL);
#elif defined(_WIN32)
	return ((*key = TlsAlloc()) != TLS_OUT_OF_INDEXES);
#endif
}

static OF_INLINE id
static OF_INLINE void*
of_tlskey_get(of_tlskey_t key)
{
#if defined(OF_HAVE_PTHREADS)
	void *ret = pthread_getspecific(key);
	return pthread_getspecific(key);
#elif defined(_WIN32)
	void *ret = TlsGetValue(key);
	return TlsGetValue(key);
#endif

	/* NULL and nil might be different! */
	if (ret == NULL)
		return nil;

	return (id)ret;
}

static OF_INLINE BOOL
of_tlskey_set(of_tlskey_t key, id obj)
of_tlskey_set(of_tlskey_t key, void *ptr)
{
	void *ptr = (obj != nil ? (void*)obj : NULL);

#if defined(OF_HAVE_PTHREADS)
	return !pthread_setspecific(key, ptr);
#elif defined(_WIN32)
	return TlsSetValue(key, ptr);
#endif
}