1219820Sjeff/*-
2219820Sjeff * Copyright (c) 2010 Isilon Systems, Inc.
3219820Sjeff * Copyright (c) 2010 iX Systems, Inc.
4219820Sjeff * Copyright (c) 2010 Panasas, Inc.
5299653Shselasky * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
6289577Shselasky * Copyright (c) 2015 Fran��ois Tigeot
7219820Sjeff * All rights reserved.
8219820Sjeff *
9219820Sjeff * Redistribution and use in source and binary forms, with or without
10219820Sjeff * modification, are permitted provided that the following conditions
11219820Sjeff * are met:
12219820Sjeff * 1. Redistributions of source code must retain the above copyright
13219820Sjeff *    notice unmodified, this list of conditions, and the following
14219820Sjeff *    disclaimer.
15219820Sjeff * 2. Redistributions in binary form must reproduce the above copyright
16219820Sjeff *    notice, this list of conditions and the following disclaimer in the
17219820Sjeff *    documentation and/or other materials provided with the distribution.
18219820Sjeff *
19219820Sjeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20219820Sjeff * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21219820Sjeff * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22219820Sjeff * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23219820Sjeff * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24219820Sjeff * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25219820Sjeff * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26219820Sjeff * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27219820Sjeff * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28219820Sjeff * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29289644Shselasky *
30289644Shselasky * $FreeBSD: stable/11/sys/compat/linuxkpi/common/include/linux/compiler.h 334766 2018-06-07 07:46:39Z hselasky $
31219820Sjeff */
32219820Sjeff#ifndef	_LINUX_COMPILER_H_
33219820Sjeff#define	_LINUX_COMPILER_H_
34219820Sjeff
35219820Sjeff#include <sys/cdefs.h>
36219820Sjeff
37219820Sjeff#define __user
38219820Sjeff#define __kernel
39219820Sjeff#define __safe
40219820Sjeff#define __force
41219820Sjeff#define __nocast
42219820Sjeff#define __iomem
43323214Srlibby#define __chk_user_ptr(x)		((void)0)
44323214Srlibby#define __chk_io_ptr(x)			((void)0)
45219820Sjeff#define __builtin_warning(x, y...)	(1)
46219820Sjeff#define __acquires(x)
47219820Sjeff#define __releases(x)
48323214Srlibby#define __acquire(x)			do { } while (0)
49323214Srlibby#define __release(x)			do { } while (0)
50219820Sjeff#define __cond_lock(x,c)		(c)
51219820Sjeff#define	__bitwise
52219820Sjeff#define __devinitdata
53299653Shselasky#define	__deprecated
54219820Sjeff#define __init
55334766Shselasky#define	__initconst
56219820Sjeff#define	__devinit
57219820Sjeff#define	__devexit
58219820Sjeff#define __exit
59299653Shselasky#define	__rcu
60329959Shselasky#define	__percpu
61329959Shselasky#define	__weak __weak_symbol
62328653Shselasky#define	__malloc
63328653Shselasky#define	___stringify(...)		#__VA_ARGS__
64328653Shselasky#define	__stringify(...)		___stringify(__VA_ARGS__)
65219820Sjeff#define	__attribute_const__		__attribute__((__const__))
66219820Sjeff#undef __always_inline
67219820Sjeff#define	__always_inline			inline
68330856Shselasky#define	noinline			__noinline
69299653Shselasky#define	____cacheline_aligned		__aligned(CACHE_LINE_SIZE)
70219820Sjeff
71219820Sjeff#define	likely(x)			__builtin_expect(!!(x), 1)
72219820Sjeff#define	unlikely(x)			__builtin_expect(!!(x), 0)
73219820Sjeff#define typeof(x)			__typeof(x)
74219820Sjeff
75219820Sjeff#define	uninitialized_var(x)		x = x
76330856Shselasky#define	__maybe_unused			__unused
77289577Shselasky#define	__always_unused			__unused
78289577Shselasky#define	__must_check			__result_use_check
79219820Sjeff
80289577Shselasky#define	__printf(a,b)			__printflike(a,b)
81289577Shselasky
82289577Shselasky#define	barrier()			__asm__ __volatile__("": : :"memory")
83289577Shselasky
84299653Shselasky#define	___PASTE(a,b) a##b
85299653Shselasky#define	__PASTE(a,b) ___PASTE(a,b)
86299653Shselasky
87292537Shselasky#define	ACCESS_ONCE(x)			(*(volatile __typeof(x) *)&(x))
88331756Semaste
89292537Shselasky#define	WRITE_ONCE(x,v) do {		\
90292537Shselasky	barrier();			\
91292537Shselasky	ACCESS_ONCE(x) = (v);		\
92292537Shselasky	barrier();			\
93292537Shselasky} while (0)
94292537Shselasky
95292537Shselasky#define	READ_ONCE(x) ({			\
96322498Shselasky	__typeof(x) __var = ({		\
97322498Shselasky		barrier();		\
98322498Shselasky		ACCESS_ONCE(x);		\
99322498Shselasky	});				\
100292537Shselasky	barrier();			\
101292537Shselasky	__var;				\
102292537Shselasky})
103299653Shselasky
104299653Shselasky#define	lockless_dereference(p) READ_ONCE(p)
105299653Shselasky
106299653Shselasky#define	_AT(T,X)	((T)(X))
107299653Shselasky
108219820Sjeff#endif	/* _LINUX_COMPILER_H_ */
109