xref: /onnv-gate/usr/src/lib/libc/inc/file64.h (revision 1846:376b8b33ed65)
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*1846Scraigm  * Common Development and Distribution License (the "License").
6*1846Scraigm  * 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  */
21*1846Scraigm 
220Sstevel@tonic-gate /*
23*1846Scraigm  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate /*
280Sstevel@tonic-gate  * This is the header where the internal to libc definition of the FILE
290Sstevel@tonic-gate  * structure is defined. The exrernal defintion defines the FILE structure
300Sstevel@tonic-gate  * as an array of longs. This prevents customers from writing code that
310Sstevel@tonic-gate  * depends upon the implemnetation of stdio. The __fbufsize(3C) man page
320Sstevel@tonic-gate  * documents a set of routines that customers can use so that they do not
330Sstevel@tonic-gate  * need access to the FILE structure.
340Sstevel@tonic-gate  *
350Sstevel@tonic-gate  * When compiling libc this file MUST be included BEFORE <stdio.h>, and
360Sstevel@tonic-gate  * any other headers that themselves directly or indirectly include
370Sstevel@tonic-gate  * <stdio.h>. Failure to do so, will cause the compile of libc to fail,
380Sstevel@tonic-gate  * since the structure members will not be visible to the stdio routines.
390Sstevel@tonic-gate  */
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #ifndef	_FILE64_H
420Sstevel@tonic-gate #define	_FILE64_H
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #include <synch.h>
470Sstevel@tonic-gate #include <stdio_tag.h>
480Sstevel@tonic-gate #include <wchar_impl.h>
490Sstevel@tonic-gate 
500Sstevel@tonic-gate #ifdef	__cplusplus
510Sstevel@tonic-gate extern "C" {
520Sstevel@tonic-gate #endif
530Sstevel@tonic-gate 
540Sstevel@tonic-gate #ifndef	_MBSTATE_T
550Sstevel@tonic-gate #define	_MBSTATE_T
560Sstevel@tonic-gate typedef __mbstate_t	mbstate_t;
570Sstevel@tonic-gate #endif
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #define	rmutex_t	mutex_t
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #ifdef	_LP64
620Sstevel@tonic-gate 
630Sstevel@tonic-gate struct __FILE_TAG {
640Sstevel@tonic-gate 	unsigned char	*_ptr;	/* next character from/to here in buffer */
650Sstevel@tonic-gate 	unsigned char	*_base;	/* the buffer */
660Sstevel@tonic-gate 	unsigned char	*_end;	/* the end of the buffer */
670Sstevel@tonic-gate 	ssize_t		_cnt;	/* number of available characters in buffer */
680Sstevel@tonic-gate 	int		_file;	/* UNIX System file descriptor */
690Sstevel@tonic-gate 	unsigned int	_flag;	/* the state of the stream */
700Sstevel@tonic-gate 	rmutex_t	_lock;	/* lock for this structure */
710Sstevel@tonic-gate 	mbstate_t	_state;	/* mbstate_t */
720Sstevel@tonic-gate 	char		__fill[32];	/* filler to bring size to 128 bytes */
730Sstevel@tonic-gate };
740Sstevel@tonic-gate 
750Sstevel@tonic-gate #else
760Sstevel@tonic-gate 
770Sstevel@tonic-gate /*
780Sstevel@tonic-gate  * Stuff missing from our 32-bit FILE struct.
790Sstevel@tonic-gate  */
800Sstevel@tonic-gate struct xFILEdata {
810Sstevel@tonic-gate 	uintptr_t	_magic;	/* Check: magic number, must be first */
820Sstevel@tonic-gate 	unsigned char	*_end;	/* the end of the buffer */
830Sstevel@tonic-gate 	rmutex_t	_lock;	/* lock for this structure */
840Sstevel@tonic-gate 	mbstate_t	_state;	/* mbstate_t */
85*1846Scraigm 	int		_altfd;	/* alternate fd if > 255 */
860Sstevel@tonic-gate };
870Sstevel@tonic-gate 
880Sstevel@tonic-gate #define	XFILEINITIALIZER	{ 0, NULL, RECURSIVEMUTEX, DEFAULTMBSTATE }
890Sstevel@tonic-gate 
900Sstevel@tonic-gate #endif	/*	_LP64	*/
910Sstevel@tonic-gate 
920Sstevel@tonic-gate #ifdef	__cplusplus
930Sstevel@tonic-gate }
940Sstevel@tonic-gate #endif
950Sstevel@tonic-gate 
960Sstevel@tonic-gate #endif	/* _FILE64_H */
97