mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-03 00:00:07 +03:00
4f6b28f54f
Hi Here I'm sending a small compile fix for bcachefs-tools. Without this patch, I get this error: cargo build --release --manifest-path rust-src/Cargo.toml Compiling bch_bindgen v0.1.0 (/usr/src/git/bcachefs-tools/rust-src/bch_bindgen) error: failed to run custom build command for `bch_bindgen v0.1.0 (/usr/src/git/bcachefs-tools/rust-src/bch_bindgen)` Caused by: process didn't exit successfully: `/usr/src/git/bcachefs-tools/rust-src/target/release/build/bch_bindgen-733e88995ce9eab7/build-script-build` (exit status: 101) --- stderr warning: optimization flag '-fkeep-inline-functions' is not supported [-Wignored-optimization-argument] ../../include/linux/bit_spinlock.h:20:3: error: call to undeclared function 'futex'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] ../../include/linux/bit_spinlock.h:28:2: error: call to undeclared function 'futex'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] ../../include/linux/bit_spinlock.h:39:2: error: call to undeclared function 'futex'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] The futex() function is declared in /usr/include/x86_64-linux-gnu/urcu/futex.h It is not declared in linux/futex.h, so we need to include urcu/futex.h Mikulas Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
45 lines
968 B
C
45 lines
968 B
C
#ifndef __LINUX_BIT_SPINLOCK_H
|
|
#define __LINUX_BIT_SPINLOCK_H
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/preempt.h>
|
|
#include <linux/futex.h>
|
|
#include <urcu/futex.h>
|
|
|
|
static inline void bit_spin_lock(int nr, unsigned long *_addr)
|
|
{
|
|
u32 mask, *addr = ((u32 *) _addr) + (nr / 32), v;
|
|
|
|
nr &= 31;
|
|
mask = 1U << nr;
|
|
|
|
while (1) {
|
|
v = __atomic_fetch_or(addr, mask, __ATOMIC_ACQUIRE);
|
|
if (!(v & mask))
|
|
break;
|
|
|
|
futex(addr, FUTEX_WAIT|FUTEX_PRIVATE_FLAG, v, NULL, NULL, 0);
|
|
}
|
|
}
|
|
|
|
static inline void bit_spin_wake(int nr, unsigned long *_addr)
|
|
{
|
|
u32 *addr = ((u32 *) _addr) + (nr / 32);
|
|
|
|
futex(addr, FUTEX_WAKE|FUTEX_PRIVATE_FLAG, INT_MAX, NULL, NULL, 0);
|
|
}
|
|
|
|
static inline void bit_spin_unlock(int nr, unsigned long *_addr)
|
|
{
|
|
u32 mask, *addr = ((u32 *) _addr) + (nr / 32);
|
|
|
|
nr &= 31;
|
|
mask = 1U << nr;
|
|
|
|
__atomic_and_fetch(addr, ~mask, __ATOMIC_RELEASE);
|
|
futex(addr, FUTEX_WAKE|FUTEX_PRIVATE_FLAG, INT_MAX, NULL, NULL, 0);
|
|
}
|
|
|
|
#endif /* __LINUX_BIT_SPINLOCK_H */
|
|
|