From nobody Mon Jul 28 13:31:07 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4brKB320t0z634n2; Mon, 28 Jul 2025 13:31:07 +0000 (UTC) (envelope-from git@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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4brKB30zr8z3tTm; Mon, 28 Jul 2025 13:31:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753709467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+o25H69hxQ3et0t8XhmqwxS4xlWzsx6yNtG2ujCPpYU=; b=DUIDpfqDGE9xpvBo+ujVkWa+0Xh0/ccznIdlMpq9VkL1eWVVR84qJwcisVUcf8SHCV399D nPWgZZnFR5gmWAl+td6pbueggYPbCc50Y7dnhkzPUDbi7jn1T4opCp8D3sjVIWuI7OzW0x f38SJjSrnUCZq42xrcMNYm6Z1xqEUJYWcr3Ro3+QAuOiOy8S5rHziNwglYLIuOGyKW3MB9 7648lNpiG7x98wrKtTdKXRY7KAbVtkdS5najUeIyUp5E3x9nh3ZmmaAWnQibMBTWxzT6wW Z9K7eNAzdS+BIfAPrJEKqdQc3hGGDGSjGhZ4Jegnvl/XJtiIWBXv78/1E0uZRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753709467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+o25H69hxQ3et0t8XhmqwxS4xlWzsx6yNtG2ujCPpYU=; b=UKAk1iDBEj/WSYswhCbPqAnG4ornSSZGPRCqWbp3u0GxxxDhF/eSWY9tV+oK+sx7nB1VjT ePBvh1ez7aS+ywJ+sywnfVsrhp6gHM2Cs+KPb0BXfWU5GeQ/GodwwuGrAGNFG4imljOVjT MZ6mbCbg5hsB+iMsV5xNJnJtNo8iBEcYJpn+hGo0kY0GuIjsbtyasXWLRYqMH/7H3yvo2C f1BUUwMQnnEFMfyXM0DyyUhh/etSm0qES4nYv5r7m4/xqaxO8fgkKOmmdX5fe/rYz1G06e qILykXGPYjk0hx2T0Z1GkOiEmpNdYWSDAu1p/Yk4EreyyEQHxY68iYZKjt5EZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753709467; a=rsa-sha256; cv=none; b=gWh688OZaWjNpWe4lOmcHKvQuH6Vow8DjHbTrzqNHEhmPr1GHAhnpfxhE+Ek+55WzmHrjX SMs0mc2pNeVQ5Z8JZIX/PK8kXJiTmKnzQWifFjHzYwQFDtRcKAqxd4h3+2QHDtyOVDCZa8 xIjNUOzTnzxuSl6jY3TEh9yYXD20Raop6Bl2HNtZ8Upp9LowYu2bMp4ecJwbyueQ/qd+pR jkCoPDUydfLO4I0Kf0B4lJlynTm7T7S6Je8yofzmG78qem244P+XdGC4SToIOW/7UHBdea DCQVGX0sR4KhucptoBSMZTJsFZSRpyekANfyn8lL0mpt8FvzSNIgV5mhbFNARw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4brKB30VmNznfC; Mon, 28 Jul 2025 13:31:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56SDV7xj079855; Mon, 28 Jul 2025 13:31:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56SDV7GU079852; Mon, 28 Jul 2025 13:31:07 GMT (envelope-from git) Date: Mon, 28 Jul 2025 13:31:07 GMT Message-Id: <202507281331.56SDV7GU079852@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 68d289075c76 - stable/14 - sys/param.h: Split some macros into new List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 68d289075c766bd742913023a56569863121021b Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=68d289075c766bd742913023a56569863121021b commit 68d289075c766bd742913023a56569863121021b Author: Olivier Certner AuthorDate: 2025-06-06 20:25:21 +0000 Commit: Olivier Certner CommitDate: 2025-07-28 13:27:52 +0000 sys/param.h: Split some macros into new Goal is to avoid having to include the full just to get some common useful macros. More macros can be moved into it as needed. This is in preparation for using NBBY and howmany() from . Reviewed by: kib, imp (both older version) MFC after: 1 month Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50880 (cherry picked from commit b93161a7e38d37ce560ca562b1f1c18f73551cc2) --- sys/sys/_param.h | 28 ++++++++++++++++++++++++++++ sys/sys/param.h | 15 ++------------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/sys/sys/_param.h b/sys/sys/_param.h new file mode 100644 index 000000000000..a7ea071c456a --- /dev/null +++ b/sys/sys/_param.h @@ -0,0 +1,28 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + */ + +#ifndef _SYS__PARAM_H_ +#define _SYS__PARAM_H_ + +#define NBBY 8 /* number of bits in a byte */ +#define NBPW sizeof(int) /* number of bytes per word (integer) */ + +/* + * Macros for counting and rounding. + */ +#define nitems(x) (sizeof((x)) / sizeof((x)[0])) +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) +#endif +#define rounddown(x, y) (((x)/(y))*(y)) +#define rounddown2(x, y) __align_down(x, y) /* if y is power of two */ +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ +#define roundup2(x, y) __align_up(x, y) /* if y is powers of two */ +#define powerof2(x) ((((x)-1)&(x))==0) + +#endif /* _SYS__PARAM_H_ */ diff --git a/sys/sys/param.h b/sys/sys/param.h index 68cbc92b5791..74490f5e6e0e 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -40,6 +40,7 @@ #define _SYS_PARAM_H_ #include +#include #define BSD 199506 /* System version (year & month). */ #define BSD4_3 1 @@ -251,9 +252,6 @@ #define NZERO 0 /* default "nice" */ -#define NBBY 8 /* number of bits in a byte */ -#define NBPW sizeof(int) /* number of bytes per word (integer) */ - #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ #define NODEV (dev_t)(-1) /* non-existent device */ @@ -317,16 +315,7 @@ #define isclr(a,i) \ ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0) -/* Macros for counting and rounding. */ -#ifndef howmany -#define howmany(x, y) (((x)+((y)-1))/(y)) -#endif -#define nitems(x) (sizeof((x)) / sizeof((x)[0])) -#define rounddown(x, y) (((x)/(y))*(y)) -#define rounddown2(x, y) __align_down(x, y) /* if y is power of two */ -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ -#define roundup2(x, y) __align_up(x, y) /* if y is powers of two */ -#define powerof2(x) ((((x)-1)&(x))==0) +/* Macros for counting and rounding provided by . */ /* Macros for min/max. */ #define MIN(a,b) (((a)<(b))?(a):(b))