xref: /freebsd/lib/libc/stdlib/atoll.c (revision 3fb3b97c4d38990da5f45b37e48a5110b3e9bc58)
159d01330SAndrey A. Chernov /*
259d01330SAndrey A. Chernov  * Copyright (c) 1988, 1993
359d01330SAndrey A. Chernov  *	The Regents of the University of California.  All rights reserved.
459d01330SAndrey A. Chernov  *
53c87aa1dSDavid Chisnall  * Copyright (c) 2011 The FreeBSD Foundation
63c87aa1dSDavid Chisnall  * All rights reserved.
73c87aa1dSDavid Chisnall  * Portions of this software were developed by David Chisnall
83c87aa1dSDavid Chisnall  * under sponsorship from the FreeBSD Foundation.
93c87aa1dSDavid Chisnall  *
1059d01330SAndrey A. Chernov  * Redistribution and use in source and binary forms, with or without
1159d01330SAndrey A. Chernov  * modification, are permitted provided that the following conditions
1259d01330SAndrey A. Chernov  * are met:
1359d01330SAndrey A. Chernov  * 1. Redistributions of source code must retain the above copyright
1459d01330SAndrey A. Chernov  *    notice, this list of conditions and the following disclaimer.
1559d01330SAndrey A. Chernov  * 2. Redistributions in binary form must reproduce the above copyright
1659d01330SAndrey A. Chernov  *    notice, this list of conditions and the following disclaimer in the
1759d01330SAndrey A. Chernov  *    documentation and/or other materials provided with the distribution.
18*3fb3b97cSEd Maste  * 3. Neither the name of the University nor the names of its contributors
1959d01330SAndrey A. Chernov  *    may be used to endorse or promote products derived from this software
2059d01330SAndrey A. Chernov  *    without specific prior written permission.
2159d01330SAndrey A. Chernov  *
2259d01330SAndrey A. Chernov  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2359d01330SAndrey A. Chernov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2459d01330SAndrey A. Chernov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2559d01330SAndrey A. Chernov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2659d01330SAndrey A. Chernov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2759d01330SAndrey A. Chernov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2859d01330SAndrey A. Chernov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2959d01330SAndrey A. Chernov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3059d01330SAndrey A. Chernov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3159d01330SAndrey A. Chernov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3259d01330SAndrey A. Chernov  * SUCH DAMAGE.
3359d01330SAndrey A. Chernov  */
3459d01330SAndrey A. Chernov 
35333fc21eSDavid E. O'Brien #include <sys/cdefs.h>
36333fc21eSDavid E. O'Brien __FBSDID("$FreeBSD$");
37333fc21eSDavid E. O'Brien 
3859d01330SAndrey A. Chernov #include <stdlib.h>
393c87aa1dSDavid Chisnall #include <xlocale.h>
4059d01330SAndrey A. Chernov 
4159d01330SAndrey A. Chernov long long
4259d01330SAndrey A. Chernov atoll(str)
4359d01330SAndrey A. Chernov 	const char *str;
4459d01330SAndrey A. Chernov {
45f7388e0dSAndrey A. Chernov 	return strtoll(str, (char **)NULL, 10);
4659d01330SAndrey A. Chernov }
473c87aa1dSDavid Chisnall 
483c87aa1dSDavid Chisnall long long
493c87aa1dSDavid Chisnall atoll_l(str, locale)
503c87aa1dSDavid Chisnall 	const char *str;
513c87aa1dSDavid Chisnall 	locale_t locale;
523c87aa1dSDavid Chisnall {
533c87aa1dSDavid Chisnall 	return strtoll_l(str, (char **)NULL, 10, locale);
543c87aa1dSDavid Chisnall }
55