[PATCH v7 14/14] linux/termios: regression test for termios speed functions
H. Peter Anvin
hpa@zytor.com
Tue Jun 10 18:11:51 GMT 2025
On 2025-06-10 08:38, Adhemerval Zanella Netto wrote:
>> +#define array_size(a) (sizeof(a)/sizeof((a)[0]))
>
> We have include/array_length.h exactly for that ;)
How would you feel about this addition to <array_length.h> (as a
separate patch)? I have found these to be incredibly useful macros in a
lot of contexts...
/* foreach (PTR, ARRAY) iterates over all the elements in an array,
assigning the locally defined pointer variable PTR to each element
in turn.
foreach_const (PTR, ARRAY) does the same, but PTR is declared const
even if the array is not. */
#define foreach(ptr,array) \
for (__typeof (&(array)[0]) ptr = (array) ; \
ptr < array_end(array) ; ptr++)
#define foreach_const(ptr,array) \
for (const __typeof (&(array)[0]) ptr = (array) ; \
ptr < array_end(array) ; ptr++)
More information about the Libc-alpha
mailing list