xref: /illumos-gate/usr/src/lib/libc/inc/file64.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1997-2003 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 };
86 
87 #define	XFILEINITIALIZER	{ 0, NULL, RECURSIVEMUTEX, DEFAULTMBSTATE }
88 
89 #endif	/*	_LP64	*/
90 
91 #ifdef	__cplusplus
92 }
93 #endif
94 
95 #endif	/* _FILE64_H */
96