Updated patch with comments merged. Added doxygen comments, and hex2bin() now also supports upper-case characters.
On Tue, Apr 08, 2008 at 08:54:40AM +0200, Segher Boessenkool wrote:
Do we really need all the types? I think that we can get by
Dunno, I just needed an abs(), but when looking at the manpage I also saw that labs() and llabs() are part of a standard libc so I thought I might as well just add them too.
with just abs(), and probably even make it a #define which will eliminate the need for type checking anyway.
Maybe, but then we could also make the other mini-functions macros again, e.g. bin2hex() or most of libc/ctype.c or libc/string.c for example. I think the usual case should be to make small functions instead of macros.
Only if you are really careful and make it a statement expression...
#define abs(_a) ((_a) >= 0 ? (_a) : -(_a))
...since this version ("the obvious version") suffers from double evaluation.
What fix do you propose? Is there a way to improve the macro or do you suggest to leave the code as a function?
Uwe.