-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompat.h
63 lines (50 loc) · 1.33 KB
/
compat.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright (c) 2024 Elastic NV */
#ifndef _COMPAT_H_
#define _COMPAT_H_
/* Linux specific */
#include <linux/types.h>
/* Sys */
#include <sys/types.h>
/* Standard */
#include <stdint.h>
/*
* General compat
*/
/* uint64_t is historically defined as unsigned long on LONG architectures, not
* unsigned long long, meaning we can't always use %llu for printing on 32 and
* 64bit. We use __u64 which is saner.
*/
typedef __u64 u64;
typedef __s64 s64;
typedef __u32 u32;
typedef __s32 s32;
typedef __u16 u16;
typedef __s16 s16;
typedef __u8 u8;
typedef __s8 s8;
typedef uintptr_t __uintptr_t; /* for freebsd_tree.h */
#ifndef __aligned
#define __aligned(x) __attribute__((aligned(x)))
#endif /* __aligned */
#ifndef likely
#define likely(x) __builtin_expect(!!(x), 1)
#endif /* likely */
#ifndef unlikely
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif /* unlikely */
#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif /* nitems */
#ifndef min
#define min(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#endif /* min */
/*
* BSD compat
*/
#include "freebsd_queue.h"
#include "freebsd_tree.h"
size_t strlcat(char *, const char *, size_t);
size_t strlcpy(char *, const char *, size_t);
long long strtonum(const char *, long long, long long, const char **);
#endif /* _COMPAT_H */