1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * Copyright (c) 2010 Isilon Systems, Inc.
3eda14cbcSMatt Macy  * Copyright (c) 2010 iXsystems, Inc.
4eda14cbcSMatt Macy  * Copyright (c) 2010 Panasas, Inc.
5eda14cbcSMatt Macy  * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
6eda14cbcSMatt Macy  * Copyright (c) 2015 François Tigeot
7eda14cbcSMatt Macy  * All rights reserved.
8eda14cbcSMatt Macy  *
9eda14cbcSMatt Macy  * Redistribution and use in source and binary forms, with or without
10eda14cbcSMatt Macy  * modification, are permitted provided that the following conditions
11eda14cbcSMatt Macy  * are met:
12eda14cbcSMatt Macy  * 1. Redistributions of source code must retain the above copyright
13eda14cbcSMatt Macy  *    notice unmodified, this list of conditions, and the following
14eda14cbcSMatt Macy  *    disclaimer.
15eda14cbcSMatt Macy  * 2. Redistributions in binary form must reproduce the above copyright
16eda14cbcSMatt Macy  *    notice, this list of conditions and the following disclaimer in the
17eda14cbcSMatt Macy  *    documentation and/or other materials provided with the distribution.
18eda14cbcSMatt Macy  *
19eda14cbcSMatt Macy  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20eda14cbcSMatt Macy  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21eda14cbcSMatt Macy  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22eda14cbcSMatt Macy  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23eda14cbcSMatt Macy  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24eda14cbcSMatt Macy  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25eda14cbcSMatt Macy  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26eda14cbcSMatt Macy  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27eda14cbcSMatt Macy  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28eda14cbcSMatt Macy  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29eda14cbcSMatt Macy  *
30eda14cbcSMatt Macy  * $FreeBSD$
31eda14cbcSMatt Macy  */
32eda14cbcSMatt Macy #ifndef	_LINUX_COMPILER_H_
33eda14cbcSMatt Macy #define	_LINUX_COMPILER_H_
34eda14cbcSMatt Macy 
35eda14cbcSMatt Macy #include <sys/cdefs.h>
36eda14cbcSMatt Macy 
37eda14cbcSMatt Macy #define	__user
38eda14cbcSMatt Macy #define	__kernel
39eda14cbcSMatt Macy #define	__safe
40eda14cbcSMatt Macy #define	__force
41eda14cbcSMatt Macy #define	__nocast
42eda14cbcSMatt Macy #define	__iomem
43eda14cbcSMatt Macy #define	__chk_user_ptr(x)		((void)0)
44eda14cbcSMatt Macy #define	__chk_io_ptr(x)			((void)0)
45eda14cbcSMatt Macy #define	__builtin_warning(x, y...)	(1)
46eda14cbcSMatt Macy #define	__acquires(x)
47eda14cbcSMatt Macy #define	__releases(x)
48eda14cbcSMatt Macy #define	__acquire(x)			do { } while (0)
49eda14cbcSMatt Macy #define	__release(x)			do { } while (0)
50eda14cbcSMatt Macy #define	__cond_lock(x, c)		(c)
51eda14cbcSMatt Macy #define	__bitwise
52eda14cbcSMatt Macy #define	__devinitdata
53eda14cbcSMatt Macy #define	__deprecated
54eda14cbcSMatt Macy #define	__init
55eda14cbcSMatt Macy #define	__initconst
56eda14cbcSMatt Macy #define	__devinit
57eda14cbcSMatt Macy #define	__devexit
58eda14cbcSMatt Macy #define	__exit
59eda14cbcSMatt Macy #define	__rcu
60eda14cbcSMatt Macy #define	__percpu
61eda14cbcSMatt Macy #define	__weak __weak_symbol
62eda14cbcSMatt Macy #define	__malloc
63eda14cbcSMatt Macy #define	___stringify(...)		#__VA_ARGS__
64eda14cbcSMatt Macy #define	__stringify(...)		___stringify(__VA_ARGS__)
65eda14cbcSMatt Macy #define	__attribute_const__		__attribute__((__const__))
66eda14cbcSMatt Macy #undef __always_inline
67eda14cbcSMatt Macy #define	__always_inline			inline
68eda14cbcSMatt Macy #define	noinline			__noinline
69eda14cbcSMatt Macy #define	____cacheline_aligned		__aligned(CACHE_LINE_SIZE)
70c03c5b1cSMartin Matuska #define	zfs_fallthrough			__attribute__((__fallthrough__))
71eda14cbcSMatt Macy 
722fec3ae8SWarner Losh #if !defined(_KERNEL) && !defined(_STANDALONE)
73eda14cbcSMatt Macy #define	likely(x)			__builtin_expect(!!(x), 1)
74eda14cbcSMatt Macy #define	unlikely(x)			__builtin_expect(!!(x), 0)
75eda14cbcSMatt Macy #endif
76eda14cbcSMatt Macy #define	typeof(x)			__typeof(x)
77eda14cbcSMatt Macy 
78eda14cbcSMatt Macy #define	uninitialized_var(x)		x = x
79eda14cbcSMatt Macy #define	__maybe_unused			__unused
80eda14cbcSMatt Macy #define	__always_unused			__unused
81eda14cbcSMatt Macy #define	__must_check			__result_use_check
82eda14cbcSMatt Macy 
83eda14cbcSMatt Macy #define	__printf(a, b)			__printflike(a, b)
84eda14cbcSMatt Macy 
85eda14cbcSMatt Macy #define	barrier()			__asm__ __volatile__("": : :"memory")
86eda14cbcSMatt Macy #define	___PASTE(a, b) a##b
87eda14cbcSMatt Macy #define	__PASTE(a, b) ___PASTE(a, b)
88eda14cbcSMatt Macy 
89eda14cbcSMatt Macy #define	ACCESS_ONCE(x)			(*(volatile __typeof(x) *)&(x))
90eda14cbcSMatt Macy 
91eda14cbcSMatt Macy #define	WRITE_ONCE(x, v) do {		\
92eda14cbcSMatt Macy 	barrier();			\
93eda14cbcSMatt Macy 	ACCESS_ONCE(x) = (v);		\
94eda14cbcSMatt Macy 	barrier();			\
95eda14cbcSMatt Macy } while (0)
96eda14cbcSMatt Macy 
97eda14cbcSMatt Macy #define	lockless_dereference(p) READ_ONCE(p)
98eda14cbcSMatt Macy 
99eda14cbcSMatt Macy #define	_AT(T, X)	((T)(X))
100eda14cbcSMatt Macy 
101eda14cbcSMatt Macy #endif	/* _LINUX_COMPILER_H_ */
102