diff --git a/criu/files.c b/criu/files.c index b83e62db1..64d7a1f86 100644 --- a/criu/files.c +++ b/criu/files.c @@ -156,30 +156,33 @@ out: int set_fds_event(pid_t virt) { struct pstree_item *item; - int old; + bool is_set; item = pstree_item_by_virt(virt); BUG_ON(!item); - old = test_and_set_bit(FDS_EVENT_BIT, (unsigned long *)&item->task_st); + is_set = !!test_and_set_bit_le(FDS_EVENT_BIT, &item->task_st_le_bits); - if (!(old & FDS_EVENT)) + if (!is_set) futex_wake(&item->task_st); return 0; } void clear_fds_event(void) { - futex_t *f = ¤t->task_st; - - clear_bit(FDS_EVENT_BIT, (unsigned long *)&f->raw.counter); + clear_bit_le(FDS_EVENT_BIT, ¤t->task_st_le_bits); } void wait_fds_event(void) { futex_t *f = ¤t->task_st; - - futex_wait_if_cond(f, FDS_EVENT, &); + int value; +#if BITS_PER_LONG == 64 + value = htole64(FDS_EVENT); +#else + value = htole32(FDS_EVENT); +#endif + futex_wait_if_cond(f, value, &); clear_fds_event(); } diff --git a/criu/include/pstree.h b/criu/include/pstree.h index 880c926ad..4f9718d26 100644 --- a/criu/include/pstree.h +++ b/criu/include/pstree.h @@ -25,7 +25,10 @@ struct pstree_item { struct pid *threads; /* array of threads */ CoreEntry **core; TaskKobjIdsEntry *ids; - futex_t task_st; + union { + futex_t task_st; + unsigned long task_st_le_bits; + }; }; enum { diff --git a/include/common/bitops.h b/include/common/bitops.h index c594a0fad..1e6411243 100644 --- a/include/common/bitops.h +++ b/include/common/bitops.h @@ -1,4 +1,23 @@ #ifndef __CR_COMMON_BITOPS_H__ #define __CR_COMMON_BITOPS_H__ #include "common/asm/bitops.h" + +#include "common/bitsperlong.h" +#include + +#if __BYTE_ORDER == __BIG_ENDIAN +#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) +#else +#define BITOP_LE_SWIZZLE 0 +#endif + +static inline int test_and_set_bit_le(int nr, void *addr) +{ + return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr); +} + +static inline void clear_bit_le(int nr, void *addr) +{ + clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); +} #endif