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

📄 sfhdr.h

📁 su 的源代码库
💻 H
📖 第 1 页 / 共 3 页
字号:
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved.                       */#ifndef _SFHDR_H#define _SFHDR_H	1#if !defined(_BLD_sfio) && !defined(_BLD_stdio)#define _BLD_sfio	1#endif/*	Internal definitions for sfio.**	Written by Kiem-Phong Vo*/#define _next		next#define _endw		endw#define _endr		endr#define _endb		endb#define _push		push#define _flags		flags#define _file		file#define _data		data#define _size		size#define _val		val#include	"FEATURE/sfio"#include	"FEATURE/mmap"/* define va_list, etc. before including sfio_t.h (sfio.h) */#if !_PACKAGE_ast/* some systems don't know large files */#if defined(_NO_LARGEFILE64_SOURCE) || _mips == 2 /* || __hppa */#undef _NO_LARGEFILE64_SOURCE#define _NO_LARGEFILE64_SOURCE	1#undef	_LARGEFILE64_SOURCE#undef	_LARGEFILE_SOURCE#endif#if !_NO_LARGEFILE64_SOURCE && _typ_off64_t && _lib_lseek64 && _lib_stat64#undef	_LARGEFILE64_SOURCE#undef	_LARGEFILE_SOURCE#undef	_FILE_OFFSET_BITS#define _LARGEFILE64_SOURCE	1	/* enabling the *64 stuff */#define _LARGEFILE_SOURCE	1	#endif#if _hdr_stdarg#include	<stdarg.h>#else#include	<varargs.h>#endif#include	"FEATURE/common"#if !__STD_C#define const	#endif#endif /* !_PACKAGE_ast */#include	"sfio_t.h"/* note that the macro vt_threaded has effect on vthread.h */#include	<vthread.h>/* file system info */#if _PACKAGE_ast#include	<ast.h>#include	<ast_time.h>#include	<ast_tty.h>#include	<ls.h>/* ast always provides multibyte handling */#undef _hdr_wchar#undef _lib_mbrtowc#undef _lib_wcrtomb#define _hdr_wchar	1#define _lib_mbrtowc	1#define _lib_wcrtomb	1#if _mem_st_blksize_stat#define _stat_blksize	1#endif#if _lib_localeconv && _hdr_locale#define _lib_locale	1#endif#define sfoff_t		off_t#define sfstat_t	struct stat#define sysclosef	close#define syscreatf	creat#define sysdupf		dup#define sysfcntlf	fcntl#define sysfstatf	fstat#define sysftruncatef	ftruncate#define syslseekf	lseek#define sysmmapf	mmap#define sysmunmapf	munmap#define sysopenf	open#define syspipef	pipe#define sysreadf	read#define sysremovef	remove#define sysstatf	stat#define syswritef	write#else /*!_PACKAGE_ast*//* when building the binary compatibility package, a number of header files   are not needed and they may get in the way so we remove them here.*/#if _SFBINARY_H#undef  _hdr_time#undef  _sys_time#undef  _sys_stat#undef  _hdr_stat#undef  _hdr_filio#undef  _sys_filio#undef  _lib_poll#undef  _stream_peek#undef  _socket_peek#undef  _hdr_vfork#undef  _sys_vfork#undef  _lib_vfork#undef  _hdr_values#undef  _hdr_math#undef  _sys_mman#undef  _hdr_mman#undef  _sys_ioctl#endif#if _hdr_stdlib#include	<stdlib.h>#endif#if _hdr_string#include	<string.h>#endif#if _hdr_time#include	<time.h>#endif#if _sys_time#include	<sys/time.h>#endif#if _sys_stat#include	<sys/stat.h>#else#if _hdr_stat#include	<stat.h>#ifndef _sys_stat#define	_sys_stat	1#endif#endif#endif /*_sys_stat*/#ifndef _sys_stat#define _sys_stat	0#endif#include	<fcntl.h>#ifndef F_SETFD#ifndef FIOCLEX#if _hdr_filio#include	<filio.h>#else#if _sys_filio#include	<sys/filio.h>#endif /*_sys_filio*/#endif /*_hdr_filio*/#endif /*_FIOCLEX*/#endif /*F_SETFD*/#if _hdr_unistd#include	<unistd.h>#endif#if !_LARGEFILE64_SOURCE	/* turn off the *64 stuff */#undef	_typ_off64_t#undef	_typ_struct_stat64#undef	_lib_creat64#undef	_lib_open64#undef	_lib_close64#undef	_lib_stat64#undef	_lib_fstat64#undef	_lib_ftruncate64#undef	_lib_lseek64#undef	_lib_mmap64#undef	_lib_munmap64#endif /*!_LARGEFILE64_SOURCE *//* see if we can use memory mapping for io */#if _LARGEFILE64_SOURCE && !_lib_mmap64#undef _mmap_worthy#endif#if !_mmap_worthy#undef _hdr_mman#undef _sys_mman#endif#if _hdr_mman#include	<mman.h>#endif#if _sys_mman#include	<sys/mman.h>#endif/* standardize system calls and types dealing with files */#if _typ_off64_t#define sfoff_t		off64_t#else#define sfoff_t		off_t#endif#if _typ_struct_stat64#define sfstat_t	struct stat64#else#define sfstat_t	struct stat#endif#if _lib_lseek64#define syslseekf	lseek64#else#define syslseekf	lseek#endif#if _lib_stat64#define sysstatf	stat64#else#define sysstatf	stat#endif#if _lib_fstat64#define sysfstatf	fstat64#else#define sysfstatf	fstat#endif#if _lib_mmap64#define sysmmapf	mmap64#else#define sysmmapf	mmap#endif#if _lib_munmap64#define sysmunmapf	munmap64#else#define sysmunmapf	munmap#endif#if _lib_open64#define sysopenf	open64#else#define sysopenf	open#endif#if _lib_creat64#define syscreatf	creat64#else#define syscreatf	creat#endif#if _lib_close64#define sysclosef	close64#else#define sysclosef	close#endif#if _lib_ftruncate64#undef _lib_ftruncate#define _lib_ftruncate	1#define sysftruncatef	ftruncate64#endif#if !_lib_ftruncate64 && _lib_ftruncate#define sysftruncatef	ftruncate#endif#if _lib_remove#define sysremovef	remove#else#define sysremovef	unlink#endif#define sysreadf	read#define syswritef	write#define syspipef	pipe#define sysdupf		dup#define sysfcntlf	fcntl#endif /*_PACKAGE_ast*/#if !_mmap_worthy#undef MAP_TYPE#endif#include	"FEATURE/float"#include	<errno.h>#include	<ctype.h>/* deal with multi-byte character and string conversions */#if _PACKAGE_ast#include	<wchar.h>#define _has_multibyte		1#define SFMBMAX			mbmax()#define SFMBCPY(to,fr)		memcpy((to), (fr), sizeof(mbstate_t))#define SFMBCLR(mb)		memset((mb), 0,  sizeof(mbstate_t))#define SFMBSET(lhs,v)		(lhs = (v))#define SFMBLEN(s,mb)		mbsize(s)#define SFMBDCL(ms)		mbstate_t ms;#else#if _hdr_wchar && _typ_mbstate_t && _lib_wcrtomb && _lib_mbrtowc#define _has_multibyte		1	/* Xopen-compliant	*/#include	<wchar.h>#define SFMBCPY(to,fr)		memcpy((to), (fr), sizeof(mbstate_t))#define SFMBCLR(mb)		memset((mb), 0,  sizeof(mbstate_t))#define SFMBSET(lhs,v)		(lhs = (v))#define SFMBDCL(mb)		mbstate_t mb;#define SFMBLEN(s,mb)		mbrtowc(NIL(wchar_t*), (s), SFMBMAX, (mb) )#endif /*_hdr_wchar && _typ_mbstate_t && _lib_wcrtomb && _lib_mbrtowc*/#if !_has_multibyte && _hdr_wchar && _lib_mbtowc && _lib_wctomb#define _has_multibyte		2	/* no shift states	*/#include	<wchar.h>#undef mbrtowc#define mbrtowc(wp,s,n,mb)	mbtowc(wp, s, n)#undef wcrtomb#define wcrtomb(s,wc,mb)	wctomb(s, wc)#define SFMBCPY(to,fr)#define SFMBCLR(mb)#define SFMBSET(lhs,v)#define SFMBDCL(mb)#define SFMBLEN(s,mb)		mbrtowc(NIL(wchar_t*), (s), SFMBMAX, (mb) )#endif /*!_has_multibyte && _hdr_wchar && _lib_mbtowc && _lib_wctomb*/#ifdef MB_CUR_MAX#define SFMBMAX			MB_CUR_MAX#else#define SFMBMAX			sizeof(Sflong_t)#endif#endif /* _PACKAGE_ast */#if !_has_multibyte#define _has_multibyte		0	/* no multibyte support	*/#define SFMBCPY(to,fr)#define SFMBCLR(mb)#define SFMBSET(lhs,v)#define SFMBLEN(s,mb)		(*(s) ? 1 : 0)#define SFMBDCL(mb)#endif /* _has_multibyte */#if vt_threaded/* initialization */#define SFONCE()	(_Sfdone ? 0 : vtonce(_Sfonce,_Sfoncef))/* to lock/unlock a stream on entering and returning from some function */#define SFMTXLOCK(f)	 (((f)->flags&SF_MTSAFE) ? sfmutex(f,SFMTX_LOCK) : 0)#define SFMTXUNLOCK(f)	 (((f)->flags&SF_MTSAFE) ? sfmutex(f,SFMTX_UNLOCK) : 0)#define SFMTXSTART(f,v)  { if(!f || SFMTXLOCK(f) != 0) return(v); }#define SFMTXRETURN(f,v) { SFMTXUNLOCK(f); return(v); }/* start and end critical region for a pool */#define POOLMTXLOCK(p)		( vtmtxlock(&(p)->mutex) )#define POOLMTXUNLOCK(p)	( vtmtxunlock(&(p)->mutex) )#define POOLMTXSTART(p)		{ POOLMTXLOCK(p); }#define POOLMTXRETURN(p,v)	{ POOLMTXUNLOCK(p); return(v); }#else /*!vt_threaded*/#undef SF_MTSAFE /* no need to worry about thread-safety */#define SF_MTSAFE		0#define SFONCE()		/*(0)*/#define SFMTXLOCK(f)		/*(0)*/#define SFMTXUNLOCK(f)		/*(0)*/#define SFMTXSTART(f,v)		{ if(!f) return(v); }#define SFMTXRETURN(f,v)	{ return(v); }#define POOLMTXLOCK(p)#define POOLMTXUNLOCK(p)#define POOLMTXSTART(p)#define POOLMTXRETURN(p,v)	{ return(v); }#endif /*vt_threaded*//* functions for polling readiness of streams */#if _lib_select#undef _lib_poll#else#if _lib_poll_fd_1 || _lib_poll_fd_2#define _lib_poll	1#endif#endif /*_lib_select_*/#if _lib_poll#include	<poll.h>#if _lib_poll_fd_1#define SFPOLL(pfd,n,tm)	poll((pfd),(ulong)(n),(tm))#else#define SFPOLL(pfd,n,tm)	poll((ulong)(n),(pfd),(tm))#endif#endif /*_lib_poll*/#if _stream_peek#include	<stropts.h>#endif#if _socket_peek#include	<sys/socket.h>#endif/* to test for executable access mode of a file */

⌨️ 快捷键说明

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