From 25d4021269d10470b9357620aebd6a921c3dd435 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 30 Apr 2019 09:32:48 -0400 Subject: [PATCH] Resolved timer/duration variable name TODO. --- test/testing_darwinunix.c | 22 +++++++++++----------- test/testing_windows.c | 9 ++++----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/test/testing_darwinunix.c b/test/testing_darwinunix.c index e32a24c1..239421ea 100644 --- a/test/testing_darwinunix.c +++ b/test/testing_darwinunix.c @@ -24,17 +24,17 @@ void testingprivRunWithTimeout(testingT *t, const char *file, long line, int64_t { char *timeoutstr; void (*prevsig)(int); - struct itimerval timer, prevtimer; + struct itimerval duration, prevDuration; int setitimerError = 0; timeoutstr = testingNsecString(timeout); prevsig = signal(SIGALRM, onTimeout); - timer.it_interval.tv_sec = 0; - timer.it_interval.tv_usec = 0; - timer.it_value.tv_sec = timeout / testingNsecPerSec; - timer.it_value.tv_usec = (timeout % testingNsecPerSec) / testingNsecPerUsec; - if (setitimer(ITIMER_REAL, &timer, &prevtimer) != 0) { + duration.it_interval.tv_sec = 0; + duration.it_interval.tv_usec = 0; + duration.it_value.tv_sec = timeout / testingNsecPerSec; + duration.it_value.tv_usec = (timeout % testingNsecPerSec) / testingNsecPerUsec; + if (setitimer(ITIMER_REAL, &duration, &prevDuration) != 0) { setitimerError = errno; testingprivTLogfFull(t, file, line, "error applying %s timeout: %s", comment, strerror(setitimerError)); testingTFail(t); @@ -51,7 +51,7 @@ void testingprivRunWithTimeout(testingT *t, const char *file, long line, int64_t out: if (setitimerError == 0) - setitimer(ITIMER_REAL, &prevtimer, NULL); + setitimer(ITIMER_REAL, &prevDuration, NULL); signal(SIGALRM, prevsig); testingFreeNsecString(timeoutstr); if (failNowOnError) @@ -60,12 +60,12 @@ out: void testingSleep(int64_t nsec) { - struct timespec rqtp; + struct timespec duration; // TODO check errors, possibly falling back to usleep, setitimer/pause, or even sleep - rqtp.tv_sec = nsec / testingNsecPerSec; - rqtp.tv_nsec = nsec % testingNsecPerSec; - nanosleep(&rqtp, NULL); + duration.tv_sec = nsec / testingNsecPerSec; + duration.tv_nsec = nsec % testingNsecPerSec; + nanosleep(&duration, NULL); } struct testingThread { diff --git a/test/testing_windows.c b/test/testing_windows.c index ed1f7379..6ce7e43c 100644 --- a/test/testing_windows.c +++ b/test/testing_windows.c @@ -300,7 +300,7 @@ void testingprivRunWithTimeout(testingT *t, const char *file, long line, int64_t MSG msg; int closeTargetThread = 0; uintptr_t timerThread = 0; - LARGE_INTEGER timer; + LARGE_INTEGER duration; int waitForTimerThread = 0; HRESULT hr; @@ -334,9 +334,9 @@ void testingprivRunWithTimeout(testingT *t, const char *file, long line, int64_t goto out; } - timer.QuadPart = timeout / 100; - timer.QuadPart = -timer.QuadPart; - hr = hrSetWaitableTimer(timeout_timer, &timer, 0, NULL, NULL, FALSE); + duration.QuadPart = timeout / 100; + duration.QuadPart = -duration.QuadPart; + hr = hrSetWaitableTimer(timeout_timer, &duration, 0, NULL, NULL, FALSE); if (hr != S_OK) { testingprivTLogfFull(t, file, line, "error applying %s timeout: 0x%08I32X", comment, hr); testingTFail(t); @@ -404,7 +404,6 @@ void testingSleep(int64_t nsec) LARGE_INTEGER duration; HRESULT hr; - // TODO rename all the other durations that are timeout or timer to duration or nsec, both here and in the Unix/Darwin code duration.QuadPart = nsec / 100; duration.QuadPart = -duration.QuadPart; hr = hrCreateWaitableTimerW(NULL, TRUE, NULL, &timer);