.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" SUCH DAMAGE.
.\"
.\" @(#)atol.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/stdlib/atol.3,v 1.13 2002/01/09 14:03:54 ru Exp $
+.\" $FreeBSD: src/lib/libc/stdlib/atol.3,v 1.16 2009/03/01 05:44:28 delphij Exp $
.\"
-.Dd November 28, 2001
+.Dd February 1, 2009
.Dt ATOL 3
.Os
.Sh NAME
-.Nm atol , atoll
+.Nm atol , atoll ,
+.Nm atol_l , atoll_l
.Nd convert
.Tn ASCII
string to
.Sh SYNOPSIS
.In stdlib.h
.Ft long
-.Fn atol "const char *nptr"
+.Fn atol "const char *str"
.Ft "long long"
-.Fn atoll "const char *nptr"
+.Fn atoll "const char *str"
+.In xlocale.h
+.Ft long
+.Fn atol_l "const char *str" "locale_t loc"
+.Ft "long long"
+.Fn atoll_l "const char *str" "locale_t loc"
.Sh DESCRIPTION
The
.Fn atol
function converts the initial portion of the string pointed to by
-.Fa nptr
+.Fa str
to
.Vt long
integer
.Pp
It is equivalent to:
.Pp
-.Dl "strtol(nptr, (char **)NULL, 10);"
+.Dl "strtol(str, (char **)NULL, 10);"
.Pp
The
.Fn atoll
function converts the initial portion of the string pointed to by
-.Fa nptr
+.Fa str
to
.Vt "long long"
integer
.Pp
It is equivalent to:
.Pp
-.Dl "strtoll(nptr, (char **)NULL, 10);"
+.Dl "strtoll(str, (char **)NULL, 10);"
+.Pp
+While the
+.Fn atol
+and
+.Fn atoll
+functions use the current locale, the
+.Fn atol_l
+and
+.Fn atoll_l
+functions may be passed locales directly. See
+.Xr xlocale 3
+for more information.
+.Sh IMPLEMENTATION NOTES
+The
+.Fn atol ,
+.Fn atoll ,
+.Fn atol_l ,
+and
+.Fn atoll_l
+functions are thread-safe and async-cancel-safe.
+.Pp
+The
+.Fx
+implementations of the
+.Fn atol
+and
+.Fn atoll
+functions are thin wrappers around
+.Fn strtol
+and
+.Fn stroll
+respectively, so these functions will affect the value of
+.Va errno
+in the same way that the
+.Fn strtol
+and
+.Fn stroll
+functions are able to.
+This behavior of
+.Fn atol
+and
+.Fn atoll
+is not required by
+.St -isoC
+or
+.St -isoC-99 ,
+but it is allowed by all of
+.St -isoC , St -isoC-99
+and
+.St -p1003.1-2001 .
.Sh ERRORS
The functions
.Fn atol
and
.Fn atoll
-need not
-affect the value of
+may affect the value of
.Va errno
on an error.
.Sh SEE ALSO
.Xr atoi 3 ,
.Xr strtod 3 ,
.Xr strtol 3 ,
-.Xr strtoul 3
+.Xr strtoul 3 ,
+.Xr xlocale 3
.Sh STANDARDS
The
.Fn atol