From 5c85f0f91dddff8e5082fdf0bcfb713493ea819c Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 27 Sep 2017 23:34:42 +0200 Subject: [PATCH] jehanne: move _fcntl_r to libposix_conf.c (to easily access fcntl.h) --- newlib/libc/sys/jehanne/libposix_conf.c | 32 +++++++++++++++++++++++++ newlib/libc/sys/jehanne/syscalls.c | 7 ------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/newlib/libc/sys/jehanne/libposix_conf.c b/newlib/libc/sys/jehanne/libposix_conf.c index 946e7688b..d9caf400c 100644 --- a/newlib/libc/sys/jehanne/libposix_conf.c +++ b/newlib/libc/sys/jehanne/libposix_conf.c @@ -355,3 +355,35 @@ initialize_newlib(void) if(__application_newlib_init != 0) __application_newlib_init(); } + +/* _fcntl_r is here to access */ +int +_fcntl_r(struct _reent *r, int fd, int cmd, int arg) +{ + int *errnop = &r->_errno; + PosixFDCmds pcmd; + switch(cmd){ + case F_DUPFD: + pcmd = PosixFDCDupFD; + break; + case F_DUPFD_CLOEXEC: + pcmd = PosixFDCDupFDCloseOnExec; + break; + case F_GETFD: + pcmd = PosixFDCGetFD; + break; + case F_SETFD: + pcmd = PosixFDCSetFD; + break; + case F_GETFL: + pcmd = PosixFDCGetFL; + break; + case F_SETFL: + pcmd = PosixFDCSetFL; + break; + default: + *errnop = EINVAL; + return -1; + } + return POSIX_fcntl(errnop, fd, pcmd, arg); +} diff --git a/newlib/libc/sys/jehanne/syscalls.c b/newlib/libc/sys/jehanne/syscalls.c index 5bd586076..7f8fff94a 100644 --- a/newlib/libc/sys/jehanne/syscalls.c +++ b/newlib/libc/sys/jehanne/syscalls.c @@ -213,13 +213,6 @@ _gettimeofday_r(struct _reent *r, struct timeval *p, void *z) return POSIX_gettimeofday(errnop, p, z); } -int -_fcntl_r(struct _reent *r, int fd, int cmd, int arg) -{ - int *errnop = &r->_errno; - return POSIX_fcntl(errnop, fd, cmd, arg); -} - unsigned int sleep(unsigned int seconds) {