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

📄 fcntl.c

📁 嵌入式实验uC-OS-II相关程序用例与参考资料
💻 C
字号:
/******************************************************************************
 *  This source code has been made available to you by CORETEK  on
 *  AS-IS.Anyone receiving this source is licensed under
 *  CORETEK copyrights to use it in any way he or she deems fit,including
 *  copying it,modifying it,compiling it,and redistributing it either with
 *  or without modifictions.
 *
 *
 *  Any person who transfers this source code or any derivative work must
 *  include the CORETEK copyright notice, this paragraph,and the preceding
 *  two paragraphs in the transferred software.
 *
 *
 *       COPYRIGHT CORETEK CORPORATION 2001
 *     LICENSED MATERIAL - PROGRAM PROPERTY OF CORETEK
 *****************************************************************************/

/******************************************************************************
 *
 *  FILE: Fcntl.c
 *
 *  MODULE: RLT
 *
 *  PURPOSE: fcntl() - POSIX 1003.1b 6.5.2 - File Control
 *
 *  AUTHOR(S):Zhang Yumin
 *
 *  GROUP:TOOL_GROUP
 *
 *  DATE CREATED:2002/04/02
 *
 *  REFERENCE DOCUMENT ID:
 *
 *  MODIFICATIONS:
 *  Date          user Name       Description
 *  2002/04/02    Zhang Yumin    Create this file
 *
 *********************************************************************************/
#include <stdarg.h>
#include <sys/reent.h>



extern int sys_fcntl(int fd, int cmd,int arg);

/********************************************************************
 *  FUNCTION: fcntl
 *
 *  PURPOSE:  The fcntl() function provides control of open file descriptors.
 *  PARAMETERS:
 *
 *    Input:  fd	-file descriptor of target file.
 *			  cmd	-commands.
 *			  ...	-Represents arguments to cmd.
 *    Output: None
 *    InOut:  None
 *
 *  Return value: If successful, fcntl() returns a value for each
 *		command. On failure, it returns -1 and sets errno values.
 *  Reentrant: Yes
 ********************************************************************/

int _fcntl_r(
	struct _reent  *ptr,
  	int fd,
  	int cmd,
  	...
)
{
  	va_list ap;
  	int rc;

  	va_start (ap, cmd);
  	rc = sys_fcntl(fd,cmd,va_arg(ap, int));
  	va_end (ap);

  	if(rc < 0)
  	{
  		ptr->_errno = -rc;
  		return -1;
  	}
  	return rc;
}


#ifndef _REENT_ONLY

int fcntl(
  	int fd,
  	int cmd,
 	...
)
{
  	va_list ap;
  	int ret;

  	va_start (ap, cmd);
  	ret = _fcntl_r(_REENT,fd,cmd,va_arg(ap, int));
  	va_end (ap);
  	return ret;
}

#endif

⌨️ 快捷键说明

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