Skip to content

Commit 79af537

Browse files
committed
core-lock: work around gcc 4.8.4 over-optimisation
Currently the lock timeout check with gcc 4.8.4 can fail to exit on a timeout due to an over-optimisation with gcc 4.8.4 on x86. Re-work the expression to work around the problem. Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
1 parent 98f39f6 commit 79af537

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

core-lock.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,12 @@ static int CONST stress_atomic_lock_deinit(stress_lock_t *lock)
191191
static int stress_atomic_lock_acquire(stress_lock_t *lock)
192192
{
193193
if (LIKELY(lock != NULL)) {
194-
double t = stress_time_now();
194+
const double t_start = stress_time_now();
195195

196196
while (test_and_set(&lock->u.flag) == true) {
197-
if (UNLIKELY(((stress_time_now() - t) > 5.0) && !stress_continue_flag())) {
197+
const double duration = stress_time_now() - t_start;
198+
199+
if ((duration > 5.0) && !stress_continue_flag()) {
198200
errno = EAGAIN;
199201
return -1;
200202
}

0 commit comments

Comments
 (0)