source: rtems/cpukit/libmisc/stringto/stringtolongdouble.c @ cc2bcea4

4.10
Last change on this file since cc2bcea4 was cc2bcea4, checked in by cvs2git <rtems-devel@…>, on 02/01/11 at 05:48:31

This commit was manufactured by cvs2svn to create branch
'rtems-4-10-branch'.

Cherrypick from master 2011-02-01 05:48:30 UTC Ralf Corsepius <ralf.corsepius@…> '2011-02-01 Ralf Corsepius <ralf.corsepius@…>':

cpukit/libmisc/stringto/stringtolongdouble.c
testsuites/libtests/POSIX/htonl.c
testsuites/libtests/math/.cvsignore
testsuites/libtests/math/Makefile.am
testsuites/libtests/math/domath.c
testsuites/libtests/math/domath.in
testsuites/libtests/math/domathf.c
testsuites/libtests/math/domathl.c
testsuites/libtests/math/init.c

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <errno.h>
19#include <stdlib.h>
20#include <math.h>
21
22#include <rtems/stringto.h>
23
24/*
25 *  Instantiate an error checking wrapper for strtod (double)
26 */
27
28rtems_status_code rtems_string_to_long_double (
29  const char *s,
30  long double *n,
31  char **endptr
32)
33{
34  long double result;
35  char *end;
36
37  if ( !n )
38    return RTEMS_INVALID_ADDRESS;
39
40  errno = 0;
41  *n = 0;
42
43  result = strtold( s, &end );
44
45  if ( endptr )
46    *endptr = end;
47
48  if ( end == s )
49    return RTEMS_NOT_DEFINED;
50
51  if ( ( errno == ERANGE ) &&
52    (( result == 0 ) || ( result == HUGE_VALL ) || ( result == -HUGE_VALL )))
53      return RTEMS_INVALID_NUMBER;
54
55  *n = result;
56
57  return RTEMS_SUCCESSFUL;
58}
Note: See TracBrowser for help on using the repository browser.