]> git.ipfire.org Git - thirdparty/glibc.git/commit
include/array_length.h: add array_foreach[_const] macros
authorH. Peter Anvin <hpa@zytor.com>
Thu, 12 Jun 2025 01:35:44 +0000 (18:35 -0700)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 17 Jun 2025 12:57:40 +0000 (09:57 -0300)
commitc66801f36135a7b031ca37e25a35e98255b20def
treed960299ccfe7b95769df607ce1e7e711eb882192
parentbe413adedfca146a6fb8cabe3df1244a70f106f3
include/array_length.h: add array_foreach[_const] macros

Add simple-to-use iterator macros for arrays.  They are used instead
of explicit for statements, like:

      /* Test all common speeds */
      array_foreach_const (ts, test_speeds)
test (fd, *ts);

In this case, ts will be a const pointer to each of the elements of
test_speeds in turn.

Named array_foreach*() to allow for other kinds of equivalent iterator
macros in the future.

Signed-off-by: "H. Peter Anvin" (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
include/array_length.h