- locale_t __locale = (locale_t)pthread_getspecific(__locale_key);
- return (__locale ? __locale : &__global_locale);
+#if TARGET_IPHONE_SIMULATOR
+ /* <rdar://problem/14136256> Crash in _objc_inform for duplicate class name during simulator launch
+ * TODO: Remove after the simulator's libSystem is initialized properly.
+ */
+ if (__locale_key == (pthread_key_t)-1) {
+ return &__global_locale;
+ }
+#endif
+ void *__thread_locale;
+ if (_pthread_has_direct_tsd()) {
+ __thread_locale = _pthread_getspecific_direct(__locale_key);
+ } else {
+ __thread_locale = pthread_getspecific(__locale_key);
+ }
+ return (__thread_locale ? (locale_t)__thread_locale : &__global_locale);