Skip to content
Permalink
Browse files
linux/kernel.h, linux/array_size.h: Split ARRAY_SIZE() into a separat…
…e header

Include <linux/array_size.h> from <linux/kernel.h> for compatibility.

Include <linux/compiler.h> for __must_be_array().

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
  • Loading branch information
alejandro-colomar authored and intel-lab-lkp committed Nov 20, 2021
1 parent d22f059 commit f4bee28948d96faeac8bdf5ac6d2abdd718d1db3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_ARRAY_SIZE_H
#define _LINUX_ARRAY_SIZE_H

#include <linux/compiler.h>


/**
* ARRAY_SIZE - get the number of elements in array @a
* @a: array to be sized
*/
#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]) + __must_be_array(a))


#endif /* _LINUX_ARRAY_SIZE_H */
@@ -2,6 +2,8 @@
#ifndef _LINUX_KERNEL_H
#define _LINUX_KERNEL_H


#include <linux/array_size.h>
#include <linux/stdarg.h>
#include <linux/align.h>
#include <linux/limits.h>
@@ -25,6 +27,7 @@

#include <uapi/linux/kernel.h>


#define STACK_MAGIC 0xdeadbeef

/**
@@ -39,12 +42,6 @@
#define READ 0
#define WRITE 1

/**
* ARRAY_SIZE - get the number of elements in array @arr
* @arr: array to be sized
*/
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))

#define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)

#define u64_to_user_ptr(x) ( \

0 comments on commit f4bee28

Please sign in to comment.