Simplify constant unops
[smatch.git] / compat-solaris.c
blob62a7714b220682e211611b634a958e16db1f0a8f
1 #include "lib.h"
2 #include "allocate.h"
4 #include "compat/id-files-stat.c"
5 #include "compat/mmap-blob.c"
8 #include <floatingpoint.h>
9 #include <limits.h>
10 #include <errno.h>
12 long double string_to_ld(const char *str, char **endptr)
14 long double res;
15 decimal_record dr;
16 enum decimal_string_form form;
17 decimal_mode dm;
18 fp_exception_field_type excp;
19 char *echar;
21 string_to_decimal ((char **)&str, INT_MAX, 0,
22 &dr, &form, &echar);
23 if (endptr) *endptr = (char *)str;
25 if (form == invalid_form) {
26 errno = EINVAL;
27 return 0.0;
30 dm.rd = fp_nearest;
31 decimal_to_quadruple (&res, &dm, &dr, &excp);
32 if (excp & ((1 << fp_overflow) | (1 << fp_underflow)))
33 errno = ERANGE;
34 return res;