Path: blob/main/sys/compat/linuxkpi/common/include/linux/compiler.h
39604 views
/*-1* Copyright (c) 2010 Isilon Systems, Inc.2* Copyright (c) 2010 iX Systems, Inc.3* Copyright (c) 2010 Panasas, Inc.4* Copyright (c) 2013-2016 Mellanox Technologies, Ltd.5* Copyright (c) 2015 François Tigeot6* All rights reserved.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice unmodified, this list of conditions, and the following13* disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17*18* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR19* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES20* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.21* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,22* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT23* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF27* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28*/29#ifndef _LINUXKPI_LINUX_COMPILER_H_30#define _LINUXKPI_LINUX_COMPILER_H_3132#include <sys/cdefs.h>3334#define __user35#define __kernel36#define __safe37#define __force38#define __nocast39#define __iomem40#define __chk_user_ptr(x) ((void)0)41#define __chk_io_ptr(x) ((void)0)42#define __builtin_warning(x, y...) (1)43#define __acquires(x)44#define __releases(x)45#define __acquire(x) do { } while (0)46#define __release(x) do { } while (0)47#define __cond_lock(x,c) (c)48#define __bitwise49#define __devinitdata50#ifndef __deprecated51#define __deprecated52#endif53#define __init54#define __initconst55#define __devinit56#define __devexit57#define __exit58#define __rcu59#define __percpu60#define __weak __weak_symbol61#define __malloc62#define __attribute_const__ __attribute__((__const__))63#undef __always_inline64#define __always_inline inline65#define noinline __noinline66#define noinline_for_stack __noinline67#define ____cacheline_aligned __aligned(CACHE_LINE_SIZE)68#define ____cacheline_aligned_in_smp __aligned(CACHE_LINE_SIZE)69#define fallthrough /* FALLTHROUGH */ do { } while(0)7071#if __has_attribute(__nonstring__)72#define __nonstring __attribute__((__nonstring__))73#else74#define __nonstring75#endif76#if __has_attribute(__counted_by__)77#define __counted_by(_x) __attribute__((__counted_by__(_x)))78#else79#define __counted_by(_x)80#endif8182#define likely(x) __builtin_expect(!!(x), 1)83#define unlikely(x) __builtin_expect(!!(x), 0)84#define typeof(x) __typeof(x)8586#define uninitialized_var(x) x = x87#define __maybe_unused __unused88#define __always_unused __unused89#define __must_check __result_use_check9091#define __printf(a,b) __printflike(a,b)9293#define __diag_push()94#define __diag_pop()95#define __diag_ignore_all(...)9697#define barrier() __asm__ __volatile__("": : :"memory")9899#define lower_32_bits(n) ((u32)(n))100#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))101102#define ___PASTE(a,b) a##b103#define __PASTE(a,b) ___PASTE(a,b)104105#define WRITE_ONCE(x,v) do { \106barrier(); \107(*(volatile __typeof(x) *)(uintptr_t)&(x)) = (v); \108barrier(); \109} while (0)110111#define READ_ONCE(x) ({ \112__typeof(x) __var = ({ \113barrier(); \114(*(const volatile __typeof(x) *)&(x)); \115}); \116barrier(); \117__var; \118})119120#define lockless_dereference(p) READ_ONCE(p)121122#define _AT(T,X) ((T)(X))123124#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))125#define __must_be_array(a) __same_type(a, &(a)[0])126127#define sizeof_field(_s, _m) sizeof(((_s *)0)->_m)128129#define is_signed_type(t) ((t)-1 < (t)1)130#define is_unsigned_type(t) ((t)-1 > (t)1)131132#if __has_builtin(__builtin_dynamic_object_size)133#define __struct_size(_s) __builtin_dynamic_object_size(_s, 0)134#else135#define __struct_size(_s) __builtin_object_size(_s, 0)136#endif137138#endif /* _LINUXKPI_LINUX_COMPILER_H_ */139140141