17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5a5f69788Scraigm * Common Development and Distribution License (the "License"). 6a5f69788Scraigm * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21a5f69788Scraigm 227c478bd9Sstevel@tonic-gate /* 23a5f69788Scraigm * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* 28*cd62a92dSRobert Mustacchi * Copyright 2020 Robert Mustacchi 29*cd62a92dSRobert Mustacchi */ 30*cd62a92dSRobert Mustacchi 31*cd62a92dSRobert Mustacchi /* 327c478bd9Sstevel@tonic-gate * This is the header where the internal to libc definition of the FILE 337c478bd9Sstevel@tonic-gate * structure is defined. The exrernal defintion defines the FILE structure 347c478bd9Sstevel@tonic-gate * as an array of longs. This prevents customers from writing code that 357c478bd9Sstevel@tonic-gate * depends upon the implemnetation of stdio. The __fbufsize(3C) man page 367c478bd9Sstevel@tonic-gate * documents a set of routines that customers can use so that they do not 377c478bd9Sstevel@tonic-gate * need access to the FILE structure. 387c478bd9Sstevel@tonic-gate * 397c478bd9Sstevel@tonic-gate * When compiling libc this file MUST be included BEFORE <stdio.h>, and 407c478bd9Sstevel@tonic-gate * any other headers that themselves directly or indirectly include 417c478bd9Sstevel@tonic-gate * <stdio.h>. Failure to do so, will cause the compile of libc to fail, 427c478bd9Sstevel@tonic-gate * since the structure members will not be visible to the stdio routines. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #ifndef _FILE64_H 467c478bd9Sstevel@tonic-gate #define _FILE64_H 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #include <synch.h> 497c478bd9Sstevel@tonic-gate #include <stdio_tag.h> 507c478bd9Sstevel@tonic-gate #include <wchar_impl.h> 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate #ifdef __cplusplus 537c478bd9Sstevel@tonic-gate extern "C" { 547c478bd9Sstevel@tonic-gate #endif 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #ifndef _MBSTATE_T 577c478bd9Sstevel@tonic-gate #define _MBSTATE_T 587c478bd9Sstevel@tonic-gate typedef __mbstate_t mbstate_t; 597c478bd9Sstevel@tonic-gate #endif 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate #define rmutex_t mutex_t 627c478bd9Sstevel@tonic-gate 63*cd62a92dSRobert Mustacchi typedef ssize_t (*fread_t)(__FILE *, char *, size_t); 64*cd62a92dSRobert Mustacchi typedef ssize_t (*fwrite_t)(__FILE *, const char *, size_t); 65*cd62a92dSRobert Mustacchi typedef off_t (*fseek_t)(__FILE *, off_t, int); 66*cd62a92dSRobert Mustacchi typedef int (*fclose_t)(__FILE *); 67*cd62a92dSRobert Mustacchi 68*cd62a92dSRobert Mustacchi typedef struct { 69*cd62a92dSRobert Mustacchi fread_t std_read; 70*cd62a92dSRobert Mustacchi fwrite_t std_write; 71*cd62a92dSRobert Mustacchi fseek_t std_seek; 72*cd62a92dSRobert Mustacchi fclose_t std_close; 73*cd62a92dSRobert Mustacchi void *std_data; 74*cd62a92dSRobert Mustacchi } stdio_ops_t; 75*cd62a92dSRobert Mustacchi 767c478bd9Sstevel@tonic-gate #ifdef _LP64 777c478bd9Sstevel@tonic-gate 78*cd62a92dSRobert Mustacchi /* 79*cd62a92dSRobert Mustacchi * This structure cannot grow beyond its current size of 128 bytes. See the file 80*cd62a92dSRobert Mustacchi * lib/libc/port/stdio/README.design for more information. 81*cd62a92dSRobert Mustacchi */ 827c478bd9Sstevel@tonic-gate struct __FILE_TAG { 837c478bd9Sstevel@tonic-gate unsigned char *_ptr; /* next character from/to here in buffer */ 847c478bd9Sstevel@tonic-gate unsigned char *_base; /* the buffer */ 857c478bd9Sstevel@tonic-gate unsigned char *_end; /* the end of the buffer */ 867c478bd9Sstevel@tonic-gate ssize_t _cnt; /* number of available characters in buffer */ 877c478bd9Sstevel@tonic-gate int _file; /* UNIX System file descriptor */ 887c478bd9Sstevel@tonic-gate unsigned int _flag; /* the state of the stream */ 897c478bd9Sstevel@tonic-gate rmutex_t _lock; /* lock for this structure */ 907c478bd9Sstevel@tonic-gate mbstate_t _state; /* mbstate_t */ 91*cd62a92dSRobert Mustacchi stdio_ops_t *_ops; /* Alternate impl ops */ 92*cd62a92dSRobert Mustacchi char __fill[24]; /* filler to bring size to 128 bytes */ 937c478bd9Sstevel@tonic-gate }; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate #else 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * Stuff missing from our 32-bit FILE struct. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate struct xFILEdata { 1017c478bd9Sstevel@tonic-gate uintptr_t _magic; /* Check: magic number, must be first */ 1027c478bd9Sstevel@tonic-gate unsigned char *_end; /* the end of the buffer */ 1037c478bd9Sstevel@tonic-gate rmutex_t _lock; /* lock for this structure */ 1047c478bd9Sstevel@tonic-gate mbstate_t _state; /* mbstate_t */ 105a5f69788Scraigm int _altfd; /* alternate fd if > 255 */ 106*cd62a92dSRobert Mustacchi stdio_ops_t *_ops; /* Alternate impl ops */ 1077c478bd9Sstevel@tonic-gate }; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #define XFILEINITIALIZER { 0, NULL, RECURSIVEMUTEX, DEFAULTMBSTATE } 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1147c478bd9Sstevel@tonic-gate } 1157c478bd9Sstevel@tonic-gate #endif 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate #endif /* _FILE64_H */ 118