Skip to content

Commit

Permalink
ioq: Avoid _nounroll warning on older GCC versions
Browse files Browse the repository at this point in the history
Some older GCC versions (11.4, 12.3, 13.2) give a false-positive warning
when a loop pragma is attached to a loop that declares a variable:

    warning: ignoring loop annotation

Work around it by hoisting the induction variable declarations.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114691
  • Loading branch information
tavianator committed Feb 3, 2025
1 parent 1ef2935 commit b21b8ce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ioq.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,12 @@ static uintptr_t ioq_slot_wait(struct ioqq *ioqq, ioq_slot *slot, uintptr_t valu
uintptr_t ret;

// Try spinning a few times before blocking
int i, j;
_nounroll
for (int i = 0; i < 10; ++i) {
for (i = 0; i < 10; ++i) {
// Exponential backoff
_nounroll
for (int j = 0; j < (1 << i); ++j) {
for (j = 0; j < (1 << i); ++j) {

Check warning on line 288 in src/ioq.c

View workflow job for this annotation

GitHub Actions / Linux (Arm64)

Compiler warning

ignoring loop annotation

Check warning on line 288 in src/ioq.c

View workflow job for this annotation

GitHub Actions / Linux (x86)

Compiler warning

ignoring loop annotation
spin_loop();
}

Expand Down

0 comments on commit b21b8ce

Please sign in to comment.