rem: if (! semthread[i] && semthread[i] != SDL_ThreadID ()) fprintf( stderr, "WARNING: tried to free a Semaphore held by another thread!\n"); semthread[i] = 0;
add: sem_name = SemMon[i].Name; if (SemMon[i].Thread && SemMon[i].Thread != NativeThreadID ()) #if defined (THREAD_QUEUE) && defined (THREAD_NAMES) if (ThreadNameNative (SemMon[i].Thread) == NULL) fprintf( stderr, "Freeing %s Semaphore in '%s' set by defunct thread '%s'!\n", sem_name, ThreadNameNative (NativeThreadID ()), SemMon[i].ThreadName); else fprintf( stderr, "Freeing %s Semaphore in '%s' set by thread '%s'!\n", sem_name, ThreadNameNative (NativeThreadID ()), ThreadNameNative (SemMon[i].Thread)); SemMon[i].ThreadName[0] = 0; #else fprintf (stderr, "Freeing %s Semaphore that was set by a different thread\n", sem_name); #endif SemMon[i].Thread = 0;
context: ClearSemaphore (Semaphore sem){	int i;#ifdef DEBUG_TRACK_SEM	Uint32 semval = SDL_SemValue (sem);	if (semval != 0)	{		fprintf (stderr, "WARNING: trying to clear a free semaphore (value=%d)\n", semval);		// Should we unset the Semaphore twice?  Perhaps not.		return;	}	for (i = 0;SemList[i] != NULL; i++)		if (*SemList[i] == sem)		{			if (! semthread[i] && semthread[i] != SDL_ThreadID ())				fprintf( stderr, "WARNING: tried to free a Semaphore held by another thread!\n");			semthread[i] = 0;			break;		}#endif	NativeClearSemaphore ((NativeSemaphore) sem);}