168349Sobrien/*	$NetBSD: atoi.c,v 1.15 2018/06/13 09:38:32 eadler Exp $	*/
268349Sobrien
3267843Sdelphij/*
468349Sobrien * Copyright (c) 1988, 1993
568349Sobrien *	The Regents of the University of California.  All rights reserved.
668349Sobrien *
768349Sobrien * Redistribution and use in source and binary forms, with or without
868349Sobrien * modification, are permitted provided that the following conditions
968349Sobrien * are met:
10267843Sdelphij * 1. Redistributions of source code must retain the above copyright
11267843Sdelphij *    notice, this list of conditions and the following disclaimer.
1268349Sobrien * 2. Redistributions in binary form must reproduce the above copyright
13267843Sdelphij *    notice, this list of conditions and the following disclaimer in the
1468349Sobrien *    documentation and/or other materials provided with the distribution.
1568349Sobrien * 3. Neither the name of the University nor the names of its contributors
1668349Sobrien *    may be used to endorse or promote products derived from this software
1768349Sobrien *    without specific prior written permission.
1868349Sobrien *
19267843Sdelphij * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2068349Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2168349Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2268349Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2368349Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24267843Sdelphij * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2568349Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2668349Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27267843Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
33#if defined(LIBC_SCCS) && !defined(lint)
34#if 0
35static char sccsid[] = "@(#)atoi.c	8.1 (Berkeley) 6/4/93";
36#else
37__RCSID("$NetBSD: atoi.c,v 1.15 2018/06/13 09:38:32 eadler Exp $");
38#endif
39#endif /* LIBC_SCCS and not lint */
40
41#include <assert.h>
42#include <stdlib.h>
43
44int
45atoi(const char *str)
46{
47	_DIAGASSERT(str != NULL);
48
49	return((int)strtol(str, NULL, 10));
50}
51