xref: /netbsd-src/common/lib/libc/stdlib/strtoll.c (revision a67fde035671e323b0b50374f03950beac2f97f2)
1*a67fde03Sjoerg /* $NetBSD: strtoll.c,v 1.7 2013/04/16 21:44:06 joerg Exp $ */
282fd1ebbSthorpej 
382fd1ebbSthorpej /*-
4245e0863Sjoerg  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.
5245e0863Sjoerg  * Copyright (c) 2003 Citrus Project,
6245e0863Sjoerg  * All rights reserved.
782fd1ebbSthorpej  *
882fd1ebbSthorpej  * Redistribution and use in source and binary forms, with or without
982fd1ebbSthorpej  * modification, are permitted provided that the following conditions
1082fd1ebbSthorpej  * are met:
1182fd1ebbSthorpej  * 1. Redistributions of source code must retain the above copyright
1282fd1ebbSthorpej  *    notice, this list of conditions and the following disclaimer.
1382fd1ebbSthorpej  * 2. Redistributions in binary form must reproduce the above copyright
1482fd1ebbSthorpej  *    notice, this list of conditions and the following disclaimer in the
1582fd1ebbSthorpej  *    documentation and/or other materials provided with the distribution.
1682fd1ebbSthorpej  *
17245e0863Sjoerg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1882fd1ebbSthorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1982fd1ebbSthorpej  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20245e0863Sjoerg  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2182fd1ebbSthorpej  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2282fd1ebbSthorpej  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2382fd1ebbSthorpej  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2482fd1ebbSthorpej  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2582fd1ebbSthorpej  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2682fd1ebbSthorpej  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2782fd1ebbSthorpej  * SUCH DAMAGE.
2882fd1ebbSthorpej  */
2982fd1ebbSthorpej 
30e74fc2a1Sdogcow #if HAVE_NBTOOL_CONFIG_H
31e74fc2a1Sdogcow #include "nbtool_config.h"
32e74fc2a1Sdogcow #endif
33e74fc2a1Sdogcow 
34245e0863Sjoerg #include <sys/cdefs.h>
35*a67fde03Sjoerg __RCSID("$NetBSD: strtoll.c,v 1.7 2013/04/16 21:44:06 joerg Exp $");
36331139bdSmatt 
37331139bdSmatt #ifdef _LIBC
38331139bdSmatt #include "namespace.h"
39331139bdSmatt #endif
4082fd1ebbSthorpej 
415577c7fcSoster #if defined(_KERNEL)
425577c7fcSoster #include <sys/param.h>
435577c7fcSoster #include <lib/libkern/libkern.h>
445577c7fcSoster #elif defined(_STANDALONE)
455577c7fcSoster #include <sys/param.h>
465577c7fcSoster #include <lib/libkern/libkern.h>
475577c7fcSoster #include <lib/libsa/stand.h>
485577c7fcSoster #else
4982fd1ebbSthorpej #include <assert.h>
5082fd1ebbSthorpej #include <ctype.h>
5182fd1ebbSthorpej #include <errno.h>
5282fd1ebbSthorpej #include <limits.h>
53245e0863Sjoerg #include <stdint.h>
5482fd1ebbSthorpej #include <stdlib.h>
5582fd1ebbSthorpej #endif
5682fd1ebbSthorpej 
57245e0863Sjoerg #define	_FUNCNAME	strtoll
58245e0863Sjoerg #define	__INT		long long
59245e0863Sjoerg #define	__INT_MIN	LLONG_MIN
60245e0863Sjoerg #define	__INT_MAX	LLONG_MAX
6182fd1ebbSthorpej 
62245e0863Sjoerg #include "_strtol.h"
6382fd1ebbSthorpej 
64331139bdSmatt #ifdef _LIBC
65331139bdSmatt __weak_alias(strtoll, _strtoll)
66*a67fde03Sjoerg __weak_alias(strtoll_l, _strtoll_l)
6782fd1ebbSthorpej #endif
68