From owner-svn-src-all@freebsd.org Mon Aug 3 09:15:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 837E2373FB0; Mon, 3 Aug 2020 09:15:39 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BKsgH2pmlz4XQZ; Mon, 3 Aug 2020 09:15:39 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 43EEC12062; Mon, 3 Aug 2020 09:15:39 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0739FdoG020862; Mon, 3 Aug 2020 09:15:39 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0739Fcqh020861; Mon, 3 Aug 2020 09:15:38 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202008030915.0739Fcqh020861@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 3 Aug 2020 09:15:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r363792 - in stable/11/sys: compat/linuxkpi/common/include/linux sys X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/11/sys: compat/linuxkpi/common/include/linux sys X-SVN-Commit-Revision: 363792 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2020 09:15:39 -0000 Author: hselasky Date: Mon Aug 3 09:15:38 2020 New Revision: 363792 URL: https://svnweb.freebsd.org/changeset/base/363792 Log: MFC r363077: Implement the array_size() function in the LinuxKPI. This function basically multiplies its two arguments and returns SIZE_MAX if the result overflows the size_t type. Else the product of the two arguments is returned. Bump the FreeBSD_version to mitigate issues with existing implementation of array_size() in drm-devel-kmod. Discussed with: manu@ Sponsored by: Mellanox Technologies Modified: stable/11/sys/compat/linuxkpi/common/include/linux/overflow.h stable/11/sys/sys/param.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/overflow.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/overflow.h Mon Aug 3 09:14:16 2020 (r363791) +++ stable/11/sys/compat/linuxkpi/common/include/linux/overflow.h Mon Aug 3 09:15:38 2020 (r363792) @@ -31,6 +31,9 @@ #ifndef __LINUX_OVERFLOW_H__ #define __LINUX_OVERFLOW_H__ +#include +#include + #ifndef __has_builtin #define __has_builtin(x) 0 #endif @@ -45,6 +48,16 @@ #if __has_builtin(__builtin_mul_overflow) #define check_mul_overflow(a, b, c) \ __builtin_mul_overflow(a, b, c) + +static inline size_t +array_size(size_t x, size_t y) +{ + size_t retval; + + if (__builtin_mul_overflow(x, y, &retval)) + retval = SIZE_MAX; + return (retval); +} #else #error "Compiler does not support __builtin_mul_overflow" #endif Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Mon Aug 3 09:14:16 2020 (r363791) +++ stable/11/sys/sys/param.h Mon Aug 3 09:15:38 2020 (r363792) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1104503 /* Master, propagated to newvers */ +#define __FreeBSD_version 1104504 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,