From: Martin Mares Date: Sun, 29 Jun 2014 11:43:05 +0000 (+0200) Subject: Strtonum: Support u32 and s32 X-Git-Tag: v6.1~8 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=bc5f818d21b7aceaf2c0e263b00aa4295211d8f9;p=libucw.git Strtonum: Support u32 and s32 I got tired of parsing to uint and then checking range. --- diff --git a/maint/libucw.abi b/maint/libucw.abi index 7c469ebd..21141179 100644 --- a/maint/libucw.abi +++ b/maint/libucw.abi @@ -499,6 +499,8 @@ str_hier_suffix str_to_uintmax str_to_uint str_to_uns +str_to_u32 +str_to_u64 # ucw/table.h table_init table_cleanup diff --git a/ucw/strtonum.c b/ucw/strtonum.c index 77858b19..e8fa4864 100644 --- a/ucw/strtonum.c +++ b/ucw/strtonum.c @@ -102,6 +102,10 @@ static inline uint get_digit(const uint c) #define STN_SUFFIX uint #include +#define STN_TYPE u32 +#define STN_SUFFIX u32 +#include + #define STN_TYPE u64 #define STN_SUFFIX u64 #include diff --git a/ucw/strtonum.h b/ucw/strtonum.h index d5631f68..ae25ff5d 100644 --- a/ucw/strtonum.h +++ b/ucw/strtonum.h @@ -11,6 +11,8 @@ #define _STRTONUM_H #ifdef CONFIG_UCW_CLEAN_ABI +#define str_to_u32 ucw_str_to_u32 +#define str_to_u64 ucw_str_to_u64 #define str_to_uint ucw_str_to_uint #define str_to_uintmax ucw_str_to_uintmax #define str_to_uns ucw_str_to_uns @@ -52,6 +54,9 @@ static inline const char *str_to_##suffix(type *num, const char *str, const char STN_DECLARE_CONVERTOR(uint, uint); STN_SIGNED_CONVERTOR(int, int, uint) +STN_DECLARE_CONVERTOR(u32, u32); +STN_SIGNED_CONVERTOR(s32, s32, u32) + STN_DECLARE_CONVERTOR(u64, u64); STN_SIGNED_CONVERTOR(s64, s64, u64)