~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/include/linux/kernel.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __TOOLS_LINUX_KERNEL_H
  3 #define __TOOLS_LINUX_KERNEL_H
  4 
  5 #include <stdarg.h>
  6 #include <stddef.h>
  7 #include <assert.h>
  8 #include <linux/build_bug.h>
  9 #include <linux/compiler.h>
 10 #include <linux/math.h>
 11 #include <linux/panic.h>
 12 #include <endian.h>
 13 #include <byteswap.h>
 14 
 15 #ifndef UINT_MAX
 16 #define UINT_MAX        (~0U)
 17 #endif
 18 
 19 #define _RET_IP_                ((unsigned long)__builtin_return_address(0))
 20 
 21 #define PERF_ALIGN(x, a)        __PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
 22 #define __PERF_ALIGN_MASK(x, mask)      (((x)+(mask))&~(mask))
 23 
 24 #ifndef offsetof
 25 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 26 #endif
 27 
 28 #ifndef container_of
 29 /**
 30  * container_of - cast a member of a structure out to the containing structure
 31  * @ptr:        the pointer to the member.
 32  * @type:       the type of the container struct this is embedded in.
 33  * @member:     the name of the member within the struct.
 34  *
 35  */
 36 #define container_of(ptr, type, member) ({                      \
 37         const typeof(((type *)0)->member) * __mptr = (ptr);     \
 38         (type *)((char *)__mptr - offsetof(type, member)); })
 39 #endif
 40 
 41 #ifndef max
 42 #define max(x, y) ({                            \
 43         typeof(x) _max1 = (x);                  \
 44         typeof(y) _max2 = (y);                  \
 45         (void) (&_max1 == &_max2);              \
 46         _max1 > _max2 ? _max1 : _max2; })
 47 #endif
 48 
 49 #ifndef min
 50 #define min(x, y) ({                            \
 51         typeof(x) _min1 = (x);                  \
 52         typeof(y) _min2 = (y);                  \
 53         (void) (&_min1 == &_min2);              \
 54         _min1 < _min2 ? _min1 : _min2; })
 55 #endif
 56 
 57 #define max_t(type, x, y)       max((type)x, (type)y)
 58 #define min_t(type, x, y)       min((type)x, (type)y)
 59 #define clamp(val, lo, hi)      min((typeof(val))max(val, lo), hi)
 60 
 61 #ifndef BUG_ON
 62 #ifdef NDEBUG
 63 #define BUG_ON(cond) do { if (cond) {} } while (0)
 64 #else
 65 #define BUG_ON(cond) assert(!(cond))
 66 #endif
 67 #endif
 68 #define BUG()   BUG_ON(1)
 69 
 70 #if __BYTE_ORDER == __BIG_ENDIAN
 71 #define cpu_to_le16 bswap_16
 72 #define cpu_to_le32 bswap_32
 73 #define cpu_to_le64 bswap_64
 74 #define le16_to_cpu bswap_16
 75 #define le32_to_cpu bswap_32
 76 #define le64_to_cpu bswap_64
 77 #define cpu_to_be16
 78 #define cpu_to_be32
 79 #define cpu_to_be64
 80 #define be16_to_cpu
 81 #define be32_to_cpu
 82 #define be64_to_cpu
 83 #else
 84 #define cpu_to_le16
 85 #define cpu_to_le32
 86 #define cpu_to_le64
 87 #define le16_to_cpu
 88 #define le32_to_cpu
 89 #define le64_to_cpu
 90 #define cpu_to_be16 bswap_16
 91 #define cpu_to_be32 bswap_32
 92 #define cpu_to_be64 bswap_64
 93 #define be16_to_cpu bswap_16
 94 #define be32_to_cpu bswap_32
 95 #define be64_to_cpu bswap_64
 96 #endif
 97 
 98 int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
 99 int scnprintf(char * buf, size_t size, const char * fmt, ...);
100 int scnprintf_pad(char * buf, size_t size, const char * fmt, ...);
101 
102 #ifndef ARRAY_SIZE
103 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
104 #endif
105 
106 #define current_gfp_context(k) 0
107 #define synchronize_rcu()
108 
109 #endif
110 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php