Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Apr 2026 20:47:26 +0000
From:      Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron <dumbbell@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 9a2de1d2042d - main - linuxkpi: Define `min_array()` and `max_array()`
Message-ID:  <69e933de.24c73.1ccf978@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by dumbbell:

URL: https://cgit.FreeBSD.org/src/commit/?id=9a2de1d2042d1c2730dd3049c26d481813b5f2bd

commit 9a2de1d2042d1c2730dd3049c26d481813b5f2bd
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-04-22 14:36:06 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-04-22 20:46:57 +0000

    linuxkpi: Define `min_array()` and `max_array()`
    
    They are macros that return the minimum or maximum values of an array of
    integers. They assume that the array contains elements.
    
    The i915 DRM driver started to use `min_array()` in Linux 6.12.x.
    
    Reviewed by:    bz
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D56583
---
 sys/compat/linuxkpi/common/include/linux/minmax.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/minmax.h b/sys/compat/linuxkpi/common/include/linux/minmax.h
index 5040d7f9141e..161d0174554a 100644
--- a/sys/compat/linuxkpi/common/include/linux/minmax.h
+++ b/sys/compat/linuxkpi/common/include/linux/minmax.h
@@ -77,4 +77,14 @@
 /* XXX would have to make sure both are unsigned. */
 #define	umin(x, y)			MIN(x, y)
 
+/* This macro assumes that the array has elements inside. */
+#define	__minmax_array(op, array, len) ({		\
+	typeof(array[0]) __val = array[0];		\
+	for (typeof(len) __i = 1; __i < len; __i++)	\
+		__val = op(__val, array[__i]);		\
+	__val; })
+
+#define	min_array(array, len) __minmax_array(min, array, len)
+#define	max_array(array, len) __minmax_array(max, array, len)
+
 #endif /* _LINUXKPI_LINUX_MINMAX_H_ */


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e933de.24c73.1ccf978>