Date: Thu, 6 Jun 2024 20:43:02 GMT From: Vladimir Kondratyev <wulf@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: afc450fac9f0 - main - LinuxKPI: Add abs_diff to linux/math.h Message-ID: <202406062043.456Kh2HL046365@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=afc450fac9f04f11cd916916ac28ffc52a973e1e commit afc450fac9f04f11cd916916ac28ffc52a973e1e Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2024-06-06 20:42:07 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2024-06-06 20:42:07 +0000 LinuxKPI: Add abs_diff to linux/math.h It returns absolute value of the difference between the arguments. Add LinuxKPI version check as the macro was moved from drm-kmod to linux/math.h in Linux kernel commit 46f12960aad (6.6 timeframe). Sponsored by: Serenity Cyber Security, LLC MFC after: 1 week Reviewed by: bz, emaste Differential Revision: https://reviews.freebsd.org/D45453 --- sys/compat/linuxkpi/common/include/linux/math.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/math.h b/sys/compat/linuxkpi/common/include/linux/math.h index fc4542c83f1f..dad7fa7fbe9c 100644 --- a/sys/compat/linuxkpi/common/include/linux/math.h +++ b/sys/compat/linuxkpi/common/include/linux/math.h @@ -5,6 +5,7 @@ * Copyright (c) 2014-2015 François Tigeot * Copyright (c) 2016 Matt Macy <mmacy@FreeBSD.org> * Copyright (c) 2019 Johannes Lundberg <johalun@FreeBSD.org> + * Copyright (c) 2023 Serenity Cyber Security, LLC. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -55,6 +56,14 @@ __ret; \ }) +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 60600 +#define abs_diff(x, y) ({ \ + __typeof(x) _x = (x); \ + __typeof(y) _y = (y); \ + _x > _y ? _x - _y : _y - _x; \ +}) +#endif + static inline uintmax_t mult_frac(uintmax_t x, uintmax_t multiplier, uintmax_t divisor) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202406062043.456Kh2HL046365>