1*f412fd2aSLoGin /* SPDX-License-Identifier: GPL-2.0 */ 2*f412fd2aSLoGin #ifndef __LINUX_COMPILER_H 3*f412fd2aSLoGin #define __LINUX_COMPILER_H 4*f412fd2aSLoGin 5*f412fd2aSLoGin #include "../compiler_types.h" 6*f412fd2aSLoGin 7*f412fd2aSLoGin #define likely(x) __builtin_expect(!!(x), 1) 8*f412fd2aSLoGin #define unlikely(x) __builtin_expect(!!(x), 0) 9*f412fd2aSLoGin #define likely_notrace(x) likely(x) 10*f412fd2aSLoGin #define unlikely_notrace(x) unlikely(x) 11*f412fd2aSLoGin 12*f412fd2aSLoGin #ifndef __ASSEMBLY__ 13*f412fd2aSLoGin 14*f412fd2aSLoGin /** 15*f412fd2aSLoGin * offset_to_ptr - convert a relative memory offset to an absolute pointer 16*f412fd2aSLoGin * @off: the address of the 32-bit offset value 17*f412fd2aSLoGin */ offset_to_ptr(const int * off)18*f412fd2aSLoGinstatic inline void *offset_to_ptr(const int *off) 19*f412fd2aSLoGin { 20*f412fd2aSLoGin return (void *)((unsigned long)off + *off); 21*f412fd2aSLoGin } 22*f412fd2aSLoGin 23*f412fd2aSLoGin #endif /* __ASSEMBLY__ */ 24*f412fd2aSLoGin 25*f412fd2aSLoGin /* 26*f412fd2aSLoGin * Whether 'type' is a signed type or an unsigned type. Supports scalar types, 27*f412fd2aSLoGin * bool and also pointer types. 28*f412fd2aSLoGin */ 29*f412fd2aSLoGin #define is_signed_type(type) (((type)(-1)) < (__force type)1) 30*f412fd2aSLoGin #define is_unsigned_type(type) (!is_signed_type(type)) 31*f412fd2aSLoGin 32*f412fd2aSLoGin #ifndef __UNIQUE_ID 33*f412fd2aSLoGin #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__) 34*f412fd2aSLoGin #endif 35*f412fd2aSLoGin #endif /* __LINUX_COMPILER_H */ 36