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))