Skip to content

Commit 1473d41

Browse files
committed
Base: redefine _NS_pthread_main_np in terms of Win32
1 parent 82f431b commit 1473d41

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

CoreFoundation/Base.subproj/CFPlatform.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,14 @@ CF_EXPORT void _NS_pthread_setname_np(const char *name) {
558558
}
559559
}
560560

561-
static _CFThreadRef __initialPthread = { NULL, 0 };
561+
static _CFThreadRef __initialPthread = INVALID_HANDLE_VALUE;
562562

563563
CF_EXPORT int _NS_pthread_main_np() {
564-
_CFThreadRef me = pthread_self();
565-
if (NULL == __initialPthread.p) {
566-
__initialPthread.p = me.p;
567-
__initialPthread.x = me.x;
568-
}
569-
return (pthread_equal(__initialPthread, me));
564+
if (__initialPthread == INVALID_HANDLE_VALUE)
565+
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
566+
GetCurrentProcess(), &__initialPthread, 0, FALSE,
567+
DUPLICATE_SAME_ACCESS);
568+
return CompareObjectHandles(__initialPthread, GetCurrentThread());
570569
}
571570

572571
#endif

0 commit comments

Comments
 (0)