xref: /netbsd-src/common/lib/libc/stdlib/strtoi.c (revision 8569e6d26fd29f294d57556215236cd14140710c)
1*8569e6d2Sroy /*	$NetBSD: strtoi.c,v 1.3 2019/11/28 12:33:23 roy Exp $	*/
2368192c4Schristos 
3368192c4Schristos /*-
4368192c4Schristos  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.
5368192c4Schristos  * Copyright (c) 2003 Citrus Project,
6368192c4Schristos  * All rights reserved.
7368192c4Schristos  *
8368192c4Schristos  * Redistribution and use in source and binary forms, with or without
9368192c4Schristos  * modification, are permitted provided that the following conditions
10368192c4Schristos  * are met:
11368192c4Schristos  * 1. Redistributions of source code must retain the above copyright
12368192c4Schristos  *    notice, this list of conditions and the following disclaimer.
13368192c4Schristos  * 2. Redistributions in binary form must reproduce the above copyright
14368192c4Schristos  *    notice, this list of conditions and the following disclaimer in the
15368192c4Schristos  *    documentation and/or other materials provided with the distribution.
16368192c4Schristos  *
17368192c4Schristos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18368192c4Schristos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19368192c4Schristos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20368192c4Schristos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21368192c4Schristos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22368192c4Schristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23368192c4Schristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24368192c4Schristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25368192c4Schristos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26368192c4Schristos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27368192c4Schristos  * SUCH DAMAGE.
28368192c4Schristos  *
29368192c4Schristos  * Created by Kamil Rytarowski, based on ID:
30368192c4Schristos  * NetBSD: src/common/lib/libc/stdlib/strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp
31368192c4Schristos  */
32368192c4Schristos 
33*8569e6d2Sroy #if defined(HAVE_NBTOOL_CONFIG_H) && HAVE_NBTOOL_CONFIG_H
34368192c4Schristos #include "nbtool_config.h"
35368192c4Schristos #endif
36368192c4Schristos 
37368192c4Schristos #include <sys/cdefs.h>
38*8569e6d2Sroy __RCSID("$NetBSD: strtoi.c,v 1.3 2019/11/28 12:33:23 roy Exp $");
3935d355f3Schristos 
4035d355f3Schristos #ifdef _LIBC
4135d355f3Schristos #include "namespace.h"
4235d355f3Schristos #endif
43368192c4Schristos 
44368192c4Schristos #if defined(_KERNEL)
45368192c4Schristos #include <sys/param.h>
46368192c4Schristos #include <sys/types.h>
47368192c4Schristos #include <lib/libkern/libkern.h>
48368192c4Schristos #elif defined(_STANDALONE)
49368192c4Schristos #include <sys/param.h>
50368192c4Schristos #include <sys/types.h>
51368192c4Schristos #include <lib/libkern/libkern.h>
52368192c4Schristos #include <lib/libsa/stand.h>
53368192c4Schristos #else
54368192c4Schristos #include <stddef.h>
55368192c4Schristos #include <assert.h>
56368192c4Schristos #include <errno.h>
57368192c4Schristos #include <inttypes.h>
58368192c4Schristos #endif
59368192c4Schristos 
60368192c4Schristos #define	_FUNCNAME	strtoi
61368192c4Schristos #define	__TYPE		intmax_t
62368192c4Schristos #define	__WRAPPED	strtoimax
63368192c4Schristos 
64368192c4Schristos #include "_strtoi.h"
6535d355f3Schristos 
6635d355f3Schristos #ifdef _LIBC
6735d355f3Schristos __weak_alias(strtoi, _strtoi)
6835d355f3Schristos __weak_alias(strtoi_l, _strtoi_l)
69368192c4Schristos #endif
70