MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lsc_timeout

Function lsc_timeout

dpdk/app/test/test_link_bonding.c:1214–1244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1212}
1213
1214static inline int
1215lsc_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
1246static int
1247test_status_interrupt(void)

Calls 2

pthread_mutex_lockFunction · 0.85
pthread_mutex_unlockFunction · 0.85

Tested by

no test coverage detected