https://bugs.winehq.org/show_bug.cgi?id=51899
--- Comment #6 from Bruni earns.61@gmail.com --- My bad
According to PTHREAD specification, it does not guarantee that instructions inside the lock itself are protected from reordering.
So, it's better to put multiple locks.
DC_ATTR *get_dc_attr( HDC hdc ) { pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock( &lock ); DWORD type = gdi_handle_type( hdc ); DC_ATTR *dc_attr; pthread_mutex_unlock( &lock );
pthread_mutex_lock( &lock ); unsigned int comparedType = type & 0x1f0000; pthread_mutex_unlock( &lock );
pthread_mutex_lock( &lock ); unsigned int ntgdiObjDc = comparedType & NTGDI_OBJ_DC; pthread_mutex_unlock( &lock );
pthread_mutex_lock( &lock ); dc_attr = get_gdi_client_ptr( hdc, 0 ); pthread_mutex_unlock( &lock );
pthread_mutex_lock( &lock ); if (!ntgdiObjDc) { SetLastError( ERROR_INVALID_HANDLE ); return NULL; } pthread_mutex_unlock( &lock );
pthread_mutex_lock( &lock ); if (!dc_attr) { SetLastError( ERROR_INVALID_HANDLE ); return NULL; } pthread_mutex_unlock( &lock ); return dc_attr->disabled ? NULL : dc_attr; }