diff --git a/porting/liteos_a/kernel/include/assert.h b/porting/liteos_a/kernel/include/assert.h index 3ea050713817b798491331883f0eadbe14cc16b4..0381fb35f42b3eb0e649f0dfb3c62d32ffa116be 100644 --- a/porting/liteos_a/kernel/include/assert.h +++ b/porting/liteos_a/kernel/include/assert.h @@ -8,23 +8,16 @@ #define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) #endif -#ifdef CONFIG_DEBUG -#define DEBUGASSERT(f) \ - { if (!(f)) up_assert((const uint8_t *)__FILE__, (int)__LINE__); } -#else -#define DEBUGASSERT(f) -#endif +#define DEBUGASSERT(x) assert(x) #if __STDC_VERSION__ >= 201112L && !defined(__cplusplus) -#undef static_assert #define static_assert _Static_assert #endif #ifdef __cplusplus extern "C" { #endif -_Noreturn void __assert(const char *, int, const char *); -_Noreturn void __assert2(const char *, int, const char *, const char *); + _Noreturn void __assert_fail (const char *, const char *, int, const char *); #ifdef __cplusplus diff --git a/porting/liteos_a/kernel/include/bits/alltypes.h b/porting/liteos_a/kernel/include/bits/alltypes.h index 9a1b92a21fdec024c37b3d1cd18a81b2409b8a87..4ebf5ac88736bca23676e834f8eb8a1409b48752 100644 --- a/porting/liteos_a/kernel/include/bits/alltypes.h +++ b/porting/liteos_a/kernel/include/bits/alltypes.h @@ -347,32 +347,7 @@ typedef struct __locale_struct *locale_t; #endif #if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE) -struct _IO_FILE { - unsigned flags; - unsigned char *rpos, *rend; - int (*close)(struct _IO_FILE *); - unsigned char *wend, *wpos; - unsigned char *mustbezero_1; - unsigned char *wbase; - size_t (*read)(struct _IO_FILE *, unsigned char *, size_t); - size_t (*write)(struct _IO_FILE *, const unsigned char *, size_t); - off_t (*seek)(struct _IO_FILE *, off_t, int); - unsigned char *buf; - size_t buf_size; - struct _IO_FILE *prev, *next; - int fd; - int pipe_pid; - int mode; - void *lock; - int lbf; - void *cookie; - off_t off; - char *getln_buf; - void *mustbezero_2; - unsigned char *shend; - off_t shlim, shcnt; - struct __locale_struct *locale; -}; +struct _IO_FILE { char __x; }; #define __DEFINED_struct__IO_FILE #endif diff --git a/porting/liteos_a/kernel/include/bits/errno.h b/porting/liteos_a/kernel/include/bits/errno.h index 0852a0458a92783a898bc3844ec9163c98ed9a9e..4b1b0954f21e097411d406fbd55d7eb2d67c6d89 100644 --- a/porting/liteos_a/kernel/include/bits/errno.h +++ b/porting/liteos_a/kernel/include/bits/errno.h @@ -133,5 +133,3 @@ #define ENOTRECOVERABLE 131 #define ERFKILL 132 #define EHWPOISON 133 - -#define ENOSUPP 201 diff --git a/porting/liteos_a/kernel/include/bits/stat.h b/porting/liteos_a/kernel/include/bits/stat.h index 8dd6ec73cf76b4f8c1defdde50b496da7abb1bbe..2c55b0a31b19c49f2dc22317c5da375ef9c548aa 100644 --- a/porting/liteos_a/kernel/include/bits/stat.h +++ b/porting/liteos_a/kernel/include/bits/stat.h @@ -24,6 +24,12 @@ struct stat { struct timespec st_ctim; }; +#define __NEED_uint16_t +#define __NEED_uint32_t +#define __NEED_uint64_t +#define __NEED_int32_t +#define __NEED_int64_t +#include struct statx { uint32_t stx_mask; uint32_t stx_blksize; diff --git a/porting/liteos_a/kernel/include/byteswap.h b/porting/liteos_a/kernel/include/byteswap.h index 293b1020ee9a1f1b5dde07ceaa7b19c5f07f09e4..00b9df3c9fa2b1511105ef60efca7650607a9f52 100644 --- a/porting/liteos_a/kernel/include/byteswap.h +++ b/porting/liteos_a/kernel/include/byteswap.h @@ -11,12 +11,12 @@ static __inline uint16_t __bswap_16(uint16_t __x) static __inline uint32_t __bswap_32(uint32_t __x) { - return (__x>>24) | (__x>>8&0xff00) | (__x<<8&0xff0000) | (__x<<24); + return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24; } static __inline uint64_t __bswap_64(uint64_t __x) { - return (__bswap_32(__x)+0ULL)<<32 | __bswap_32(__x>>32); + return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32); } #define bswap_16(x) __bswap_16(x) diff --git a/porting/liteos_a/kernel/include/endian.h b/porting/liteos_a/kernel/include/endian.h index ba7b7d3f4c66f94cefe1b7cac2cbd0572899505e..9b794ac91a1e51e7b632fa51f7bb8179df8f22eb 100644 --- a/porting/liteos_a/kernel/include/endian.h +++ b/porting/liteos_a/kernel/include/endian.h @@ -27,12 +27,12 @@ static __inline uint16_t __bswap16(uint16_t __x) static __inline uint32_t __bswap32(uint32_t __x) { - return (__x>>24) | ((__x>>8)&(0xff00)) | ((__x<<8)&(0xff0000)) | ((__x<<24)); + return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24; } static __inline uint64_t __bswap64(uint64_t __x) { - return (__bswap32(__x)+0ULL)<<32 | __bswap32(__x>>32); + return __bswap32(__x)+0ULL<<32 | __bswap32(__x>>32); } #if __BYTE_ORDER == __LITTLE_ENDIAN diff --git a/porting/liteos_a/kernel/include/errno.h b/porting/liteos_a/kernel/include/errno.h index 7213ec95f2970d300d83546cb125c1be6cd069a3..2443577c8b3906c6bfafd8306d9f38ee65521bc0 100644 --- a/porting/liteos_a/kernel/include/errno.h +++ b/porting/liteos_a/kernel/include/errno.h @@ -9,15 +9,14 @@ extern "C" { #include -void set_errno(int err_code); -int get_errno(void); -int *__errno_location(void); - #ifdef __GNUC__ __attribute__((const)) #endif -extern volatile int* __errno(void); -#define errno (*__errno()) +int *__errno_location(void); +#define errno (*__errno_location()) + +#define set_errno(err) do { if (err) { errno = (err); } } while(0) +#define get_errno() errno #ifdef _GNU_SOURCE extern char *program_invocation_short_name, *program_invocation_name; diff --git a/porting/liteos_a/kernel/include/features.h b/porting/liteos_a/kernel/include/features.h index 53e509644fd82bb80a6938b6363d97e43fe0f9ce..cf25d72b920851df9a1c4f60e503de8e2da94178 100644 --- a/porting/liteos_a/kernel/include/features.h +++ b/porting/liteos_a/kernel/include/features.h @@ -1,8 +1,6 @@ #ifndef _FEATURES_H #define _FEATURES_H -#define _DEFAULT_SOURCE -#define _LARGEFILE64_SOURCE #define _GNU_SOURCE #if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE) @@ -41,6 +39,4 @@ #define __REDIR(x,y) __typeof__(x) x __asm__(#y) -#include "../src/include/features.h" - -#endif \ No newline at end of file +#endif diff --git a/porting/liteos_a/kernel/include/langinfo.h b/porting/liteos_a/kernel/include/langinfo.h index 2332864dea00746d0fdf372f32ea969baf0df3bd..519c061294c0f96fa3bffa40ec9ec3f1da8bd02c 100644 --- a/porting/liteos_a/kernel/include/langinfo.h +++ b/porting/liteos_a/kernel/include/langinfo.h @@ -91,8 +91,6 @@ extern "C" { char *nl_langinfo(nl_item); char *nl_langinfo_l(nl_item, locale_t); -#include "../src/include/langinfo.h" - #ifdef __cplusplus } #endif diff --git a/porting/liteos_a/kernel/include/net/ethernet.h b/porting/liteos_a/kernel/include/net/ethernet.h index 5805ae3d086555c5913c220e067b26f444269b5b..c8d4177fd278b2829a198c915919ac5f184f670d 100644 --- a/porting/liteos_a/kernel/include/net/ethernet.h +++ b/porting/liteos_a/kernel/include/net/ethernet.h @@ -32,7 +32,7 @@ struct ether_header { #define ETHERTYPE_LOOPBACK 0x9000 -#define ETHER_ADDR_LEN 6 +#define ETHER_ADDR_LEN ETH_ALEN #define ETHER_TYPE_LEN 2 #define ETHER_CRC_LEN 4 #define ETHER_HDR_LEN ETH_HLEN diff --git a/porting/liteos_a/kernel/include/netinet/in.h b/porting/liteos_a/kernel/include/netinet/in.h index 225ca288cc4dcba9e916b5856b9d0f069ef754af..5b8b21e6416e2c0beae34678e19617e3c3336209 100644 --- a/porting/liteos_a/kernel/include/netinet/in.h +++ b/porting/liteos_a/kernel/include/netinet/in.h @@ -311,7 +311,6 @@ struct ip6_mtuinfo { struct sockaddr_in6 ip6m_addr; uint32_t ip6m_mtu; }; - #endif #define IPV6_ADDRFORM 1 diff --git a/porting/liteos_a/kernel/include/netinet/ip_icmp.h b/porting/liteos_a/kernel/include/netinet/ip_icmp.h index 804293d3f18356f04f8349e458dfb967e03541c2..b9e0df8997e145726e1c0eef5768c52c5c69fb97 100644 --- a/porting/liteos_a/kernel/include/netinet/ip_icmp.h +++ b/porting/liteos_a/kernel/include/netinet/ip_icmp.h @@ -69,7 +69,6 @@ struct icmphdr { #define ICMP_EXC_TTL 0 #define ICMP_EXC_FRAGTIME 1 -#define ICMP_FILTER 1 struct icmp_ra_addr { uint32_t ira_addr; @@ -115,10 +114,6 @@ struct icmp { } icmp_dun; }; -struct icmp_filter { - uint32_t data; -}; - #define icmp_pptr icmp_hun.ih_pptr #define icmp_gwaddr icmp_hun.ih_gwaddr #define icmp_id icmp_hun.ih_idseq.icd_id diff --git a/porting/liteos_a/kernel/include/netinet/tcp.h b/porting/liteos_a/kernel/include/netinet/tcp.h index cc5fbd596ec8fe880fe37e3ba65b7b669208e9b0..44a007aaf5a252f21f5e5c76ec5fafd69267cf69 100644 --- a/porting/liteos_a/kernel/include/netinet/tcp.h +++ b/porting/liteos_a/kernel/include/netinet/tcp.h @@ -54,13 +54,6 @@ #define TCP_LISTEN 10 #define TCP_CLOSING 11 -enum { - TCP_NO_QUEUE, - TCP_RECV_QUEUE, - TCP_SEND_QUEUE, - TCP_QUEUES_NR, -}; - enum { TCP_NLA_PAD, TCP_NLA_BUSY, diff --git a/porting/liteos_a/kernel/include/poll.h b/porting/liteos_a/kernel/include/poll.h index 08063a0184d9810136bae210147133eaa05cbf6d..f4a7f75fd8fb1c67d38aeb185d8f31821aeb3f0f 100644 --- a/porting/liteos_a/kernel/include/poll.h +++ b/porting/liteos_a/kernel/include/poll.h @@ -1,5 +1,5 @@ -#ifndef _SYS_POLL_H -#define _SYS_POLL_H +#ifndef _POLL_H +#define _POLL_H #ifdef __cplusplus extern "C" { diff --git a/porting/liteos_a/kernel/include/signal.h b/porting/liteos_a/kernel/include/signal.h index 50ebb1bf7d1d56d1cb4348872a0524b9be7e0d69..99d63585c04dc277374c62e8acdca66eedca2536 100644 --- a/porting/liteos_a/kernel/include/signal.h +++ b/porting/liteos_a/kernel/include/signal.h @@ -94,34 +94,34 @@ typedef struct sigaltstack stack_t; #define CLD_CONTINUED 6 union sigval { - int sival_int; - void *sival_ptr; + int sival_int; + void *sival_ptr; }; typedef struct { - int si_signo, si_errno, si_code; - union { - char __pad[128 - 2*sizeof(int) - sizeof(long)]; - struct { - union { - struct { - pid_t si_pid; - uid_t si_uid; - } __piduid; - struct { - int si_timerid; - int si_overrun; - } __timer; - } __first; - union { - union sigval si_value; - struct { - int si_status; - clock_t si_utime, si_stime; - } __sigchld; - } __second; - } __si_common; - } __si_fields; + int si_signo, si_errno, si_code; + union { + char __pad[128 - 2*sizeof(int) - sizeof(long)]; + struct { + union { + struct { + pid_t si_pid; + uid_t si_uid; + } __piduid; + struct { + int si_timerid; + int si_overrun; + } __timer; + } __first; + union { + union sigval si_value; + struct { + int si_status; + clock_t si_utime, si_stime; + } __sigchld; + } __second; + } __si_common; + } __si_fields; } siginfo_t; #define si_pid __si_fields.__si_common.__first.__piduid.si_pid #define si_uid __si_fields.__si_common.__first.__piduid.si_uid @@ -133,22 +133,22 @@ typedef struct { #define si_overrun __si_fields.__si_common.__first.__timer.si_overrun struct sigaction { - union { - void (*sa_handler)(int); - void (*sa_sigaction)(int, siginfo_t *, void *); - } sa_sigactionhandler; - sigset_t sa_mask; - int sa_flags; - void (*sa_restorer)(void); + union { + void (*sa_handler)(int); + void (*sa_sigaction)(int, siginfo_t *, void *); + } sa_sigactionhandler; + sigset_t sa_mask; + int sa_flags; + void (*sa_restorer)(void); }; #define sa_handler sa_sigactionhandler.sa_handler #define sa_sigaction sa_sigactionhandler.sa_sigaction struct sigevent { - union sigval sigev_value; - int sigev_signo; - int sigev_notify; - void (*sigev_notify_function)(union sigval); + union sigval sigev_value; + int sigev_signo; + int sigev_notify; + void (*sigev_notify_function)(union sigval); void *sigev_notify_attributes; }; diff --git a/porting/liteos_a/kernel/include/stdalign.h b/porting/liteos_a/kernel/include/stdalign.h index 13c70d234e023912ac5586f94114353aa36c93d9..2cc94be3f6d7e4b65839cbcd35a1e5286139e4c8 100644 --- a/porting/liteos_a/kernel/include/stdalign.h +++ b/porting/liteos_a/kernel/include/stdalign.h @@ -5,9 +5,7 @@ /* this whole header only works in C11 or with compiler extensions */ #if __STDC_VERSION__ < 201112L && defined( __GNUC__) -#undef _Alignas #define _Alignas(t) __attribute__((__aligned__(t))) -#undef _Alignof #define _Alignof(t) __alignof__(t) #endif diff --git a/porting/liteos_a/kernel/include/stdio.h b/porting/liteos_a/kernel/include/stdio.h index d56a7472137bf2d7204609d6b1ce21fed319fa18..91c3172487ac29c59da2127ba713ecea40a14f87 100644 --- a/porting/liteos_a/kernel/include/stdio.h +++ b/porting/liteos_a/kernel/include/stdio.h @@ -12,7 +12,6 @@ extern "C" { #define __NEED_size_t #if __STDC_VERSION__ < 201112L -#define __NEED_off_t #define __NEED_struct__IO_FILE #endif diff --git a/porting/liteos_a/kernel/include/string.h b/porting/liteos_a/kernel/include/string.h index 2472f570587cd60f331043d6b15cacca5c0642df..816909e05ae4747fa143c16c1188148591282c72 100644 --- a/porting/liteos_a/kernel/include/string.h +++ b/porting/liteos_a/kernel/include/string.h @@ -98,8 +98,6 @@ char *basename(const char *); #endif #endif -#include "../src/include/string.h" - #ifdef __cplusplus } #endif diff --git a/porting/liteos_a/kernel/include/sys/mman.h b/porting/liteos_a/kernel/include/sys/mman.h index 691185a2f0de34cadfecb8917dc18cc1e33ccd9a..8bbb36b21dfe3e8429d4c7cd5517adaf30017dcc 100644 --- a/porting/liteos_a/kernel/include/sys/mman.h +++ b/porting/liteos_a/kernel/include/sys/mman.h @@ -146,8 +146,6 @@ int shm_unlink (const char *); #define mmap64 mmap #endif -#include "../src/include/sys/mman.h" - #ifdef __cplusplus } #endif diff --git a/porting/liteos_a/kernel/include/sys/reboot.h b/porting/liteos_a/kernel/include/sys/reboot.h index 28f95470404bd88570007f9fd76d3f25094ac98d..9702eddba4ba24accb231b81d9e7ed0f79d37656 100644 --- a/porting/liteos_a/kernel/include/sys/reboot.h +++ b/porting/liteos_a/kernel/include/sys/reboot.h @@ -5,6 +5,14 @@ extern "C" { #endif #define RB_AUTOBOOT 0x01234567 +#define RB_HALT_SYSTEM 0xcdef0123 +#define RB_ENABLE_CAD 0x89abcdef +#define RB_DISABLE_CAD 0 +#define RB_POWER_OFF 0x4321fedc +#define RB_SW_SUSPEND 0xd000fce2 +#define RB_KEXEC 0x45584543 + +int reboot(int); #ifdef __cplusplus } diff --git a/porting/liteos_a/kernel/include/sys/select.h b/porting/liteos_a/kernel/include/sys/select.h index 8880e86f7b980e6436ba4b6fc1b3a04145768be6..d7e269aac03bd4fd8a49c960ef291d950fd523a1 100644 --- a/porting/liteos_a/kernel/include/sys/select.h +++ b/porting/liteos_a/kernel/include/sys/select.h @@ -20,7 +20,7 @@ extern "C" { /* FD_SETSIZE is defined in "vfs_config.h" */ #else -#define FD_SETSIZE 512 +#define FD_SETSIZE 1024 #define FD_SET_TOTAL_SIZE FD_SETSIZE #endif diff --git a/porting/liteos_a/kernel/include/sys/stat.h b/porting/liteos_a/kernel/include/sys/stat.h index 62c53046169fad67d748bf6d44d2bb1910983f54..97c4fff7f5f2dd736bb7f8f2463511279d94cc46 100644 --- a/porting/liteos_a/kernel/include/sys/stat.h +++ b/porting/liteos_a/kernel/include/sys/stat.h @@ -6,11 +6,6 @@ extern "C" { #include -#define __NEED_uint16_t -#define __NEED_uint32_t -#define __NEED_uint64_t -#define __NEED_int32_t -#define __NEED_int64_t #define __NEED_dev_t #define __NEED_ino_t #define __NEED_mode_t @@ -19,7 +14,6 @@ extern "C" { #define __NEED_gid_t #define __NEED_off_t #define __NEED_time_t -#define __NEED_suseconds_t #define __NEED_blksize_t #define __NEED_blkcnt_t #define __NEED_struct_timespec @@ -106,13 +100,13 @@ int lchmod(const char *, mode_t); #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) #define stat64 stat +int fstat64(int, struct stat64 *); #define lstat64 lstat #define fstatat64 fstatat #define blkcnt64_t blkcnt_t #define fsblkcnt64_t fsblkcnt_t #define fsfilcnt64_t fsfilcnt_t #define ino64_t ino_t -int fstat64(int, struct stat64 *); #endif #if _REDIR_TIME64 diff --git a/porting/liteos_a/kernel/include/time.h b/porting/liteos_a/kernel/include/time.h index 7c7b34776665304afc1bf812ef3ef7a4c413295d..51cc5d6c424e18393bb1f218805666536eacde96 100644 --- a/porting/liteos_a/kernel/include/time.h +++ b/porting/liteos_a/kernel/include/time.h @@ -172,8 +172,6 @@ __REDIR(timegm, __timegm_time64); #endif #endif -#include "../src/include/time.h" - #ifdef __cplusplus } #endif diff --git a/porting/liteos_a/kernel/include/unistd.h b/porting/liteos_a/kernel/include/unistd.h index cb9dd803602021656f09c0619b907edfdf00b7d8..7a80a7afcea9d41c9cab08a5098ede071d98218e 100644 --- a/porting/liteos_a/kernel/include/unistd.h +++ b/porting/liteos_a/kernel/include/unistd.h @@ -73,30 +73,6 @@ int ftruncate(int, off_t); int access(const char *, int); int faccessat(int, const char *, int, int); - -/* Format options */ -#define FMT_FAT 0x01 -#define FMT_FAT32 0x02 -#define FMT_ANY 0x07 -#define FMT_ERASE 0x08 - -/** - * @brief format FAT device (SD card, U disk, and MMC card), this function is OHOS-specific - * @param dev device name. - * @param sectors sectors per cluster, can be 0 OR power of 2. The sector size for standard FAT volumes is 512 bytes. - * -- sector number is 0 OR >128: automatically choose the appropriate cluster size. - * -- sector number is 1 ~ 128: cluster size = sectors per cluster * 512B. - * @param option file system type. - * -- FMT_FAT - * -- FMT_FAT32 - * -- FMT_ANY - * -- FMT_ERASE (USB not supported) - * @return format result - * @retval -1 format error - * @retval 0 format successful - */ -int format(const char *dev, int sectors, int option); - int chdir(const char *); int fchdir(int); char *getcwd(char *, size_t); @@ -216,12 +192,14 @@ ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); #endif #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define lockf64 lockf off64_t lseek64(int, off64_t, int); ssize_t pread64(int, void *, size_t, off64_t); ssize_t pwrite64(int, const void *, size_t, off64_t); int truncate64(const char *, off64_t); int ftruncate64(int, off64_t); +off_t _lseek(int fd, off_t offset, int whence); +off64_t _lseek64(int fd, int offsetHigh, int offsetLow, off64_t *result, int whence); +#define lockf64 lockf #endif #define POSIX_CLOSE_RESTART 0 diff --git a/porting/liteos_a/kernel/include/wchar.h b/porting/liteos_a/kernel/include/wchar.h index 3ee3b00b082eecf0a1a7f3f1b7a00993c43814d7..88eb55b18cc1ff04819adb40f75fb8c33d860af8 100644 --- a/porting/liteos_a/kernel/include/wchar.h +++ b/porting/liteos_a/kernel/include/wchar.h @@ -15,7 +15,6 @@ extern "C" { #define __NEED_mbstate_t #if __STDC_VERSION__ < 201112L -#define __NEED_off_t #define __NEED_struct__IO_FILE #endif diff --git a/porting/liteos_a/kernel/musl.gni b/porting/liteos_a/kernel/musl.gni index ae272ee0571cd36a57c11002addcd7b849e46753..0d421fda973999072c344263cf9ea27bffd8cade 100644 --- a/porting/liteos_a/kernel/musl.gni +++ b/porting/liteos_a/kernel/musl.gni @@ -39,12 +39,8 @@ MUSL_SRC_COMMON = [ "$MUSLPORTINGDIR/src/ctype/isxdigit.c", "$MUSLPORTINGDIR/src/ctype/tolower.c", "$MUSLPORTINGDIR/src/ctype/toupper.c", - "$MUSLPORTINGDIR/src/env/getenv.c", - "$MUSLPORTINGDIR/src/errno/errno.c", "$MUSLPORTINGDIR/src/errno/strerror.c", - "$MUSLPORTINGDIR/src/exit/abort.c", "$MUSLPORTINGDIR/src/exit/assert.c", - "$MUSLPORTINGDIR/src/exit/exit.c", "$MUSLPORTINGDIR/src/fenv/fenv.c", "$MUSLPORTINGDIR/src/internal/floatscan.c", "$MUSLPORTINGDIR/src/internal/intscan.c", @@ -55,7 +51,6 @@ MUSL_SRC_COMMON = [ "$MUSLPORTINGDIR/src/locale/c_locale.c", "$MUSLPORTINGDIR/src/locale/langinfo.c", "$MUSLPORTINGDIR/src/locale/locale_map.c", - "$MUSLPORTINGDIR/src/malloc/malloc.c", "$MUSLPORTINGDIR/src/math/__cos.c", "$MUSLPORTINGDIR/src/math/__cosdf.c", "$MUSLPORTINGDIR/src/math/__cosl.c", @@ -294,9 +289,7 @@ MUSL_SRC_COMMON = [ "$MUSLPORTINGDIR/src/network/htons.c", "$MUSLPORTINGDIR/src/network/ntohl.c", "$MUSLPORTINGDIR/src/network/ntohs.c", - "$MUSLPORTINGDIR/src/prng/rand.c", "$MUSLPORTINGDIR/src/prng/random.c", - "$MUSLPORTINGDIR/src/sched/sched_yield.c", "$MUSLPORTINGDIR/src/stdio/__fdopen.c", "$MUSLPORTINGDIR/src/stdio/__fmodeflags.c", "$MUSLPORTINGDIR/src/stdio/__lockfile.c", @@ -390,7 +383,6 @@ MUSL_SRC_COMMON = [ "$MUSLPORTINGDIR/src/time/mktime.c", "$MUSLPORTINGDIR/src/time/strftime.c", "$MUSLPORTINGDIR/src/time/strptime.c", - "$MUSLPORTINGDIR/src/time/time.c", ] MUSL_SRC_ARM = [ diff --git a/porting/liteos_a/kernel/src/env/getenv.c b/porting/liteos_a/kernel/src/env/getenv.c deleted file mode 100644 index 81499d095e40bc59728b994082d18fee60d5579a..0000000000000000000000000000000000000000 --- a/porting/liteos_a/kernel/src/env/getenv.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "stdlib.h" -#include "string.h" -#include "los_exc.h" - -/* - * getenv -- - * Returns ptr to value associated with name, if any, else NULL. - */ -char * -getenv(const char *name) -{ -#ifdef LOSCFG_LLTREPORT - if (strncmp(name, "GCOV_PREFIX", sizeof("GCOV_PREFIX")) == 0) { -#ifdef LOSCFG_LLTSER - extern const char *gcov_dir; - return (char *)gcov_dir; -#else - return "/bin/vs/sd"; -#endif - } - if (strncmp(name, "GCOV_PREFIX_STRIP", sizeof("GCOV_PREFIX_STRIP")) == 0) - return "6"; -#endif - return (NULL); -} diff --git a/porting/liteos_a/kernel/src/errno/__strerror.h b/porting/liteos_a/kernel/src/errno/__strerror.h index ca41be08ffb6879e803624496fcde4066e8977d5..2f04d400b3fc9f00dc4b555c14618c98c09a4081 100644 --- a/porting/liteos_a/kernel/src/errno/__strerror.h +++ b/porting/liteos_a/kernel/src/errno/__strerror.h @@ -103,5 +103,3 @@ E(EMEDIUMTYPE, "Wrong medium type") E(EMULTIHOP, "Multihop attempted") E(0, "No error information") - -E(ENOSUPP, "Operation not supported") diff --git a/porting/liteos_a/kernel/src/errno/errno.c b/porting/liteos_a/kernel/src/errno/errno.c deleted file mode 100644 index 03cb605950613a04fbda87e7c7a8eb739b329df6..0000000000000000000000000000000000000000 --- a/porting/liteos_a/kernel/src/errno/errno.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "errno.h" -#include "los_errno.h" -#include "los_task_pri.h" - -/* the specific errno get or set in interrupt service routine */ -static int errno_isr; - -void set_errno(int err_code) { - LosTaskCB *runTask = NULL; - - /* errno can not be set to 0 as posix standard */ - if (err_code == 0) - return; - - if (OS_INT_INACTIVE) { - runTask = OsCurrTaskGet(); - runTask->errorNo = err_code; - } - else { - errno_isr = err_code; - } -} - -int get_errno(void) { - LosTaskCB *runTask = NULL; - - if (OS_INT_INACTIVE) { - runTask = OsCurrTaskGet(); - return runTask->errorNo; - } - else { - return errno_isr; - } -} - -int *__errno_location(void) { - LosTaskCB *runTask = NULL; - - if (OS_INT_INACTIVE) { - runTask = OsCurrTaskGet(); - return &runTask->errorNo; - } - else { - return &errno_isr; - } -} - -volatile int *__errno(void) { - LosTaskCB *runTask = NULL; - - if (OS_INT_INACTIVE) { - runTask = OsCurrTaskGet(); - return (volatile int *)(&runTask->errorNo); - } - else { - return (volatile int *)(&errno_isr); - } -} diff --git a/porting/liteos_a/kernel/src/errno/strerror.c b/porting/liteos_a/kernel/src/errno/strerror.c index b8ee518e5064b30122f58531a7a7c1e8d024c8ea..3a93eea66456bca34df1f04b85601e6c61ccaf43 100644 --- a/porting/liteos_a/kernel/src/errno/strerror.c +++ b/porting/liteos_a/kernel/src/errno/strerror.c @@ -2,10 +2,6 @@ #include #include "locale_impl.h" -#ifdef __cplusplus -extern "C" { -#endif - #define E(a,b) ((unsigned char)a), static const unsigned char errid[] = { #include "__strerror.h" @@ -33,7 +29,3 @@ char *strerror(int e) } weak_alias(__strerror_l, strerror_l); - -#ifdef __cplusplus -} -#endif diff --git a/porting/liteos_a/kernel/src/exit/abort.c b/porting/liteos_a/kernel/src/exit/abort.c deleted file mode 100644 index 5a3a5d63286f4d4368bd60eb3bc4172886af5905..0000000000000000000000000000000000000000 --- a/porting/liteos_a/kernel/src/exit/abort.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "stdlib.h" -#include "string.h" -#include "los_exc.h" - -void abort(void) { - LOS_Panic("System was being aborted\n"); - while (1); -} \ No newline at end of file diff --git a/porting/liteos_a/kernel/src/exit/assert.c b/porting/liteos_a/kernel/src/exit/assert.c index 51938edda87cfb369438c3847a8ec750050e59b6..81c64a7d30b561297a3543e89bcc1a5c8647cdf2 100644 --- a/porting/liteos_a/kernel/src/exit/assert.c +++ b/porting/liteos_a/kernel/src/exit/assert.c @@ -1,61 +1,10 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - #include "assert.h" -#include "los_hwi.h" #include "los_printf.h" #include "los_exc.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -void __assert(const char* file, int line, const char* expr) { - PRINT_ERR("__assert error: %s, %d, %s\n", file, line, expr); - LOS_Panic("__assert error:\n"); - while (1); -} - -void __assert2(const char* file, int line, const char* func, const char* expr) { - PRINT_ERR("%s:%d: %s: assertion \"%s\" failed", file, line, func, expr); - LOS_Panic("__assert error:\n"); - while (1); -} - -void __assert_fail(const char* expr, const char* file, int line, const char* func) { - PRINT_ERR("%s:%d: %s: assertion \"%s\" failed", file, line, func, expr); - LOS_Panic("__assert error:\n"); - while (1); -} - -#ifdef __cplusplus +_Noreturn void __assert_fail(const char *expr, const char *file, int line, const char *func) +{ + PRINT_ERR("%s:%d: %s: assertion \"%s\" failed", file, line, func, expr); + LOS_Panic("__assert error:\n"); + while (1); } -#endif /* __cplusplus */ \ No newline at end of file diff --git a/porting/liteos_a/kernel/src/exit/exit.c b/porting/liteos_a/kernel/src/exit/exit.c deleted file mode 100644 index 4fd2028ca943e193bd1f86e8fc9564227956ee7b..0000000000000000000000000000000000000000 --- a/porting/liteos_a/kernel/src/exit/exit.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "los_printf.h" - -void _exit(int status) { - PRINT_ERR("%s NOT SUPPORT\n", __FUNCTION__); - errno = ENOSYS; - while (1); -} - -void exit(int status) { - PRINT_ERR("%s NOT SUPPORT\n", __FUNCTION__); - errno = ENOSYS; - while (1); -} diff --git a/porting/liteos_a/kernel/src/include/features.h b/porting/liteos_a/kernel/src/include/features.h index 3c16def3713914fd1aad33ca86ef4d8d5b526c12..dcf8461d27b1b9b91600a9e70440870c16e6694d 100644 --- a/porting/liteos_a/kernel/src/include/features.h +++ b/porting/liteos_a/kernel/src/include/features.h @@ -4,12 +4,7 @@ #include "../../include/features.h" #define hidden __attribute__((__visibility__("hidden"))) -#ifndef weak_alias #define weak_alias(old, new) \ - extern __typeof(old) new __attribute__((__weak__, __alias__(#old))) -#endif -#ifndef strong_alias -#define strong_alias(old, new) \ - extern __typeof(old) new __attribute__((__alias__(#old))) -#endif + extern __typeof(old) new __attribute__((__weak__, __alias__(#old))) + #endif diff --git a/porting/liteos_a/kernel/src/internal/floatscan.c b/porting/liteos_a/kernel/src/internal/floatscan.c index 04f55d0c4a84aae6e27e80191fb2f1323b9e534f..8c0828fcb39e6e0e742309913eef1aa955e582e5 100644 --- a/porting/liteos_a/kernel/src/internal/floatscan.c +++ b/porting/liteos_a/kernel/src/internal/floatscan.c @@ -185,7 +185,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po x[k] = x[k]/p10 + carry; carry = 1000000000/p10 * tmp; if (k==a && !x[k]) { - a = ((a+1) & MASK); + a = (a+1 & MASK); rp -= 9; } } @@ -197,7 +197,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po while (rp < 9*LD_B1B_DIG || (rp == 9*LD_B1B_DIG && x[a] 1000000000) { carry = tmp / 1000000000; @@ -206,15 +206,15 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po carry = 0; x[k] = tmp; } - if (k==((z-1) & MASK) && k!=a && !x[k]) z = k; + if (k==(z-1 & MASK) && k!=a && !x[k]) z = k; if (k==a) break; } if (carry) { rp += 9; - a = ((a-1) & MASK); + a = (a-1 & MASK); if (a == z) { - z = ((z-1) & MASK); - x[(z-1) & MASK] |= x[z]; + z = (z-1 & MASK); + x[z-1 & MASK] |= x[z]; } x[a] = carry; } @@ -225,39 +225,39 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po uint32_t carry = 0; int sh = 1; for (i=0; i th[i]) break; + if (x[a+i & MASK] > th[i]) break; } if (i==LD_B1B_DIG && rp==9*LD_B1B_DIG) break; /* FIXME: find a way to compute optimal sh */ if (rp > 9+9*LD_B1B_DIG) sh = 9; e2 += sh; - for (k=a; k!=z; k=((k+1) & MASK)) { - uint32_t tmp = x[k] & ((1<>sh) + carry; carry = (1000000000>>sh) * tmp; if (k==a && !x[k]) { - a = ((a+1) & MASK); + a = (a+1 & MASK); i--; rp -= 9; } } if (carry) { - if (((z+1) & MASK) != a) { + if ((z+1 & MASK) != a) { x[z] = carry; - z = ((z+1) & MASK); - } else x[(z-1) & MASK] |= 1; + z = (z+1 & MASK); + } else x[z-1 & MASK] |= 1; } } /* Assemble desired bits into floating point variable */ for (y=i=0; i 500000000) frac += 0.75*sign; else if (t == 500000000) { - if (((a+i+1) & MASK) == z) + if ((a+i+1 & MASK) == z) frac += 0.5*sign; else frac += 0.75*sign; @@ -297,7 +297,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po y += frac; y -= bias; - if (((e2+LDBL_MANT_DIG) & INT_MAX) > emax-5) { + if ((e2+LDBL_MANT_DIG & INT_MAX) > emax-5) { if (fabsl(y) >= 2/LDBL_EPSILON) { if (denormal && bits==LDBL_MANT_DIG+e2-emin) denormal = 0; diff --git a/porting/liteos_a/kernel/src/internal/intscan.c b/porting/liteos_a/kernel/src/internal/intscan.c index 7ebb389fc7f09430d2f14c01c2e9718acd706c78..a4a5ae861282863035a492ce8db0e18d4acfe3ac 100644 --- a/porting/liteos_a/kernel/src/internal/intscan.c +++ b/porting/liteos_a/kernel/src/internal/intscan.c @@ -67,7 +67,7 @@ unsigned long long __intscan(FILE *f, unsigned base, int pok, unsigned long long for (y=x; c-'0'<10U && y<=ULLONG_MAX/10 && 10*y<=ULLONG_MAX-(c-'0'); c=shgetc(f)) y = y*10 + (c-'0'); if (c-'0'>=10U) goto done; - } else if (!(base & (base-1))) { + } else if (!(base & base-1)) { int bs = "\0\1\2\4\7\3\6\5"[(0x17*base)>>5&7]; for (x=0; val[c]shlim) && (cnt >= f->shlim)) || ((c=__uflow(f)) < 0)) { + if (f->shlim && cnt >= f->shlim || (c=__uflow(f)) < 0) { f->shcnt = f->buf - f->rpos + cnt; f->shend = f->rpos; f->shlim = -1; diff --git a/porting/liteos_a/kernel/src/internal/stdio_impl.h b/porting/liteos_a/kernel/src/internal/stdio_impl.h index 1a95fd103f881424cde60b409273b43b8272843a..e149fa0541d1fbb217bb9732caa1a181c5fe7726 100644 --- a/porting/liteos_a/kernel/src/internal/stdio_impl.h +++ b/porting/liteos_a/kernel/src/internal/stdio_impl.h @@ -16,6 +16,32 @@ #define F_SVB 64 #define F_APP 128 +struct _IO_FILE { + unsigned flags; + unsigned char *rpos, *rend; + int (*close)(struct _IO_FILE *); + unsigned char *wend, *wpos; + unsigned char *mustbezero_1; + unsigned char *wbase; + size_t (*read)(struct _IO_FILE *, unsigned char *, size_t); + size_t (*write)(struct _IO_FILE *, const unsigned char *, size_t); + off_t (*seek)(struct _IO_FILE *, off_t, int); + unsigned char *buf; + size_t buf_size; + struct _IO_FILE *prev, *next; + int fd; + int pipe_pid; + int mode; + void *lock; + int lbf; + void *cookie; + off_t off; + char *getln_buf; + void *mustbezero_2; + unsigned char *shend; + off_t shlim, shcnt; + struct __locale_struct *locale; +}; extern hidden FILE *volatile __stdin_used; extern hidden FILE *volatile __stdout_used; diff --git a/porting/liteos_a/kernel/src/locale/__mo_lookup.c b/porting/liteos_a/kernel/src/locale/__mo_lookup.c index fa3e0c4ba89d918d1026218131f74d9e6ddd9bd4..d18ab7744246bd286fbc8a67117c320a29169700 100644 --- a/porting/liteos_a/kernel/src/locale/__mo_lookup.c +++ b/porting/liteos_a/kernel/src/locale/__mo_lookup.c @@ -3,7 +3,7 @@ static inline uint32_t swapc(uint32_t x, int c) { - return c ? (x>>24) | ((x>>8)&(0xff00)) | ((x<<8)&(0xff0000)) | (x<<24) : x; + return c ? x>>24 | x>>8&0xff00 | x<<8&0xff0000 | x<<24 : x; } const char *__mo_lookup(const void *p, size_t size, const char *s) diff --git a/porting/liteos_a/kernel/src/malloc/malloc.c b/porting/liteos_a/kernel/src/malloc/malloc.c deleted file mode 100644 index ccac6fcce26b1bc589a12c4e25b2177118bd3f80..0000000000000000000000000000000000000000 --- a/porting/liteos_a/kernel/src/malloc/malloc.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "stdlib.h" -#include "string.h" -#include "los_vm_map.h" - -/* - * Allocates the requested memory and returns a pointer to it. The requested - * size is nitems each size bytes long (total memory requested is nitems*size). - * The space is initialized to all zero bits. - */ - -void* calloc(size_t nitems, size_t size) { /*lint !e578*/ - size_t real_size; - void* ptr = NULL; - - if (nitems == 0 || size == 0) { - return NULL; - } - - real_size = (size_t)(nitems * size); - ptr = LOS_KernelMalloc((UINT32)real_size); - if (ptr != NULL) { - (void)memset_s((void *)ptr, real_size, 0, real_size); - } - return ptr; -} - -/* - * Deallocates the memory previously allocated by a call to calloc, malloc, or - * realloc. The argument ptr points to the space that was previously allocated. - * If ptr points to a memory block that was not allocated with calloc, malloc, - * or realloc, or is a space that has been deallocated, then the result is undefined. - */ - -void free(void* ptr) { - if (ptr == NULL) { - return; - } - - LOS_KernelFree(ptr); -} - -/* - * Allocates the requested memory and returns a pointer to it. The requested - * size is size bytes. The value of the space is indeterminate. - */ - -void* malloc(size_t size) { /*lint !e31 !e10*/ - if (size == 0) { - return NULL; - } - - return LOS_KernelMalloc((UINT32)size); -} - -void* zalloc(size_t size) { /*lint !e10*/ - void* ptr = NULL; - - if (size == 0) { - return NULL; - } - - ptr = LOS_KernelMalloc((UINT32)size); - if (ptr != NULL) { - (void)memset_s(ptr, size, 0, size); - } - return ptr; -} - -/* - * allocates a block of size bytes whose address is a multiple of boundary. - * The boundary must be a power of two! - */ - -void* memalign(size_t boundary, size_t size) { - if (size == 0) { - return NULL; - } - - return LOS_KernelMallocAlign((UINT32)size, (UINT32)boundary); -} - -/* - * Attempts to resize the memory block pointed to by ptr that was previously - * allocated with a call to malloc or calloc. The contents pointed to by ptr are - * unchanged. If the value of size is greater than the previous size of the - * block, then the additional bytes have an undeterminate value. If the value - * of size is less than the previous size of the block, then the difference of - * bytes at the end of the block are freed. If ptr is null, then it behaves like - * malloc. If ptr points to a memory block that was not allocated with calloc - * or malloc, or is a space that has been deallocated, then the result is - * undefined. If the new space cannot be allocated, then the contents pointed - * to by ptr are unchanged. If size is zero, then the memory block is completely - * freed. - */ - -void* realloc(void* ptr, size_t size) { - if (ptr == NULL) { - ptr = malloc(size); - return ptr; - } - - if (size == 0) { - free(ptr); - return NULL; - } - - return LOS_KernelRealloc(ptr, (UINT32)size); -} \ No newline at end of file diff --git a/porting/liteos_a/kernel/src/math/acos.c b/porting/liteos_a/kernel/src/math/acos.c index 6104a32bc90e53a962e060004dfa1fe48a375226..ea9c87bf087809f9a6b1fa6a2ed2f065d8184f72 100644 --- a/porting/liteos_a/kernel/src/math/acos.c +++ b/porting/liteos_a/kernel/src/math/acos.c @@ -69,7 +69,7 @@ double acos(double x) uint32_t lx; GET_LOW_WORD(lx,x); - if (((ix-0x3ff00000) | lx) == 0) { + if ((ix-0x3ff00000 | lx) == 0) { /* acos(1)=0, acos(-1)=pi */ if (hx >> 31) return 2*pio2_hi + 0x1p-120f; diff --git a/porting/liteos_a/kernel/src/math/asin.c b/porting/liteos_a/kernel/src/math/asin.c index 96b4cdfaaaaf64782b3d0243a3ff115af60b0567..c926b188552b20b1842a26e4c5500b2f0686a95f 100644 --- a/porting/liteos_a/kernel/src/math/asin.c +++ b/porting/liteos_a/kernel/src/math/asin.c @@ -75,7 +75,7 @@ double asin(double x) if (ix >= 0x3ff00000) { uint32_t lx; GET_LOW_WORD(lx, x); - if (((ix-0x3ff00000) | lx) == 0) + if ((ix-0x3ff00000 | lx) == 0) /* asin(1) = +-pi/2 with inexact */ return x*pio2_hi + 0x1p-120f; return 0/(x-x); diff --git a/porting/liteos_a/kernel/src/math/atan2.c b/porting/liteos_a/kernel/src/math/atan2.c index 91378b977a25e42c65d744a2d05208670fb7705c..5a1903c6240821b70e6993f3769563c5eb1ba18f 100644 --- a/porting/liteos_a/kernel/src/math/atan2.c +++ b/porting/liteos_a/kernel/src/math/atan2.c @@ -52,7 +52,7 @@ double atan2(double y, double x) return x+y; EXTRACT_WORDS(ix, lx, x); EXTRACT_WORDS(iy, ly, y); - if (((ix-0x3ff00000) | lx) == 0) /* x = 1.0 */ + if ((ix-0x3ff00000 | lx) == 0) /* x = 1.0 */ return atan(y); m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */ ix = ix & 0x7fffffff; diff --git a/porting/liteos_a/kernel/src/math/fma.c b/porting/liteos_a/kernel/src/math/fma.c index 139f53299e365b6010b3a3a984a3dda0f28cccc8..0c6f90c9cfd14e7ba584c3828dd01077171ca420 100644 --- a/porting/liteos_a/kernel/src/math/fma.c +++ b/porting/liteos_a/kernel/src/math/fma.c @@ -69,7 +69,7 @@ double fma(double x, double y, double z) if (d > 0) { if (d < 64) { zlo = nz.m<>(64-d); + zhi = nz.m>>64-d; } else { zlo = 0; zhi = nz.m; @@ -77,7 +77,7 @@ double fma(double x, double y, double z) d -= 64; if (d == 0) { } else if (d < 64) { - rlo = rhi<<(64-d) | rlo>>d | !!(rlo<<(64-d)); + rlo = rhi<<64-d | rlo>>d | !!(rlo<<64-d); rhi = rhi>>d; } else { rlo = 1; @@ -90,7 +90,7 @@ double fma(double x, double y, double z) if (d == 0) { zlo = nz.m; } else if (d < 64) { - zlo = nz.m>>d | !!(nz.m<<(64-d)); + zlo = nz.m>>d | !!(nz.m<<64-d); } else { zlo = 1; } @@ -122,7 +122,7 @@ double fma(double x, double y, double z) e += 64; d = a_clz_64(rhi)-1; /* note: d > 0 */ - rhi = rhi<>(64-d) | !!(rlo<>64-d | !!(rlo<>d | !!(rhi<<(64-d)) ) << d; + i = ( rhi>>d | !!(rhi<<64-d) ) << d; if (sign) i = -i; r = i; diff --git a/porting/liteos_a/kernel/src/math/lgammaf_r.c b/porting/liteos_a/kernel/src/math/lgammaf_r.c index 8dae675a72ca3cd24178097bf1e3ef91d212823e..3f353f19b339f03cdbd022d24fc69284b9b2c3f7 100644 --- a/porting/liteos_a/kernel/src/math/lgammaf_r.c +++ b/porting/liteos_a/kernel/src/math/lgammaf_r.c @@ -105,8 +105,7 @@ static float sin_pi(float x) float __lgammaf_r(float x, int *signgamp) { union {float f; uint32_t i;} u = {x}; - float nadj = 0; - float t,y,z,p,p1,p2,p3,q,r,w; + float t,y,z,nadj,p,p1,p2,p3,q,r,w; uint32_t ix; int i,sign; diff --git a/porting/liteos_a/kernel/src/multibyte/mbtowc.c b/porting/liteos_a/kernel/src/multibyte/mbtowc.c index 87fb5ba3e2ebfdc9395d858132462f517a5a0a61..c191bb038bbfdb05a81daf64c732de3b43b40424 100644 --- a/porting/liteos_a/kernel/src/multibyte/mbtowc.c +++ b/porting/liteos_a/kernel/src/multibyte/mbtowc.c @@ -24,21 +24,21 @@ int mbtowc(wchar_t *restrict wc, const char *restrict src, size_t n) if (n<4 && ((c<<(6*n-6)) & (1U<<31))) goto ilseq; if (OOB(c,*s)) goto ilseq; - c = (c<<6) | (*s++-0x80); + c = c<<6 | *s++-0x80; if (!(c&(1U<<31))) { *wc = c; return 2; } if (*s-0x80u >= 0x40) goto ilseq; - c = (c<<6) | (*s++-0x80); + c = c<<6 | *s++-0x80; if (!(c&(1U<<31))) { *wc = c; return 3; } if (*s-0x80u >= 0x40) goto ilseq; - *wc = (c<<6) | (*s++-0x80); + *wc = c<<6 | *s++-0x80; return 4; ilseq: diff --git a/porting/liteos_a/kernel/src/prng/rand.c b/porting/liteos_a/kernel/src/prng/rand.c deleted file mode 100644 index 65ad238435cc1f73ac06411b8b499921b68fd0c8..0000000000000000000000000000000000000000 --- a/porting/liteos_a/kernel/src/prng/rand.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -void srand(unsigned s) -{ - return srandom(s); -} - -int rand(void) -{ - return random(); -} diff --git a/porting/liteos_a/kernel/src/sched/sched_yield.c b/porting/liteos_a/kernel/src/sched/sched_yield.c deleted file mode 100644 index c511cfdfae1722b1e064ffa894d16b83875c1688..0000000000000000000000000000000000000000 --- a/porting/liteos_a/kernel/src/sched/sched_yield.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "los_process.h" - -int sched_yield() -{ - (void)LOS_TaskYield(); - return 0; -} diff --git a/porting/liteos_a/kernel/src/stdio/__stdio_close.c b/porting/liteos_a/kernel/src/stdio/__stdio_close.c index 9b4f24615efdf29f08150c5c3528ac0df7590515..14858bbfd7f0310652080dcbcc6638d3dcb083c4 100644 --- a/porting/liteos_a/kernel/src/stdio/__stdio_close.c +++ b/porting/liteos_a/kernel/src/stdio/__stdio_close.c @@ -1,9 +1,6 @@ #include "stdio_impl.h" #include -#ifndef LOSCFG_FS_VFS -#define close(...) (-1) -#endif int __stdio_close(FILE *f) { diff --git a/porting/liteos_a/kernel/src/stdio/__stdio_seek.c b/porting/liteos_a/kernel/src/stdio/__stdio_seek.c index b16b17bd75d48e5da21ecce9de76cab57abd9228..70b856b0bae7e552e9b5e49ef48c0c3c3f7df2f3 100644 --- a/porting/liteos_a/kernel/src/stdio/__stdio_seek.c +++ b/porting/liteos_a/kernel/src/stdio/__stdio_seek.c @@ -1,62 +1,8 @@ #include "stdio_impl.h" #include -#include -#include -#ifdef LOSCFG_FS_VFS -#include - -static off64_t __stdio_lseek64(int fd, int offsetHigh, int offsetLow, off64_t *result, int whence) -{ - off64_t ret; - struct file *filep = NULL; - off64_t offset = ((off64_t)offsetHigh << 32) + (uint)offsetLow; /* 32: offsetHigh is high 32 bits */ - - /* Get the file structure corresponding to the file descriptor. */ - ret = fs_getfilep(fd, &filep); - if (ret < 0) { - /* The errno value has already been set */ - return (off64_t)-get_errno(); - } - - /* libc seekdir function should set the whence to SEEK_SET, so we can discard - * the whence argument here */ - if (filep->f_oflags & O_DIRECTORY) { - /* defensive coding */ - if (filep->f_dir == NULL) { - return (off64_t)-EINVAL; - } - if (offsetLow == 0) { - rewinddir(filep->f_dir); - } else { - seekdir(filep->f_dir, offsetLow); - } - ret = telldir(filep->f_dir); - if (ret < 0) { - return (off64_t)-get_errno(); - } - goto out; - } - - /* Then let file_seek do the real work */ - ret = file_seek64(filep, offset, whence); - if (ret < 0) { - return (off64_t)-get_errno(); - } - -out: - *result = ret; - - return 0; -} off_t __stdio_seek(FILE *f, off_t off, int whence) { off_t result = 0; - return __stdio_lseek64(f->fd, off>>32, off, &result, whence) ? -1 : result; -} -#else -off_t __stdio_seek(FILE *f, off_t off, int whence) -{ - return 0; + return _lseek64(f->fd, off>>32, off, &result, whence) ? -1 : result; } -#endif diff --git a/porting/liteos_a/kernel/src/stdio/__stdio_write.c b/porting/liteos_a/kernel/src/stdio/__stdio_write.c index e03d3fd446fca01433f0caa22f7ad654d20777fb..94158cb87cc4d29022e08135f1251f244032750c 100644 --- a/porting/liteos_a/kernel/src/stdio/__stdio_write.c +++ b/porting/liteos_a/kernel/src/stdio/__stdio_write.c @@ -1,10 +1,6 @@ #include "stdio_impl.h" #include -#ifndef LOSCFG_FS_VFS -#define writev(...) (-1) -#endif - size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) { struct iovec iovs[2] = { diff --git a/porting/liteos_a/kernel/src/stdio/__stdout_write.c b/porting/liteos_a/kernel/src/stdio/__stdout_write.c index 1cec32de61efde071cd1fa3bc092fa765ac968cb..4762696285d547671a37f09e67cdf034e5640d5e 100644 --- a/porting/liteos_a/kernel/src/stdio/__stdout_write.c +++ b/porting/liteos_a/kernel/src/stdio/__stdout_write.c @@ -1,19 +1,11 @@ #include "stdio_impl.h" #include -#ifndef LOSCFG_FS_VFS -static int _ioctl (int fd, int cmd, ...) -{ - return -1; -} -#define ioctl _ioctl -#endif - size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len) { - struct winsize wsz; - if (!(f->flags & F_SVB) && ioctl(f->fd, TIOCGWINSZ, &wsz)) { - f->lbf = EOF; - } - return __stdio_write(f, buf, len); + struct winsize wsz; + f->write = __stdio_write; + if (!(f->flags & F_SVB) && ioctl(f->fd, TIOCGWINSZ, &wsz)) + f->lbf = EOF; + return __stdio_write(f, buf, len); } diff --git a/porting/liteos_a/kernel/src/stdio/__toread.c b/porting/liteos_a/kernel/src/stdio/__toread.c index d2a377e09a1750a4d8b788552c68f6daf686b350..f142ff09c087ef5459a29acd004fd005ddfc8a0c 100644 --- a/porting/liteos_a/kernel/src/stdio/__toread.c +++ b/porting/liteos_a/kernel/src/stdio/__toread.c @@ -11,4 +11,9 @@ int __toread(FILE *f) } f->rpos = f->rend = f->buf + f->buf_size; return (f->flags & F_EOF) ? EOF : 0; -} \ No newline at end of file +} + +hidden void __toread_needs_stdio_exit() +{ + __stdio_exit_needed(); +} diff --git a/porting/liteos_a/kernel/src/stdio/__towrite.c b/porting/liteos_a/kernel/src/stdio/__towrite.c index 5bb97f31459dd8a2df2cd1dd98d0ac3d3b9d43a0..4c9c66ae79c9e8c5abe8750df8ebfce149b1e061 100644 --- a/porting/liteos_a/kernel/src/stdio/__towrite.c +++ b/porting/liteos_a/kernel/src/stdio/__towrite.c @@ -16,3 +16,8 @@ int __towrite(FILE *f) return 0; } + +hidden void __towrite_needs_stdio_exit() +{ + __stdio_exit_needed(); +} diff --git a/porting/liteos_a/kernel/src/stdio/fclose.c b/porting/liteos_a/kernel/src/stdio/fclose.c index c53f3cd6e6b7fa621b684f64e70f464a75aec671..f4005d5f5076dfaffa8317b6b82251faa536ff45 100644 --- a/porting/liteos_a/kernel/src/stdio/fclose.c +++ b/porting/liteos_a/kernel/src/stdio/fclose.c @@ -1,17 +1,11 @@ #include "stdio_impl.h" #include -#ifdef LOSCFG_LLTSER -#include "gcov_ser.h" -#endif static void dummy(FILE *f) { } weak_alias(dummy, __unlist_locked_file); int fclose(FILE *f) { -#ifdef LOSCFG_LLTSER - GCOV_FCLOSE(fp); -#endif int r; FLOCK(f); diff --git a/porting/liteos_a/kernel/src/stdio/fopen.c b/porting/liteos_a/kernel/src/stdio/fopen.c index 37d91130f476b49d783b3fc4c21dc73bcb2f0190..e29336fde7da5f4f85b7cbe74302fa3e189ccab3 100644 --- a/porting/liteos_a/kernel/src/stdio/fopen.c +++ b/porting/liteos_a/kernel/src/stdio/fopen.c @@ -4,15 +4,9 @@ #include #include #include -#ifdef LOSCFG_LLTSER -#include "gcov_ser.h" -#endif FILE *fopen(const char *restrict filename, const char *restrict mode) { -#ifdef LOSCFG_LLTSER - GCOV_FOPEN(filename); -#endif FILE *f; int fd; int flags; diff --git a/porting/liteos_a/kernel/src/stdio/fread.c b/porting/liteos_a/kernel/src/stdio/fread.c index 5d3b869ef9f918cde3a3e0a889151b46f78609a1..a2116da61370bd829c634353ad6f6fa6732d0d8b 100644 --- a/porting/liteos_a/kernel/src/stdio/fread.c +++ b/porting/liteos_a/kernel/src/stdio/fread.c @@ -1,8 +1,5 @@ #include "stdio_impl.h" #include -#ifdef LOSCFG_LLTSER -#include "gcov_ser.h" -#endif #define MIN(a,b) ((a)<(b) ? (a) : (b)) @@ -13,9 +10,7 @@ size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f) if (!size) nmemb = 0; FLOCK(f); -#ifdef LOSCFG_LLTSER - GCOV_FREAD(f, destv, size, nmemb); -#endif + f->mode |= f->mode-1; if (f->rpos != f->rend) { diff --git a/porting/liteos_a/kernel/src/stdio/fwrite.c b/porting/liteos_a/kernel/src/stdio/fwrite.c index a7cd0aa2ca9764e1d0fe75b72408c9801becd820..7a567b2c55a94b30288444bd93f6fc48fff7e433 100644 --- a/porting/liteos_a/kernel/src/stdio/fwrite.c +++ b/porting/liteos_a/kernel/src/stdio/fwrite.c @@ -1,8 +1,5 @@ #include "stdio_impl.h" #include -#ifdef LOSCFG_LLTSER -#include "gcov_ser.h" -#endif size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) { @@ -30,9 +27,6 @@ size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) size_t fwrite(const void *restrict src, size_t size, size_t nmemb, FILE *restrict f) { -#ifdef LOSCFG_LLTSER - GCOV_FWRITE(f, src, size, nmemb); -#endif size_t k, l = size*nmemb; if (!size) nmemb = 0; FLOCK(f); diff --git a/porting/liteos_a/kernel/src/stdio/ungetc.c b/porting/liteos_a/kernel/src/stdio/ungetc.c index 180673a47663ad57b11d3e6525c35cc23858939a..bc629d4ca511f812976abb93224e2732e0788e6e 100644 --- a/porting/liteos_a/kernel/src/stdio/ungetc.c +++ b/porting/liteos_a/kernel/src/stdio/ungetc.c @@ -16,5 +16,5 @@ int ungetc(int c, FILE *f) f->flags &= ~F_EOF; FUNLOCK(f); - return c; + return (unsigned char)c; } diff --git a/porting/liteos_a/kernel/src/stdio/vfprintf.c b/porting/liteos_a/kernel/src/stdio/vfprintf.c index a5bcee8a14614a40ed51eb1f9ff00c250836ac9f..8ca639ccb1affb04eaaf9603b240a023083620ac 100644 --- a/porting/liteos_a/kernel/src/stdio/vfprintf.c +++ b/porting/liteos_a/kernel/src/stdio/vfprintf.c @@ -20,12 +20,12 @@ /* Convenient bit representation for modifier flags, which all fall * within 31 codepoints of the space character. */ -#define ALT_FORM (1U<<('#'-' ')) -#define ZERO_PAD (1U<<('0'-' ')) -#define LEFT_ADJ (1U<<('-'-' ')) -#define PAD_POS (1U<<(' '-' ')) -#define MARK_POS (1U<<('+'-' ')) -#define GROUPED (1U<<('\''-' ')) +#define ALT_FORM (1U<<'#'-' ') +#define ZERO_PAD (1U<<'0'-' ') +#define LEFT_ADJ (1U<<'-'-' ') +#define PAD_POS (1U<<' '-' ') +#define MARK_POS (1U<<'+'-' ') +#define GROUPED (1U<<'\''-' ') #define FLAGMASK (ALT_FORM|ZERO_PAD|LEFT_ADJ|PAD_POS|MARK_POS|GROUPED) @@ -191,8 +191,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) char buf[9+LDBL_MANT_DIG/4], *s; const char *prefix="-0X+0X 0X-0x+0x 0x"; int pl; - char ebuf0[3*sizeof(int)], *ebuf=&ebuf0[3*sizeof(int)]; - char *estr = NULL; + char ebuf0[3*sizeof(int)], *ebuf=&ebuf0[3*sizeof(int)], *estr; pl=1; if (signbit(y)) { @@ -297,7 +296,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) uint32_t carry=0, *b; int sh=MIN(9,-e2), need=1+(p+LDBL_MANT_DIG/3U+8)/9; for (d=a; d>sh) + carry; carry = (1000000000>>sh) * rm; } @@ -486,8 +485,8 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, } /* Read modifier flags */ - for (fl=0; (unsigned)*s-' '<32 && (FLAGMASK&(1U<<(*s-' '))); s++) - fl |= 1U<<(*s-' '); + for (fl=0; (unsigned)*s-' '<32 && (FLAGMASK&(1U<<*s-' ')); s++) + fl |= 1U<<*s-' '; /* Read field width */ if (*s=='*') { diff --git a/porting/liteos_a/kernel/src/stdlib/strtol.c b/porting/liteos_a/kernel/src/stdlib/strtol.c index 8dfc1386232d925c192b1be8d841cfa48e0f1677..bfefea69d1c4f8cd8d4abb3dfa7c323f7d3c646f 100644 --- a/porting/liteos_a/kernel/src/stdlib/strtol.c +++ b/porting/liteos_a/kernel/src/stdlib/strtol.c @@ -53,4 +53,4 @@ weak_alias(strtoul, __strtoul_internal); weak_alias(strtoll, __strtoll_internal); weak_alias(strtoull, __strtoull_internal); weak_alias(strtoimax, __strtoimax_internal); -weak_alias(strtoumax, __strtoumax_internal); \ No newline at end of file +weak_alias(strtoumax, __strtoumax_internal); diff --git a/porting/liteos_a/kernel/src/string/memchr.c b/porting/liteos_a/kernel/src/string/memchr.c index 6f3233b43e56804f428a543cbce1bbb4d8aac1e8..65f0d789b2c9a4e2bf8fbd89e9cbc704dd7a538f 100644 --- a/porting/liteos_a/kernel/src/string/memchr.c +++ b/porting/liteos_a/kernel/src/string/memchr.c @@ -6,7 +6,7 @@ #define ALIGN (sizeof(size_t)-1) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS) +#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) void *memchr(const void *src, int c, size_t n) { @@ -18,7 +18,7 @@ void *memchr(const void *src, int c, size_t n) typedef size_t __attribute__((__may_alias__)) word; const word *w; size_t k = ONES * c; - for (w = (const void *)s; (n>=SS) && !HASZERO(*w^k); w++, n-=SS); + for (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS); s = (const void *)w; } #endif diff --git a/porting/liteos_a/kernel/src/string/stpcpy.c b/porting/liteos_a/kernel/src/string/stpcpy.c index 81ec14b80c6d48d4e2ca51200904902b6f557b04..4db46a9e50b2f53278a22b91bebea08fc7544f6b 100644 --- a/porting/liteos_a/kernel/src/string/stpcpy.c +++ b/porting/liteos_a/kernel/src/string/stpcpy.c @@ -5,7 +5,7 @@ #define ALIGN (sizeof(size_t)) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS) +#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) char *__stpcpy(char *restrict d, const char *restrict s) { diff --git a/porting/liteos_a/kernel/src/string/stpncpy.c b/porting/liteos_a/kernel/src/string/stpncpy.c index fad9372e770a094f4808022b3f33af55f8abec48..f57fa6b71bf3d2479a3eeff24fba5225e3007c18 100644 --- a/porting/liteos_a/kernel/src/string/stpncpy.c +++ b/porting/liteos_a/kernel/src/string/stpncpy.c @@ -5,7 +5,7 @@ #define ALIGN (sizeof(size_t)-1) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS) +#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) char *__stpncpy(char *restrict d, const char *restrict s, size_t n) { @@ -17,7 +17,7 @@ char *__stpncpy(char *restrict d, const char *restrict s, size_t n) for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++); if (!n || !*s) goto tail; wd=(void *)d; ws=(const void *)s; - for (; (n>=sizeof(size_t)) && !HASZERO(*ws); + for (; n>=sizeof(size_t) && !HASZERO(*ws); n-=sizeof(size_t), ws++, wd++) *wd = *ws; d=(void *)wd; s=(const void *)ws; } @@ -29,3 +29,4 @@ tail: } weak_alias(__stpncpy, stpncpy); + diff --git a/porting/liteos_a/kernel/src/string/strchrnul.c b/porting/liteos_a/kernel/src/string/strchrnul.c index f628f869b0a4307019092ac1cdf655910d1d6539..39e2635b3064df1e2b15cb45d60c654238ad8f79 100644 --- a/porting/liteos_a/kernel/src/string/strchrnul.c +++ b/porting/liteos_a/kernel/src/string/strchrnul.c @@ -5,7 +5,7 @@ #define ALIGN (sizeof(size_t)) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS) +#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) char *__strchrnul(const char *s, int c) { diff --git a/porting/liteos_a/kernel/src/string/strlcpy.c b/porting/liteos_a/kernel/src/string/strlcpy.c index 4785d10192501fb450db558332b0679149e64a08..ffa0b0b01458041a91f50d0d2c09f7ff2a8e828d 100644 --- a/porting/liteos_a/kernel/src/string/strlcpy.c +++ b/porting/liteos_a/kernel/src/string/strlcpy.c @@ -6,7 +6,7 @@ #define ALIGN (sizeof(size_t)-1) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS) +#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) size_t strlcpy(char *d, const char *s, size_t n) { diff --git a/porting/liteos_a/kernel/src/string/strlen.c b/porting/liteos_a/kernel/src/string/strlen.c index 66f818367779321aee7e965d964ea132750691fe..309990f029f0c09b4c7c0405258b92ac8f93310d 100644 --- a/porting/liteos_a/kernel/src/string/strlen.c +++ b/porting/liteos_a/kernel/src/string/strlen.c @@ -5,7 +5,7 @@ #define ALIGN (sizeof(size_t)) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS) +#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) size_t strlen(const char *s) { diff --git a/porting/liteos_a/kernel/src/time/__tz.c b/porting/liteos_a/kernel/src/time/__tz.c index cbef265f81a53604247ba5e2d2c362b4ae3b5976..58a33fbd610f010a897843fbaad50950925ca060 100644 --- a/porting/liteos_a/kernel/src/time/__tz.c +++ b/porting/liteos_a/kernel/src/time/__tz.c @@ -219,7 +219,7 @@ weak_alias(__tzset, tzset); const char *__tm_to_tzname(const struct tm *tm) { - const void *p = tm->tm_zone; + const void *p = tm->__tm_zone; LOCK(); do_tzset(); if (p != __utc && p != __tzname[0] && p != __tzname[1] && diff --git a/porting/liteos_a/kernel/src/time/strftime.c b/porting/liteos_a/kernel/src/time/strftime.c index 74d1ff40ee9788208a25736157a0aff66df203de..cc53d5369ca717900ef5816ed7bdc400d149dc6b 100644 --- a/porting/liteos_a/kernel/src/time/strftime.c +++ b/porting/liteos_a/kernel/src/time/strftime.c @@ -278,4 +278,4 @@ size_t strftime(char *restrict s, size_t n, const char *restrict f, const struct return __strftime_l(s, n, f, tm, CURRENT_LOCALE); } -weak_alias(__strftime_l, strftime_l); \ No newline at end of file +weak_alias(__strftime_l, strftime_l); diff --git a/porting/liteos_a/kernel/src/time/time.c b/porting/liteos_a/kernel/src/time/time.c deleted file mode 100644 index dcf19c7d5aa204b278f76fee1bbe9cd65adb489d..0000000000000000000000000000000000000000 --- a/porting/liteos_a/kernel/src/time/time.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "los_typedef.h" -#include -#include - -time_t time(time_t *t) -{ - struct timeval tp; - int ret; - - /* Get the current time from the system */ - ret = gettimeofday(&tp, (struct timezone *)NULL); - if (ret == LOS_OK) { - /* Return the seconds since the epoch */ - if (t) { - *t = tp.tv_sec; - } - return tp.tv_sec; - } - return (time_t)OS_ERROR; -}