diff options
| author | yangjie <[email protected]> | 2020-12-28 12:02:31 +0800 |
|---|---|---|
| committer | yangjie <[email protected]> | 2020-12-28 12:02:31 +0800 |
| commit | eeaf1fcc50a9a6d25bebcc531db8e03baafaded3 (patch) | |
| tree | 3a7e70fbb26fad36211874a5bc4f9f9f22c8fa38 /components/libc | |
| parent | ef62febf1f2461bdd72efcffde050905865a99c5 (diff) | |
| parent | e3e86337862c6d84f2b55906a49d48aa33084d39 (diff) | |
resolve Conflicts
bsp/nrf52832/board/Sconscript
bsp/nrf52832/startups/Sconscript
bsp/raspberry-pi/raspi4-32/driver/SConscript
Diffstat (limited to 'components/libc')
| -rw-r--r-- | components/libc/compilers/armlibc/sys/types.h | 14 | ||||
| -rw-r--r-- | components/libc/compilers/armlibc/sys/unistd.h | 7 | ||||
| -rw-r--r-- | components/libc/compilers/common/sys/time.h | 6 | ||||
| -rw-r--r-- | components/libc/compilers/common/termios.h | 2 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/types.h | 13 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/unistd.h | 7 | ||||
| -rw-r--r-- | components/libc/pthreads/semaphore.c | 2 | ||||
| -rw-r--r-- | components/libc/time/posix_sleep.c | 11 |
8 files changed, 46 insertions, 16 deletions
diff --git a/components/libc/compilers/armlibc/sys/types.h b/components/libc/compilers/armlibc/sys/types.h index 2aad77c99d..78fee1bb99 100644 --- a/components/libc/compilers/armlibc/sys/types.h +++ b/components/libc/compilers/armlibc/sys/types.h @@ -5,20 +5,22 @@ * * Change Logs: * Date Author Notes - * 2020-09-05 Meco Man fix bugs + * 2020-09-05 Meco Man fix bugs + * 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 int32_t pid_t; /* Used for process IDs and process group IDs. */ +typedef int32_t clockid_t; +typedef int32_t key_t; /* Used for interprocess communication. */ +typedef int32_t pid_t; /* Used for process IDs and process group IDs. */ #ifndef ARCH_CPU_64BIT -typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */ +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. */ +typedef long signed int ssize_t; /* Used for a count of bytes or an error indication. */ #endif +typedef unsigned long useconds_t; /* microseconds (unsigned) */ #endif diff --git a/components/libc/compilers/armlibc/sys/unistd.h b/components/libc/compilers/armlibc/sys/unistd.h index 524de2cf83..73a73a267e 100644 --- a/components/libc/compilers/armlibc/sys/unistd.h +++ b/components/libc/compilers/armlibc/sys/unistd.h @@ -5,11 +5,13 @@ * * Change Logs: * Date Author Notes + * 2020-12-16 Meco Man add usleep */ #ifndef _SYS_UNISTD_H #define _SYS_UNISTD_H -#include <rtthread.h> +#include <rtconfig.h> +#include "types.h" #ifdef RT_USING_DFS @@ -68,4 +70,7 @@ int isatty (int fd); char * ttyname (int desc); +unsigned int sleep(unsigned int seconds); +int usleep(useconds_t usec); + #endif /* _SYS_UNISTD_H */ diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index 22f1c17f5e..28a977c1f9 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -36,6 +36,12 @@ struct timeval { }; #endif /* _TIMEVAL_DEFINED */ +#if !defined __GNUC__ && !defined __ICCARM__ +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* and nanoseconds */ +}; +#endif struct timezone { int tz_minuteswest; /* minutes west of Greenwich */ diff --git a/components/libc/compilers/common/termios.h b/components/libc/compilers/common/termios.h index ee2b4d5718..414d0c0cb3 100644 --- a/components/libc/compilers/common/termios.h +++ b/components/libc/compilers/common/termios.h @@ -9,6 +9,8 @@ #ifndef _TERMIOS_H__ #define _TERMIOS_H__ +#include <rtconfig.h> + #ifdef RT_USING_POSIX_TERMIOS #include <sys/types.h> #include <posix_termios.h> diff --git a/components/libc/compilers/dlib/sys/types.h b/components/libc/compilers/dlib/sys/types.h index 001ace4dd2..7dbeddcaa9 100644 --- a/components/libc/compilers/dlib/sys/types.h +++ b/components/libc/compilers/dlib/sys/types.h @@ -5,20 +5,21 @@ * * Change Logs: * Date Author Notes + * 2020-12-16 Meco Man add useconds_t */ #ifndef __TYPES_H__ #define __TYPES_H__ #include <stdint.h> -#include <rtthread.h> -typedef rt_int32_t clockid_t; -typedef rt_int32_t key_t; /* Used for interprocess communication. */ -typedef rt_int32_t pid_t; /* Used for process IDs and process group IDs. */ +typedef int32_t clockid_t; +typedef int32_t key_t; /* Used for interprocess communication. */ +typedef int32_t pid_t; /* Used for process IDs and process group IDs. */ #ifndef ARCH_CPU_64BIT -typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */ +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. */ +typedef long signed int ssize_t; /* Used for a count of bytes or an error indication. */ #endif +typedef unsigned long useconds_t; /* microseconds (unsigned) */ #endif diff --git a/components/libc/compilers/dlib/sys/unistd.h b/components/libc/compilers/dlib/sys/unistd.h index 9564daba8d..6d99cd6c55 100644 --- a/components/libc/compilers/dlib/sys/unistd.h +++ b/components/libc/compilers/dlib/sys/unistd.h @@ -5,10 +5,14 @@ * * 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 */ @@ -40,4 +44,7 @@ int isatty (int fd); char * ttyname (int desc); +unsigned int sleep(unsigned int seconds); +int usleep(useconds_t usec); + #endif /* _SYS_UNISTD_H */ diff --git a/components/libc/pthreads/semaphore.c b/components/libc/pthreads/semaphore.c index 2bef10022e..2ed93e99b6 100644 --- a/components/libc/pthreads/semaphore.c +++ b/components/libc/pthreads/semaphore.c @@ -64,7 +64,7 @@ static sem_t *posix_sem_find(const char* name) for (iter = posix_sem_list; iter != RT_NULL; iter = iter->next) { - object = (rt_object_t)&(iter->sem); + object = (rt_object_t)iter->sem; if (strncmp(object->name, name, RT_NAME_MAX) == 0) { diff --git a/components/libc/time/posix_sleep.c b/components/libc/time/posix_sleep.c index f21b0a7994..e50bda7d4a 100644 --- a/components/libc/time/posix_sleep.c +++ b/components/libc/time/posix_sleep.c @@ -5,10 +5,10 @@ * * Change Logs: * Date Author Notes + * 2020-12-16 Meco Man add usleep */ -#include <stdlib.h> #include <rtthread.h> - +#include <rthw.h> #include <unistd.h> unsigned int sleep(unsigned int seconds) @@ -21,3 +21,10 @@ unsigned int sleep(unsigned int seconds) return seconds - delta_tick/RT_TICK_PER_SECOND; } + +int usleep(useconds_t usec) +{ + rt_thread_mdelay(usec / 1000u); + rt_hw_us_delay(usec % 1000u); + return 0; +} |
