diff options
| author | Meco Man <[email protected]> | 2021-04-18 00:51:07 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2021-04-18 00:51:07 +0800 |
| commit | 9d401ea8b06518a49b59b6d246325afa5902e3f4 (patch) | |
| tree | 27b26edc705bad8c61938f92942eaf32204f1bb8 /components | |
| parent | 349a85e83f2a9db7786335674bb65d6d1d7f1dab (diff) | |
重新整理libc重复共用文件,创建common_for_all 和 common_for_keiliar
Diffstat (limited to 'components')
| -rw-r--r-- | components/libc/compilers/armlibc/dirent.h | 62 | ||||
| -rw-r--r-- | components/libc/compilers/armlibc/sys/mman.h | 58 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/SConscript (renamed from components/libc/compilers/common/SConscript) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/dirent.h (renamed from components/libc/compilers/newlib/sys/dirent.h) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/readme.md (renamed from components/libc/compilers/common/readme.md) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/stdlib.c (renamed from components/libc/compilers/common/stdlib.c) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/sys/ioctl.h (renamed from components/libc/compilers/common/sys/ioctl.h) | 5 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/sys/mman.h (renamed from components/libc/compilers/newlib/sys/mman.h) | 2 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/sys/statfs.h (renamed from components/libc/compilers/newlib/sys/statfs.h) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/sys/termios.h (renamed from components/libc/compilers/newlib/sys/termios.h) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/sys/time.h (renamed from components/libc/compilers/common/sys/time.h) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/termios.h (renamed from components/libc/compilers/common/termios.h) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/time.c (renamed from components/libc/compilers/common/time.c) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_all/unistd.c (renamed from components/libc/compilers/common/unistd.c) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_except_gcc/SConscript | 13 | ||||
| -rw-r--r-- | components/libc/compilers/common_except_gcc/fcntl.h (renamed from components/libc/compilers/armlibc/fcntl.h) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_except_gcc/sys/stat.h (renamed from components/libc/compilers/armlibc/sys/stat.h) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_except_gcc/sys/types.h (renamed from components/libc/compilers/armlibc/sys/types.h) | 2 | ||||
| -rw-r--r-- | components/libc/compilers/common_except_gcc/sys/unistd.h (renamed from components/libc/compilers/armlibc/sys/unistd.h) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/common_except_gcc/unistd.h (renamed from components/libc/compilers/armlibc/unistd.h) | 0 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/dirent.h | 62 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/fcntl.h | 8 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/mman.h | 58 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/stat.h | 8 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/types.h | 33 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/unistd.h | 57 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/unistd.h | 14 |
27 files changed, 21 insertions, 361 deletions
diff --git a/components/libc/compilers/armlibc/dirent.h b/components/libc/compilers/armlibc/dirent.h deleted file mode 100644 index 2c0521d2e3..0000000000 --- a/components/libc/compilers/armlibc/dirent.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __RTT_DIRENT_H__ -#define __RTT_DIRENT_H__ - -#include <rtthread.h> -#include <rtlibc.h> - -/* -* dirent.h - format of directory entries - * Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html - */ - -/* File types */ -#define FT_REGULAR 0 /* regular file */ -#define FT_SOCKET 1 /* socket file */ -#define FT_DIRECTORY 2 /* directory */ -#define FT_USER 3 /* user defined */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef HAVE_DIR_STRUCTURE -typedef struct -{ - int fd; /* directory file */ - char buf[512]; - int num; - int cur; -} DIR; -#endif - -#ifndef HAVE_DIRENT_STRUCTURE -struct dirent -{ - rt_uint8_t d_type; /* The type of the file */ - rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */ - rt_uint16_t d_reclen; /* length of this record */ - char d_name[256]; /* The null-terminated file name */ -}; -#endif - -int closedir(DIR *); -DIR *opendir(const char *); -struct dirent *readdir(DIR *); -int readdir_r(DIR *, struct dirent *, struct dirent **); -void rewinddir(DIR *); -void seekdir(DIR *, long int); -long telldir(DIR *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/components/libc/compilers/armlibc/sys/mman.h b/components/libc/compilers/armlibc/sys/mman.h deleted file mode 100644 index 6a260ccd70..0000000000 --- a/components/libc/compilers/armlibc/sys/mman.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 - * 2017/11/30 Bernard The first version. - */ - -#ifndef _SYS_MMAN_H -#define _SYS_MMAN_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAP_FAILED ((void *) -1) - -#define MAP_SHARED 0x01 -#define MAP_PRIVATE 0x02 -#define MAP_TYPE 0x0f -#define MAP_FIXED 0x10 -#define MAP_ANON 0x20 -#define MAP_ANONYMOUS MAP_ANON -#define MAP_NORESERVE 0x4000 -#define MAP_GROWSDOWN 0x0100 -#define MAP_DENYWRITE 0x0800 -#define MAP_EXECUTABLE 0x1000 -#define MAP_LOCKED 0x2000 -#define MAP_POPULATE 0x8000 -#define MAP_NONBLOCK 0x10000 -#define MAP_STACK 0x20000 -#define MAP_HUGETLB 0x40000 -#define MAP_FILE 0 - -#define PROT_NONE 0 -#define PROT_READ 1 -#define PROT_WRITE 2 -#define PROT_EXEC 4 -#define PROT_GROWSDOWN 0x01000000 -#define PROT_GROWSUP 0x02000000 - -#define MS_ASYNC 1 -#define MS_INVALIDATE 2 -#define MS_SYNC 4 - -#define MCL_CURRENT 1 -#define MCL_FUTURE 2 -#define MCL_ONFAULT 4 - -void *mmap (void *start, size_t len, int prot, int flags, int fd, off_t off); -int munmap (void *start, size_t len); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common_all/SConscript index 319e1a3555..319e1a3555 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common_all/SConscript diff --git a/components/libc/compilers/newlib/sys/dirent.h b/components/libc/compilers/common_all/dirent.h index bfba586093..bfba586093 100644 --- a/components/libc/compilers/newlib/sys/dirent.h +++ b/components/libc/compilers/common_all/dirent.h diff --git a/components/libc/compilers/common/readme.md b/components/libc/compilers/common_all/readme.md index 81bb005d0a..81bb005d0a 100644 --- a/components/libc/compilers/common/readme.md +++ b/components/libc/compilers/common_all/readme.md diff --git a/components/libc/compilers/common/stdlib.c b/components/libc/compilers/common_all/stdlib.c index 9d8952e99e..9d8952e99e 100644 --- a/components/libc/compilers/common/stdlib.c +++ b/components/libc/compilers/common_all/stdlib.c diff --git a/components/libc/compilers/common/sys/ioctl.h b/components/libc/compilers/common_all/sys/ioctl.h index df17b19a61..648d90230d 100644 --- a/components/libc/compilers/common/sys/ioctl.h +++ b/components/libc/compilers/common_all/sys/ioctl.h @@ -10,6 +10,9 @@ #ifndef _SYS_IOCTL_H #define _SYS_IOCTL_H - +#include <rtconfig.h> +#ifdef RT_USING_POSIX +#include <dfs_posix.h> +#endif #endif diff --git a/components/libc/compilers/newlib/sys/mman.h b/components/libc/compilers/common_all/sys/mman.h index 6a260ccd70..a9235d61f0 100644 --- a/components/libc/compilers/newlib/sys/mman.h +++ b/components/libc/compilers/common_all/sys/mman.h @@ -15,6 +15,8 @@ extern "C" { #endif +#include <sys/types.h> + #define MAP_FAILED ((void *) -1) #define MAP_SHARED 0x01 diff --git a/components/libc/compilers/newlib/sys/statfs.h b/components/libc/compilers/common_all/sys/statfs.h index 0996af9a18..0996af9a18 100644 --- a/components/libc/compilers/newlib/sys/statfs.h +++ b/components/libc/compilers/common_all/sys/statfs.h diff --git a/components/libc/compilers/newlib/sys/termios.h b/components/libc/compilers/common_all/sys/termios.h index c4b42083c4..c4b42083c4 100644 --- a/components/libc/compilers/newlib/sys/termios.h +++ b/components/libc/compilers/common_all/sys/termios.h diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common_all/sys/time.h index ef1c810608..ef1c810608 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common_all/sys/time.h diff --git a/components/libc/compilers/common/termios.h b/components/libc/compilers/common_all/termios.h index 2960d52c58..2960d52c58 100644 --- a/components/libc/compilers/common/termios.h +++ b/components/libc/compilers/common_all/termios.h diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common_all/time.c index 33d8907165..33d8907165 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common_all/time.c diff --git a/components/libc/compilers/common/unistd.c b/components/libc/compilers/common_all/unistd.c index 20130cbb8a..20130cbb8a 100644 --- a/components/libc/compilers/common/unistd.c +++ b/components/libc/compilers/common_all/unistd.c diff --git a/components/libc/compilers/common_except_gcc/SConscript b/components/libc/compilers/common_except_gcc/SConscript new file mode 100644 index 0000000000..bda0d5610f --- /dev/null +++ b/components/libc/compilers/common_except_gcc/SConscript @@ -0,0 +1,13 @@ +from building import * + +Import('rtconfig') + +if rtconfig.PLATFORM == 'iar' or rtconfig.PLATFORM == 'armcc' or rtconfig.PLATFORM == 'armclang': + src = [] + cwd = GetCurrentDir() + CPPPATH = [cwd] + group = [] + src += Glob('*.c') + + group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], CPPPATH = CPPPATH) + Return('group') diff --git a/components/libc/compilers/armlibc/fcntl.h b/components/libc/compilers/common_except_gcc/fcntl.h index f247b926e9..f247b926e9 100644 --- a/components/libc/compilers/armlibc/fcntl.h +++ b/components/libc/compilers/common_except_gcc/fcntl.h diff --git a/components/libc/compilers/armlibc/sys/stat.h b/components/libc/compilers/common_except_gcc/sys/stat.h index c4b42083c4..c4b42083c4 100644 --- a/components/libc/compilers/armlibc/sys/stat.h +++ b/components/libc/compilers/common_except_gcc/sys/stat.h diff --git a/components/libc/compilers/armlibc/sys/types.h b/components/libc/compilers/common_except_gcc/sys/types.h index a6b245b81c..7222326a2a 100644 --- a/components/libc/compilers/armlibc/sys/types.h +++ b/components/libc/compilers/common_except_gcc/sys/types.h @@ -18,6 +18,8 @@ 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 diff --git a/components/libc/compilers/armlibc/sys/unistd.h b/components/libc/compilers/common_except_gcc/sys/unistd.h index 7752a1caf7..7752a1caf7 100644 --- a/components/libc/compilers/armlibc/sys/unistd.h +++ b/components/libc/compilers/common_except_gcc/sys/unistd.h diff --git a/components/libc/compilers/armlibc/unistd.h b/components/libc/compilers/common_except_gcc/unistd.h index cd77a12e3b..cd77a12e3b 100644 --- a/components/libc/compilers/armlibc/unistd.h +++ b/components/libc/compilers/common_except_gcc/unistd.h diff --git a/components/libc/compilers/dlib/dirent.h b/components/libc/compilers/dlib/dirent.h deleted file mode 100644 index 2c0521d2e3..0000000000 --- a/components/libc/compilers/dlib/dirent.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __RTT_DIRENT_H__ -#define __RTT_DIRENT_H__ - -#include <rtthread.h> -#include <rtlibc.h> - -/* -* dirent.h - format of directory entries - * Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html - */ - -/* File types */ -#define FT_REGULAR 0 /* regular file */ -#define FT_SOCKET 1 /* socket file */ -#define FT_DIRECTORY 2 /* directory */ -#define FT_USER 3 /* user defined */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef HAVE_DIR_STRUCTURE -typedef struct -{ - int fd; /* directory file */ - char buf[512]; - int num; - int cur; -} DIR; -#endif - -#ifndef HAVE_DIRENT_STRUCTURE -struct dirent -{ - rt_uint8_t d_type; /* The type of the file */ - rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */ - rt_uint16_t d_reclen; /* length of this record */ - char d_name[256]; /* The null-terminated file name */ -}; -#endif - -int closedir(DIR *); -DIR *opendir(const char *); -struct dirent *readdir(DIR *); -int readdir_r(DIR *, struct dirent *, struct dirent **); -void rewinddir(DIR *); -void seekdir(DIR *, long int); -long telldir(DIR *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/components/libc/compilers/dlib/fcntl.h b/components/libc/compilers/dlib/fcntl.h deleted file mode 100644 index c4b42083c4..0000000000 --- a/components/libc/compilers/dlib/fcntl.h +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ diff --git a/components/libc/compilers/dlib/sys/mman.h b/components/libc/compilers/dlib/sys/mman.h deleted file mode 100644 index 6a260ccd70..0000000000 --- a/components/libc/compilers/dlib/sys/mman.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 - * 2017/11/30 Bernard The first version. - */ - -#ifndef _SYS_MMAN_H -#define _SYS_MMAN_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAP_FAILED ((void *) -1) - -#define MAP_SHARED 0x01 -#define MAP_PRIVATE 0x02 -#define MAP_TYPE 0x0f -#define MAP_FIXED 0x10 -#define MAP_ANON 0x20 -#define MAP_ANONYMOUS MAP_ANON -#define MAP_NORESERVE 0x4000 -#define MAP_GROWSDOWN 0x0100 -#define MAP_DENYWRITE 0x0800 -#define MAP_EXECUTABLE 0x1000 -#define MAP_LOCKED 0x2000 -#define MAP_POPULATE 0x8000 -#define MAP_NONBLOCK 0x10000 -#define MAP_STACK 0x20000 -#define MAP_HUGETLB 0x40000 -#define MAP_FILE 0 - -#define PROT_NONE 0 -#define PROT_READ 1 -#define PROT_WRITE 2 -#define PROT_EXEC 4 -#define PROT_GROWSDOWN 0x01000000 -#define PROT_GROWSUP 0x02000000 - -#define MS_ASYNC 1 -#define MS_INVALIDATE 2 -#define MS_SYNC 4 - -#define MCL_CURRENT 1 -#define MCL_FUTURE 2 -#define MCL_ONFAULT 4 - -void *mmap (void *start, size_t len, int prot, int flags, int fd, off_t off); -int munmap (void *start, size_t len); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/components/libc/compilers/dlib/sys/stat.h b/components/libc/compilers/dlib/sys/stat.h deleted file mode 100644 index c4b42083c4..0000000000 --- a/components/libc/compilers/dlib/sys/stat.h +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ diff --git a/components/libc/compilers/dlib/sys/types.h b/components/libc/compilers/dlib/sys/types.h deleted file mode 100644 index 6e2d1ce839..0000000000 --- a/components/libc/compilers/dlib/sys/types.h +++ /dev/null @@ -1,33 +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 useconds_t - */ -#ifndef __TYPES_H__ -#define __TYPES_H__ - -#include <stdint.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; -#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 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/dlib/sys/unistd.h b/components/libc/compilers/dlib/sys/unistd.h deleted file mode 100644 index 14966a2bad..0000000000 --- a/components/libc/compilers/dlib/sys/unistd.h +++ /dev/null @@ -1,57 +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 - */ -#ifndef _SYS_UNISTD_H -#define _SYS_UNISTD_H - -#include <rtconfig.h> -#include "types.h" - -#ifdef RT_USING_DFS - -#define STDIN_FILENO 0 /* standard input file descriptor */ -#define STDOUT_FILENO 1 /* standard output file descriptor */ -#define STDERR_FILENO 2 /* standard error file descriptor */ - -#include <dfs_posix.h> -#else -#define _FREAD 0x0001 /* read enabled */ -#define _FWRITE 0x0002 /* write enabled */ -#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */ -#define _FMARK 0x0010 /* internal; mark during gc() */ -#define _FDEFER 0x0020 /* internal; defer for next gc pass */ -#define _FASYNC 0x0040 /* signal pgrp when data ready */ -#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */ -#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */ -#define _FCREAT 0x0200 /* open with file create */ -#define _FTRUNC 0x0400 /* open with truncation */ -#define _FEXCL 0x0800 /* error on open if file exists */ -#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */ -#define _FSYNC 0x2000 /* do all writes synchronously */ -#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ -#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */ -#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ - -#endif - - -int isatty (int fd); -char * ttyname (int desc); - -unsigned int sleep(unsigned int seconds); -int usleep(useconds_t usec); - -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/dlib/unistd.h b/components/libc/compilers/dlib/unistd.h deleted file mode 100644 index 72b9d538ec..0000000000 --- a/components/libc/compilers/dlib/unistd.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef _UNISTD_H_ -#define _UNISTD_H_ - -# include "sys/unistd.h" - -#endif /* _UNISTD_H_ */ |
