libfuse: fuse-3.18.1/lib/util.h Source File

libfuse

util.h
1#ifndef FUSE_UTIL_H_
2#define FUSE_UTIL_H_
3
4#include <stdint.h>
5#include <stdbool.h>
6
7#define ROUND_UP(val, round_to) (((val) + (round_to - 1)) & ~(round_to - 1))
8
9#define likely(x) __builtin_expect(!!(x), 1)
10#define unlikely(x) __builtin_expect(!!(x), 0)
11
12struct fuse_conn_info;
13
14int libfuse_strtol(const char *str, long *res);
15void fuse_set_thread_name(const char *name);
16
20static inline uint32_t fuse_lower_32_bits(uint64_t nr)
21{
22 return (uint32_t)(nr & 0xffffffff);
23}
24
28static inline uint64_t fuse_higher_32_bits(uint64_t nr)
29{
30 return nr & ~0xffffffffULL;
31}
32
33#ifndef FUSE_VAR_UNUSED
34#define FUSE_VAR_UNUSED __attribute__((__unused__))
35#endif
36
37#define container_of(ptr, type, member) \
38 ({ \
39 unsigned long __mptr = (unsigned long)(ptr); \
40 ((type *)(__mptr - offsetof(type, member))); \
41 })
42
43#if __has_attribute(__fallthrough__)
44#define fallthrough __attribute__((__fallthrough__))
45#else
46#define fallthrough do {} while (0)
47#endif
48
49#endif /* FUSE_UTIL_H_ */
fuse_conn_info
Definition fuse_common.h:538