git: 1c641d0436e3 - main - linuxkpi: Move `ARRAY_SIZE` to <linux/array_size.h>
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Apr 2026 20:47:24 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=1c641d0436e377c57a767e37f56ce65253817d67
commit 1c641d0436e377c57a767e37f56ce65253817d67
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-04-20 21:34:08 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-04-22 20:46:57 +0000
linuxkpi: Move `ARRAY_SIZE` to <linux/array_size.h>
The DRM generic code started to import this header directly in Linux
6.12.x. Let's move the definition of `ARRAY_SIZE()` (the only thing that
<linux/array_size.h> defines) to this header.
Also, include <linux/array_size.h> from the same headers as Linux. This
includes <linux/kernel.h>, so the change should not break anything.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56570
---
sys/compat/linuxkpi/common/include/linux/array_size.h | 17 +++++++++++++++++
sys/compat/linuxkpi/common/include/linux/kernel.h | 3 +--
sys/compat/linuxkpi/common/include/linux/kfifo.h | 1 +
sys/compat/linuxkpi/common/include/linux/string.h | 1 +
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/sys/compat/linuxkpi/common/include/linux/array_size.h b/sys/compat/linuxkpi/common/include/linux/array_size.h
new file mode 100644
index 000000000000..ebfaeccc9536
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/linux/array_size.h
@@ -0,0 +1,17 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * All rights reserved.
+ */
+
+#ifndef _LINUXKPI_LINUX_ARRAY_SIZE_H_
+#define _LINUXKPI_LINUX_ARRAY_SIZE_H_
+
+#include <linux/compiler.h>
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+#endif /* _LINUXKPI_LINUX_ARRAY_SIZE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h
index 8caaf520fd3e..afbd9208a410 100644
--- a/sys/compat/linuxkpi/common/include/linux/kernel.h
+++ b/sys/compat/linuxkpi/common/include/linux/kernel.h
@@ -40,6 +40,7 @@
#include <sys/syslog.h>
#include <sys/time.h>
+#include <linux/array_size.h>
#include <linux/bitops.h>
#include <linux/build_bug.h>
#include <linux/compiler.h>
@@ -266,8 +267,6 @@ extern int linuxkpi_debug;
})
#endif
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
#define u64_to_user_ptr(val) ((void *)(uintptr_t)(val))
#define offsetofend(t, m) \
diff --git a/sys/compat/linuxkpi/common/include/linux/kfifo.h b/sys/compat/linuxkpi/common/include/linux/kfifo.h
index b0d0c17f07e4..c8cea1226b3c 100644
--- a/sys/compat/linuxkpi/common/include/linux/kfifo.h
+++ b/sys/compat/linuxkpi/common/include/linux/kfifo.h
@@ -30,6 +30,7 @@
#include <sys/types.h>
+#include <linux/array_size.h>
#include <linux/slab.h>
#include <linux/gfp.h>
diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h
index ad2b2fe7d377..ba6549804edc 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -31,6 +31,7 @@
#include <sys/ctype.h>
+#include <linux/array_size.h>
#include <linux/types.h>
#include <linux/gfp.h>
#include <linux/slab.h>