aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorwelinder@troll.com <welinder@troll.com>2004-08-12 14:59:07 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:02:42 -0700
commit14cc09a4c7f79edca01b7bb5b10604418eb55fea (patch)
treefbd4440d1540743318a0881e0ef313a92b18f256
parentc873994b241acb1e6532288b5dee1db6c5eb56ab (diff)
downloadsparse-dev-14cc09a4c7f79edca01b7bb5b10604418eb55fea.tar.gz
lib.c, lib.h:
Under __sun__, implement a strtold.
-rw-r--r--lib.c32
-rw-r--r--lib.h4
2 files changed, 36 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 128ff775..aacce449 100644
--- a/lib.c
+++ b/lib.c
@@ -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
diff --git a/lib.h b/lib.h
index db6a8f4a..a04680cb 100644
--- a/lib.h
+++ b/lib.h
@@ -133,6 +133,10 @@ extern int preprocess_only;
extern void create_builtin_stream(void);
+#ifdef __sun__
+extern long double strtold (char const *str, char **end);
+#endif
+
static inline int symbol_list_size(struct symbol_list* list)
{
return ptr_list_size((struct ptr_list *)(list));