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