NetBSD Problem Report #10366
Received: (qmail 21686 invoked from network); 14 Jun 2000 19:05:17 -0000
Message-Id: <200006141905.MAA04382@nbwww.isc.org>
Date: Wed, 14 Jun 2000 12:05:17 -0700 (PDT)
From: cgd@netbsd.org
Reply-To: cgd@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: there is no 'how many elements' macro in the kernel.
X-Send-Pr-Version: www-1.0
>Number: 10366
>Category: kern
>Synopsis: there is no 'how many elements' macro in the kernel.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Jun 14 19:06:00 +0000 2000
>Closed-Date: Thu Mar 08 22:26:44 +0000 2007
>Last-Modified: Thu Mar 08 22:26:44 +0000 2007
>Originator: Chris Demetriou
>Release: NetBSD-current as of today (20000614)
>Organization:
>Environment:
N/A
>Description:
The kernel headers (most notably sys/param.h) define lots of
convenience macros, e.g. howmany(), powerof2(), etc. for kernel
code.
One which is notably missing is a 'how many array elements' macro,
which implemented something like:
#define foo(x) (sizeof x / sizeof x[0])
where 'x' is a statically-initialized array, and the value
is the number of elements in that array.
there's a bunch of kernel code which does things like:
const struct foo bar[] = { ... many entries ... };
const int bar_size = sizeof bar / sizeof bar[0];
this is wasteful, and error-prone.
>How-To-Repeat:
>Fix:
Pick a name, and commit it. I'd have done that myself, if any two
people could agree on a name, but don't have time to spend to gather
that consensus.
my personal favorite name, btw, is howmanyelems() (a la howmany()).
>Release-Note:
>Audit-Trail:
From: Hubert Feyrer <feyrer@rfhs8012.fh-regensburg.de>
To: cgd@netbsd.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/10366: there is no 'how many elements' macro in the kernel.
Date: Wed, 14 Jun 2000 23:36:02 +0200 (MET DST)
On Wed, 14 Jun 2000 cgd@netbsd.org wrote:
> my personal favorite name, btw, is howmanyelems() (a la howmany()).
nelements() ?
- Hubert
--
NetBSD - because Unix isn't just #include <linux.h>, i386, ILP32, ELF, ...!
State-Changed-From-To: open->closed
State-Changed-By: dsl@netbsd.org
State-Changed-When: Thu, 08 Mar 2007 22:26:44 +0000
State-Changed-Why:
__ARRAYCOUNT() got added
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.