xref: /titanic_41/usr/src/lib/libc/inc/file64.h (revision b509e89b2befbaa42939abad9da1d7f5a8c6aaae)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * This is the header where the internal to libc definition of the FILE
29  * structure is defined. The exrernal defintion defines the FILE structure
30  * as an array of longs. This prevents customers from writing code that
31  * depends upon the implemnetation of stdio. The __fbufsize(3C) man page
32  * documents a set of routines that customers can use so that they do not
33  * need access to the FILE structure.
34  *
35  * When compiling libc this file MUST be included BEFORE <stdio.h>, and
36  * any other headers that themselves directly or indirectly include
37  * <stdio.h>. Failure to do so, will cause the compile of libc to fail,
38  * since the structure members will not be visible to the stdio routines.
39  */
40 
41 #ifndef	_FILE64_H
42 #define	_FILE64_H
43 
44 #pragma ident	"%Z%%M%	%I%	%E% SMI"
45 
46 #include <synch.h>
47 #include <stdio_tag.h>
48 #include <wchar_impl.h>
49 
50 #ifdef	__cplusplus
51 extern "C" {
52 #endif
53 
54 #ifndef	_MBSTATE_T
55 #define	_MBSTATE_T
56 typedef __mbstate_t	mbstate_t;
57 #endif
58 
59 #define	rmutex_t	mutex_t
60 
61 #ifdef	_LP64
62 
63 struct __FILE_TAG {
64 	unsigned char	*_ptr;	/* next character from/to here in buffer */
65 	unsigned char	*_base;	/* the buffer */
66 	unsigned char	*_end;	/* the end of the buffer */
67 	ssize_t		_cnt;	/* number of available characters in buffer */
68 	int		_file;	/* UNIX System file descriptor */
69 	unsigned int	_flag;	/* the state of the stream */
70 	rmutex_t	_lock;	/* lock for this structure */
71 	mbstate_t	_state;	/* mbstate_t */
72 	char		__fill[32];	/* filler to bring size to 128 bytes */
73 };
74 
75 #else
76 
77 /*
78  * Stuff missing from our 32-bit FILE struct.
79  */
80 struct xFILEdata {
81 	uintptr_t	_magic;	/* Check: magic number, must be first */
82 	unsigned char	*_end;	/* the end of the buffer */
83 	rmutex_t	_lock;	/* lock for this structure */
84 	mbstate_t	_state;	/* mbstate_t */
85 	int		_altfd;	/* alternate fd if > 255 */
86 };
87 
88 #define	XFILEINITIALIZER	{ 0, NULL, RECURSIVEMUTEX, DEFAULTMBSTATE }
89 
90 #endif	/*	_LP64	*/
91 
92 #ifdef	__cplusplus
93 }
94 #endif
95 
96 #endif	/* _FILE64_H */
97