diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2002-05-12 16:58:16 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2002-05-12 16:58:16 +0000 |
commit | 54727a5dc42fdfc0b45e0ff1e943fa20ded72914 (patch) | |
tree | 9fe14f5600c897a7b6fbae5eabf961e97ef60903 /libc/stdlib/stdlib.c | |
parent | 9277ed9a95f73c3eaef4b41236e222cf23609a17 (diff) |
Revert Erik's previous patch and fix what I believe he was trying to, while
preserving the space-saving aliases.
Diffstat (limited to 'libc/stdlib/stdlib.c')
-rw-r--r-- | libc/stdlib/stdlib.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c index d909417be..1cd350c31 100644 --- a/libc/stdlib/stdlib.c +++ b/libc/stdlib/stdlib.c @@ -35,12 +35,32 @@ #include <assert.h> #include <unistd.h> -/* Work around gcc's refusal to create aliases. */ +/* Work around gcc's refusal to create aliases. + * TODO: Add in a define to disable the aliases? */ + +#if UINT_MAX == ULONG_MAX #define atoi __ignore_atoi #define abs __ignore_abs +#endif +#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX) +#define llabs __ignore_llabs +#define atoll __ignore_atoll +#define strtoll __ignore_strtoll +#define strtoull __ignore_strtoull +#endif + #include <stdlib.h> + +#if UINT_MAX == ULONG_MAX #undef atoi #undef abs +#endif +#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX) +#undef llabs +#undef atoll +#undef strtoll +#undef strtoull +#endif extern unsigned long _stdlib_strto_l(register const char * __restrict str, @@ -82,10 +102,7 @@ strong_alias(labs,abs) #endif #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX) -long long int llabs (long long int j) -{ - return (j >= 0) ? j : -j; -} +strong_alias(labs,llabs) #endif #if ULONG_MAX == UINTMAX_MAX @@ -136,10 +153,7 @@ strong_alias(atol,atoi) #endif #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX) -long long int atoll (const char *nptr) -{ - return strtol(nptr, (char **) NULL, 10); -} +strong_alias(atol,atoll) #endif long atol(const char *nptr) @@ -169,16 +183,14 @@ strong_alias(strtol,strtoimax) #endif #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX) -long long int strtoll (__const char *__restrict str, char **__restrict endptr, int base) -{ - return _stdlib_strto_l(str, endptr, base, 1); -} +strong_alias(strtol,strtoll) #endif long strtol(const char * __restrict str, char ** __restrict endptr, int base) { return _stdlib_strto_l(str, endptr, base, 1); } + #endif /**********************************************************************/ #ifdef L_strtoll @@ -206,15 +218,11 @@ strong_alias(strtoul,strtoumax) #endif #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX) -unsigned long long int strtoull (__const char *__restrict str, - char **__restrict endptr, int base) -{ - return _stdlib_strto_l(str, endptr, base, 0); -} +strong_alias(strtoul,strtoull) #endif -unsigned long strtoul(const char * __restrict str, - char ** __restrict endptr, int base) +unsigned long strtoul(const char * __restrict str, + char ** __restrict endptr, int base) { return _stdlib_strto_l(str, endptr, base, 0); } |