4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
28 * Use is subject to license terms.
43 #include <sys/types.h>
48 * 32-bit shadow functions _vwprintf_c89(), _vfwprintf_c89(),
49 * _vswprintf_c89() are included here.
50 * When using the c89 compiler to build 32-bit applications, the size
51 * of intmax_t is 32-bits, otherwise the size of intmax_t is 64-bits.
52 * The shadow function uses 32-bit size of intmax_t for j conversion.
53 * The #pragma redefine_extname in <wchar.h> selects the proper routine
54 * at compile time for the user application.
55 * NOTE: shadow functions only exist in the 32-bit library.
59 #ifdef _C89_INTMAX32 /* _C89_INTMAX32 version in 32-bit libc only */
60 _vwprintf_c89(const wchar_t *format
, va_list ap
)
62 vwprintf(const wchar_t *format
, va_list ap
)
68 FLOCKFILE(lk
, stdout
);
70 if (GET_NO_MODE(stdout
))
71 _setorientation(stdout
, _WC_MODE
);
72 if (!(stdout
->_flag
& _IOWRT
)) {
73 /* if no write flag */
74 if (stdout
->_flag
& _IORW
) {
75 /* if ok, cause read-write */
76 stdout
->_flag
|= _IOWRT
;
85 count
= _wndoprnt(format
, ap
, stdout
, _F_INTMAX32
);
87 count
= _wndoprnt(format
, ap
, stdout
, 0);
88 #endif /* _C89_INTMAX32 */
90 if (FERROR(stdout
) || count
== EOF
) {
95 /* check for overflow */
96 if ((size_t)count
> MAXINT
) {
105 #ifdef _C89_INTMAX32 /* _C89_INTMAX32 version in 32-bit libc only */
106 _vfwprintf_c89(FILE *iop
, const wchar_t *format
, va_list ap
)
108 vfwprintf(FILE *iop
, const wchar_t *format
, va_list ap
)
116 if (GET_NO_MODE(iop
))
117 _setorientation(iop
, _WC_MODE
);
119 if (!(iop
->_flag
& _IOWRT
)) {
120 /* if no write flag */
121 if (iop
->_flag
& _IORW
) {
122 /* if ok, cause read-write */
123 iop
->_flag
|= _IOWRT
;
132 count
= _wndoprnt(format
, ap
, iop
, _F_INTMAX32
);
134 count
= _wndoprnt(format
, ap
, iop
, 0);
136 if (FERROR(iop
) || count
== EOF
) {
141 /* check for overflow */
142 if ((size_t)count
> MAXINT
) {
151 #ifdef _C89_INTMAX32 /* _C89_INTMAX32 version in 32-bit libc only */
152 _vswprintf_c89(wchar_t *string
, size_t n
, const wchar_t *format
, va_list ap
)
154 vswprintf(wchar_t *string
, size_t n
, const wchar_t *format
, va_list ap
)
164 siop
._cnt
= (ssize_t
)n
- 1;
165 siop
._base
= siop
._ptr
= (unsigned char *)string
;
166 siop
._flag
= _IOREAD
;
169 count
= _wndoprnt(format
, ap
, &siop
, _F_INTMAX32
);
171 count
= _wndoprnt(format
, ap
, &siop
, 0);
173 wp
= (wchar_t *)(uintptr_t)siop
._ptr
;
178 /* check for overflow */
179 if ((size_t)count
> MAXINT
) {