| 1212 | } |
| 1213 | |
| 1214 | static inline int |
| 1215 | lsc_timeout(int wait_us) |
| 1216 | { |
| 1217 | int retval = 0; |
| 1218 | |
| 1219 | struct timespec ts; |
| 1220 | struct timeval tp; |
| 1221 | |
| 1222 | gettimeofday(&tp, NULL); |
| 1223 | |
| 1224 | /* Convert from timeval to timespec */ |
| 1225 | ts.tv_sec = tp.tv_sec; |
| 1226 | ts.tv_nsec = tp.tv_usec * 1000; |
| 1227 | ts.tv_nsec += wait_us * 1000; |
| 1228 | /* Normalize tv_nsec to [0,999999999L] */ |
| 1229 | while (ts.tv_nsec > 1000000000L) { |
| 1230 | ts.tv_nsec -= 1000000000L; |
| 1231 | ts.tv_sec += 1; |
| 1232 | } |
| 1233 | |
| 1234 | pthread_mutex_lock(&mutex); |
| 1235 | if (test_lsc_interrupt_count < 1) |
| 1236 | retval = pthread_cond_timedwait(&cvar, &mutex, &ts); |
| 1237 | |
| 1238 | pthread_mutex_unlock(&mutex); |
| 1239 | |
| 1240 | if (retval == 0 && test_lsc_interrupt_count < 1) |
| 1241 | return -1; |
| 1242 | |
| 1243 | return retval; |
| 1244 | } |
| 1245 | |
| 1246 | static int |
| 1247 | test_status_interrupt(void) |
no test coverage detected