xref: /onnv-gate/usr/src/lib/libc/port/i18n/wcstoimax.c (revision 6812:febeba71273d)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*6812Sraf  * Common Development and Distribution License (the "License").
6*6812Sraf  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211219Sraf 
220Sstevel@tonic-gate /*
23*6812Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
280Sstevel@tonic-gate 
29*6812Sraf #include "lint.h"
300Sstevel@tonic-gate #include <stddef.h>
310Sstevel@tonic-gate #include <inttypes.h>
320Sstevel@tonic-gate #include <wchar.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate /*
350Sstevel@tonic-gate  * In _LP64
360Sstevel@tonic-gate  *	intmax_t and uintmax_t are always equivalent to
370Sstevel@tonic-gate  *	int64_t and uint64_t, respectively.
380Sstevel@tonic-gate  *
390Sstevel@tonic-gate  * In _ILP32
400Sstevel@tonic-gate  *	intmax_t and uintmax_t are equivalent to int64_t and uint64_t,
410Sstevel@tonic-gate  *	respectively, when the following both conditions become
420Sstevel@tonic-gate  *	true:
430Sstevel@tonic-gate  *		- strict c89 mode is not used
440Sstevel@tonic-gate  *		- _NO_LONGLONG is not defined
450Sstevel@tonic-gate  *	Otherwise, intmax_t and uintmax_t are equivalent to
460Sstevel@tonic-gate  *	int32_t and uint32_t, respectively.
470Sstevel@tonic-gate  *
480Sstevel@tonic-gate  * libc is compiled neither in strict-c89 mode nor is _NO_LONGLONG
490Sstevel@tonic-gate  * defined.
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate 
520Sstevel@tonic-gate /* for int64_t instance */
530Sstevel@tonic-gate intmax_t
wcstoimax(const wchar_t * nptr,wchar_t ** endptr,int base)540Sstevel@tonic-gate wcstoimax(const wchar_t *nptr, wchar_t **endptr, int base)
550Sstevel@tonic-gate {
560Sstevel@tonic-gate 	return ((intmax_t)wcstoll(nptr, endptr, base));
570Sstevel@tonic-gate }
580Sstevel@tonic-gate 
590Sstevel@tonic-gate /* for uint64_t instance */
600Sstevel@tonic-gate uintmax_t
wcstoumax(const wchar_t * nptr,wchar_t ** endptr,int base)610Sstevel@tonic-gate wcstoumax(const wchar_t *nptr, wchar_t **endptr, int base)
620Sstevel@tonic-gate {
630Sstevel@tonic-gate 	return ((uintmax_t)wcstoull(nptr, endptr, base));
640Sstevel@tonic-gate }
650Sstevel@tonic-gate 
660Sstevel@tonic-gate #if	!defined(_LP64)
670Sstevel@tonic-gate /* for int32_t instance */
680Sstevel@tonic-gate int32_t
_wcstoimax_c89(const wchar_t * nptr,wchar_t ** endptr,int base)690Sstevel@tonic-gate _wcstoimax_c89(const wchar_t *nptr, wchar_t **endptr, int base)
700Sstevel@tonic-gate {
710Sstevel@tonic-gate 	return ((int32_t)wcstol(nptr, endptr, base));
720Sstevel@tonic-gate }
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /* for int32_t instance */
750Sstevel@tonic-gate uint32_t
_wcstoumax_c89(const wchar_t * nptr,wchar_t ** endptr,int base)760Sstevel@tonic-gate _wcstoumax_c89(const wchar_t *nptr, wchar_t **endptr, int base)
770Sstevel@tonic-gate {
780Sstevel@tonic-gate 	return ((uint32_t)wcstoul(nptr, endptr, base));
790Sstevel@tonic-gate }
800Sstevel@tonic-gate #endif
81