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.
44 #include <sys/types.h>
49 * 32-bit shadow functions _wprintf_c89(), _fwprintf_c89(), _swprintf_c89()
51 * When using the c89 compiler to build 32-bit applications, the size
52 * of intmax_t is 32-bits, otherwise the size of intmax_t is 64-bits.
53 * The shadow function uses 32-bit size of intmax_t for j conversion.
54 * The #pragma redefine_extname in <stdio.h> selects the proper routine
55 * at compile time for the user application.
56 * NOTE: the shadow functions only exist in the 32-bit library.
60 wprintf(const wchar_t *format
, ...)
67 FLOCKFILE(lk
, stdout
);
69 if (GET_NO_MODE(stdout
))
70 _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
, 0);
87 if (FERROR(stdout
) || count
== EOF
) {
92 /* check for overflow */
93 if ((size_t)count
> MAXINT
) {
102 fwprintf(FILE *iop
, const wchar_t *format
, ...)
108 va_start(ap
, format
);
112 if (GET_NO_MODE(iop
))
113 _setorientation(iop
, _WC_MODE
);
115 if (!(iop
->_flag
& _IOWRT
)) {
116 /* if no write flag */
117 if (iop
->_flag
& _IORW
) {
118 /* if ok, cause read-write */
119 iop
->_flag
|= _IOWRT
;
128 count
= _wndoprnt(format
, ap
, iop
, 0);
130 if (FERROR(iop
) || count
== EOF
) {
135 /* check for overflow */
136 if ((size_t)count
> MAXINT
) {
145 swprintf(wchar_t *string
, size_t n
, const wchar_t *format
, ...)
154 siop
._cnt
= (ssize_t
)n
- 1;
155 siop
._base
= siop
._ptr
= (unsigned char *)string
;
156 siop
._flag
= _IOREAD
;
158 va_start(ap
, format
);
159 count
= _wndoprnt(format
, ap
, &siop
, 0);
161 wp
= (wchar_t *)(uintptr_t)siop
._ptr
;
166 /* check for overflow */
167 if ((size_t)count
> MAXINT
) {
178 _wprintf_c89(const wchar_t *format
, ...)
183 va_start(ap
, format
);
184 count
= _vwprintf_c89(format
, ap
);
190 _fwprintf_c89(FILE *iop
, const wchar_t *format
, ...)
195 va_start(ap
, format
);
196 count
= _vfwprintf_c89(iop
, format
, ap
);
202 _swprintf_c89(wchar_t *string
, size_t n
, const wchar_t *format
, ...)
207 va_start(ap
, format
);
208 count
= _vswprintf_c89(string
, n
, format
, ap
);