strtoi.c revision 1.3
11.3Sroy/*	$NetBSD: strtoi.c,v 1.3 2019/11/28 12:33:23 roy Exp $	*/
21.1Schristos
31.1Schristos/*-
41.1Schristos * Copyright (c) 2005 The DragonFly Project.  All rights reserved.
51.1Schristos * Copyright (c) 2003 Citrus Project,
61.1Schristos * All rights reserved.
71.1Schristos *
81.1Schristos * Redistribution and use in source and binary forms, with or without
91.1Schristos * modification, are permitted provided that the following conditions
101.1Schristos * are met:
111.1Schristos * 1. Redistributions of source code must retain the above copyright
121.1Schristos *    notice, this list of conditions and the following disclaimer.
131.1Schristos * 2. Redistributions in binary form must reproduce the above copyright
141.1Schristos *    notice, this list of conditions and the following disclaimer in the
151.1Schristos *    documentation and/or other materials provided with the distribution.
161.1Schristos *
171.1Schristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
181.1Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191.1Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201.1Schristos * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
211.1Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221.1Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231.1Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241.1Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251.1Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261.1Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271.1Schristos * SUCH DAMAGE.
281.1Schristos *
291.1Schristos * Created by Kamil Rytarowski, based on ID:
301.1Schristos * NetBSD: src/common/lib/libc/stdlib/strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp
311.1Schristos */
321.1Schristos
331.3Sroy#if defined(HAVE_NBTOOL_CONFIG_H) && HAVE_NBTOOL_CONFIG_H
341.1Schristos#include "nbtool_config.h"
351.1Schristos#endif
361.1Schristos
371.1Schristos#include <sys/cdefs.h>
381.3Sroy__RCSID("$NetBSD: strtoi.c,v 1.3 2019/11/28 12:33:23 roy Exp $");
391.2Schristos
401.2Schristos#ifdef _LIBC
411.2Schristos#include "namespace.h"
421.2Schristos#endif
431.1Schristos
441.1Schristos#if defined(_KERNEL)
451.1Schristos#include <sys/param.h>
461.1Schristos#include <sys/types.h>
471.1Schristos#include <lib/libkern/libkern.h>
481.1Schristos#elif defined(_STANDALONE)
491.1Schristos#include <sys/param.h>
501.1Schristos#include <sys/types.h>
511.1Schristos#include <lib/libkern/libkern.h>
521.1Schristos#include <lib/libsa/stand.h>
531.1Schristos#else
541.1Schristos#include <stddef.h>
551.1Schristos#include <assert.h>
561.1Schristos#include <errno.h>
571.1Schristos#include <inttypes.h>
581.1Schristos#endif
591.1Schristos
601.1Schristos#define	_FUNCNAME	strtoi
611.1Schristos#define	__TYPE		intmax_t
621.1Schristos#define	__WRAPPED	strtoimax
631.1Schristos
641.1Schristos#include "_strtoi.h"
651.2Schristos
661.2Schristos#ifdef _LIBC
671.2Schristos__weak_alias(strtoi, _strtoi)
681.2Schristos__weak_alias(strtoi_l, _strtoi_l)
691.1Schristos#endif
70