File: util.h

package info (click to toggle)
fuse3 3.17.2-3
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 37,592 kB
  • sloc: ansic: 22,937; perl: 6,044; cpp: 3,853; python: 1,128; sh: 408; javascript: 313; makefile: 59
file content (42 lines) | stat: -rw-r--r-- 923 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef FUSE_UTIL_H_
#define FUSE_UTIL_H_

#include <stdint.h>
#include <stdbool.h>

#define ROUND_UP(val, round_to) (((val) + (round_to - 1)) & ~(round_to - 1))

#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)

struct fuse_conn_info;

int libfuse_strtol(const char *str, long *res);

/**
 * Return the low bits of a number
 */
static inline uint32_t fuse_lower_32_bits(uint64_t nr)
{
	return (uint32_t)(nr & 0xffffffff);
}

/**
 * Return the high bits of a number
 */
static inline uint64_t fuse_higher_32_bits(uint64_t nr)
{
	return nr & ~0xffffffffULL;
}

#ifndef FUSE_VAR_UNUSED
#define FUSE_VAR_UNUSED(var) (__attribute__((unused)) var)
#endif

#define container_of(ptr, type, member)                      \
	({                                                   \
		unsigned long __mptr = (unsigned long)(ptr); \
		((type *)(__mptr - offsetof(type, member))); \
	})

#endif