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

📄 uclibc_stdio.h

📁 它通过提供glibc兼容使得应用程序移植到较小的c 库时相当得容易. 它能够应用到带虚拟存储的Linux和uClinux上.在大多数带MMU部件的平台上为使它更加紧凑,它也能够编译成共享库.uClib
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifdef __STDIO_PUTC_MACRO	unsigned char *bufputc;		/* 1 past last writeable by putc */#endif /* __STDIO_PUTC_MACRO */#endif /* __STDIO_BUFFERS */#ifdef __STDIO_GLIBC_CUSTOM_STREAMS	void *cookie;	_IO_cookie_io_functions_t gcs;#endif /* __STDIO_GLIBC_CUSTOM_STREAMS */#ifdef __STDIO_MBSTATE	__mbstate_t state;#endif#ifdef __STDIO_THREADSAFE	int user_locking;	pthread_mutex_t lock;#endif/* Everything after this is unimplemented... and may be trashed. */#if __STDIO_BUILTIN_BUF_SIZE > 0	unsigned char builtinbuf[__STDIO_BUILTIN_BUF_SIZE];#endif /* __STDIO_BUILTIN_BUF_SIZE > 0 */};/***********************************************************************/#define __MASK_UNGOT    	(0x0002|0x0001)#define __MASK_UNGOT1    	0x0001#define __MASK_UNGOT2    	0x0002#define __FLAG_EOF			0x0004	/* EOF reached? */#define __FLAG_ERROR		0x0008	/* stream in error state? */#define __FLAG_WRITEONLY  	0x0010	/* unreadable */#define __FLAG_READONLY  	0x0020	/* unwriteable */#define __FLAG_FREEFILE		0x0040	/* free FILE struct after use */#define __FLAG_NARROW       0x0080#define __FLAG_FBF          0		/* convenience value */#define __FLAG_LBF          0x0100#define __FLAG_NBF          0x0200#define __MASK_BUFMODE      0x0300#define __FLAG_APPEND       0x0400#define __FLAG_WIDE			0x0800#define __FLAG_READING		0x1000#define __FLAG_WRITING		0x2000#define __FLAG_FREEBUF		0x4000	/* free buffer after use */#define __FLAG_LARGEFILE    0x8000/**********************************************************************/#ifdef __STDIO_GLIBC_CUSTOM_STREAMSextern __ssize_t _cs_read(void *cookie, char *buf, size_t bufsize);extern __ssize_t _cs_write(void *cookie, const char *buf, size_t bufsize);extern int _cs_seek(void *cookie, __offmax_t *pos, int whence);extern int _cs_close(void *cookie);#endif /* __STDIO_GLIBC_CUSTOM_STREAMS *//**********************************************************************/#ifdef __STDIO_MBSTATE#define __COPY_MBSTATE(dest,src)  ((dest)->mask = (src)->mask, (dest)->wc = (src)->wc)#define __INIT_MBSTATE(dest) ((dest)->mask = 0)#else#define __COPY_MBSTATE(dest,src)#define __INIT_MBSTATE(dest)#endif/**********************************************************************//* TODO -- thread safety issues */#define __CLEARERR(stream) \	((stream)->modeflags &= ~(__FLAG_EOF|__FLAG_ERROR), (void)0)#define __FEOF(stream)		((stream)->modeflags & __FLAG_EOF)#define __FERROR(stream)	((stream)->modeflags & __FLAG_ERROR)#define __FEOF_OR_FERROR(stream) \	((stream)->modeflags & (__FLAG_EOF|__FLAG_ERROR))/* TODO: check this * If we want to implement the getc and putc macros, we need to take * into account wide streams.  So... would need two additional variables * if we have wide streams (bufread and bufwrite), and one otherwise * (bufwrite).  getc would be effective for FBF streams.  It isn't for * LBF streams because other LBF streams need to be flushed.  putc * thouch is only effective for FBF streams.  Of course, to support * threads, we have to use functions. */#ifdef __STDIO_GETC_MACRO#define __GETC(stream)		( ((stream)->bufpos < (stream)->bufgetc) \							? (*(stream)->bufpos++) \							: fgetc_unlocked(stream) )#else  /* __STDIO_GETC_MACRO */#define __GETC(stream)		fgetc_unlocked(stream)#endif /* __STDIO_GETC_MACRO */#ifdef __STDIO_PUTC_MACRO#define __PUTC(c, stream)	( ((stream)->bufpos < (stream)->bufputc) \							? (*(stream)->bufpos++) = (c) \							: fputc_unlocked((c),(stream)) )#else  /* __STDIO_PUTC_MACRO */#define __PUTC(c, stream)	fputc_unlocked(c, stream);#endif /* __STDIO_PUTC_MACRO */#if 0/* TODO: disabled for now *//* Masking macros for the above _are_ allowed by the standard. */#define clearerr(stream)	__CLEARERR(stream)#define feof(stream)		__FEOF(stream)#define ferror(stream)		__FERROR(stream)#endif#if 0/* TODO -- what about custom streams!!! *//* Only use the macro below if you know fp is a valid FILE for a valid fd. */#define __fileno(fp)	((fp)->filedes)#endif/********************************************************************** * PROTOTYPES OF INTERNAL FUNCTIONS **********************************************************************/extern FILE *_stdio_openlist;#ifdef __STDIO_THREADSAFEextern pthread_mutex_t _stdio_openlist_lock;extern void __stdio_init_mutex(pthread_mutex_t *m);#endifextern int _stdio_adjpos(FILE * __restrict stream, __offmax_t * pos);extern int _stdio_lseek(FILE *stream, __offmax_t *pos, int whence);/* TODO: beware of signals with _stdio_fwrite!!!! */extern size_t _stdio_fwrite(const unsigned char *buffer, size_t bytes,							  FILE *stream);extern size_t _stdio_fread(unsigned char *buffer, size_t bytes,							 FILE *stream);extern FILE *_stdio_fopen(const char * __restrict filename,							const char * __restrict mode,							FILE * __restrict stream, int filedes);extern FILE *_stdio_fsfopen(const char * __restrict filename,							const char * __restrict mode,							register FILE * __restrict stream);extern void _stdio_init(void);extern void _stdio_term(void);#ifndef NDEBUGextern void __stdio_validate_FILE(FILE *stream);#else#define __stdio_validate_FILE(stream)		((void)0)#endif#ifdef __STDIO_WIDEextern size_t _wstdio_fwrite(const wchar_t *__restrict ws, size_t n,							 register FILE *__restrict stream);#endif/********************************************************************** * UTILITY functions **********************************************************************/#ifdef _STDIO_UTILITY#include <features.h>#include <limits.h>#include <stdint.h>#if INTMAX_MAX <= 2147483647L#define __UIM_BUFLEN			12 /* 10 digits + 1 nul + 1 sign */#elif INTMAX_MAX <= 9223372036854775807LL#define __UIM_BUFLEN			22 /* 20 digits + 1 nul + 1 sign */#else#error unknown number of digits for intmax_t!#endif#ifdef LLONG_MAX				/* --------------- */#if LLONG_MAX <= 2147483647L#define __UIM_BUFLEN_LLONG		12 /* 10 digits + 1 nul + 1 sign */#elif LLONG_MAX <= 9223372036854775807LL#define __UIM_BUFLEN_LLONG		22 /* 20 digits + 1 nul + 1 sign */#else#error unknown number of digits for long long!#endif#endif /* ULLONG_MAX ----------------------------- */#if LONG_MAX <= 2147483647L#define __UIM_BUFLEN_LONG		12 /* 10 digits + 1 nul + 1 sign */#elif LONG_MAX <= 9223372036854775807LL#define __UIM_BUFLEN_LONG		22 /* 20 digits + 1 nul + 1 sign */#else#error unknown number of digits for long!#endif#if INT_MAX <= 32767#define __UIM_BUFLEN_INT		7 /* 10 digits + 1 nul + 1 sign */#elif INT_MAX <= 2147483647L#define __UIM_BUFLEN_INT		12 /* 10 digits + 1 nul + 1 sign */#else#error unknown number of digits for int!#endiftypedef enum {	__UIM_DECIMAL = 0,	__UIM_GROUP = ',',			/* Base 10 locale-dependent grouping. */	__UIM_LOWER = 'a' - 10,	__UIM_UPPER = 'A' - 10,} __UIM_CASE;/* Write a NULL-terminated list of "char *" args to file descriptor fd. * For an example of usage, see __assert.c. */extern void _stdio_fdout(int fd, ...);/* Convert the int val to a string in base abs(base).  val is treated as * an unsigned ??? int type if base > 0, and signed if base < 0.  This * is an internal function with _no_ error checking done unless assert()s * are enabled. * * Note: bufend is a pointer to the END of the buffer passed. * Call like this: *     char buf[SIZE], *p; *     p = _xltostr(buf + sizeof(buf) - 1, {unsigned int},  10, __UIM_DECIMAL) *     p = _xltostr(buf + sizeof(buf) - 1,          {int}, -10, __UIM_DECIMAL) * * WARNING: If base > 10, case _must_be_ either __UIM_LOWER or __UIM_UPPER *          for lower and upper case alphas respectively. * WARNING: If val is really a signed type, make sure base is negative! *          Otherwise, you could overflow your buffer. */extern char *_uintmaxtostr(char * __restrict bufend, uintmax_t uval,						   int base, __UIM_CASE alphacase);/* TODO -- make this either a (possibly inline) function? */#ifndef __BCC__#define _int10tostr(bufend, intval) \	_uintmaxtostr((bufend), (intval), -10, __UIM_DECIMAL)#else  /* bcc doesn't do prototypes, we need to explicitly cast */#define _int10tostr(bufend, intval) \	_uintmaxtostr((bufend), (uintmax_t)(intval), -10, __UIM_DECIMAL)#endif#define __BUFLEN_INT10TOSTR		__UIM_BUFLEN_INT#endif /* _STDIO_UTILITY *//**********************************************************************//* uClibc translations *//**********************************************************************//* TODO: note done above..  typedef struct __stdio_file_struct _UC_FILE; */typedef __stdio_fpos_t		_UC_fpos_t;#ifdef __STDIO_LARGE_FILEStypedef __stdio_fpos64_t	_UC_fpos64_t;#endif#define _UC_IOFBF		_STDIO_IOFBF /* Fully buffered.  */#define _UC_IOLBF 		_STDIO_IOLBF /* Line buffered.  */#define _UC_IONBF 		_STDIO_IONBF /* No buffering.  */#define _UC_BUFSIZ		_STDIO_BUFSIZ

⌨️ 快捷键说明

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