Files

39 lines
1.0 KiB
C
Raw Permalink Normal View History

2018-02-23 00:57:47 +00:00
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <stdio.h>
#include <errno.h>
#include <sys/iosupport.h>
#ifdef REENTRANT_SYSCALLS_PROVIDED
//---------------------------------------------------------------------------------
2018-05-27 20:47:46 +01:00
_ssize_t _write_r( struct _reent * r, int fileDesc, const void *ptr, size_t len) {
2018-02-23 00:57:47 +00:00
//---------------------------------------------------------------------------------
#else
//---------------------------------------------------------------------------------
2018-05-27 20:47:46 +01:00
_ssize_t _write( int fileDesc, const char *ptr, int len) {
2018-02-23 00:57:47 +00:00
//---------------------------------------------------------------------------------
struct _reent *r = _REENT;
#endif
int ret = -1;
unsigned int dev = 0;
__handle * handle = NULL;
if(fileDesc!=-1) {
handle = __get_handle(fileDesc);
if ( NULL == handle ) return ret;
dev = handle->device;
if(devoptab_list[dev]->write_r) {
r->deviceData = devoptab_list[dev]->deviceData;
ret = devoptab_list[dev]->write_r(r,handle->fileStruct,ptr,len);
} else
r->_errno=ENOSYS;
}
return ret;
}