summaryrefslogtreecommitdiff
path: root/regress/sys/net/rtable/kern_compat.h
blob: a97f55cd499b90f8358e7a02906a5a9e7f656b3c (plain)
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
/* 	$OpenBSD: kern_compat.h,v 1.1 2015/11/04 09:45:52 mpi Exp $ */

#ifndef _KERN_COMPAT_H_
#define _KERN_COMPAT_H_

#include <sys/socket.h>
#include <sys/domain.h>
#include <sys/queue.h>
#include <arpa/inet.h>

#include <assert.h>
#include <err.h>
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define DIAGNOSTIC
#define INET
#define INET6

#define KASSERT(x)		assert(x)
#define KERNEL_ASSERT_LOCKED()	/* nothing */

#define panic(x...) errx(1, x)

#define malloc(size, bucket, flag)		calloc(1, size)
#define mallocarray(nelems, size, bucket, flag)	calloc(nelems, size)
#define free(x, bucket, size)			free(x)

struct pool {
	size_t pr_size;
};

#define	pool_init(a, b, c, d, e, f, g)	do { (a)->pr_size = (b); } while (0)
#define pool_get(pp, flags)		malloc((pp)->pr_size, 0, 0)
#define	pool_put(pp, rp)		free((rp), 0, 0)

#define	log(lvl, x...)	fprintf(stderr, x)

#define min(a, b) (a < b ? a : b)
#define max(a, b) (a < b ? b : a)

#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif

#define rtref(_rt)	((_rt)->rt_refcnt++)
#define rtfree(_rt)	(assert(--(_rt)->rt_refcnt >= 0))

extern struct domain *domains[];

#endif /* _KERN_COMPAT_H_ */