1219820Sjeff/*- 2219820Sjeff * Copyright (c) 2010 Isilon Systems, Inc. 3219820Sjeff * Copyright (c) 2010 iX Systems, Inc. 4219820Sjeff * Copyright (c) 2010 Panasas, Inc. 5293151Shselasky * Copyright (c) 2013-2015 Mellanox Technologies, Ltd. 6293151Shselasky * 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. 29219820Sjeff */ 30219820Sjeff 31219820Sjeff#ifndef _LINUX_COMPILER_H_ 32219820Sjeff#define _LINUX_COMPILER_H_ 33219820Sjeff 34219820Sjeff#include <sys/cdefs.h> 35219820Sjeff 36219820Sjeff#define __user 37219820Sjeff#define __kernel 38219820Sjeff#define __safe 39219820Sjeff#define __force 40219820Sjeff#define __nocast 41219820Sjeff#define __iomem 42219820Sjeff#define __chk_user_ptr(x) 0 43219820Sjeff#define __chk_io_ptr(x) 0 44219820Sjeff#define __builtin_warning(x, y...) (1) 45219820Sjeff#define __acquires(x) 46219820Sjeff#define __releases(x) 47219820Sjeff#define __acquire(x) 0 48219820Sjeff#define __release(x) 0 49219820Sjeff#define __cond_lock(x,c) (c) 50219820Sjeff#define __bitwise 51219820Sjeff#define __devinitdata 52219820Sjeff#define __init 53219820Sjeff#define __devinit 54219820Sjeff#define __devexit 55219820Sjeff#define __exit 56219820Sjeff#define __stringify(x) #x 57219820Sjeff#define __attribute_const__ __attribute__((__const__)) 58219820Sjeff#undef __always_inline 59219820Sjeff#define __always_inline inline 60219820Sjeff 61219820Sjeff#define likely(x) __builtin_expect(!!(x), 1) 62219820Sjeff#define unlikely(x) __builtin_expect(!!(x), 0) 63219820Sjeff#define typeof(x) __typeof(x) 64219820Sjeff 65219820Sjeff#define uninitialized_var(x) x = x 66293151Shselasky#define __read_mostly __attribute__((__section__(".data.read_mostly"))) 67293151Shselasky#define __always_unused __unused 68293151Shselasky#define __must_check __result_use_check 69219820Sjeff 70293151Shselasky#define __printf(a,b) __printflike(a,b) 71293151Shselasky 72293151Shselasky#define barrier() __asm__ __volatile__("": : :"memory") 73293151Shselasky 74293151Shselasky#define ACCESS_ONCE(x) (*(volatile __typeof(x) *)&(x)) 75293151Shselasky 76293151Shselasky#define WRITE_ONCE(x,v) do { \ 77293151Shselasky barrier(); \ 78293151Shselasky ACCESS_ONCE(x) = (v); \ 79293151Shselasky barrier(); \ 80293151Shselasky} while (0) 81293151Shselasky 82293151Shselasky#define READ_ONCE(x) ({ \ 83293151Shselasky __typeof(x) __var; \ 84293151Shselasky barrier(); \ 85293151Shselasky __var = ACCESS_ONCE(x); \ 86293151Shselasky barrier(); \ 87293151Shselasky __var; \ 88293151Shselasky}) 89293151Shselasky 90219820Sjeff#endif /* _LINUX_COMPILER_H_ */ 91