⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uclibc_stdio.h

📁 它通过提供glibc兼容使得应用程序移植到较小的c 库时相当得容易. 它能够应用到带虚拟存储的Linux和uClinux上.在大多数带MMU部件的平台上为使它更加紧凑,它也能够编译成共享库.uClib
💻 H
📖 第 1 页 / 共 2 页
字号:
/*  Copyright (C) 2002     Manuel Novoa III *  Header for my stdio library for linux and (soon) elks. * *  This library is free software; you can redistribute it and/or *  modify it under the terms of the GNU Library General Public *  License as published by the Free Software Foundation; either *  version 2 of the License, or (at your option) any later version. * *  This library is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *  Library General Public License for more details. * *  You should have received a copy of the GNU Library General Public *  License along with this library; if not, write to the Free *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//*  ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION! * *  This code is currently under development.  Also, I plan to port *  it to elks which is a 16-bit environment with a fairly limited *  compiler.  Therefore, please refrain from modifying this code *  and, instead, pass any bug-fixes, etc. to me.  Thanks.  Manuel * *  ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION! */#ifndef _STDIO_H#error Always include <stdio.h> rather than <bits/uClibc_stdio.h>#endif/**********************************************************************/#ifdef __UCLIBC__#ifdef __UCLIBC_HAS_THREADS__#define __STDIO_THREADSAFE#endif#ifdef __UCLIBC_HAS_LFS__#define __STDIO_LARGE_FILES#endif /* __UCLIBC_HAS_LFS__ */#ifdef __UCLIBC_HAS_WCHAR__#define __STDIO_WIDE#endif/* Make sure defines related to large files are consistent. */#ifdef _LIBC#ifdef __UCLIBC_HAS_LFS__#undef __USE_LARGEFILE#undef __USE_LARGEFILE64#undef __USE_FILE_OFFSET64/* if we're actually building uClibc with large file support, only define... */#define __USE_LARGEFILE64	1#endif /* __UCLIBC_HAS_LFS__ */#else  /* not _LIBC */#ifndef __UCLIBC_HAS_LFS__#if defined(__LARGEFILE64_SOURCE) || defined(__USE_LARGEFILE64) \    || defined(__USE_FILE_OFFSET64)#error Sorry... uClibc was built without large file support!#endif#endif /* __UCLIBC_HAS_LFS__ */#endif /* _LIBC */#endif /* __UCLIBC__ *//**********************************************************************//* These are the stdio configuration options.  Keep them here until   uClibc's configuration process gets reworked. */#ifdef __STDIO_WIDE#define __need_wchar_t#include <stddef.h>/* Note: we don't really need mbstate for 8-bit locales.  We do for UTF-8. * For now, always use it. */#define __STDIO_MBSTATE#define __need_mbstate_t#include <wchar.h>#endif#define __STDIO_BUFFERS#define __STDIO_GETC_MACRO#define __STDIO_PUTC_MACRO/* For uClibc, these are currently handled above. *//*  #define __STDIO_LARGE_FILES *//*  #define __STDIO_THREADSAFE *//* L mode extension for fopen. */#define __STDIO_FOPEN_LARGEFILE_MODE/* size of builtin buf -- only tested with 0 */#define _STDIO_BUILTIN_BUF_SIZE		0/* TODO - enable features based on __STDIO_GLIBC_FEATURES *//*  #define __STDIO_GLIBC_FEATURES */#define __STDIO_AUTO_RW_TRANSITION#define __STDIO_FOPEN_EXCLUSIVE_MODE#define __STDIO_PRINTF_M_SPEC#define __STDIO_GLIBC_CUSTOM_STREAMS/* ANSI/ISO mandate at least 256. */#define _STDIO_BUFSIZ			256/* Currently unimplemented/untested *//* #define __STDIO_FLEXIBLE_SETVBUF *//**********************************************************************//* TODO -- posix or gnu -- belongs in limits.h and >= 9 for sus *//* NOTE: for us it is currently _always_ 9 *//*#define NL_ARGMAX			9*//**********************************************************************//* These are consistency checks on the different options */#ifndef __STDIO_BUFFERS#undef __STDIO_GETC_MACRO#undef __STDIO_PUTC_MACRO#endif#ifdef __BCC__#undef __STDIO_LARGE_FILES#endif#ifndef __STDIO_LARGE_FILES#undef __STDIO_FOPEN_LARGEFILE_MODE#endif/**********************************************************************/#ifdef __STDIO_THREADSAFE/* Need this for pthread_mutex_t. */#include <bits/pthreadtypes.h>#define __STDIO_THREADLOCK(STREAM) \	if ((STREAM)->user_locking == 0) { \		pthread_mutex_lock(&(STREAM)->lock); \	}#define __STDIO_THREADUNLOCK(STREAM) \	if ((STREAM)->user_locking == 0) { \		pthread_mutex_unlock(&(STREAM)->lock); \	}#define __STDIO_THREADTRYLOCK(STREAM) \	if ((STREAM)->user_locking == 0) { \		pthread_mutex_trylock(&(STREAM)->lock); \	}#else  /* __STDIO_THREADSAFE */#define __STDIO_THREADLOCK(STREAM)#define __STDIO_THREADUNLOCK(STREAM)#define __STDIO_THREADTRYLOCK(STREAM)#endif /* __STDIO_THREADSAFE *//* This file may eventually have two personalities:   1) core stuff (similar to glibc's libio.h)   2) extern inlines (for glibc's bits/stdio.h)   Right now, only (1) is implemented. */#define _STDIO_IOFBF 0	/* Fully buffered.  */#define _STDIO_IOLBF 1	/* Line buffered.  */#define _STDIO_IONBF 2	/* No buffering.  */typedef struct {	__off_t __pos;#ifdef __STDIO_MBSTATE  __mbstate_t __mbstate;#endif} __stdio_fpos_t;#ifdef __STDIO_LARGE_FILEStypedef struct {	__off64_t __pos;#ifdef __STDIO_MBSTATE  __mbstate_t __mbstate;#endif} __stdio_fpos64_t;#endif/**********************************************************************/#ifdef __STDIO_LARGE_FILEStypedef __off64_t __offmax_t;	/* TODO -- rename this? */#elsetypedef __off_t __offmax_t;		/* TODO -- rename this? */#endif/**********************************************************************/#ifdef __STDIO_GLIBC_CUSTOM_STREAMStypedef __ssize_t __io_read_fn(void *cookie,							   char *buf, size_t bufsize);typedef __ssize_t __io_write_fn(void *cookie,								const char *buf, size_t bufsize);/* NOTE: GLIBC difference!!! -- fopencookie seek function * For glibc, the type of pos is always (__off64_t *) but in our case * it is type (__off_t *) when the lib is built without large file support. */typedef int __io_seek_fn(void *cookie,						 __offmax_t *pos, int whence);typedef int __io_close_fn(void *cookie);typedef struct {	__io_read_fn *read;	__io_write_fn *write;	__io_seek_fn *seek;	__io_close_fn *close;} _IO_cookie_io_functions_t;#if defined(_LIBC) || defined(_GNU_SOURCE)typedef __io_read_fn cookie_read_function_t;typedef __io_write_fn cookie_write_function_t;typedef __io_seek_fn cookie_seek_function_t;typedef __io_close_fn cookie_close_function_t;typedef _IO_cookie_io_functions_t cookie_io_functions_t;#endif /* _GNU_SOURCE */#endif /* __STDIO_GLIBC_CUSTOM_STREAMS *//* * ungot scheme: * 0 0   none * 0 1   one user (unused ungot is 1) or one scanf (unused ungot is 0) * 1 0   must be scanf[0] and user[1] * 1 1   illegal -- could be used to signal safe for setbuf */#ifdef __UCLIBC__#define __stdio_file_struct _UC_FILE#endifstruct __stdio_file_struct {	unsigned short modeflags;	/* There could be a hole here, but modeflags is used most.*/#ifdef __STDIO_WIDE	/* TOOD - ungot_width could be combined with ungot.  But what about hole? */	unsigned char ungot_width[2];	wchar_t ungot[2];#else  /* __STDIO_WIDE */	unsigned char ungot[2];#endif /* __STDIO_WIDE */	int filedes;#if defined(__STDIO_BUFFERS) || defined(__STDIO_GLIBC_CUSTOM_STREAMS)	struct __stdio_file_struct *nextopen;#endif /* defined(__STDIO_BUFFERS) || defined(__STDIO_GLIBC_CUSTOM_STREAMS) */#ifdef __STDIO_BUFFERS	unsigned char *bufstart;	/* pointer to buffer */	unsigned char *bufend;		/* pointer to 1 past end of buffer */	unsigned char *bufpos;	unsigned char *bufread;		/* pointer to 1 past last buffered read char. */#ifdef __STDIO_GETC_MACRO	unsigned char *bufgetc;		/* 1 past last readable by getc */#endif /* __STDIO_GETC_MACRO */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -