Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdlib / atoi.c
blob4da53e80ac9b6bdb30afedaae0fafa772827d9fe
1 /*
2 FUNCTION
3 <<atoi>>, <<atol>>---string to integer
5 INDEX
6 atoi
7 INDEX
8 atol
9 INDEX
10 _atoi_r
11 INDEX
12 _atol_r
14 SYNOPSIS
15 #include <stdlib.h>
16 int atoi(const char *<[s]>);
17 long atol(const char *<[s]>);
18 int _atoi_r(struct _reent *<[ptr]>, const char *<[s]>);
19 long _atol_r(struct _reent *<[ptr]>, const char *<[s]>);
21 DESCRIPTION
22 <<atoi>> converts the initial portion of a string to an <<int>>.
23 <<atol>> converts the initial portion of a string to a <<long>>.
25 <<atoi(s)>> is implemented as <<(int)strtol(s, NULL, 10).>>
26 <<atol(s)>> is implemented as <<strtol(s, NULL, 10).>>
28 <<_atoi_r>> and <<_atol_r>> are reentrant versions of <<atoi>> and
29 <<atol>> respectively, passing the reentrancy struct pointer.
31 RETURNS
32 The functions return the converted value, if any. If no conversion was
33 made, <<0>> is returned.
35 PORTABILITY
36 <<atoi>>, <<atol>> are ANSI.
38 No supporting OS subroutines are required.
42 * Andy Wilson, 2-Oct-89.
45 #include <stdlib.h>
46 #include <_ansi.h>
48 #ifndef _REENT_ONLY
49 int
50 atoi (const char *s)
52 return (int) strtol (s, NULL, 10);
54 #endif /* !_REENT_ONLY */
56 int
57 _atoi_r (struct _reent *ptr,
58 const char *s)
60 return (int) _strtol_r (ptr, s, NULL, 10);