Coverage Report

Created: 2025-07-12 06:19

/src/libfuse/lib/util.h
Line
Count
Source (jump to first uncovered line)
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
12
struct fuse_conn_info;
13
14
int libfuse_strtol(const char *str, long *res);
15
void fuse_set_thread_name(const char *name);
16
17
/**
18
 * Return the low bits of a number
19
 */
20
static inline uint32_t fuse_lower_32_bits(uint64_t nr)
21
0
{
22
0
  return (uint32_t)(nr & 0xffffffff);
23
0
}
24
25
/**
26
 * Return the high bits of a number
27
 */
28
static inline uint64_t fuse_higher_32_bits(uint64_t nr)
29
0
{
30
0
  return nr & ~0xffffffffULL;
31
0
}
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
#endif /* FUSE_UTIL_H_ */