src/thread/pthread/SDL_syssem.c
branchSDL-1.2
changeset 6297 c787fb1b5699
parent 6218 f114f1434ff6
equal deleted inserted replaced
6294:7a2e0f7b30cb 6297:c787fb1b5699
   142 	/* Wait. */
   142 	/* Wait. */
   143 	do
   143 	do
   144 		retval = sem_timedwait(&sem->sem, &ts_timeout);
   144 		retval = sem_timedwait(&sem->sem, &ts_timeout);
   145 	while (retval == -1 && errno == EINTR);
   145 	while (retval == -1 && errno == EINTR);
   146 
   146 
   147 	if (retval == -1)
   147 	if (retval == -1) {
   148 		SDL_SetError(strerror(errno));
   148 		if (errno == ETIMEDOUT) {
       
   149 			retval = SDL_MUTEX_TIMEDOUT;
       
   150 		}
       
   151 		else {
       
   152 			SDL_SetError(strerror(errno));
       
   153 		}
       
   154 	}
   149 #else
   155 #else
   150 	end = SDL_GetTicks() + timeout;
   156 	end = SDL_GetTicks() + timeout;
   151 	while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) {
   157 	while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) {
   152 		if ((SDL_GetTicks() - end) >= 0) {
   158 		if ((SDL_GetTicks() - end) >= 0) {
   153 			break;
   159 			break;