diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c --- a/compiler-rt/lib/profile/GCDAProfiling.c +++ b/compiler-rt/lib/profile/GCDAProfiling.c @@ -74,23 +74,12 @@ static __inline void gcov_flush_init_once(void) {} #else #include -static CRITICAL_SECTION gcov_flush_mutex; +static SRWLOCK gcov_flush_mutex = SRWLOCK_INIT; static __inline void gcov_flush_lock() { - EnterCriticalSection(&gcov_flush_mutex); + AcquireSRWLockExclusive(&gcov_flush_mutex); } static __inline void gcov_flush_unlock() { - LeaveCriticalSection(&gcov_flush_mutex); -} -static __inline void gcov_flush_exit(void) { - DeleteCriticalSection(&gcov_flush_mutex); -} -static __inline void gcov_flush_init(void) { - InitializeCriticalSection(&gcov_flush_mutex); - atexit(&gcov_flush_exit); -} -static __inline void gcov_flush_init_once(void) { - static INIT_ONCE once; - InitOnceExecuteOnce(&once, gcov_flush_init, NULL, NULL); + ReleaseSRWLockExclusive(&gcov_flush_mutex); } #endif @@ -651,7 +640,6 @@ } void __gcov_flush() { - gcov_flush_init_once(); gcov_flush_lock(); struct fn_node* curr = flush_fn_list.head;