kernel: fix a type bug handling err_cast()
[smatch.git] / compat-solaris.c
blob7253a892d50daaaf88b7be11e60526753ff77ea1
1 #include "lib.h"
2 #include "allocate.h"
4 #include "compat/mmap-blob.c"
6 #include <floatingpoint.h>
7 #include <limits.h>
8 #include <errno.h>
10 long double string_to_ld(const char *str, char **endptr)
12 long double res;
13 decimal_record dr;
14 enum decimal_string_form form;
15 decimal_mode dm;
16 fp_exception_field_type excp;
17 char *echar;
19 string_to_decimal ((char **)&str, INT_MAX, 0,
20 &dr, &form, &echar);
21 if (endptr) *endptr = (char *)str;
23 if (form == invalid_form) {
24 errno = EINVAL;
25 return 0.0;
28 dm.rd = fp_nearest;
29 decimal_to_quadruple (&res, &dm, &dr, &excp);
30 if (excp & ((1 << fp_overflow) | (1 << fp_underflow)))
31 errno = ERANGE;
32 return res;