diff options
author | welinder@troll.com <welinder@troll.com> | 2004-08-12 14:59:07 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:02:42 -0700 |
commit | 14cc09a4c7f79edca01b7bb5b10604418eb55fea (patch) | |
tree | fbd4440d1540743318a0881e0ef313a92b18f256 /lib.c | |
parent | parse.c: (diff) | |
download | sparse-14cc09a4c7f79edca01b7bb5b10604418eb55fea.tar.gz sparse-14cc09a4c7f79edca01b7bb5b10604418eb55fea.tar.bz2 sparse-14cc09a4c7f79edca01b7bb5b10604418eb55fea.zip |
lib.c, lib.h:
Under __sun__, implement a strtold.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -683,3 +683,35 @@ void create_builtin_stream(void) add_pre_buffer("#define __builtin_va_arg(arg,type) ((type)0)\n"); add_pre_buffer("#define __builtin_va_end(arg)\n"); } + +#ifdef __sun__ +#include <floatingpoint.h> +#include <limits.h> +#include <errno.h> + +long double +strtold (char const *str, char **end) +{ + long double res; + decimal_record dr; + enum decimal_string_form form; + decimal_mode dm; + fp_exception_field_type excp; + char *echar; + + string_to_decimal ((char **)&str, INT_MAX, 0, + &dr, &form, &echar); + if (end) *end = (char *)str; + + if (form == invalid_form) { + errno = EINVAL; + return 0.0; + } + + dm.rd = fp_nearest; + decimal_to_quadruple (&res, &dm, &dr, &excp); + if (excp & ((1 << fp_overflow) | (1 << fp_underflow))) + errno = ERANGE; + return res; +} +#endif |