#define LIBC_EXTSN(sym) __asm("_" __STRING(sym) LIBC_SUF_EXTSN)
#define LIBC_EXTSN_C(sym) __asm("_" __STRING(sym) LIBC_SUF_EXTSN LIBC_SUF_NON_CANCELABLE)
-extern int __pthread_tsd_first;
extern int pthread_key_init_np(int, void (*)(void *));
-#define __LIBC_PTHREAD_KEY(x) (__pthread_tsd_first + (x))
+#include <TargetConditionals.h>
+#if TARGET_IPHONE_SIMULATOR
+/* Simulator keys are offset by 200 */
+#define __LIBC_PTHREAD_KEY(x) (210 + (x))
+#else
+#define __LIBC_PTHREAD_KEY(x) (10 + (x))
+#endif
/*
* Libc pthread key assignments