From 76cab376adf0cf52a17d11e633be711ba6149c4a Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 14 Jan 2022 23:31:59 -0500 Subject: [libc] 调整文件结构 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../libc/compilers/common/extension/SConscript | 14 + components/libc/compilers/common/extension/fcntl.h | 71 +++ .../libc/compilers/common/extension/readme.md | 4 + .../libc/compilers/common/extension/sys/errno.h | 585 +++++++++++++++++++++ .../libc/compilers/common/extension/sys/select.h | 58 ++ .../libc/compilers/common/extension/sys/stat.h | 83 +++ .../libc/compilers/common/extension/sys/types.h | 40 ++ .../libc/compilers/common/extension/sys/unistd.h | 46 ++ .../libc/compilers/common/extension/unistd.h | 10 + components/libc/compilers/common/nogcc/SConscript | 14 - components/libc/compilers/common/nogcc/fcntl.h | 71 --- components/libc/compilers/common/nogcc/readme.md | 3 - components/libc/compilers/common/nogcc/sys/errno.h | 585 --------------------- .../libc/compilers/common/nogcc/sys/select.h | 58 -- components/libc/compilers/common/nogcc/sys/stat.h | 83 --- components/libc/compilers/common/nogcc/sys/types.h | 40 -- .../libc/compilers/common/nogcc/sys/unistd.h | 46 -- components/libc/compilers/common/nogcc/unistd.h | 10 - components/libc/compilers/gcc/SConscript | 15 - components/libc/compilers/gcc/newlib/README.md | 4 - components/libc/compilers/gcc/newlib/SConscript | 31 -- components/libc/compilers/gcc/newlib/fcntl.h | 24 - .../libc/compilers/gcc/newlib/legacy/SConscript | 15 - .../compilers/gcc/newlib/legacy/_select/SConscript | 20 - .../compilers/gcc/newlib/legacy/_select/readme.md | 2 - .../gcc/newlib/legacy/_select/sys/select.h | 58 -- components/libc/compilers/gcc/newlib/libc_syms.c | 53 -- .../libc/compilers/gcc/newlib/machine/time.h | 17 - components/libc/compilers/gcc/newlib/syscalls.c | 339 ------------ components/libc/compilers/newlib/README.md | 4 + components/libc/compilers/newlib/SConscript | 31 ++ components/libc/compilers/newlib/fcntl.h | 24 + components/libc/compilers/newlib/legacy/SConscript | 15 + .../compilers/newlib/legacy/_select/SConscript | 20 + .../libc/compilers/newlib/legacy/_select/readme.md | 2 + .../compilers/newlib/legacy/_select/sys/select.h | 58 ++ components/libc/compilers/newlib/libc_syms.c | 53 ++ components/libc/compilers/newlib/machine/time.h | 17 + components/libc/compilers/newlib/syscalls.c | 339 ++++++++++++ 39 files changed, 1474 insertions(+), 1488 deletions(-) create mode 100644 components/libc/compilers/common/extension/SConscript create mode 100644 components/libc/compilers/common/extension/fcntl.h create mode 100644 components/libc/compilers/common/extension/readme.md create mode 100644 components/libc/compilers/common/extension/sys/errno.h create mode 100644 components/libc/compilers/common/extension/sys/select.h create mode 100644 components/libc/compilers/common/extension/sys/stat.h create mode 100644 components/libc/compilers/common/extension/sys/types.h create mode 100644 components/libc/compilers/common/extension/sys/unistd.h create mode 100644 components/libc/compilers/common/extension/unistd.h delete mode 100644 components/libc/compilers/common/nogcc/SConscript delete mode 100644 components/libc/compilers/common/nogcc/fcntl.h delete mode 100644 components/libc/compilers/common/nogcc/readme.md delete mode 100644 components/libc/compilers/common/nogcc/sys/errno.h delete mode 100644 components/libc/compilers/common/nogcc/sys/select.h delete mode 100644 components/libc/compilers/common/nogcc/sys/stat.h delete mode 100644 components/libc/compilers/common/nogcc/sys/types.h delete mode 100644 components/libc/compilers/common/nogcc/sys/unistd.h delete mode 100644 components/libc/compilers/common/nogcc/unistd.h delete mode 100644 components/libc/compilers/gcc/SConscript delete mode 100644 components/libc/compilers/gcc/newlib/README.md delete mode 100644 components/libc/compilers/gcc/newlib/SConscript delete mode 100644 components/libc/compilers/gcc/newlib/fcntl.h delete mode 100644 components/libc/compilers/gcc/newlib/legacy/SConscript delete mode 100644 components/libc/compilers/gcc/newlib/legacy/_select/SConscript delete mode 100644 components/libc/compilers/gcc/newlib/legacy/_select/readme.md delete mode 100644 components/libc/compilers/gcc/newlib/legacy/_select/sys/select.h delete mode 100644 components/libc/compilers/gcc/newlib/libc_syms.c delete mode 100644 components/libc/compilers/gcc/newlib/machine/time.h delete mode 100644 components/libc/compilers/gcc/newlib/syscalls.c create mode 100644 components/libc/compilers/newlib/README.md create mode 100644 components/libc/compilers/newlib/SConscript create mode 100644 components/libc/compilers/newlib/fcntl.h create mode 100644 components/libc/compilers/newlib/legacy/SConscript create mode 100644 components/libc/compilers/newlib/legacy/_select/SConscript create mode 100644 components/libc/compilers/newlib/legacy/_select/readme.md create mode 100644 components/libc/compilers/newlib/legacy/_select/sys/select.h create mode 100644 components/libc/compilers/newlib/libc_syms.c create mode 100644 components/libc/compilers/newlib/machine/time.h create mode 100644 components/libc/compilers/newlib/syscalls.c (limited to 'components/libc') diff --git a/components/libc/compilers/common/extension/SConscript b/components/libc/compilers/common/extension/SConscript new file mode 100644 index 0000000000..dbc26ac177 --- /dev/null +++ b/components/libc/compilers/common/extension/SConscript @@ -0,0 +1,14 @@ +from building import * + +Import('rtconfig') + +src = [] +cwd = GetCurrentDir() +CPPPATH = [cwd] +group = [] + +src += Glob('*.c') + +if rtconfig.PLATFORM != 'gcc' or rtconfig.ARCH == 'sim': + group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH) +Return('group') diff --git a/components/libc/compilers/common/extension/fcntl.h b/components/libc/compilers/common/extension/fcntl.h new file mode 100644 index 0000000000..83c3ec0b6b --- /dev/null +++ b/components/libc/compilers/common/extension/fcntl.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-02 Meco Man First version + */ + +#ifndef __FCNTL_H__ +#define __FCNTL_H__ + +#include + +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 + +#define O_CREAT 0100 +#define O_EXCL 0200 +#define O_NOCTTY 0400 +#define O_TRUNC 01000 +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_DSYNC 010000 +#define O_SYNC 04010000 +#define O_RSYNC 04010000 +#define O_BINARY 0100000 +#define O_DIRECTORY 0200000 +#define O_NOFOLLOW 0400000 +#define O_CLOEXEC 02000000 + +#define O_ASYNC 020000 +#define O_DIRECT 040000 +#define O_LARGEFILE 0100000 +#define O_NOATIME 01000000 +#define O_PATH 010000000 +#define O_TMPFILE 020200000 +#define O_NDELAY O_NONBLOCK + +#define O_SEARCH O_PATH +#define O_EXEC O_PATH + +#define O_ACCMODE (03|O_SEARCH) + +#define F_DUPFD 0 +#define F_GETFD 1 +#define F_SETFD 2 +#define F_GETFL 3 +#define F_SETFL 4 + +#define F_SETOWN 8 +#define F_GETOWN 9 +#define F_SETSIG 10 +#define F_GETSIG 11 + +#define F_GETLK 12 +#define F_SETLK 13 +#define F_SETLKW 14 + +#define F_SETOWN_EX 15 +#define F_GETOWN_EX 16 + +#define F_GETOWNER_UIDS 17 + +int open(const char *file, int flags, ...); +int fcntl(int fildes, int cmd, ...); +int creat(const char *, mode_t); + +#endif diff --git a/components/libc/compilers/common/extension/readme.md b/components/libc/compilers/common/extension/readme.md new file mode 100644 index 0000000000..ca0df69246 --- /dev/null +++ b/components/libc/compilers/common/extension/readme.md @@ -0,0 +1,4 @@ +## Attentions + +This folder is "common" for toolchains, which only support ISO C, as an extension part, such as Keil-MDK and IAR. + diff --git a/components/libc/compilers/common/extension/sys/errno.h b/components/libc/compilers/common/extension/sys/errno.h new file mode 100644 index 0000000000..d53ce4b386 --- /dev/null +++ b/components/libc/compilers/common/extension/sys/errno.h @@ -0,0 +1,585 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-05-22 Meco Man The first version. + */ + +#ifndef __SYS_ERRNO_H__ +#define __SYS_ERRNO_H__ + +#if defined(__ARMCC_VERSION) +/* +defined in armcc/errno.h + +#define EDOM 1 +#define ERANGE 2 +#define EILSEQ 4 +#define ESIGNUM 3 +#define EINVAL 5 +#define ENOMEM 6 +*/ + +#define ERROR_BASE_NO 7 + +#elif defined(__IAR_SYSTEMS_ICC__) +/* defined in iar/errno.h +#define EDOM 33 +#define ERANGE 34 +#define EFPOS 35 +#define EILSEQ 36 +*/ +#define ERROR_BASE_NO 36 + +#else +#define ERROR_BASE_NO 0 +#endif + +#if defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__) +#include + +#ifndef EPERM +#define EPERM (ERROR_BASE_NO + 1) +#endif + +#ifndef ENOENT +#define ENOENT (ERROR_BASE_NO + 2) +#endif + +#ifndef ESRCH +#define ESRCH (ERROR_BASE_NO + 3) +#endif + +#ifndef EINTR +#define EINTR (ERROR_BASE_NO + 4) +#endif + +#ifndef EIO +#define EIO (ERROR_BASE_NO + 5) +#endif + +#ifndef ENXIO +#define ENXIO (ERROR_BASE_NO + 6) +#endif + +#ifndef E2BIG +#define E2BIG (ERROR_BASE_NO + 7) +#endif + +#ifndef ENOEXEC +#define ENOEXEC (ERROR_BASE_NO + 8) +#endif + +#ifndef EBADF +#define EBADF (ERROR_BASE_NO + 9) +#endif + +#ifndef ECHILD +#define ECHILD (ERROR_BASE_NO + 10) +#endif + +#ifndef EAGAIN +#define EAGAIN (ERROR_BASE_NO + 11) +#endif + +#ifndef ENOMEM +#define ENOMEM (ERROR_BASE_NO + 12) +#endif + +#ifndef EACCES +#define EACCES (ERROR_BASE_NO + 13) +#endif + +#ifndef EFAULT +#define EFAULT (ERROR_BASE_NO + 14) +#endif + +#ifndef ENOTBLK +#define ENOTBLK (ERROR_BASE_NO + 15) +#endif + +#ifndef EBUSY +#define EBUSY (ERROR_BASE_NO + 16) +#endif + +#ifndef EEXIST +#define EEXIST (ERROR_BASE_NO + 17) +#endif + +#ifndef EXDEV +#define EXDEV (ERROR_BASE_NO + 18) +#endif + +#ifndef ENODEV +#define ENODEV (ERROR_BASE_NO + 19) +#endif + +#ifndef ENOTDIR +#define ENOTDIR (ERROR_BASE_NO + 20) +#endif + +#ifndef EISDIR +#define EISDIR (ERROR_BASE_NO + 21) +#endif + +#ifndef EINVAL +#define EINVAL (ERROR_BASE_NO + 22) +#endif + +#ifndef ENFILE +#define ENFILE (ERROR_BASE_NO + 23) +#endif + +#ifndef EMFILE +#define EMFILE (ERROR_BASE_NO + 24) +#endif + +#ifndef ENOTTY +#define ENOTTY (ERROR_BASE_NO + 25) +#endif + +#ifndef ETXTBSY +#define ETXTBSY (ERROR_BASE_NO + 26) +#endif + +#ifndef EFBIG +#define EFBIG (ERROR_BASE_NO + 27) +#endif + +#ifndef ENOSPC +#define ENOSPC (ERROR_BASE_NO + 28) +#endif + +#ifndef ESPIPE +#define ESPIPE (ERROR_BASE_NO + 29) +#endif + +#ifndef EROFS +#define EROFS (ERROR_BASE_NO + 30) +#endif + +#ifndef EMLINK +#define EMLINK (ERROR_BASE_NO + 31) +#endif + +#ifndef EPIPE +#define EPIPE (ERROR_BASE_NO + 32) +#endif + +#ifndef EDOM +#define EDOM (ERROR_BASE_NO + 33) +#endif + +#ifndef ERANGE +#define ERANGE (ERROR_BASE_NO + 34) +#endif + +#ifndef EDEADLK +#define EDEADLK (ERROR_BASE_NO + 35) +#endif + +#ifndef ENAMETOOLONG +#define ENAMETOOLONG (ERROR_BASE_NO + 36) +#endif + +#ifndef ENOLCK +#define ENOLCK (ERROR_BASE_NO + 37) +#endif + +#ifndef ENOSYS +#define ENOSYS (ERROR_BASE_NO + 38) +#endif + +#ifndef ENOTEMPTY +#define ENOTEMPTY (ERROR_BASE_NO + 39) +#endif + +#ifndef ELOOP +#define ELOOP (ERROR_BASE_NO + 40) +#endif + +#ifndef EWOULDBLOCK +#define EWOULDBLOCK EAGAIN +#endif + +#ifndef ENOMSG +#define ENOMSG (ERROR_BASE_NO + 42) +#endif + +#ifndef EIDRM +#define EIDRM (ERROR_BASE_NO + 43) +#endif + +#ifndef ECHRNG +#define ECHRNG (ERROR_BASE_NO + 44) +#endif + +#ifndef EL2NSYNC +#define EL2NSYNC (ERROR_BASE_NO + 45) +#endif + +#ifndef EL3HLT +#define EL3HLT (ERROR_BASE_NO + 46) +#endif + +#ifndef EL3RST +#define EL3RST (ERROR_BASE_NO + 47) +#endif + +#ifndef ELNRNG +#define ELNRNG (ERROR_BASE_NO + 48) +#endif + +#ifndef EUNATCH +#define EUNATCH (ERROR_BASE_NO + 49) +#endif + +#ifndef ENOCSI +#define ENOCSI (ERROR_BASE_NO + 50) +#endif + +#ifndef EL2HLT +#define EL2HLT (ERROR_BASE_NO + 51) +#endif + +#ifndef EBADE +#define EBADE (ERROR_BASE_NO + 52) +#endif + +#ifndef EBADR +#define EBADR (ERROR_BASE_NO + 53) +#endif + +#ifndef EXFULL +#define EXFULL (ERROR_BASE_NO + 54) +#endif + +#ifndef ENOANO +#define ENOANO (ERROR_BASE_NO + 55) +#endif + +#ifndef EBADRQC +#define EBADRQC (ERROR_BASE_NO + 56) +#endif + +#ifndef EBADSLT +#define EBADSLT (ERROR_BASE_NO + 57) +#endif + +#ifndef EDEADLOCK +#define EDEADLOCK EDEADLK +#endif + +#ifndef EBFONT +#define EBFONT (ERROR_BASE_NO + 59) +#endif + +#ifndef ENOSTR +#define ENOSTR (ERROR_BASE_NO + 60) +#endif + +#ifndef ENODATA +#define ENODATA (ERROR_BASE_NO + 61) +#endif + +#ifndef ETIME +#define ETIME (ERROR_BASE_NO + 62) +#endif + +#ifndef ENOSR +#define ENOSR (ERROR_BASE_NO + 63) +#endif + +#ifndef ENONET +#define ENONET (ERROR_BASE_NO + 64) +#endif + +#ifndef ENOPKG +#define ENOPKG (ERROR_BASE_NO + 65) +#endif + +#ifndef EREMOTE +#define EREMOTE (ERROR_BASE_NO + 66) +#endif + +#ifndef ENOLINK +#define ENOLINK (ERROR_BASE_NO + 67) +#endif + +#ifndef EADV +#define EADV (ERROR_BASE_NO + 68) +#endif + +#ifndef ESRMNT +#define ESRMNT (ERROR_BASE_NO + 69) +#endif + +#ifndef ECOMM +#define ECOMM (ERROR_BASE_NO + 70) +#endif + +#ifndef EPROTO +#define EPROTO (ERROR_BASE_NO + 71) +#endif + +#ifndef EMULTIHOP +#define EMULTIHOP (ERROR_BASE_NO + 72) +#endif + +#ifndef EDOTDOT +#define EDOTDOT (ERROR_BASE_NO + 73) +#endif + +#ifndef EBADMSG +#define EBADMSG (ERROR_BASE_NO + 74) +#endif + +#ifndef EOVERFLOW +#define EOVERFLOW (ERROR_BASE_NO + 75) +#endif + +#ifndef ENOTUNIQ +#define ENOTUNIQ (ERROR_BASE_NO + 76) +#endif + +#ifndef EBADFD +#define EBADFD (ERROR_BASE_NO + 77) +#endif + +#ifndef EREMCHG +#define EREMCHG (ERROR_BASE_NO + 78) +#endif + +#ifndef ELIBACC +#define ELIBACC (ERROR_BASE_NO + 79) +#endif + +#ifndef ELIBBAD +#define ELIBBAD (ERROR_BASE_NO + 80) +#endif + +#ifndef ELIBSCN +#define ELIBSCN (ERROR_BASE_NO + 81) +#endif + +#ifndef ELIBMAX +#define ELIBMAX (ERROR_BASE_NO + 82) +#endif + +#ifndef ELIBEXEC +#define ELIBEXEC (ERROR_BASE_NO + 83) +#endif + +#ifndef EILSEQ +#define EILSEQ (ERROR_BASE_NO + 84) +#endif + +#ifndef ERESTART +#define ERESTART (ERROR_BASE_NO + 85) +#endif + +#ifndef ESTRPIPE +#define ESTRPIPE (ERROR_BASE_NO + 86) +#endif + +#ifndef EUSERS +#define EUSERS (ERROR_BASE_NO + 87) +#endif + +#ifndef ENOTSOCK +#define ENOTSOCK (ERROR_BASE_NO + 88) +#endif + +#ifndef EDESTADDRREQ +#define EDESTADDRREQ (ERROR_BASE_NO + 89) +#endif + +#ifndef EMSGSIZE +#define EMSGSIZE (ERROR_BASE_NO + 90) +#endif + +#ifndef EPROTOTYPE +#define EPROTOTYPE (ERROR_BASE_NO + 91) +#endif + +#ifndef ENOPROTOOPT +#define ENOPROTOOPT (ERROR_BASE_NO + 92) +#endif + +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT (ERROR_BASE_NO + 93) +#endif + +#ifndef ESOCKTNOSUPPORT +#define ESOCKTNOSUPPORT (ERROR_BASE_NO + 94) +#endif + +#ifndef EOPNOTSUPP +#define EOPNOTSUPP (ERROR_BASE_NO + 95) +#endif + +#ifndef ENOTSUP +#define ENOTSUP EOPNOTSUPP +#endif + +#ifndef EPFNOSUPPORT +#define EPFNOSUPPORT (ERROR_BASE_NO + 96) +#endif + +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT (ERROR_BASE_NO + 97) +#endif + +#ifndef EADDRINUSE +#define EADDRINUSE (ERROR_BASE_NO + 98) +#endif + +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL (ERROR_BASE_NO + 99) +#endif + +#ifndef ENETDOWN +#define ENETDOWN (ERROR_BASE_NO + 100) +#endif + +#ifndef ENETUNREACH +#define ENETUNREACH (ERROR_BASE_NO + 101) +#endif + +#ifndef ENETRESET +#define ENETRESET (ERROR_BASE_NO + 102) +#endif + +#ifndef ECONNABORTED +#define ECONNABORTED (ERROR_BASE_NO + 103) +#endif + +#ifndef ECONNRESET +#define ECONNRESET (ERROR_BASE_NO + 104) +#endif + +#ifndef ENOBUFS +#define ENOBUFS (ERROR_BASE_NO + 105) +#endif + +#ifndef EISCONN +#define EISCONN (ERROR_BASE_NO + 106) +#endif + +#ifndef ENOTCONN +#define ENOTCONN (ERROR_BASE_NO + 107) +#endif + +#ifndef ESHUTDOWN +#define ESHUTDOWN (ERROR_BASE_NO + 108) +#endif + +#ifndef ETOOMANYREFS +#define ETOOMANYREFS (ERROR_BASE_NO + 109) +#endif + +#ifndef ETIMEDOUT +#define ETIMEDOUT (ERROR_BASE_NO + 110) +#endif + +#ifndef ECONNREFUSED +#define ECONNREFUSED (ERROR_BASE_NO + 111) +#endif + +#ifndef EHOSTDOWN +#define EHOSTDOWN (ERROR_BASE_NO + 112) +#endif + +#ifndef EHOSTUNREACH +#define EHOSTUNREACH (ERROR_BASE_NO + 113) +#endif + +#ifndef EALREADY +#define EALREADY (ERROR_BASE_NO + 114) +#endif + +#ifndef EINPROGRESS +#define EINPROGRESS (ERROR_BASE_NO + 115) +#endif + +#ifndef ESTALE +#define ESTALE (ERROR_BASE_NO + 116) +#endif + +#ifndef EUCLEAN +#define EUCLEAN (ERROR_BASE_NO + 117) +#endif + +#ifndef ENOTNAM +#define ENOTNAM (ERROR_BASE_NO + 118) +#endif + +#ifndef ENAVAIL +#define ENAVAIL (ERROR_BASE_NO + 119) +#endif + +#ifndef EISNAM +#define EISNAM (ERROR_BASE_NO + 120) +#endif + +#ifndef EREMOTEIO +#define EREMOTEIO (ERROR_BASE_NO + 121) +#endif + +#ifndef EDQUOT +#define EDQUOT (ERROR_BASE_NO + 122) +#endif + +#ifndef ENOMEDIUM +#define ENOMEDIUM (ERROR_BASE_NO + 123) +#endif + +#ifndef EMEDIUMTYPE +#define EMEDIUMTYPE (ERROR_BASE_NO + 124) +#endif + +#ifndef ECANCELED +#define ECANCELED (ERROR_BASE_NO + 125) +#endif + +#ifndef ENOKEY +#define ENOKEY (ERROR_BASE_NO + 126) +#endif + +#ifndef EKEYEXPIRED +#define EKEYEXPIRED (ERROR_BASE_NO + 127) +#endif + +#ifndef EKEYREVOKED +#define EKEYREVOKED (ERROR_BASE_NO + 128) +#endif + +#ifndef EKEYREJECTED +#define EKEYREJECTED (ERROR_BASE_NO + 129) +#endif + +#ifndef EOWNERDEAD +#define EOWNERDEAD (ERROR_BASE_NO + 130) +#endif + +#ifndef ENOTRECOVERABLE +#define ENOTRECOVERABLE (ERROR_BASE_NO + 131) +#endif + +#ifndef ERFKILL +#define ERFKILL (ERROR_BASE_NO + 132) +#endif + +#ifndef EHWPOISON +#define EHWPOISON (ERROR_BASE_NO + 133) +#endif + +#elif defined(_WIN32) +#include + +#endif /* defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__) */ + +#endif /* __SYS_ERRNO_H__ */ diff --git a/components/libc/compilers/common/extension/sys/select.h b/components/libc/compilers/common/extension/sys/select.h new file mode 100644 index 0000000000..44f9b4ed91 --- /dev/null +++ b/components/libc/compilers/common/extension/sys/select.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-07-21 Meco Man The first version + * 2021-12-25 Meco Man Handle newlib 2.2.0 or lower version + */ + +#ifndef __SYS_SELECT_H__ +#define __SYS_SELECT_H__ + +#include +#include +#include + +#ifdef _WIN32 +#include +#endif + +#ifndef FD_SETSIZE +#define FD_SETSIZE 32 +#endif + +#ifdef SAL_USING_POSIX +#ifdef FD_SETSIZE +#undef FD_SETSIZE +#endif +#define FD_SETSIZE DFS_FD_MAX +#endif /* SAL_USING_POSIX */ + +typedef long fd_mask; + +#ifndef _WIN32 +#ifndef _SYS_TYPES_FD_SET /* Newlib 2.2.0 or lower version */ +#define NBBY 8 /* number of bits in a byte */ +#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ +#ifndef howmany +#define howmany(x,y) (((x)+((y)-1))/(y)) +#endif /* howmany */ + +typedef struct _types_fd_set { + fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; +} _types_fd_set; +#define fd_set _types_fd_set + +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) +#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p))) +#endif /* _SYS_TYPES_FD_SET */ + +int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); +#endif /* _WIN32 */ + +#endif /* __SYS_SELECT_H__ */ diff --git a/components/libc/compilers/common/extension/sys/stat.h b/components/libc/compilers/common/extension/sys/stat.h new file mode 100644 index 0000000000..107c15decf --- /dev/null +++ b/components/libc/compilers/common/extension/sys/stat.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-02 Meco Man First version + */ + +#ifndef __SYS_STAT_H__ +#define __SYS_STAT_H__ + +#include +#include + +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +struct stat +{ + struct rt_device *st_dev; + uint16_t st_ino; + uint16_t st_mode; + uint16_t st_nlink; + uint16_t st_uid; + uint16_t st_gid; + struct rt_device *st_rdev; + uint32_t st_size; + time_t st_atime; + long st_spare1; + time_t st_mtime; + long st_spare2; + time_t st_ctime; + long st_spare3; + uint32_t st_blksize; + uint32_t st_blocks; + long st_spare4[2]; +}; + +int chmod(const char *, mode_t); +int fchmod(int, mode_t); +int fstat(int, struct stat *); +int lstat(const char *, struct stat *); +int mkdir(const char *, mode_t); +int mkfifo(const char *, mode_t); +int mknod(const char *, mode_t, dev_t); +int stat(const char *, struct stat *); +mode_t umask(mode_t); + +#endif diff --git a/components/libc/compilers/common/extension/sys/types.h b/components/libc/compilers/common/extension/sys/types.h new file mode 100644 index 0000000000..32b2493c95 --- /dev/null +++ b/components/libc/compilers/common/extension/sys/types.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2020-09-05 Meco Man fix bugs + * 2020-12-16 Meco Man add useconds_t + */ + +#ifndef __SYS_TYPES_H__ +#define __SYS_TYPES_H__ + +#include +#include +#include + +typedef int32_t clockid_t; +typedef int32_t key_t; /* Used for interprocess communication. */ +typedef int pid_t; /* Used for process IDs and process group IDs. */ +typedef unsigned short uid_t; +typedef unsigned short gid_t; +typedef signed long off_t; +typedef int mode_t; +#ifndef ARCH_CPU_64BIT +typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */ +#else +typedef long signed int ssize_t; /* Used for a count of bytes or an error indication. */ +#endif +typedef long suseconds_t; /* microseconds. */ +typedef unsigned long useconds_t; /* microseconds (unsigned) */ + +typedef unsigned long dev_t; + +typedef unsigned int u_int; +typedef unsigned char u_char; +typedef unsigned long u_long; + +#endif diff --git a/components/libc/compilers/common/extension/sys/unistd.h b/components/libc/compilers/common/extension/sys/unistd.h new file mode 100644 index 0000000000..650c87dc18 --- /dev/null +++ b/components/libc/compilers/common/extension/sys/unistd.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2020-12-16 Meco Man add usleep + * 2021-09-11 Meco Man move functions from dfs_posix.h to unistd.h + */ + +#ifndef __SYS_UNISTD_H__ +#define __SYS_UNISTD_H__ + +#include +#include "types.h" /* */ + +#define STDIN_FILENO 0 /* standard input file descriptor */ +#define STDOUT_FILENO 1 /* standard output file descriptor */ +#define STDERR_FILENO 2 /* standard error file descriptor */ + +ssize_t read(int fd, void *buf, size_t len); +ssize_t write(int fd, const void *buf, size_t len); +off_t lseek(int fd, off_t offset, int whence); +int fsync(int fildes); +int unlink(const char *pathname); +int close(int d); +int ftruncate(int fd, off_t length); +int rmdir(const char *path); +int chdir(const char *path); +char *getcwd(char *buf, size_t size); +int access(const char *path, int amode); +int pipe(int fildes[2]); +int isatty(int fd); +char *ttyname(int desc); +unsigned int sleep(unsigned int seconds); +int usleep(useconds_t usec); +pid_t gettid(void); +pid_t getpid(void); +pid_t getppid(void); +uid_t getuid(void); +uid_t geteuid(void); +gid_t getgid(void); +gid_t getegid(void); + +#endif /* _SYS_UNISTD_H */ diff --git a/components/libc/compilers/common/extension/unistd.h b/components/libc/compilers/common/extension/unistd.h new file mode 100644 index 0000000000..4dd71c842e --- /dev/null +++ b/components/libc/compilers/common/extension/unistd.h @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + */ + +#include "sys/unistd.h" diff --git a/components/libc/compilers/common/nogcc/SConscript b/components/libc/compilers/common/nogcc/SConscript deleted file mode 100644 index dbc26ac177..0000000000 --- a/components/libc/compilers/common/nogcc/SConscript +++ /dev/null @@ -1,14 +0,0 @@ -from building import * - -Import('rtconfig') - -src = [] -cwd = GetCurrentDir() -CPPPATH = [cwd] -group = [] - -src += Glob('*.c') - -if rtconfig.PLATFORM != 'gcc' or rtconfig.ARCH == 'sim': - group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH) -Return('group') diff --git a/components/libc/compilers/common/nogcc/fcntl.h b/components/libc/compilers/common/nogcc/fcntl.h deleted file mode 100644 index 83c3ec0b6b..0000000000 --- a/components/libc/compilers/common/nogcc/fcntl.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-09-02 Meco Man First version - */ - -#ifndef __FCNTL_H__ -#define __FCNTL_H__ - -#include - -#define O_RDONLY 00 -#define O_WRONLY 01 -#define O_RDWR 02 - -#define O_CREAT 0100 -#define O_EXCL 0200 -#define O_NOCTTY 0400 -#define O_TRUNC 01000 -#define O_APPEND 02000 -#define O_NONBLOCK 04000 -#define O_DSYNC 010000 -#define O_SYNC 04010000 -#define O_RSYNC 04010000 -#define O_BINARY 0100000 -#define O_DIRECTORY 0200000 -#define O_NOFOLLOW 0400000 -#define O_CLOEXEC 02000000 - -#define O_ASYNC 020000 -#define O_DIRECT 040000 -#define O_LARGEFILE 0100000 -#define O_NOATIME 01000000 -#define O_PATH 010000000 -#define O_TMPFILE 020200000 -#define O_NDELAY O_NONBLOCK - -#define O_SEARCH O_PATH -#define O_EXEC O_PATH - -#define O_ACCMODE (03|O_SEARCH) - -#define F_DUPFD 0 -#define F_GETFD 1 -#define F_SETFD 2 -#define F_GETFL 3 -#define F_SETFL 4 - -#define F_SETOWN 8 -#define F_GETOWN 9 -#define F_SETSIG 10 -#define F_GETSIG 11 - -#define F_GETLK 12 -#define F_SETLK 13 -#define F_SETLKW 14 - -#define F_SETOWN_EX 15 -#define F_GETOWN_EX 16 - -#define F_GETOWNER_UIDS 17 - -int open(const char *file, int flags, ...); -int fcntl(int fildes, int cmd, ...); -int creat(const char *, mode_t); - -#endif diff --git a/components/libc/compilers/common/nogcc/readme.md b/components/libc/compilers/common/nogcc/readme.md deleted file mode 100644 index b10940d003..0000000000 --- a/components/libc/compilers/common/nogcc/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -## Attentions - -This folder is "common" for toolchains excluding gcc. \ No newline at end of file diff --git a/components/libc/compilers/common/nogcc/sys/errno.h b/components/libc/compilers/common/nogcc/sys/errno.h deleted file mode 100644 index d53ce4b386..0000000000 --- a/components/libc/compilers/common/nogcc/sys/errno.h +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-05-22 Meco Man The first version. - */ - -#ifndef __SYS_ERRNO_H__ -#define __SYS_ERRNO_H__ - -#if defined(__ARMCC_VERSION) -/* -defined in armcc/errno.h - -#define EDOM 1 -#define ERANGE 2 -#define EILSEQ 4 -#define ESIGNUM 3 -#define EINVAL 5 -#define ENOMEM 6 -*/ - -#define ERROR_BASE_NO 7 - -#elif defined(__IAR_SYSTEMS_ICC__) -/* defined in iar/errno.h -#define EDOM 33 -#define ERANGE 34 -#define EFPOS 35 -#define EILSEQ 36 -*/ -#define ERROR_BASE_NO 36 - -#else -#define ERROR_BASE_NO 0 -#endif - -#if defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__) -#include - -#ifndef EPERM -#define EPERM (ERROR_BASE_NO + 1) -#endif - -#ifndef ENOENT -#define ENOENT (ERROR_BASE_NO + 2) -#endif - -#ifndef ESRCH -#define ESRCH (ERROR_BASE_NO + 3) -#endif - -#ifndef EINTR -#define EINTR (ERROR_BASE_NO + 4) -#endif - -#ifndef EIO -#define EIO (ERROR_BASE_NO + 5) -#endif - -#ifndef ENXIO -#define ENXIO (ERROR_BASE_NO + 6) -#endif - -#ifndef E2BIG -#define E2BIG (ERROR_BASE_NO + 7) -#endif - -#ifndef ENOEXEC -#define ENOEXEC (ERROR_BASE_NO + 8) -#endif - -#ifndef EBADF -#define EBADF (ERROR_BASE_NO + 9) -#endif - -#ifndef ECHILD -#define ECHILD (ERROR_BASE_NO + 10) -#endif - -#ifndef EAGAIN -#define EAGAIN (ERROR_BASE_NO + 11) -#endif - -#ifndef ENOMEM -#define ENOMEM (ERROR_BASE_NO + 12) -#endif - -#ifndef EACCES -#define EACCES (ERROR_BASE_NO + 13) -#endif - -#ifndef EFAULT -#define EFAULT (ERROR_BASE_NO + 14) -#endif - -#ifndef ENOTBLK -#define ENOTBLK (ERROR_BASE_NO + 15) -#endif - -#ifndef EBUSY -#define EBUSY (ERROR_BASE_NO + 16) -#endif - -#ifndef EEXIST -#define EEXIST (ERROR_BASE_NO + 17) -#endif - -#ifndef EXDEV -#define EXDEV (ERROR_BASE_NO + 18) -#endif - -#ifndef ENODEV -#define ENODEV (ERROR_BASE_NO + 19) -#endif - -#ifndef ENOTDIR -#define ENOTDIR (ERROR_BASE_NO + 20) -#endif - -#ifndef EISDIR -#define EISDIR (ERROR_BASE_NO + 21) -#endif - -#ifndef EINVAL -#define EINVAL (ERROR_BASE_NO + 22) -#endif - -#ifndef ENFILE -#define ENFILE (ERROR_BASE_NO + 23) -#endif - -#ifndef EMFILE -#define EMFILE (ERROR_BASE_NO + 24) -#endif - -#ifndef ENOTTY -#define ENOTTY (ERROR_BASE_NO + 25) -#endif - -#ifndef ETXTBSY -#define ETXTBSY (ERROR_BASE_NO + 26) -#endif - -#ifndef EFBIG -#define EFBIG (ERROR_BASE_NO + 27) -#endif - -#ifndef ENOSPC -#define ENOSPC (ERROR_BASE_NO + 28) -#endif - -#ifndef ESPIPE -#define ESPIPE (ERROR_BASE_NO + 29) -#endif - -#ifndef EROFS -#define EROFS (ERROR_BASE_NO + 30) -#endif - -#ifndef EMLINK -#define EMLINK (ERROR_BASE_NO + 31) -#endif - -#ifndef EPIPE -#define EPIPE (ERROR_BASE_NO + 32) -#endif - -#ifndef EDOM -#define EDOM (ERROR_BASE_NO + 33) -#endif - -#ifndef ERANGE -#define ERANGE (ERROR_BASE_NO + 34) -#endif - -#ifndef EDEADLK -#define EDEADLK (ERROR_BASE_NO + 35) -#endif - -#ifndef ENAMETOOLONG -#define ENAMETOOLONG (ERROR_BASE_NO + 36) -#endif - -#ifndef ENOLCK -#define ENOLCK (ERROR_BASE_NO + 37) -#endif - -#ifndef ENOSYS -#define ENOSYS (ERROR_BASE_NO + 38) -#endif - -#ifndef ENOTEMPTY -#define ENOTEMPTY (ERROR_BASE_NO + 39) -#endif - -#ifndef ELOOP -#define ELOOP (ERROR_BASE_NO + 40) -#endif - -#ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN -#endif - -#ifndef ENOMSG -#define ENOMSG (ERROR_BASE_NO + 42) -#endif - -#ifndef EIDRM -#define EIDRM (ERROR_BASE_NO + 43) -#endif - -#ifndef ECHRNG -#define ECHRNG (ERROR_BASE_NO + 44) -#endif - -#ifndef EL2NSYNC -#define EL2NSYNC (ERROR_BASE_NO + 45) -#endif - -#ifndef EL3HLT -#define EL3HLT (ERROR_BASE_NO + 46) -#endif - -#ifndef EL3RST -#define EL3RST (ERROR_BASE_NO + 47) -#endif - -#ifndef ELNRNG -#define ELNRNG (ERROR_BASE_NO + 48) -#endif - -#ifndef EUNATCH -#define EUNATCH (ERROR_BASE_NO + 49) -#endif - -#ifndef ENOCSI -#define ENOCSI (ERROR_BASE_NO + 50) -#endif - -#ifndef EL2HLT -#define EL2HLT (ERROR_BASE_NO + 51) -#endif - -#ifndef EBADE -#define EBADE (ERROR_BASE_NO + 52) -#endif - -#ifndef EBADR -#define EBADR (ERROR_BASE_NO + 53) -#endif - -#ifndef EXFULL -#define EXFULL (ERROR_BASE_NO + 54) -#endif - -#ifndef ENOANO -#define ENOANO (ERROR_BASE_NO + 55) -#endif - -#ifndef EBADRQC -#define EBADRQC (ERROR_BASE_NO + 56) -#endif - -#ifndef EBADSLT -#define EBADSLT (ERROR_BASE_NO + 57) -#endif - -#ifndef EDEADLOCK -#define EDEADLOCK EDEADLK -#endif - -#ifndef EBFONT -#define EBFONT (ERROR_BASE_NO + 59) -#endif - -#ifndef ENOSTR -#define ENOSTR (ERROR_BASE_NO + 60) -#endif - -#ifndef ENODATA -#define ENODATA (ERROR_BASE_NO + 61) -#endif - -#ifndef ETIME -#define ETIME (ERROR_BASE_NO + 62) -#endif - -#ifndef ENOSR -#define ENOSR (ERROR_BASE_NO + 63) -#endif - -#ifndef ENONET -#define ENONET (ERROR_BASE_NO + 64) -#endif - -#ifndef ENOPKG -#define ENOPKG (ERROR_BASE_NO + 65) -#endif - -#ifndef EREMOTE -#define EREMOTE (ERROR_BASE_NO + 66) -#endif - -#ifndef ENOLINK -#define ENOLINK (ERROR_BASE_NO + 67) -#endif - -#ifndef EADV -#define EADV (ERROR_BASE_NO + 68) -#endif - -#ifndef ESRMNT -#define ESRMNT (ERROR_BASE_NO + 69) -#endif - -#ifndef ECOMM -#define ECOMM (ERROR_BASE_NO + 70) -#endif - -#ifndef EPROTO -#define EPROTO (ERROR_BASE_NO + 71) -#endif - -#ifndef EMULTIHOP -#define EMULTIHOP (ERROR_BASE_NO + 72) -#endif - -#ifndef EDOTDOT -#define EDOTDOT (ERROR_BASE_NO + 73) -#endif - -#ifndef EBADMSG -#define EBADMSG (ERROR_BASE_NO + 74) -#endif - -#ifndef EOVERFLOW -#define EOVERFLOW (ERROR_BASE_NO + 75) -#endif - -#ifndef ENOTUNIQ -#define ENOTUNIQ (ERROR_BASE_NO + 76) -#endif - -#ifndef EBADFD -#define EBADFD (ERROR_BASE_NO + 77) -#endif - -#ifndef EREMCHG -#define EREMCHG (ERROR_BASE_NO + 78) -#endif - -#ifndef ELIBACC -#define ELIBACC (ERROR_BASE_NO + 79) -#endif - -#ifndef ELIBBAD -#define ELIBBAD (ERROR_BASE_NO + 80) -#endif - -#ifndef ELIBSCN -#define ELIBSCN (ERROR_BASE_NO + 81) -#endif - -#ifndef ELIBMAX -#define ELIBMAX (ERROR_BASE_NO + 82) -#endif - -#ifndef ELIBEXEC -#define ELIBEXEC (ERROR_BASE_NO + 83) -#endif - -#ifndef EILSEQ -#define EILSEQ (ERROR_BASE_NO + 84) -#endif - -#ifndef ERESTART -#define ERESTART (ERROR_BASE_NO + 85) -#endif - -#ifndef ESTRPIPE -#define ESTRPIPE (ERROR_BASE_NO + 86) -#endif - -#ifndef EUSERS -#define EUSERS (ERROR_BASE_NO + 87) -#endif - -#ifndef ENOTSOCK -#define ENOTSOCK (ERROR_BASE_NO + 88) -#endif - -#ifndef EDESTADDRREQ -#define EDESTADDRREQ (ERROR_BASE_NO + 89) -#endif - -#ifndef EMSGSIZE -#define EMSGSIZE (ERROR_BASE_NO + 90) -#endif - -#ifndef EPROTOTYPE -#define EPROTOTYPE (ERROR_BASE_NO + 91) -#endif - -#ifndef ENOPROTOOPT -#define ENOPROTOOPT (ERROR_BASE_NO + 92) -#endif - -#ifndef EPROTONOSUPPORT -#define EPROTONOSUPPORT (ERROR_BASE_NO + 93) -#endif - -#ifndef ESOCKTNOSUPPORT -#define ESOCKTNOSUPPORT (ERROR_BASE_NO + 94) -#endif - -#ifndef EOPNOTSUPP -#define EOPNOTSUPP (ERROR_BASE_NO + 95) -#endif - -#ifndef ENOTSUP -#define ENOTSUP EOPNOTSUPP -#endif - -#ifndef EPFNOSUPPORT -#define EPFNOSUPPORT (ERROR_BASE_NO + 96) -#endif - -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT (ERROR_BASE_NO + 97) -#endif - -#ifndef EADDRINUSE -#define EADDRINUSE (ERROR_BASE_NO + 98) -#endif - -#ifndef EADDRNOTAVAIL -#define EADDRNOTAVAIL (ERROR_BASE_NO + 99) -#endif - -#ifndef ENETDOWN -#define ENETDOWN (ERROR_BASE_NO + 100) -#endif - -#ifndef ENETUNREACH -#define ENETUNREACH (ERROR_BASE_NO + 101) -#endif - -#ifndef ENETRESET -#define ENETRESET (ERROR_BASE_NO + 102) -#endif - -#ifndef ECONNABORTED -#define ECONNABORTED (ERROR_BASE_NO + 103) -#endif - -#ifndef ECONNRESET -#define ECONNRESET (ERROR_BASE_NO + 104) -#endif - -#ifndef ENOBUFS -#define ENOBUFS (ERROR_BASE_NO + 105) -#endif - -#ifndef EISCONN -#define EISCONN (ERROR_BASE_NO + 106) -#endif - -#ifndef ENOTCONN -#define ENOTCONN (ERROR_BASE_NO + 107) -#endif - -#ifndef ESHUTDOWN -#define ESHUTDOWN (ERROR_BASE_NO + 108) -#endif - -#ifndef ETOOMANYREFS -#define ETOOMANYREFS (ERROR_BASE_NO + 109) -#endif - -#ifndef ETIMEDOUT -#define ETIMEDOUT (ERROR_BASE_NO + 110) -#endif - -#ifndef ECONNREFUSED -#define ECONNREFUSED (ERROR_BASE_NO + 111) -#endif - -#ifndef EHOSTDOWN -#define EHOSTDOWN (ERROR_BASE_NO + 112) -#endif - -#ifndef EHOSTUNREACH -#define EHOSTUNREACH (ERROR_BASE_NO + 113) -#endif - -#ifndef EALREADY -#define EALREADY (ERROR_BASE_NO + 114) -#endif - -#ifndef EINPROGRESS -#define EINPROGRESS (ERROR_BASE_NO + 115) -#endif - -#ifndef ESTALE -#define ESTALE (ERROR_BASE_NO + 116) -#endif - -#ifndef EUCLEAN -#define EUCLEAN (ERROR_BASE_NO + 117) -#endif - -#ifndef ENOTNAM -#define ENOTNAM (ERROR_BASE_NO + 118) -#endif - -#ifndef ENAVAIL -#define ENAVAIL (ERROR_BASE_NO + 119) -#endif - -#ifndef EISNAM -#define EISNAM (ERROR_BASE_NO + 120) -#endif - -#ifndef EREMOTEIO -#define EREMOTEIO (ERROR_BASE_NO + 121) -#endif - -#ifndef EDQUOT -#define EDQUOT (ERROR_BASE_NO + 122) -#endif - -#ifndef ENOMEDIUM -#define ENOMEDIUM (ERROR_BASE_NO + 123) -#endif - -#ifndef EMEDIUMTYPE -#define EMEDIUMTYPE (ERROR_BASE_NO + 124) -#endif - -#ifndef ECANCELED -#define ECANCELED (ERROR_BASE_NO + 125) -#endif - -#ifndef ENOKEY -#define ENOKEY (ERROR_BASE_NO + 126) -#endif - -#ifndef EKEYEXPIRED -#define EKEYEXPIRED (ERROR_BASE_NO + 127) -#endif - -#ifndef EKEYREVOKED -#define EKEYREVOKED (ERROR_BASE_NO + 128) -#endif - -#ifndef EKEYREJECTED -#define EKEYREJECTED (ERROR_BASE_NO + 129) -#endif - -#ifndef EOWNERDEAD -#define EOWNERDEAD (ERROR_BASE_NO + 130) -#endif - -#ifndef ENOTRECOVERABLE -#define ENOTRECOVERABLE (ERROR_BASE_NO + 131) -#endif - -#ifndef ERFKILL -#define ERFKILL (ERROR_BASE_NO + 132) -#endif - -#ifndef EHWPOISON -#define EHWPOISON (ERROR_BASE_NO + 133) -#endif - -#elif defined(_WIN32) -#include - -#endif /* defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__) */ - -#endif /* __SYS_ERRNO_H__ */ diff --git a/components/libc/compilers/common/nogcc/sys/select.h b/components/libc/compilers/common/nogcc/sys/select.h deleted file mode 100644 index 44f9b4ed91..0000000000 --- a/components/libc/compilers/common/nogcc/sys/select.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-07-21 Meco Man The first version - * 2021-12-25 Meco Man Handle newlib 2.2.0 or lower version - */ - -#ifndef __SYS_SELECT_H__ -#define __SYS_SELECT_H__ - -#include -#include -#include - -#ifdef _WIN32 -#include -#endif - -#ifndef FD_SETSIZE -#define FD_SETSIZE 32 -#endif - -#ifdef SAL_USING_POSIX -#ifdef FD_SETSIZE -#undef FD_SETSIZE -#endif -#define FD_SETSIZE DFS_FD_MAX -#endif /* SAL_USING_POSIX */ - -typedef long fd_mask; - -#ifndef _WIN32 -#ifndef _SYS_TYPES_FD_SET /* Newlib 2.2.0 or lower version */ -#define NBBY 8 /* number of bits in a byte */ -#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ -#ifndef howmany -#define howmany(x,y) (((x)+((y)-1))/(y)) -#endif /* howmany */ - -typedef struct _types_fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; -} _types_fd_set; -#define fd_set _types_fd_set - -#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) -#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p))) -#endif /* _SYS_TYPES_FD_SET */ - -int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); -#endif /* _WIN32 */ - -#endif /* __SYS_SELECT_H__ */ diff --git a/components/libc/compilers/common/nogcc/sys/stat.h b/components/libc/compilers/common/nogcc/sys/stat.h deleted file mode 100644 index 107c15decf..0000000000 --- a/components/libc/compilers/common/nogcc/sys/stat.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-09-02 Meco Man First version - */ - -#ifndef __SYS_STAT_H__ -#define __SYS_STAT_H__ - -#include -#include - -#define S_IFMT 00170000 -#define S_IFSOCK 0140000 -#define S_IFLNK 0120000 -#define S_IFREG 0100000 -#define S_IFBLK 0060000 -#define S_IFDIR 0040000 -#define S_IFCHR 0020000 -#define S_IFIFO 0010000 -#define S_ISUID 0004000 -#define S_ISGID 0002000 -#define S_ISVTX 0001000 - -#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) - -#define S_IRWXU 00700 -#define S_IRUSR 00400 -#define S_IWUSR 00200 -#define S_IXUSR 00100 - -#define S_IRWXG 00070 -#define S_IRGRP 00040 -#define S_IWGRP 00020 -#define S_IXGRP 00010 - -#define S_IRWXO 00007 -#define S_IROTH 00004 -#define S_IWOTH 00002 -#define S_IXOTH 00001 - -struct stat -{ - struct rt_device *st_dev; - uint16_t st_ino; - uint16_t st_mode; - uint16_t st_nlink; - uint16_t st_uid; - uint16_t st_gid; - struct rt_device *st_rdev; - uint32_t st_size; - time_t st_atime; - long st_spare1; - time_t st_mtime; - long st_spare2; - time_t st_ctime; - long st_spare3; - uint32_t st_blksize; - uint32_t st_blocks; - long st_spare4[2]; -}; - -int chmod(const char *, mode_t); -int fchmod(int, mode_t); -int fstat(int, struct stat *); -int lstat(const char *, struct stat *); -int mkdir(const char *, mode_t); -int mkfifo(const char *, mode_t); -int mknod(const char *, mode_t, dev_t); -int stat(const char *, struct stat *); -mode_t umask(mode_t); - -#endif diff --git a/components/libc/compilers/common/nogcc/sys/types.h b/components/libc/compilers/common/nogcc/sys/types.h deleted file mode 100644 index 32b2493c95..0000000000 --- a/components/libc/compilers/common/nogcc/sys/types.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2020-09-05 Meco Man fix bugs - * 2020-12-16 Meco Man add useconds_t - */ - -#ifndef __SYS_TYPES_H__ -#define __SYS_TYPES_H__ - -#include -#include -#include - -typedef int32_t clockid_t; -typedef int32_t key_t; /* Used for interprocess communication. */ -typedef int pid_t; /* Used for process IDs and process group IDs. */ -typedef unsigned short uid_t; -typedef unsigned short gid_t; -typedef signed long off_t; -typedef int mode_t; -#ifndef ARCH_CPU_64BIT -typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */ -#else -typedef long signed int ssize_t; /* Used for a count of bytes or an error indication. */ -#endif -typedef long suseconds_t; /* microseconds. */ -typedef unsigned long useconds_t; /* microseconds (unsigned) */ - -typedef unsigned long dev_t; - -typedef unsigned int u_int; -typedef unsigned char u_char; -typedef unsigned long u_long; - -#endif diff --git a/components/libc/compilers/common/nogcc/sys/unistd.h b/components/libc/compilers/common/nogcc/sys/unistd.h deleted file mode 100644 index 650c87dc18..0000000000 --- a/components/libc/compilers/common/nogcc/sys/unistd.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2020-12-16 Meco Man add usleep - * 2021-09-11 Meco Man move functions from dfs_posix.h to unistd.h - */ - -#ifndef __SYS_UNISTD_H__ -#define __SYS_UNISTD_H__ - -#include -#include "types.h" /* */ - -#define STDIN_FILENO 0 /* standard input file descriptor */ -#define STDOUT_FILENO 1 /* standard output file descriptor */ -#define STDERR_FILENO 2 /* standard error file descriptor */ - -ssize_t read(int fd, void *buf, size_t len); -ssize_t write(int fd, const void *buf, size_t len); -off_t lseek(int fd, off_t offset, int whence); -int fsync(int fildes); -int unlink(const char *pathname); -int close(int d); -int ftruncate(int fd, off_t length); -int rmdir(const char *path); -int chdir(const char *path); -char *getcwd(char *buf, size_t size); -int access(const char *path, int amode); -int pipe(int fildes[2]); -int isatty(int fd); -char *ttyname(int desc); -unsigned int sleep(unsigned int seconds); -int usleep(useconds_t usec); -pid_t gettid(void); -pid_t getpid(void); -pid_t getppid(void); -uid_t getuid(void); -uid_t geteuid(void); -gid_t getgid(void); -gid_t getegid(void); - -#endif /* _SYS_UNISTD_H */ diff --git a/components/libc/compilers/common/nogcc/unistd.h b/components/libc/compilers/common/nogcc/unistd.h deleted file mode 100644 index 4dd71c842e..0000000000 --- a/components/libc/compilers/common/nogcc/unistd.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ - -#include "sys/unistd.h" diff --git a/components/libc/compilers/gcc/SConscript b/components/libc/compilers/gcc/SConscript deleted file mode 100644 index 4c815c49b8..0000000000 --- a/components/libc/compilers/gcc/SConscript +++ /dev/null @@ -1,15 +0,0 @@ -# RT-Thread building script for bridge - -import os -from building import * - -cwd = GetCurrentDir() -objs = [] -list = os.listdir(cwd) - -for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(d, 'SConscript')) - -Return('objs') diff --git a/components/libc/compilers/gcc/newlib/README.md b/components/libc/compilers/gcc/newlib/README.md deleted file mode 100644 index 4614375b45..0000000000 --- a/components/libc/compilers/gcc/newlib/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# NEWLIB (GCC) porting for RT-Thread - -https://sourceware.org/newlib/libc.html#Reentrancy - diff --git a/components/libc/compilers/gcc/newlib/SConscript b/components/libc/compilers/gcc/newlib/SConscript deleted file mode 100644 index 8076a73727..0000000000 --- a/components/libc/compilers/gcc/newlib/SConscript +++ /dev/null @@ -1,31 +0,0 @@ -import os -from building import * -from gcc import * -Import('rtconfig') - -src = [] -cwd = GetCurrentDir() -group = [] -LIBS = ['m'] # link libm -CPPPATH = [cwd] - -if rtconfig.PLATFORM == 'gcc': - LIBS += ['c'] # link libc - src += Glob('*.c') - - #report newlib version - print('Newlib version:' + GetNewLibVersion(rtconfig)) - - # identify this is Newlib, and only enable POSIX.1-1990 - CPPDEFINES = ['RT_USING_NEWLIB', '_POSIX_C_SOURCE=1'] - - group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) - - -list = os.listdir(cwd) -for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - group = group + SConscript(os.path.join(d, 'SConscript')) - -Return('group') diff --git a/components/libc/compilers/gcc/newlib/fcntl.h b/components/libc/compilers/gcc/newlib/fcntl.h deleted file mode 100644 index 847ae3d35b..0000000000 --- a/components/libc/compilers/gcc/newlib/fcntl.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-09-02 Meco Man First version - */ - -#ifndef __FCNTL_H__ -#define __FCNTL_H__ - -#include - -#ifndef O_DIRECTORY -#define O_DIRECTORY 0x200000 -#endif - -#ifndef O_BINARY -#define O_BINARY 0x10000 -#endif - -#endif diff --git a/components/libc/compilers/gcc/newlib/legacy/SConscript b/components/libc/compilers/gcc/newlib/legacy/SConscript deleted file mode 100644 index 4c815c49b8..0000000000 --- a/components/libc/compilers/gcc/newlib/legacy/SConscript +++ /dev/null @@ -1,15 +0,0 @@ -# RT-Thread building script for bridge - -import os -from building import * - -cwd = GetCurrentDir() -objs = [] -list = os.listdir(cwd) - -for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(d, 'SConscript')) - -Return('objs') diff --git a/components/libc/compilers/gcc/newlib/legacy/_select/SConscript b/components/libc/compilers/gcc/newlib/legacy/_select/SConscript deleted file mode 100644 index b7bd86a36c..0000000000 --- a/components/libc/compilers/gcc/newlib/legacy/_select/SConscript +++ /dev/null @@ -1,20 +0,0 @@ -from shutil import copy -from building import * -from gcc import * -Import('rtconfig') - -src = [] -cwd = GetCurrentDir() -CPPPATH = [cwd] -group = [] - -# sys/select.h does not exist in newlib 2.1.0 or lower version -if rtconfig.PLATFORM == 'gcc' and (CheckHeader(rtconfig, 'sys/select.h') == False): - try: - copy("../../../../common/nogcc/sys/select.h", "./sys/select.h") # copy from 'nogcc/sys/select.h' - except: - pass - - group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH) - -Return('group') diff --git a/components/libc/compilers/gcc/newlib/legacy/_select/readme.md b/components/libc/compilers/gcc/newlib/legacy/_select/readme.md deleted file mode 100644 index 4ad9f21923..0000000000 --- a/components/libc/compilers/gcc/newlib/legacy/_select/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -Newlib 2.2.0 or lower version does not provide `sys/select.h`, and `fd_set` is defined in `sys/types.h`. It will be generated by scons automatically, and **DO NOT** change it. - diff --git a/components/libc/compilers/gcc/newlib/legacy/_select/sys/select.h b/components/libc/compilers/gcc/newlib/legacy/_select/sys/select.h deleted file mode 100644 index 02fb77dd89..0000000000 --- a/components/libc/compilers/gcc/newlib/legacy/_select/sys/select.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-07-21 Meco Man The first version - */ - -#ifndef __SYS_SELECT_H__ -#define __SYS_SELECT_H__ - -#include -#include -#include - -#ifdef _WIN32 -#include -#endif - -#ifndef FD_SETSIZE -#define FD_SETSIZE 32 -#endif - -#ifdef SAL_USING_POSIX -#ifdef FD_SETSIZE -#undef FD_SETSIZE -#endif -#define FD_SETSIZE DFS_FD_MAX -#endif /* SAL_USING_POSIX */ - -typedef long fd_mask; - -#ifndef _WIN32 -#ifndef _SYS_TYPES_FD_SET /* MIPS */ - -#define NBBY 8 /* number of bits in a byte */ -#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ -#ifndef howmany -#define howmany(x,y) (((x)+((y)-1))/(y)) -#endif - -typedef struct _types_fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; -} _types_fd_set; -#define fd_set _types_fd_set - -#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) -#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p))) -#endif /* _SYS_TYPES_FD_SET */ - -int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); -#endif /* _WIN32 */ - -#endif /* __SYS_SELECT_H__ */ diff --git a/components/libc/compilers/gcc/newlib/libc_syms.c b/components/libc/compilers/gcc/newlib/libc_syms.c deleted file mode 100644 index e6ca23b393..0000000000 --- a/components/libc/compilers/gcc/newlib/libc_syms.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2017/10/15 bernard the first version - */ - -#include -#include - -#include -#include -#include - -RTM_EXPORT(strcpy); -RTM_EXPORT(strncpy); -RTM_EXPORT(strlen); -RTM_EXPORT(strcat); -RTM_EXPORT(strstr); -RTM_EXPORT(strchr); -RTM_EXPORT(strcmp); -RTM_EXPORT(strtol); -RTM_EXPORT(strtoul); -RTM_EXPORT(strncmp); - -RTM_EXPORT(memcpy); -RTM_EXPORT(memcmp); -RTM_EXPORT(memmove); -RTM_EXPORT(memset); -RTM_EXPORT(memchr); - -RTM_EXPORT(putchar); -RTM_EXPORT(puts); -RTM_EXPORT(printf); -RTM_EXPORT(sprintf); -RTM_EXPORT(snprintf); - -RTM_EXPORT(fwrite); - -#include -RTM_EXPORT(longjmp); -RTM_EXPORT(setjmp); - -RTM_EXPORT(exit); -RTM_EXPORT(abort); - -RTM_EXPORT(rand); - -#include -RTM_EXPORT(__assert_func); diff --git a/components/libc/compilers/gcc/newlib/machine/time.h b/components/libc/compilers/gcc/newlib/machine/time.h deleted file mode 100644 index 805b061aea..0000000000 --- a/components/libc/compilers/gcc/newlib/machine/time.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-02-16 Meco Man The first version - */ - -#ifndef _MACHTIME_H_ -#define _MACHTIME_H_ - -#include -#define _CLOCKS_PER_SEC_ RT_TICK_PER_SECOND - -#endif /* _MACHTIME_H_ */ diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c deleted file mode 100644 index dcf26ccfb7..0000000000 --- a/components/libc/compilers/gcc/newlib/syscalls.c +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-02-11 Meco Man remove _gettimeofday_r() and _times_r() - * 2020-02-13 Meco Man re-implement exit() and abort() - * 2020-02-21 Meco Man improve and beautify syscalls - * 2020-02-24 Meco Man fix bug of _isatty_r() - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef RT_USING_POSIX_STDIO -#include "libc.h" -#endif /* RT_USING_POSIX_STDIO */ -#ifdef RT_USING_MODULE -#include -#endif /* RT_USING_MODULE */ -#include -#define DBG_TAG "newlib.syscalls" -#define DBG_LVL DBG_INFO -#include - -#ifdef RT_USING_HEAP /* Memory routine */ -void *_malloc_r (struct _reent *ptr, size_t size) -{ - void* result; - - result = (void*)rt_malloc (size); - if (result == RT_NULL) - { - ptr->_errno = ENOMEM; - } - - return result; -} - -void *_realloc_r (struct _reent *ptr, void *old, size_t newlen) -{ - void* result; - - result = (void*)rt_realloc (old, newlen); - if (result == RT_NULL) - { - ptr->_errno = ENOMEM; - } - - return result; -} - -void *_calloc_r (struct _reent *ptr, size_t size, size_t len) -{ - void* result; - - result = (void*)rt_calloc (size, len); - if (result == RT_NULL) - { - ptr->_errno = ENOMEM; - } - - return result; -} - -void _free_r (struct _reent *ptr, void *addr) -{ - rt_free (addr); -} - -#else -void * -_sbrk_r(struct _reent *ptr, ptrdiff_t incr) -{ - LOG_E("Please enable RT_USING_HEAP"); - RT_ASSERT(0); - return RT_NULL; -} -#endif /*RT_USING_HEAP*/ - -void __libc_init_array(void) -{ - /* we not use __libc init_aray to initialize C++ objects */ - /* __libc_init_array is ARM code, not Thumb; it will cause a hardfault. */ -} - -/* Reentrant versions of system calls. */ -#ifndef _REENT_ONLY -int *__errno () -{ - return _rt_errno(); -} -#endif - -int _getpid_r(struct _reent *ptr) -{ - return 0; -} - -int _close_r(struct _reent *ptr, int fd) -{ -#ifdef DFS_USING_POSIX - return close(fd); -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); - ptr->_errno = ENOTSUP; - return -1; -#endif /* DFS_USING_POSIX */ -} - -int _execve_r(struct _reent *ptr, const char * name, char *const *argv, char *const *env) -{ - ptr->_errno = ENOTSUP; - return -1; -} - -int _fcntl_r(struct _reent *ptr, int fd, int cmd, int arg) -{ - ptr->_errno = ENOTSUP; - return -1; -} - -int _fork_r(struct _reent *ptr) -{ - ptr->_errno = ENOTSUP; - return -1; -} - -int _fstat_r(struct _reent *ptr, int fd, struct stat *pstat) -{ - ptr->_errno = ENOTSUP; - return -1; -} - -int _isatty_r(struct _reent *ptr, int fd) -{ - if (fd >=0 && fd < 3) - { - return 1; - } - else - { - return 0; - } -} - -int _kill_r(struct _reent *ptr, int pid, int sig) -{ - ptr->_errno = ENOTSUP; - return -1; -} - -int _link_r(struct _reent *ptr, const char *old, const char *new) -{ - ptr->_errno = ENOTSUP; - return -1; -} - -int _wait_r(struct _reent *ptr, int *status) -{ - ptr->_errno = ENOTSUP; - return -1; -} - -mode_t umask(mode_t mask) -{ - return 022; -} - -int flock(int fd, int operation) -{ - return 0; -} - -_off_t _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence) -{ -#ifdef DFS_USING_POSIX - _off_t rc; - rc = lseek(fd, pos, whence); - return rc; -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); - ptr->_errno = ENOTSUP; - return -1; -#endif /* DFS_USING_POSIX */ -} - -int _mkdir_r(struct _reent *ptr, const char *name, int mode) -{ -#ifdef DFS_USING_POSIX - int rc; - rc = mkdir(name, mode); - return rc; -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); - ptr->_errno = ENOTSUP; - return -1; -#endif /* DFS_USING_POSIX */ -} - -int _open_r(struct _reent *ptr, const char *file, int flags, int mode) -{ -#ifdef DFS_USING_POSIX - int rc; - rc = open(file, flags, mode); - return rc; -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); - ptr->_errno = ENOTSUP; - return -1; -#endif /* DFS_USING_POSIX */ -} - -_ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes) -{ -#ifdef DFS_USING_POSIX - _ssize_t rc; - if (fd == STDIN_FILENO) - { -#ifdef RT_USING_POSIX_STDIO - if (libc_stdio_get_console() < 0) - { - LOG_W("Do not invoke standard input before initializing Compiler"); - return 0; - } -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO); - ptr->_errno = ENOTSUP; - return -1; -#endif /* RT_USING_POSIX_STDIO */ - } - else if (fd == STDOUT_FILENO || fd == STDERR_FILENO) - { - ptr->_errno = ENOTSUP; - return -1; - } - - rc = read(fd, buf, nbytes); - return rc; -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); - ptr->_errno = ENOTSUP; - return -1; -#endif /* DFS_USING_POSIX */ -} - -int _rename_r(struct _reent *ptr, const char *old, const char *new) -{ -#ifdef DFS_USING_POSIX - int rc; - rc = rename(old, new); - return rc; -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); - ptr->_errno = ENOTSUP; - return -1; -#endif /* DFS_USING_POSIX */ -} - -int _stat_r(struct _reent *ptr, const char *file, struct stat *pstat) -{ -#ifdef DFS_USING_POSIX - int rc; - rc = stat(file, pstat); - return rc; -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); - ptr->_errno = ENOTSUP; - return -1; -#endif /* DFS_USING_POSIX */ -} - -int _unlink_r(struct _reent *ptr, const char *file) -{ -#ifdef DFS_USING_POSIX - return unlink(file); -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); - ptr->_errno = ENOTSUP; - return -1; -#endif /* DFS_USING_POSIX */ -} - -_ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes) -{ -#ifdef DFS_USING_POSIX - _ssize_t rc; -#endif /* DFS_USING_POSIX */ - - if (fd == STDOUT_FILENO || fd == STDERR_FILENO) - { -#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) - rt_device_t console; - - console = rt_console_get_device(); - if (console) - return rt_device_write(console, -1, buf, nbytes); -#else - ptr->_errno = ENOTSUP; - return -1; -#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */ - } - else if (fd == STDIN_FILENO) - { - ptr->_errno = ENOTSUP; - return -1; - } - -#ifdef DFS_USING_POSIX - rc = write(fd, buf, nbytes); - return rc; -#else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); - ptr->_errno = ENOTSUP; - return -1; -#endif /* DFS_USING_POSIX */ -} - -/* for exit() and abort() */ -__attribute__ ((noreturn)) void _exit (int status) -{ - extern void __rt_libc_exit(int status); - __rt_libc_exit(status); - while(1); -} - -/* -These functions are implemented and replaced by the 'common/time.c' file -int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp); -_CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms); -*/ diff --git a/components/libc/compilers/newlib/README.md b/components/libc/compilers/newlib/README.md new file mode 100644 index 0000000000..4614375b45 --- /dev/null +++ b/components/libc/compilers/newlib/README.md @@ -0,0 +1,4 @@ +# NEWLIB (GCC) porting for RT-Thread + +https://sourceware.org/newlib/libc.html#Reentrancy + diff --git a/components/libc/compilers/newlib/SConscript b/components/libc/compilers/newlib/SConscript new file mode 100644 index 0000000000..8076a73727 --- /dev/null +++ b/components/libc/compilers/newlib/SConscript @@ -0,0 +1,31 @@ +import os +from building import * +from gcc import * +Import('rtconfig') + +src = [] +cwd = GetCurrentDir() +group = [] +LIBS = ['m'] # link libm +CPPPATH = [cwd] + +if rtconfig.PLATFORM == 'gcc': + LIBS += ['c'] # link libc + src += Glob('*.c') + + #report newlib version + print('Newlib version:' + GetNewLibVersion(rtconfig)) + + # identify this is Newlib, and only enable POSIX.1-1990 + CPPDEFINES = ['RT_USING_NEWLIB', '_POSIX_C_SOURCE=1'] + + group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) + + +list = os.listdir(cwd) +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + group = group + SConscript(os.path.join(d, 'SConscript')) + +Return('group') diff --git a/components/libc/compilers/newlib/fcntl.h b/components/libc/compilers/newlib/fcntl.h new file mode 100644 index 0000000000..847ae3d35b --- /dev/null +++ b/components/libc/compilers/newlib/fcntl.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-02 Meco Man First version + */ + +#ifndef __FCNTL_H__ +#define __FCNTL_H__ + +#include + +#ifndef O_DIRECTORY +#define O_DIRECTORY 0x200000 +#endif + +#ifndef O_BINARY +#define O_BINARY 0x10000 +#endif + +#endif diff --git a/components/libc/compilers/newlib/legacy/SConscript b/components/libc/compilers/newlib/legacy/SConscript new file mode 100644 index 0000000000..4c815c49b8 --- /dev/null +++ b/components/libc/compilers/newlib/legacy/SConscript @@ -0,0 +1,15 @@ +# RT-Thread building script for bridge + +import os +from building import * + +cwd = GetCurrentDir() +objs = [] +list = os.listdir(cwd) + +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(d, 'SConscript')) + +Return('objs') diff --git a/components/libc/compilers/newlib/legacy/_select/SConscript b/components/libc/compilers/newlib/legacy/_select/SConscript new file mode 100644 index 0000000000..b7bd86a36c --- /dev/null +++ b/components/libc/compilers/newlib/legacy/_select/SConscript @@ -0,0 +1,20 @@ +from shutil import copy +from building import * +from gcc import * +Import('rtconfig') + +src = [] +cwd = GetCurrentDir() +CPPPATH = [cwd] +group = [] + +# sys/select.h does not exist in newlib 2.1.0 or lower version +if rtconfig.PLATFORM == 'gcc' and (CheckHeader(rtconfig, 'sys/select.h') == False): + try: + copy("../../../../common/nogcc/sys/select.h", "./sys/select.h") # copy from 'nogcc/sys/select.h' + except: + pass + + group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/libc/compilers/newlib/legacy/_select/readme.md b/components/libc/compilers/newlib/legacy/_select/readme.md new file mode 100644 index 0000000000..4ad9f21923 --- /dev/null +++ b/components/libc/compilers/newlib/legacy/_select/readme.md @@ -0,0 +1,2 @@ +Newlib 2.2.0 or lower version does not provide `sys/select.h`, and `fd_set` is defined in `sys/types.h`. It will be generated by scons automatically, and **DO NOT** change it. + diff --git a/components/libc/compilers/newlib/legacy/_select/sys/select.h b/components/libc/compilers/newlib/legacy/_select/sys/select.h new file mode 100644 index 0000000000..02fb77dd89 --- /dev/null +++ b/components/libc/compilers/newlib/legacy/_select/sys/select.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-07-21 Meco Man The first version + */ + +#ifndef __SYS_SELECT_H__ +#define __SYS_SELECT_H__ + +#include +#include +#include + +#ifdef _WIN32 +#include +#endif + +#ifndef FD_SETSIZE +#define FD_SETSIZE 32 +#endif + +#ifdef SAL_USING_POSIX +#ifdef FD_SETSIZE +#undef FD_SETSIZE +#endif +#define FD_SETSIZE DFS_FD_MAX +#endif /* SAL_USING_POSIX */ + +typedef long fd_mask; + +#ifndef _WIN32 +#ifndef _SYS_TYPES_FD_SET /* MIPS */ + +#define NBBY 8 /* number of bits in a byte */ +#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ +#ifndef howmany +#define howmany(x,y) (((x)+((y)-1))/(y)) +#endif + +typedef struct _types_fd_set { + fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; +} _types_fd_set; +#define fd_set _types_fd_set + +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) +#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p))) +#endif /* _SYS_TYPES_FD_SET */ + +int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); +#endif /* _WIN32 */ + +#endif /* __SYS_SELECT_H__ */ diff --git a/components/libc/compilers/newlib/libc_syms.c b/components/libc/compilers/newlib/libc_syms.c new file mode 100644 index 0000000000..e6ca23b393 --- /dev/null +++ b/components/libc/compilers/newlib/libc_syms.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2017/10/15 bernard the first version + */ + +#include +#include + +#include +#include +#include + +RTM_EXPORT(strcpy); +RTM_EXPORT(strncpy); +RTM_EXPORT(strlen); +RTM_EXPORT(strcat); +RTM_EXPORT(strstr); +RTM_EXPORT(strchr); +RTM_EXPORT(strcmp); +RTM_EXPORT(strtol); +RTM_EXPORT(strtoul); +RTM_EXPORT(strncmp); + +RTM_EXPORT(memcpy); +RTM_EXPORT(memcmp); +RTM_EXPORT(memmove); +RTM_EXPORT(memset); +RTM_EXPORT(memchr); + +RTM_EXPORT(putchar); +RTM_EXPORT(puts); +RTM_EXPORT(printf); +RTM_EXPORT(sprintf); +RTM_EXPORT(snprintf); + +RTM_EXPORT(fwrite); + +#include +RTM_EXPORT(longjmp); +RTM_EXPORT(setjmp); + +RTM_EXPORT(exit); +RTM_EXPORT(abort); + +RTM_EXPORT(rand); + +#include +RTM_EXPORT(__assert_func); diff --git a/components/libc/compilers/newlib/machine/time.h b/components/libc/compilers/newlib/machine/time.h new file mode 100644 index 0000000000..805b061aea --- /dev/null +++ b/components/libc/compilers/newlib/machine/time.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-02-16 Meco Man The first version + */ + +#ifndef _MACHTIME_H_ +#define _MACHTIME_H_ + +#include +#define _CLOCKS_PER_SEC_ RT_TICK_PER_SECOND + +#endif /* _MACHTIME_H_ */ diff --git a/components/libc/compilers/newlib/syscalls.c b/components/libc/compilers/newlib/syscalls.c new file mode 100644 index 0000000000..dcf26ccfb7 --- /dev/null +++ b/components/libc/compilers/newlib/syscalls.c @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-02-11 Meco Man remove _gettimeofday_r() and _times_r() + * 2020-02-13 Meco Man re-implement exit() and abort() + * 2020-02-21 Meco Man improve and beautify syscalls + * 2020-02-24 Meco Man fix bug of _isatty_r() + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef RT_USING_POSIX_STDIO +#include "libc.h" +#endif /* RT_USING_POSIX_STDIO */ +#ifdef RT_USING_MODULE +#include +#endif /* RT_USING_MODULE */ +#include +#define DBG_TAG "newlib.syscalls" +#define DBG_LVL DBG_INFO +#include + +#ifdef RT_USING_HEAP /* Memory routine */ +void *_malloc_r (struct _reent *ptr, size_t size) +{ + void* result; + + result = (void*)rt_malloc (size); + if (result == RT_NULL) + { + ptr->_errno = ENOMEM; + } + + return result; +} + +void *_realloc_r (struct _reent *ptr, void *old, size_t newlen) +{ + void* result; + + result = (void*)rt_realloc (old, newlen); + if (result == RT_NULL) + { + ptr->_errno = ENOMEM; + } + + return result; +} + +void *_calloc_r (struct _reent *ptr, size_t size, size_t len) +{ + void* result; + + result = (void*)rt_calloc (size, len); + if (result == RT_NULL) + { + ptr->_errno = ENOMEM; + } + + return result; +} + +void _free_r (struct _reent *ptr, void *addr) +{ + rt_free (addr); +} + +#else +void * +_sbrk_r(struct _reent *ptr, ptrdiff_t incr) +{ + LOG_E("Please enable RT_USING_HEAP"); + RT_ASSERT(0); + return RT_NULL; +} +#endif /*RT_USING_HEAP*/ + +void __libc_init_array(void) +{ + /* we not use __libc init_aray to initialize C++ objects */ + /* __libc_init_array is ARM code, not Thumb; it will cause a hardfault. */ +} + +/* Reentrant versions of system calls. */ +#ifndef _REENT_ONLY +int *__errno () +{ + return _rt_errno(); +} +#endif + +int _getpid_r(struct _reent *ptr) +{ + return 0; +} + +int _close_r(struct _reent *ptr, int fd) +{ +#ifdef DFS_USING_POSIX + return close(fd); +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); + ptr->_errno = ENOTSUP; + return -1; +#endif /* DFS_USING_POSIX */ +} + +int _execve_r(struct _reent *ptr, const char * name, char *const *argv, char *const *env) +{ + ptr->_errno = ENOTSUP; + return -1; +} + +int _fcntl_r(struct _reent *ptr, int fd, int cmd, int arg) +{ + ptr->_errno = ENOTSUP; + return -1; +} + +int _fork_r(struct _reent *ptr) +{ + ptr->_errno = ENOTSUP; + return -1; +} + +int _fstat_r(struct _reent *ptr, int fd, struct stat *pstat) +{ + ptr->_errno = ENOTSUP; + return -1; +} + +int _isatty_r(struct _reent *ptr, int fd) +{ + if (fd >=0 && fd < 3) + { + return 1; + } + else + { + return 0; + } +} + +int _kill_r(struct _reent *ptr, int pid, int sig) +{ + ptr->_errno = ENOTSUP; + return -1; +} + +int _link_r(struct _reent *ptr, const char *old, const char *new) +{ + ptr->_errno = ENOTSUP; + return -1; +} + +int _wait_r(struct _reent *ptr, int *status) +{ + ptr->_errno = ENOTSUP; + return -1; +} + +mode_t umask(mode_t mask) +{ + return 022; +} + +int flock(int fd, int operation) +{ + return 0; +} + +_off_t _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence) +{ +#ifdef DFS_USING_POSIX + _off_t rc; + rc = lseek(fd, pos, whence); + return rc; +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); + ptr->_errno = ENOTSUP; + return -1; +#endif /* DFS_USING_POSIX */ +} + +int _mkdir_r(struct _reent *ptr, const char *name, int mode) +{ +#ifdef DFS_USING_POSIX + int rc; + rc = mkdir(name, mode); + return rc; +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); + ptr->_errno = ENOTSUP; + return -1; +#endif /* DFS_USING_POSIX */ +} + +int _open_r(struct _reent *ptr, const char *file, int flags, int mode) +{ +#ifdef DFS_USING_POSIX + int rc; + rc = open(file, flags, mode); + return rc; +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); + ptr->_errno = ENOTSUP; + return -1; +#endif /* DFS_USING_POSIX */ +} + +_ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes) +{ +#ifdef DFS_USING_POSIX + _ssize_t rc; + if (fd == STDIN_FILENO) + { +#ifdef RT_USING_POSIX_STDIO + if (libc_stdio_get_console() < 0) + { + LOG_W("Do not invoke standard input before initializing Compiler"); + return 0; + } +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO); + ptr->_errno = ENOTSUP; + return -1; +#endif /* RT_USING_POSIX_STDIO */ + } + else if (fd == STDOUT_FILENO || fd == STDERR_FILENO) + { + ptr->_errno = ENOTSUP; + return -1; + } + + rc = read(fd, buf, nbytes); + return rc; +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); + ptr->_errno = ENOTSUP; + return -1; +#endif /* DFS_USING_POSIX */ +} + +int _rename_r(struct _reent *ptr, const char *old, const char *new) +{ +#ifdef DFS_USING_POSIX + int rc; + rc = rename(old, new); + return rc; +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); + ptr->_errno = ENOTSUP; + return -1; +#endif /* DFS_USING_POSIX */ +} + +int _stat_r(struct _reent *ptr, const char *file, struct stat *pstat) +{ +#ifdef DFS_USING_POSIX + int rc; + rc = stat(file, pstat); + return rc; +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); + ptr->_errno = ENOTSUP; + return -1; +#endif /* DFS_USING_POSIX */ +} + +int _unlink_r(struct _reent *ptr, const char *file) +{ +#ifdef DFS_USING_POSIX + return unlink(file); +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); + ptr->_errno = ENOTSUP; + return -1; +#endif /* DFS_USING_POSIX */ +} + +_ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes) +{ +#ifdef DFS_USING_POSIX + _ssize_t rc; +#endif /* DFS_USING_POSIX */ + + if (fd == STDOUT_FILENO || fd == STDERR_FILENO) + { +#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) + rt_device_t console; + + console = rt_console_get_device(); + if (console) + return rt_device_write(console, -1, buf, nbytes); +#else + ptr->_errno = ENOTSUP; + return -1; +#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */ + } + else if (fd == STDIN_FILENO) + { + ptr->_errno = ENOTSUP; + return -1; + } + +#ifdef DFS_USING_POSIX + rc = write(fd, buf, nbytes); + return rc; +#else + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS); + ptr->_errno = ENOTSUP; + return -1; +#endif /* DFS_USING_POSIX */ +} + +/* for exit() and abort() */ +__attribute__ ((noreturn)) void _exit (int status) +{ + extern void __rt_libc_exit(int status); + __rt_libc_exit(status); + while(1); +} + +/* +These functions are implemented and replaced by the 'common/time.c' file +int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp); +_CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms); +*/ -- cgit v1.3.1