Merge pull request #4815 from mysterywolf/syscall

[libc][syscall]整理函数格式
This commit is contained in:
Bernard Xiong 2021-06-23 09:59:57 +08:00 committed by GitHub
commit 14c791f50a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 48 deletions

View File

@ -29,21 +29,18 @@
/* Reentrant versions of system calls. */ /* Reentrant versions of system calls. */
#ifndef _REENT_ONLY #ifndef _REENT_ONLY
int * int *__errno ()
__errno ()
{ {
return _rt_errno(); return _rt_errno();
} }
#endif #endif
int int _getpid_r(struct _reent *ptr)
_getpid_r(struct _reent *ptr)
{ {
return 0; return 0;
} }
int int _close_r(struct _reent *ptr, int fd)
_close_r(struct _reent *ptr, int fd)
{ {
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
/* return "not supported" */ /* return "not supported" */
@ -54,40 +51,35 @@ _close_r(struct _reent *ptr, int fd)
#endif #endif
} }
int int _execve_r(struct _reent *ptr, const char * name, char *const *argv, char *const *env)
_execve_r(struct _reent *ptr, const char * name, char *const *argv, char *const *env)
{ {
/* return "not supported" */ /* return "not supported" */
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
} }
int int _fcntl_r(struct _reent *ptr, int fd, int cmd, int arg)
_fcntl_r(struct _reent *ptr, int fd, int cmd, int arg)
{ {
/* return "not supported" */ /* return "not supported" */
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
} }
int int _fork_r(struct _reent *ptr)
_fork_r(struct _reent *ptr)
{ {
/* return "not supported" */ /* return "not supported" */
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
} }
int int _fstat_r(struct _reent *ptr, int fd, struct stat *pstat)
_fstat_r(struct _reent *ptr, int fd, struct stat *pstat)
{ {
/* return "not supported" */ /* return "not supported" */
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
} }
int int _isatty_r(struct _reent *ptr, int fd)
_isatty_r(struct _reent *ptr, int fd)
{ {
if (fd >=0 && fd < 3) if (fd >=0 && fd < 3)
{ {
@ -99,24 +91,21 @@ _isatty_r(struct _reent *ptr, int fd)
} }
} }
int int _kill_r(struct _reent *ptr, int pid, int sig)
_kill_r(struct _reent *ptr, int pid, int sig)
{ {
/* return "not supported" */ /* return "not supported" */
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
} }
int int _link_r(struct _reent *ptr, const char *old, const char *new)
_link_r(struct _reent *ptr, const char *old, const char *new)
{ {
/* return "not supported" */ /* return "not supported" */
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
} }
_off_t _off_t _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence)
_lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence)
{ {
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
/* return "not supported" */ /* return "not supported" */
@ -130,8 +119,7 @@ _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence)
#endif #endif
} }
int int _mkdir_r(struct _reent *ptr, const char *name, int mode)
_mkdir_r(struct _reent *ptr, const char *name, int mode)
{ {
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
/* return "not supported" */ /* return "not supported" */
@ -145,8 +133,7 @@ _mkdir_r(struct _reent *ptr, const char *name, int mode)
#endif #endif
} }
int int _open_r(struct _reent *ptr, const char *file, int flags, int mode)
_open_r(struct _reent *ptr, const char *file, int flags, int mode)
{ {
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
/* return "not supported" */ /* return "not supported" */
@ -160,8 +147,7 @@ _open_r(struct _reent *ptr, const char *file, int flags, int mode)
#endif #endif
} }
_ssize_t _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
_read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
{ {
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
/* return "not supported" */ /* return "not supported" */
@ -175,8 +161,7 @@ _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
#endif #endif
} }
int int _rename_r(struct _reent *ptr, const char *old, const char *new)
_rename_r(struct _reent *ptr, const char *old, const char *new)
{ {
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
/* return "not supported" */ /* return "not supported" */
@ -190,8 +175,7 @@ _rename_r(struct _reent *ptr, const char *old, const char *new)
#endif #endif
} }
int int _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
_stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
{ {
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
/* return "not supported" */ /* return "not supported" */
@ -205,8 +189,7 @@ _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
#endif #endif
} }
int int _unlink_r(struct _reent *ptr, const char *file)
_unlink_r(struct _reent *ptr, const char *file)
{ {
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
/* return "not supported" */ /* return "not supported" */
@ -217,16 +200,14 @@ _unlink_r(struct _reent *ptr, const char *file)
#endif #endif
} }
int int _wait_r(struct _reent *ptr, int *status)
_wait_r(struct _reent *ptr, int *status)
{ {
/* return "not supported" */ /* return "not supported" */
ptr->_errno = ENOTSUP; ptr->_errno = ENOTSUP;
return -1; return -1;
} }
_ssize_t _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
_write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
{ {
#ifndef RT_USING_DFS #ifndef RT_USING_DFS
#ifdef RT_USING_DEVICE #ifdef RT_USING_DEVICE
@ -253,8 +234,7 @@ _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
} }
#ifdef RT_USING_HEAP /* Memory routine */ #ifdef RT_USING_HEAP /* Memory routine */
void * void *_malloc_r (struct _reent *ptr, size_t size)
_malloc_r (struct _reent *ptr, size_t size)
{ {
void* result; void* result;
@ -267,8 +247,7 @@ _malloc_r (struct _reent *ptr, size_t size)
return result; return result;
} }
void * void *_realloc_r (struct _reent *ptr, void *old, size_t newlen)
_realloc_r (struct _reent *ptr, void *old, size_t newlen)
{ {
void* result; void* result;
@ -294,8 +273,7 @@ void *_calloc_r (struct _reent *ptr, size_t size, size_t len)
return result; return result;
} }
void void _free_r (struct _reent *ptr, void *addr)
_free_r (struct _reent *ptr, void *addr)
{ {
rt_free (addr); rt_free (addr);
} }
@ -309,16 +287,14 @@ _sbrk_r(struct _reent *ptr, ptrdiff_t incr)
#endif /*RT_USING_HEAP*/ #endif /*RT_USING_HEAP*/
/* for exit() and abort() */ /* for exit() and abort() */
__attribute__ ((noreturn)) void __attribute__ ((noreturn)) void _exit (int status)
_exit (int status)
{ {
extern void __rt_libc_exit(int status); extern void __rt_libc_exit(int status);
__rt_libc_exit(status); __rt_libc_exit(status);
while(1); while(1);
} }
void void _system(const char *s)
_system(const char *s)
{ {
extern int __rt_libc_system(const char *string); extern int __rt_libc_system(const char *string);
__rt_libc_system(s); __rt_libc_system(s);