lib/stdlib: Change some macro to inline function

to avoid the build break for "using ::xxx"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ib5d861a6c2b9e6ba585df83b3cdff8a3e1495bce
This commit is contained in:
Xiang Xiao 2020-06-01 14:19:26 +08:00 committed by patacongo
parent 806710b225
commit eac66d76b3

View File

@ -158,7 +158,15 @@ int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg);
/* _Exit() is a stdlib.h equivalent to the unistd.h _exit() function */ /* _Exit() is a stdlib.h equivalent to the unistd.h _exit() function */
void _exit(int status); /* See unistd.h */ void _exit(int status); /* See unistd.h */
#ifdef __cplusplus
inline void _Exit(int s)
{
_exit(s);
}
#else
#define _Exit(s) _exit(s) #define _Exit(s) _exit(s)
#endif
/* System() command is not implemented in the NuttX libc because it is so /* System() command is not implemented in the NuttX libc because it is so
* entangled with shell logic. There is an experimental version at * entangled with shell logic. There is an experimental version at
@ -187,14 +195,45 @@ double strtod(FAR const char *str, FAR char **endptr);
long double strtold(FAR const char *str, FAR char **endptr); long double strtold(FAR const char *str, FAR char **endptr);
#endif #endif
#ifdef __cplusplus
inline int atoi(FAR const char *nptr)
{
return (int)strtol(nptr, NULL, 10);
}
#else
#define atoi(nptr) ((int)strtol((nptr), NULL, 10)) #define atoi(nptr) ((int)strtol((nptr), NULL, 10))
#endif
#ifdef __cplusplus
inline int atol(FAR const char *nptr)
{
return strtol(nptr, NULL, 10);
}
#else
#define atol(nptr) strtol((nptr), NULL, 10) #define atol(nptr) strtol((nptr), NULL, 10)
#endif
#ifdef CONFIG_HAVE_LONG_LONG #ifdef CONFIG_HAVE_LONG_LONG
#ifdef __cplusplus
inline long long atoll(FAR const char *nptr)
{
return strtoll(nptr, NULL, 10);
}
#else
#define atoll(nptr) strtoll((nptr), NULL, 10) #define atoll(nptr) strtoll((nptr), NULL, 10)
#endif #endif
#endif
#ifdef CONFIG_HAVE_DOUBLE #ifdef CONFIG_HAVE_DOUBLE
#ifdef __cplusplus
inline double atof(FAR const char *nptr)
{
return strtod(nptr, NULL);
}
#else
#define atof(nptr) strtod((nptr), NULL) #define atof(nptr) strtod((nptr), NULL)
#endif #endif
#endif
/* Binary to string conversions */ /* Binary to string conversions */