mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 11:18:52 +03:00
Refactor ccompile.h to not include system headers
This is a step toward being able to vendor the OpenZFS code in FreeBSD. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Matt Macy <mmacy@FreeBSD.org> Closes #10625
This commit is contained in:
@@ -164,14 +164,19 @@ extern "C" {
|
||||
|
||||
#define KMALLOC_MAX_SIZE MAXPHYS
|
||||
|
||||
#ifdef _KERNEL
|
||||
#if !defined(LOCORE) && !defined(_ASM)
|
||||
typedef unsigned long long u_longlong_t;
|
||||
typedef long long longlong_t;
|
||||
|
||||
|
||||
typedef void zfs_kernel_param_t;
|
||||
#ifndef LOCORE
|
||||
#ifndef HAVE_RPC_TYPES
|
||||
typedef int bool_t;
|
||||
typedef int enum_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define __init
|
||||
#define __exit
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define param_set_charp(a, b) (0)
|
||||
#define ATTR_UID AT_UID
|
||||
#define ATTR_GID AT_GID
|
||||
@@ -186,127 +191,7 @@ typedef void zfs_kernel_param_t;
|
||||
#define MUTEX_NOLOCKDEP 0
|
||||
#define RW_NOLOCKDEP 0
|
||||
|
||||
#if !defined(LOCORE) && !defined(_ASM)
|
||||
#include <sys/param.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#if __FreeBSD_version < 1300051
|
||||
#define vm_page_valid(m) (m)->valid = VM_PAGE_BITS_ALL
|
||||
#define vm_page_do_sunbusy(m)
|
||||
#define vm_page_none_valid(m) ((m)->valid == 0)
|
||||
#else
|
||||
#define vm_page_do_sunbusy(m) vm_page_sunbusy(m)
|
||||
#endif
|
||||
|
||||
#if __FreeBSD_version < 1300074
|
||||
#define VOP_UNLOCK1(x) VOP_UNLOCK(x, 0)
|
||||
#else
|
||||
#define VOP_UNLOCK1(x) VOP_UNLOCK(x)
|
||||
#endif
|
||||
|
||||
#if __FreeBSD_version < 1300064
|
||||
#define VN_IS_DOOMED(vp) ((vp)->v_iflag & VI_DOOMED)
|
||||
#endif
|
||||
|
||||
#if __FreeBSD_version < 1300068
|
||||
#define VFS_VOP_VECTOR_REGISTER(x)
|
||||
#endif
|
||||
|
||||
#if __FreeBSD_version >= 1300076
|
||||
#define getnewvnode_reserve_() getnewvnode_reserve()
|
||||
#else
|
||||
#define getnewvnode_reserve_() getnewvnode_reserve(1)
|
||||
#endif
|
||||
struct hlist_node {
|
||||
struct hlist_node *next, **pprev;
|
||||
};
|
||||
|
||||
struct hlist_head {
|
||||
struct hlist_node *first;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
volatile int counter;
|
||||
} atomic_t;
|
||||
|
||||
/* BEGIN CSTYLED */
|
||||
#define hlist_for_each(p, head) \
|
||||
for (p = (head)->first; p; p = (p)->next)
|
||||
|
||||
#define hlist_entry(ptr, type, field) container_of(ptr, type, field)
|
||||
|
||||
#define container_of(ptr, type, member) \
|
||||
({ \
|
||||
const __typeof(((type *)0)->member) *__p = (ptr); \
|
||||
(type *)((uintptr_t)__p - offsetof(type, member)); \
|
||||
})
|
||||
/* END CSTYLED */
|
||||
|
||||
static inline void
|
||||
hlist_add_head(struct hlist_node *n, struct hlist_head *h)
|
||||
{
|
||||
n->next = h->first;
|
||||
if (h->first != NULL)
|
||||
h->first->pprev = &n->next;
|
||||
WRITE_ONCE(h->first, n);
|
||||
n->pprev = &h->first;
|
||||
}
|
||||
|
||||
static inline void
|
||||
hlist_del(struct hlist_node *n)
|
||||
{
|
||||
WRITE_ONCE(*(n->pprev), n->next);
|
||||
if (n->next != NULL)
|
||||
n->next->pprev = n->pprev;
|
||||
}
|
||||
/* BEGIN CSTYLED */
|
||||
#define READ_ONCE(x) ({ \
|
||||
__typeof(x) __var = ({ \
|
||||
barrier(); \
|
||||
ACCESS_ONCE(x); \
|
||||
}); \
|
||||
barrier(); \
|
||||
__var; \
|
||||
})
|
||||
|
||||
#define HLIST_HEAD_INIT { }
|
||||
#define HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT
|
||||
#define INIT_HLIST_HEAD(head) (head)->first = NULL
|
||||
|
||||
#define INIT_HLIST_NODE(node) \
|
||||
do { \
|
||||
(node)->next = NULL; \
|
||||
(node)->pprev = NULL; \
|
||||
} while (0)
|
||||
|
||||
/* END CSTYLED */
|
||||
static inline int
|
||||
atomic_read(const atomic_t *v)
|
||||
{
|
||||
return (READ_ONCE(v->counter));
|
||||
}
|
||||
|
||||
static inline int
|
||||
atomic_inc(atomic_t *v)
|
||||
{
|
||||
return (atomic_fetchadd_int(&v->counter, 1) + 1);
|
||||
}
|
||||
|
||||
static inline int
|
||||
atomic_dec(atomic_t *v)
|
||||
{
|
||||
return (atomic_fetchadd_int(&v->counter, -1) - 1);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
typedef long loff_t;
|
||||
typedef long rlim64_t;
|
||||
typedef int bool_t;
|
||||
typedef int enum_t;
|
||||
#ifndef __cplusplus
|
||||
#define __init
|
||||
#endif
|
||||
#define __exit
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user