📄 uclibc_stdio.h
字号:
/* Copyright (C) 2002-2004 Manuel Novoa III <mjn3@codepoet.org> * * GNU Library General Public License (LGPL) version 2 or later. * * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */#ifndef _STDIO_H#error Always include <stdio.h> rather than <bits/uClibc_stdio.h>#endif/**********************************************************************/#define __STDIO_BUFFERS/* ANSI/ISO mandate at least 256. */#if defined(__UCLIBC_HAS_STDIO_BUFSIZ_NONE__)/* Fake this because some apps use stdio.h BUFSIZ. */#define __STDIO_BUFSIZ 256#undef __STDIO_BUFFERS#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_256__)#define __STDIO_BUFSIZ 256#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_512__)#define __STDIO_BUFSIZ 512#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_1024__)#define __STDIO_BUFSIZ 1024#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_2048__)#define __STDIO_BUFSIZ 2048#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_4096__)#define __STDIO_BUFSIZ 4096#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_8192__)#define __STDIO_BUFSIZ 8192#else#error config seems to be out of sync regarding bufsiz options#endif#ifdef __UCLIBC_HAS_STDIO_BUFSIZ_NONE__#define __STDIO_BUILTIN_BUF_SIZE 0#else /* __UCLIBC_HAS_STDIO_BUFSIZ_NONE__ */#if defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE__)#define __STDIO_BUILTIN_BUF_SIZE 0#elif defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4__)#define __STDIO_BUILTIN_BUF_SIZE 4#elif defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8__)#define __STDIO_BUILTIN_BUF_SIZE 8#else#error config seems to be out of sync regarding builtin buffer size#endif#endif#if defined(__STDIO_BUFFERS) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__) || defined(__UCLIBC_HAS_THREADS__)#define __STDIO_HAS_OPENLIST 1#else#undef __STDIO_HAS_OPENLIST#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 *//**********************************************************************/#ifdef __UCLIBC_HAS_WCHAR__#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/**********************************************************************//* Currently unimplemented/untested *//* #define __STDIO_FLEXIBLE_SETVBUF */#ifdef __UCLIBC_HAS_STDIO_GETC_MACRO__#define __STDIO_GETC_MACRO#endif#ifdef __UCLIBC_HAS_STDIO_PUTC_MACRO__#define __STDIO_PUTC_MACRO#endif/* These are consistency checks on the different options */#ifndef __STDIO_BUFFERS#undef __STDIO_GETC_MACRO#undef __STDIO_PUTC_MACRO#endif#ifdef __BCC__#undef __UCLIBC_HAS_LFS__#endif#ifndef __UCLIBC_HAS_LFS__#undef __UCLIBC_HAS_FOPEN_LARGEFILE_MODE__#endif/**********************************************************************/#ifdef __UCLIBC_HAS_THREADS__/* Need this for pthread_mutex_t. */#include <bits/pthreadtypes.h>/* user_locking * 0 : do auto locking/unlocking * 1 : user does locking/unlocking * 2 : initial state prior to thread initialization * with no auto locking/unlocking * * When threading is initialized, walk the stdio open stream list * and do "if (user_locking == 2) user_locking = 0;". * * This way, we avoid calling the weak lock/unlock functions. */#define __STDIO_AUTO_THREADLOCK_VAR int __infunc_user_locking#define __STDIO_AUTO_THREADLOCK(__stream) \ if ((__infunc_user_locking = (__stream)->__user_locking) == 0) { \ __pthread_mutex_lock(&(__stream)->__lock); \ }#define __STDIO_AUTO_THREADUNLOCK(__stream) \ if (__infunc_user_locking == 0) { \ __pthread_mutex_unlock(&(__stream)->__lock); \ }#define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1)#define __STDIO_ALWAYS_THREADLOCK(__stream) \ __pthread_mutex_lock(&(__stream)->__lock)#define __STDIO_ALWAYS_THREADTRYLOCK(__stream) \ __pthread_mutex_trylock(&(__stream)->__lock)#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \ __pthread_mutex_unlock(&(__stream)->__lock)#else /* __UCLIBC_HAS_THREADS__ */#define __STDIO_AUTO_THREADLOCK_VAR ((void)0)#define __STDIO_AUTO_THREADLOCK(__stream) ((void)0)#define __STDIO_AUTO_THREADUNLOCK(__stream) ((void)0)#define __STDIO_SET_USER_LOCKING(__stream) ((void)0)#define __STDIO_ALWAYS_THREADLOCK(__stream) ((void)0)#define __STDIO_ALWAYS_THREADTRYLOCK(__stream) (0) /* Always succeed. */#define __STDIO_ALWAYS_THREADUNLOCK(__stream) ((void)0)#endif /* __UCLIBC_HAS_THREADS__ *//**********************************************************************/#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#ifdef __UCLIBC_HAS_WCHAR__ int __mblen_pending;#endif} __STDIO_fpos_t;#ifdef __UCLIBC_HAS_LFS__typedef struct { __off64_t __pos;#ifdef __STDIO_MBSTATE __mbstate_t __mbstate;#endif#ifdef __UCLIBC_HAS_WCHAR__ int __mblen_pending;#endif} __STDIO_fpos64_t;#endif/**********************************************************************/#ifdef __UCLIBC_HAS_LFS__typedef __off64_t __offmax_t; /* TODO -- rename this? */#elsetypedef __off_t __offmax_t; /* TODO -- rename this? */#endif/**********************************************************************/#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__typedef __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#endif/**********************************************************************/struct __STDIO_FILE_STRUCT { unsigned short __modeflags; /* There could be a hole here, but modeflags is used most.*/#ifdef __UCLIBC_HAS_WCHAR__ unsigned char __ungot_width[2]; /* 0: current (building) char; 1: scanf */ /* Move the following futher down to avoid problems with getc/putc * macros breaking shared apps when wchar config support is changed. */ /* wchar_t ungot[2]; */#else /* __UCLIBC_HAS_WCHAR__ */ unsigned char __ungot[2];#endif /* __UCLIBC_HAS_WCHAR__ */ int __filedes;#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_u; /* 1 past last readable by getc_unlocked */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -