diff options
author | Thomas Bertschinger <tahbertschinger@gmail.com> | 2024-01-15 23:41:02 -0700 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-16 01:47:05 -0500 |
commit | f5baaf48e3e82b1caf9f5cd1207d4d6feba3a2e5 (patch) | |
tree | 59f7b0e4667df7a9d3d5a45725f2aaab3e79b4c5 /c_src/include/linux/bug.h | |
parent | fb35dbfdc5a9446fbb856dae5542b23963e28b89 (diff) |
move Rust sources to top level, C sources into c_src
This moves the Rust sources out of rust_src/ and into the top level.
Running the bcachefs executable out of the development tree is now:
$ ./target/release/bcachefs command
or
$ cargo run --profile release -- command
instead of "./bcachefs command".
Building and installing is still:
$ make && make install
Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src/include/linux/bug.h')
-rw-r--r-- | c_src/include/linux/bug.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/c_src/include/linux/bug.h b/c_src/include/linux/bug.h new file mode 100644 index 00000000..1a10f7e6 --- /dev/null +++ b/c_src/include/linux/bug.h @@ -0,0 +1,66 @@ +#ifndef __TOOLS_LINUX_BUG_H +#define __TOOLS_LINUX_BUG_H + +#include <assert.h> +#include <stdio.h> +#include <linux/compiler.h> + +#ifdef CONFIG_VALGRIND +#include <valgrind/memcheck.h> + +#define DEBUG_MEMORY_FREED(p, len) VALGRIND_MAKE_MEM_UNDEFINED(p, len) +#endif + +#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ + BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) +#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) + +#define BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2*!!(cond)])) + +#define BUG() do { fflush(stdout); assert(0); unreachable(); } while (0) +#define BUG_ON(cond) assert(!(cond)) + +#define WARN(cond, fmt, ...) \ +({ \ + int __ret_warn_on = unlikely(!!(cond)); \ + if (__ret_warn_on) \ + fprintf(stderr, "WARNING at " __FILE__ ":%d: " fmt "\n",\ + __LINE__, ##__VA_ARGS__); \ + __ret_warn_on; \ +}) + +#define __WARN() \ +do { \ + fprintf(stderr, "WARNING at " __FILE__ ":%d\n", __LINE__); \ +} while (0) + +#define WARN_ON(cond) ({ \ + int __ret_warn_on = unlikely(!!(cond)); \ + if (__ret_warn_on) \ + __WARN(); \ + __ret_warn_on; \ +}) + +#define WARN_ONCE(cond, fmt, ...) \ +({ \ + static bool __warned; \ + int __ret_warn_on = unlikely(!!(cond)); \ + if (__ret_warn_on && !__warned) { \ + __warned = true; \ + __WARN(); \ + } \ + __ret_warn_on; \ +}) + +#define WARN_ON_ONCE(cond) ({ \ + static bool __warned; \ + int __ret_warn_on = unlikely(!!(cond)); \ + if (__ret_warn_on && !__warned) { \ + __warned = true; \ + __WARN(); \ + } \ + __ret_warn_on; \ +}) + +#endif /* __TOOLS_LINUX_BUG_H */ |