Skip to content

Commit

Permalink
lto bugcheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
bscottm committed Jan 9, 2025
1 parent ac391fe commit df82146
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
20 changes: 16 additions & 4 deletions sim_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,18 @@ static SIM_INLINE sim_atomic_type_t sim_atomic_add(sim_atomic_value_t *p, sim_at
(void) __atomic_fetch_add_8(&p->value, x, __ATOMIC_ACQ_REL);
# endif
/* Return the updated value. */
retval = sim_atomic_get(p);
retval = p->value;
# else
# error "sim_atomic_add: No __ATOMIC_ACQ_REL intrinsic?"
# endif
# elif defined(_WIN32) || defined(_WIN64)
# if defined(InterlockedAdd)
retval = InterlockedAdd(&p->value, x);
# else
/* Older Windows InterlockedExchangeAdd, which returns the original value in p->value. */
InterlockedExchangeAdd(&p->value, x);
retval = p->value;
# endif
# else
# error "sim_atomic_add: No intrinsic?"
# endif
Expand Down Expand Up @@ -206,13 +212,19 @@ static SIM_INLINE sim_atomic_type_t sim_atomic_sub(sim_atomic_value_t *p, sim_at
__atomic_fetch_sub_8(&p->value, x, __ATOMIC_ACQ_REL);
# endif
/* Return the updated value. */
retval = sim_atomic_get(p);
retval = p->value;
# else
# error "sim_atomic_sub: No __ATOMIC_ACQ_REL intrinsic?"
# endif
# elif defined(_WIN32) || defined(_WIN64)
/* No InterlockedSub() -- use the math identity. */
retval = sim_atomic_add(p, -x);
/* There isn't a InterlockedSub function. Revert to basic math(s). */
# if defined(InterlockedAdd)
retval = InterlockedAdd(&p->value, -x);
# else
/* Older Windows InterlockedExchangeAdd, which returns the original value in p->value. */
InterlockedExchangeAdd(&p->value, -x);
retval = p->value;
# endif
# else
# error "sim_atomic_sub: No intrinsic?"
# endif
Expand Down
12 changes: 7 additions & 5 deletions sim_fio.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,17 @@ sim_byte_swap_data (bptr, size, count);

void sim_byte_swap_data (void *bptr, size_t size, size_t count)
{
uint32 j;
int32 k;
size_t j;
unsigned char by, *sptr, *dptr;

if (sim_end || (count == 0) || (size == sizeof (char)))
return;
for (j = 0, dptr = sptr = (unsigned char *) bptr; /* loop on items */
j < count; j++) {
for (k = (int32)(size - 1); k >= (((int32) size + 1) / 2); k--) {
dptr = sptr = (unsigned char *) bptr;
for (j = 0; j < count; j++) { /* loop on items */
size_t k;
const size_t midpoint = (size + 1) / 2;

for (k = size - 1; k >= midpoint; k--) {
by = *sptr; /* swap end-for-end */
*sptr++ = *(dptr + k);
*(dptr + k) = by;
Expand Down

0 comments on commit df82146

Please sign in to comment.