From nobody Wed Jun 18 02:13:06 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 4bMS2B71fRz5q6Vm; Wed, 18 Jun 2025 02:13:06 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bMS2B6X4cz410M; Wed, 18 Jun 2025 02:13:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750212786; 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=UT0NL5/GGhcCnTibqfP2Q+2PeV8TojkBI0R0c0FwGq8=; b=aCvcdIcmgiifUl2uar3AZD4Vd0q9w7p5YcXzE4NBun/rRsFACI7Hui9NZn1+z12k7k9Yfp RfRFaFzmUWlxkUrJXGPaKaGGUVOOx3yonOb/jhnQGxf6UgoMAgBjzKXKLxXs4e5Jb+VWu5 DjguwYFT9+tirqH5WlN+EE9MprAs1prGkbMlhVTxQcJQFtyvkdiMbTBKvIIHybagocBMAw UscYZ7mROcoxBZqUnqXyd3SUo067aaoozqBemU15+eukVWBKvoAq1mjHw3wlR6vl/L5OQH 6t/ER+I1lB1Gc9kCOovovPanNKU1E/f5RA7cNbB4ONQWIbJ5t82OuFtMnBp+zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750212786; 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=UT0NL5/GGhcCnTibqfP2Q+2PeV8TojkBI0R0c0FwGq8=; b=I4qhaL2gTCw3lLMNniIlxJdaStR7jdszhdJyvyrIBBhnBWIU3kZD2MFefCbAkC1KNA3duH ICMfVx6Seg4S3RU6wewhcio5/D/UAFIbdHJdSXkWAuEmiqUHOsGkHlgcLbolpPCNUZv8t0 LiA7PgHj4gRSpqn88pLLwN7f6b0lWRbM+sxZdfkNitpIm1kk+/oaoDxy2OqewSA78JcsaS TT55xxyyxmozN1xcpGBrHsl7f/BhGq/FF5Ozu92vaRkGru9N0c74MQh4YEKFYk9Erle8zf cBgurogykTlGX1695UBvZCrbxfTpdclxB0qGQHJ1pkDWSpPfdafKI3C+IMu01A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750212786; a=rsa-sha256; cv=none; b=KruTcMVOIfqybb5leFhtHngKte8jnPyJpxRBRePGnI6zfnJy8U9rlZ4iNMYVcXxmI1IknX MRfcI7iNsiNpAdCOsLFd/4SJjAuJ1Pm4jPacxC8irzz1yHOx/wV0N6RONow65D8xem/Usz GZWj7bEF/f3H9gtdzw34xMxCocJC/5e1o4zOeKY6+gUfjJmohW2AxQd2n/e6aid6heuPW7 73AMvJXX6y9uoYI+7Go7gHRPtDGUg1bAL02EV0Ie8c86mElFbUUdPM1Fo1+Yt1Cb1aobEH hr1GGoloQ5p+r2wHyWAaneeHSO2RzXonWFg2jhzRBZ0CwZfzSmmQmbWzpvraTg== 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 4bMS2B60tbz18k6; Wed, 18 Jun 2025 02:13:06 +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 55I2D6pg023903; Wed, 18 Jun 2025 02:13:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55I2D66H023900; Wed, 18 Jun 2025 02:13:06 GMT (envelope-from git) Date: Wed, 18 Jun 2025 02:13:06 GMT Message-Id: <202506180213.55I2D66H023900@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: b93161a7e38d - main - 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/main X-Git-Reftype: branch X-Git-Commit: b93161a7e38d37ce560ca562b1f1c18f73551cc2 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=b93161a7e38d37ce560ca562b1f1c18f73551cc2 commit b93161a7e38d37ce560ca562b1f1c18f73551cc2 Author: Olivier Certner AuthorDate: 2025-06-06 20:25:21 +0000 Commit: Olivier Certner CommitDate: 2025-06-18 02:07:48 +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 --- 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 77e62439aad4..37fa46ffdf3d 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -38,6 +38,7 @@ #define _SYS_PARAM_H_ #include +#include #define BSD 199506 /* System version (year & month). */ #define BSD4_3 1 @@ -253,9 +254,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 */ @@ -319,16 +317,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))