File indexing completed on 2025-05-11 08:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifdef HAVE_CONFIG_H
0021 #include "config.h"
0022 #endif
0023
0024 #include <errno.h>
0025 #include <stdlib.h>
0026 #include <math.h>
0027
0028 #include <rtems/stringto.h>
0029
0030
0031
0032
0033
0034 rtems_status_code rtems_string_to_long_double (
0035 const char *s,
0036 long double *n,
0037 char **endptr
0038 )
0039 {
0040 long double result;
0041 char *end;
0042
0043 if ( !n )
0044 return RTEMS_INVALID_ADDRESS;
0045
0046 errno = 0;
0047 *n = 0;
0048
0049 result = strtold( s, &end );
0050
0051 if ( endptr )
0052 *endptr = end;
0053
0054 if ( end == s )
0055 return RTEMS_NOT_DEFINED;
0056
0057 if ( ( errno == ERANGE ) &&
0058 (( result == 0 ) || ( result == HUGE_VALL ) || ( result == -HUGE_VALL )))
0059 return RTEMS_INVALID_NUMBER;
0060
0061 *n = result;
0062
0063 return RTEMS_SUCCESSFUL;
0064 }