📄 write.c
字号:
/* $id:dmWrite.c V1.0 2001/09/5 */
/******************************************************************************
* 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: write.c
*
* MODULE: RTL
*
* PURPOSE: write() - POSIX 1003.1b 6.4.2 - Write to a File
*
* AUTHOR(S):Zhang Yumin
*
* GROUP:TOOL_GROUP
*
* DATE CREATED:2001/09/05
*
* REFERENCE DOCUMENT ID:
*
* MODIFICATIONS:
* Date user Name Description
* 2001/09/05 Zhang Yumin Create this file
*
*********************************************************************************/
#include <sys/types.h>
#include <sys/reent.h>
#include "driver/ucbsp.h"
ssize_t sys_write(int fd,const void* buffer, size_t count)
{
//实现write系统调用方法
return ucBsp_write(fd, buffer, count);
}
/********************************************************************
* FUNCTION: write
*
* PURPOSE: Write() attempts to write nbytes of data to a file
* referenced by the descriptor fd from the buffer
* PARAMETERS:
*
* Input: fd -file descriptor of target file.
* buffer-data buffer.
* nbyte -the number of data in bytes.
* Output: None
* InOut: None
*
* Return value: Upon successful completion the number of bytes which
* were written is returned.Otherwise a -1 is returned
* ` and the global variable errno is set to indicate the
* error.
* Reentrant: Yes
********************************************************************/
ssize_t _write_r(
struct _reent *ptr,
int fd,
const void *buffer,
size_t count
)
{
int rc = sys_write(fd,buffer,count);
if(rc < 0)
{
ptr->_errno = -rc;
return -1;
}
return rc;
}
#ifndef _REENT_ONLY
ssize_t write(
int fd,
const int *buffer,
size_t count
)
{
return _write_r(_REENT,fd,buffer,count);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -