summaryrefslogtreecommitdiff
path: root/components/libc/compilers/common/nogcc/sys
diff options
context:
space:
mode:
authorliukangcc <[email protected]>2021-09-17 15:03:14 +0800
committerliukangcc <[email protected]>2021-09-17 15:03:14 +0800
commit4b3df6010f7870aebcd1df20bbaabd5fe9212c6d (patch)
tree95b0e12447425f803be46d16eaf6e7188c364fec /components/libc/compilers/common/nogcc/sys
parentf07507a91310bc5696a08f5bbf6ab8679cfbcf73 (diff)
parentef71de34f76d4403fcd2cddd21a17f3a53a40296 (diff)
Merge remote-tracking branch 'remotes/rtt_github/master'
Diffstat (limited to 'components/libc/compilers/common/nogcc/sys')
-rw-r--r--components/libc/compilers/common/nogcc/sys/errno.h197
-rw-r--r--components/libc/compilers/common/nogcc/sys/select.h52
-rw-r--r--components/libc/compilers/common/nogcc/sys/stat.h83
-rw-r--r--components/libc/compilers/common/nogcc/sys/types.h39
-rw-r--r--components/libc/compilers/common/nogcc/sys/unistd.h45
5 files changed, 416 insertions, 0 deletions
diff --git a/components/libc/compilers/common/nogcc/sys/errno.h b/components/libc/compilers/common/nogcc/sys/errno.h
new file mode 100644
index 0000000000..ff1abca387
--- /dev/null
+++ b/components/libc/compilers/common/nogcc/sys/errno.h
@@ -0,0 +1,197 @@
+/*
+ * 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 <errno.h>
+#define EPERM (ERROR_BASE_NO + 1)
+#define ENOENT (ERROR_BASE_NO + 2)
+#define ESRCH (ERROR_BASE_NO + 3)
+#define EINTR (ERROR_BASE_NO + 4)
+#define EIO (ERROR_BASE_NO + 5)
+#define ENXIO (ERROR_BASE_NO + 6)
+#define E2BIG (ERROR_BASE_NO + 7)
+#define ENOEXEC (ERROR_BASE_NO + 8)
+#define EBADF (ERROR_BASE_NO + 9)
+#define ECHILD (ERROR_BASE_NO + 10)
+#define EAGAIN (ERROR_BASE_NO + 11)
+
+#ifndef ENOMEM
+#define ENOMEM (ERROR_BASE_NO + 12)
+#endif
+
+#define EACCES (ERROR_BASE_NO + 13)
+#define EFAULT (ERROR_BASE_NO + 14)
+#define ENOTBLK (ERROR_BASE_NO + 15)
+#define EBUSY (ERROR_BASE_NO + 16)
+#define EEXIST (ERROR_BASE_NO + 17)
+#define EXDEV (ERROR_BASE_NO + 18)
+#define ENODEV (ERROR_BASE_NO + 19)
+#define ENOTDIR (ERROR_BASE_NO + 20)
+#define EISDIR (ERROR_BASE_NO + 21)
+
+#ifndef EINVAL
+#define EINVAL (ERROR_BASE_NO + 22)
+#endif
+
+#define ENFILE (ERROR_BASE_NO + 23)
+#define EMFILE (ERROR_BASE_NO + 24)
+#define ENOTTY (ERROR_BASE_NO + 25)
+#define ETXTBSY (ERROR_BASE_NO + 26)
+#define EFBIG (ERROR_BASE_NO + 27)
+#define ENOSPC (ERROR_BASE_NO + 28)
+#define ESPIPE (ERROR_BASE_NO + 29)
+#define EROFS (ERROR_BASE_NO + 30)
+#define EMLINK (ERROR_BASE_NO + 31)
+#define EPIPE (ERROR_BASE_NO + 32)
+
+#ifndef EDOM
+#define EDOM (ERROR_BASE_NO + 33)
+#endif
+
+#ifndef ERANGE
+#define ERANGE (ERROR_BASE_NO + 34)
+#endif
+
+#define EDEADLK (ERROR_BASE_NO + 35)
+#define ENAMETOOLONG (ERROR_BASE_NO + 36)
+#define ENOLCK (ERROR_BASE_NO + 37)
+#define ENOSYS (ERROR_BASE_NO + 38)
+#define ENOTEMPTY (ERROR_BASE_NO + 39)
+#define ELOOP (ERROR_BASE_NO + 40)
+#define EWOULDBLOCK EAGAIN
+#define ENOMSG (ERROR_BASE_NO + 42)
+#define EIDRM (ERROR_BASE_NO + 43)
+#define ECHRNG (ERROR_BASE_NO + 44)
+#define EL2NSYNC (ERROR_BASE_NO + 45)
+#define EL3HLT (ERROR_BASE_NO + 46)
+#define EL3RST (ERROR_BASE_NO + 47)
+#define ELNRNG (ERROR_BASE_NO + 48)
+#define EUNATCH (ERROR_BASE_NO + 49)
+#define ENOCSI (ERROR_BASE_NO + 50)
+#define EL2HLT (ERROR_BASE_NO + 51)
+#define EBADE (ERROR_BASE_NO + 52)
+#define EBADR (ERROR_BASE_NO + 53)
+#define EXFULL (ERROR_BASE_NO + 54)
+#define ENOANO (ERROR_BASE_NO + 55)
+#define EBADRQC (ERROR_BASE_NO + 56)
+#define EBADSLT (ERROR_BASE_NO + 57)
+#define EDEADLOCK EDEADLK
+#define EBFONT (ERROR_BASE_NO + 59)
+#define ENOSTR (ERROR_BASE_NO + 60)
+#define ENODATA (ERROR_BASE_NO + 61)
+#define ETIME (ERROR_BASE_NO + 62)
+#define ENOSR (ERROR_BASE_NO + 63)
+#define ENONET (ERROR_BASE_NO + 64)
+#define ENOPKG (ERROR_BASE_NO + 65)
+#define EREMOTE (ERROR_BASE_NO + 66)
+#define ENOLINK (ERROR_BASE_NO + 67)
+#define EADV (ERROR_BASE_NO + 68)
+#define ESRMNT (ERROR_BASE_NO + 69)
+#define ECOMM (ERROR_BASE_NO + 70)
+#define EPROTO (ERROR_BASE_NO + 71)
+#define EMULTIHOP (ERROR_BASE_NO + 72)
+#define EDOTDOT (ERROR_BASE_NO + 73)
+#define EBADMSG (ERROR_BASE_NO + 74)
+#define EOVERFLOW (ERROR_BASE_NO + 75)
+#define ENOTUNIQ (ERROR_BASE_NO + 76)
+#define EBADFD (ERROR_BASE_NO + 77)
+#define EREMCHG (ERROR_BASE_NO + 78)
+#define ELIBACC (ERROR_BASE_NO + 79)
+#define ELIBBAD (ERROR_BASE_NO + 80)
+#define ELIBSCN (ERROR_BASE_NO + 81)
+#define ELIBMAX (ERROR_BASE_NO + 82)
+#define ELIBEXEC (ERROR_BASE_NO + 83)
+
+#ifndef EILSEQ
+#define EILSEQ (ERROR_BASE_NO + 84)
+#endif
+
+#define ERESTART (ERROR_BASE_NO + 85)
+#define ESTRPIPE (ERROR_BASE_NO + 86)
+#define EUSERS (ERROR_BASE_NO + 87)
+#define ENOTSOCK (ERROR_BASE_NO + 88)
+#define EDESTADDRREQ (ERROR_BASE_NO + 89)
+#define EMSGSIZE (ERROR_BASE_NO + 90)
+#define EPROTOTYPE (ERROR_BASE_NO + 91)
+#define ENOPROTOOPT (ERROR_BASE_NO + 92)
+#define EPROTONOSUPPORT (ERROR_BASE_NO + 93)
+#define ESOCKTNOSUPPORT (ERROR_BASE_NO + 94)
+#define EOPNOTSUPP (ERROR_BASE_NO + 95)
+#define ENOTSUP EOPNOTSUPP
+#define EPFNOSUPPORT (ERROR_BASE_NO + 96)
+#define EAFNOSUPPORT (ERROR_BASE_NO + 97)
+#define EADDRINUSE (ERROR_BASE_NO + 98)
+#define EADDRNOTAVAIL (ERROR_BASE_NO + 99)
+#define ENETDOWN (ERROR_BASE_NO + 100)
+#define ENETUNREACH (ERROR_BASE_NO + 101)
+#define ENETRESET (ERROR_BASE_NO + 102)
+#define ECONNABORTED (ERROR_BASE_NO + 103)
+#define ECONNRESET (ERROR_BASE_NO + 104)
+#define ENOBUFS (ERROR_BASE_NO + 105)
+#define EISCONN (ERROR_BASE_NO + 106)
+#define ENOTCONN (ERROR_BASE_NO + 107)
+#define ESHUTDOWN (ERROR_BASE_NO + 108)
+#define ETOOMANYREFS (ERROR_BASE_NO + 109)
+#define ETIMEDOUT (ERROR_BASE_NO + 110)
+#define ECONNREFUSED (ERROR_BASE_NO + 111)
+#define EHOSTDOWN (ERROR_BASE_NO + 112)
+#define EHOSTUNREACH (ERROR_BASE_NO + 113)
+#define EALREADY (ERROR_BASE_NO + 114)
+#define EINPROGRESS (ERROR_BASE_NO + 115)
+#define ESTALE (ERROR_BASE_NO + 116)
+#define EUCLEAN (ERROR_BASE_NO + 117)
+#define ENOTNAM (ERROR_BASE_NO + 118)
+#define ENAVAIL (ERROR_BASE_NO + 119)
+#define EISNAM (ERROR_BASE_NO + 120)
+#define EREMOTEIO (ERROR_BASE_NO + 121)
+#define EDQUOT (ERROR_BASE_NO + 122)
+#define ENOMEDIUM (ERROR_BASE_NO + 123)
+#define EMEDIUMTYPE (ERROR_BASE_NO + 124)
+#define ECANCELED (ERROR_BASE_NO + 125)
+#define ENOKEY (ERROR_BASE_NO + 126)
+#define EKEYEXPIRED (ERROR_BASE_NO + 127)
+#define EKEYREVOKED (ERROR_BASE_NO + 128)
+#define EKEYREJECTED (ERROR_BASE_NO + 129)
+#define EOWNERDEAD (ERROR_BASE_NO + 130)
+#define ENOTRECOVERABLE (ERROR_BASE_NO + 131)
+#define ERFKILL (ERROR_BASE_NO + 132)
+#define EHWPOISON (ERROR_BASE_NO + 133)
+#endif
+
+#endif
diff --git a/components/libc/compilers/common/nogcc/sys/select.h b/components/libc/compilers/common/nogcc/sys/select.h
new file mode 100644
index 0000000000..575ad3a1b5
--- /dev/null
+++ b/components/libc/compilers/common/nogcc/sys/select.h
@@ -0,0 +1,52 @@
+/*
+ * 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 <rtconfig.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+#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 */
+
+#define NBBY 8 /* number of bits in a byte */
+
+typedef long fd_mask;
+
+#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
+#ifndef howmany
+#define howmany(x,y) (((x)+((y)-1))/(y))
+#endif
+
+#ifndef _SYS_TYPES_FD_SET /* MIPS */
+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 /* __SYS_SELECT_H__ */
diff --git a/components/libc/compilers/common/nogcc/sys/stat.h b/components/libc/compilers/common/nogcc/sys/stat.h
new file mode 100644
index 0000000000..107c15decf
--- /dev/null
+++ b/components/libc/compilers/common/nogcc/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 <sys/types.h>
+#include <sys/time.h>
+
+#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
new file mode 100644
index 0000000000..f7f563035c
--- /dev/null
+++ b/components/libc/compilers/common/nogcc/sys/types.h
@@ -0,0 +1,39 @@
+/*
+ * 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 <stdint.h>
+#include <stddef.h>
+#include <time.h>
+
+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 \ No newline at end of file
diff --git a/components/libc/compilers/common/nogcc/sys/unistd.h b/components/libc/compilers/common/nogcc/sys/unistd.h
new file mode 100644
index 0000000000..6195c4c2aa
--- /dev/null
+++ b/components/libc/compilers/common/nogcc/sys/unistd.h
@@ -0,0 +1,45 @@
+/*
+ * 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 <stddef.h>
+#include "types.h" /* <sys/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 */