]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/atoi/a2i.[ch]: Add const-generic macros
authorAlejandro Colomar <alx@kernel.org>
Mon, 15 Apr 2024 11:20:55 +0000 (13:20 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 17 May 2024 13:40:03 +0000 (15:40 +0200)
commitb0498564b22faeb874dd4fc248fab4220b68e41a
treee745289914fba6e12b337a7e9d4a7480519701d6
parent26c9dd37157353092e8709255a6a601915057c05
lib/atoi/a2i.[ch]: Add const-generic macros

These overloaded macros allow passing either a const or a non-const
endp, and will call the appropriate function.  This kind of const
overloading has prior art in C23's string functions, such as memchr(3).

Martin suggested using an artificial function pointer in _Generic(3); it
allows switching on various types at the same time.

Also add a comment referring to liba2i's PDF manual for documentation.

Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf#subsubsection.7.26.5.2>
Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114731>
Link: <http://www.alejandro-colomar.es/share/dist/liba2i/git/HEAD/liba2i-HEAD.pdf>
Co-developed-by: Martin Uecker <muecker@gwdg.de>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/atoi/a2i.c
lib/atoi/a2i.h