提交 8b75c667 编写于 作者: C Caoruihong

chore(musl): reduce the modifications of musl

Signed-off-by: NCaoruihong <crh.cao@huawei.com>
Change-Id: I36ed85c6af3b80f780f26c047e096fe861b9e8c3
上级 53a0d8a1
...@@ -8,23 +8,16 @@ ...@@ -8,23 +8,16 @@
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) #define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
#endif #endif
#ifdef CONFIG_DEBUG #define DEBUGASSERT(x) assert(x)
#define DEBUGASSERT(f) \
{ if (!(f)) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
#else
#define DEBUGASSERT(f)
#endif
#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus) #if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
#undef static_assert
#define static_assert _Static_assert #define static_assert _Static_assert
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #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 *); _Noreturn void __assert_fail (const char *, const char *, int, const char *);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -347,32 +347,7 @@ typedef struct __locale_struct *locale_t; ...@@ -347,32 +347,7 @@ typedef struct __locale_struct *locale_t;
#endif #endif
#if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE) #if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE)
struct _IO_FILE { struct _IO_FILE { char __x; };
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;
};
#define __DEFINED_struct__IO_FILE #define __DEFINED_struct__IO_FILE
#endif #endif
......
...@@ -133,5 +133,3 @@ ...@@ -133,5 +133,3 @@
#define ENOTRECOVERABLE 131 #define ENOTRECOVERABLE 131
#define ERFKILL 132 #define ERFKILL 132
#define EHWPOISON 133 #define EHWPOISON 133
#define ENOSUPP 201
...@@ -24,6 +24,12 @@ struct stat { ...@@ -24,6 +24,12 @@ struct stat {
struct timespec st_ctim; 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 <bits/alltypes.h>
struct statx { struct statx {
uint32_t stx_mask; uint32_t stx_mask;
uint32_t stx_blksize; uint32_t stx_blksize;
......
...@@ -11,12 +11,12 @@ static __inline uint16_t __bswap_16(uint16_t __x) ...@@ -11,12 +11,12 @@ static __inline uint16_t __bswap_16(uint16_t __x)
static __inline uint32_t __bswap_32(uint32_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) 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) #define bswap_16(x) __bswap_16(x)
......
...@@ -27,12 +27,12 @@ static __inline uint16_t __bswap16(uint16_t __x) ...@@ -27,12 +27,12 @@ static __inline uint16_t __bswap16(uint16_t __x)
static __inline uint32_t __bswap32(uint32_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) 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 #if __BYTE_ORDER == __LITTLE_ENDIAN
......
...@@ -9,15 +9,14 @@ extern "C" { ...@@ -9,15 +9,14 @@ extern "C" {
#include <bits/errno.h> #include <bits/errno.h>
void set_errno(int err_code);
int get_errno(void);
int *__errno_location(void);
#ifdef __GNUC__ #ifdef __GNUC__
__attribute__((const)) __attribute__((const))
#endif #endif
extern volatile int* __errno(void); int *__errno_location(void);
#define errno (*__errno()) #define errno (*__errno_location())
#define set_errno(err) do { if (err) { errno = (err); } } while(0)
#define get_errno() errno
#ifdef _GNU_SOURCE #ifdef _GNU_SOURCE
extern char *program_invocation_short_name, *program_invocation_name; extern char *program_invocation_short_name, *program_invocation_name;
......
#ifndef _FEATURES_H #ifndef _FEATURES_H
#define _FEATURES_H #define _FEATURES_H
#define _DEFAULT_SOURCE
#define _LARGEFILE64_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE) #if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE)
...@@ -41,6 +39,4 @@ ...@@ -41,6 +39,4 @@
#define __REDIR(x,y) __typeof__(x) x __asm__(#y) #define __REDIR(x,y) __typeof__(x) x __asm__(#y)
#include "../src/include/features.h" #endif
#endif
\ No newline at end of file
...@@ -91,8 +91,6 @@ extern "C" { ...@@ -91,8 +91,6 @@ extern "C" {
char *nl_langinfo(nl_item); char *nl_langinfo(nl_item);
char *nl_langinfo_l(nl_item, locale_t); char *nl_langinfo_l(nl_item, locale_t);
#include "../src/include/langinfo.h"
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -32,7 +32,7 @@ struct ether_header { ...@@ -32,7 +32,7 @@ struct ether_header {
#define ETHERTYPE_LOOPBACK 0x9000 #define ETHERTYPE_LOOPBACK 0x9000
#define ETHER_ADDR_LEN 6 #define ETHER_ADDR_LEN ETH_ALEN
#define ETHER_TYPE_LEN 2 #define ETHER_TYPE_LEN 2
#define ETHER_CRC_LEN 4 #define ETHER_CRC_LEN 4
#define ETHER_HDR_LEN ETH_HLEN #define ETHER_HDR_LEN ETH_HLEN
......
...@@ -311,7 +311,6 @@ struct ip6_mtuinfo { ...@@ -311,7 +311,6 @@ struct ip6_mtuinfo {
struct sockaddr_in6 ip6m_addr; struct sockaddr_in6 ip6m_addr;
uint32_t ip6m_mtu; uint32_t ip6m_mtu;
}; };
#endif #endif
#define IPV6_ADDRFORM 1 #define IPV6_ADDRFORM 1
......
...@@ -69,7 +69,6 @@ struct icmphdr { ...@@ -69,7 +69,6 @@ struct icmphdr {
#define ICMP_EXC_TTL 0 #define ICMP_EXC_TTL 0
#define ICMP_EXC_FRAGTIME 1 #define ICMP_EXC_FRAGTIME 1
#define ICMP_FILTER 1
struct icmp_ra_addr { struct icmp_ra_addr {
uint32_t ira_addr; uint32_t ira_addr;
...@@ -115,10 +114,6 @@ struct icmp { ...@@ -115,10 +114,6 @@ struct icmp {
} icmp_dun; } icmp_dun;
}; };
struct icmp_filter {
uint32_t data;
};
#define icmp_pptr icmp_hun.ih_pptr #define icmp_pptr icmp_hun.ih_pptr
#define icmp_gwaddr icmp_hun.ih_gwaddr #define icmp_gwaddr icmp_hun.ih_gwaddr
#define icmp_id icmp_hun.ih_idseq.icd_id #define icmp_id icmp_hun.ih_idseq.icd_id
......
...@@ -54,13 +54,6 @@ ...@@ -54,13 +54,6 @@
#define TCP_LISTEN 10 #define TCP_LISTEN 10
#define TCP_CLOSING 11 #define TCP_CLOSING 11
enum {
TCP_NO_QUEUE,
TCP_RECV_QUEUE,
TCP_SEND_QUEUE,
TCP_QUEUES_NR,
};
enum { enum {
TCP_NLA_PAD, TCP_NLA_PAD,
TCP_NLA_BUSY, TCP_NLA_BUSY,
......
#ifndef _SYS_POLL_H #ifndef _POLL_H
#define _SYS_POLL_H #define _POLL_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -94,34 +94,34 @@ typedef struct sigaltstack stack_t; ...@@ -94,34 +94,34 @@ typedef struct sigaltstack stack_t;
#define CLD_CONTINUED 6 #define CLD_CONTINUED 6
union sigval { union sigval {
int sival_int; int sival_int;
void *sival_ptr; void *sival_ptr;
}; };
typedef struct { typedef struct {
int si_signo, si_errno, si_code; int si_signo, si_errno, si_code;
union { union {
char __pad[128 - 2*sizeof(int) - sizeof(long)]; char __pad[128 - 2*sizeof(int) - sizeof(long)];
struct { struct {
union { union {
struct { struct {
pid_t si_pid; pid_t si_pid;
uid_t si_uid; uid_t si_uid;
} __piduid; } __piduid;
struct { struct {
int si_timerid; int si_timerid;
int si_overrun; int si_overrun;
} __timer; } __timer;
} __first; } __first;
union { union {
union sigval si_value; union sigval si_value;
struct { struct {
int si_status; int si_status;
clock_t si_utime, si_stime; clock_t si_utime, si_stime;
} __sigchld; } __sigchld;
} __second; } __second;
} __si_common; } __si_common;
} __si_fields; } __si_fields;
} siginfo_t; } siginfo_t;
#define si_pid __si_fields.__si_common.__first.__piduid.si_pid #define si_pid __si_fields.__si_common.__first.__piduid.si_pid
#define si_uid __si_fields.__si_common.__first.__piduid.si_uid #define si_uid __si_fields.__si_common.__first.__piduid.si_uid
...@@ -133,22 +133,22 @@ typedef struct { ...@@ -133,22 +133,22 @@ typedef struct {
#define si_overrun __si_fields.__si_common.__first.__timer.si_overrun #define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
struct sigaction { struct sigaction {
union { union {
void (*sa_handler)(int); void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *); void (*sa_sigaction)(int, siginfo_t *, void *);
} sa_sigactionhandler; } sa_sigactionhandler;
sigset_t sa_mask; sigset_t sa_mask;
int sa_flags; int sa_flags;
void (*sa_restorer)(void); void (*sa_restorer)(void);
}; };
#define sa_handler sa_sigactionhandler.sa_handler #define sa_handler sa_sigactionhandler.sa_handler
#define sa_sigaction sa_sigactionhandler.sa_sigaction #define sa_sigaction sa_sigactionhandler.sa_sigaction
struct sigevent { struct sigevent {
union sigval sigev_value; union sigval sigev_value;
int sigev_signo; int sigev_signo;
int sigev_notify; int sigev_notify;
void (*sigev_notify_function)(union sigval); void (*sigev_notify_function)(union sigval);
void *sigev_notify_attributes; void *sigev_notify_attributes;
}; };
......
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
/* this whole header only works in C11 or with compiler extensions */ /* this whole header only works in C11 or with compiler extensions */
#if __STDC_VERSION__ < 201112L && defined( __GNUC__) #if __STDC_VERSION__ < 201112L && defined( __GNUC__)
#undef _Alignas
#define _Alignas(t) __attribute__((__aligned__(t))) #define _Alignas(t) __attribute__((__aligned__(t)))
#undef _Alignof
#define _Alignof(t) __alignof__(t) #define _Alignof(t) __alignof__(t)
#endif #endif
......
...@@ -12,7 +12,6 @@ extern "C" { ...@@ -12,7 +12,6 @@ extern "C" {
#define __NEED_size_t #define __NEED_size_t
#if __STDC_VERSION__ < 201112L #if __STDC_VERSION__ < 201112L
#define __NEED_off_t
#define __NEED_struct__IO_FILE #define __NEED_struct__IO_FILE
#endif #endif
......
...@@ -98,8 +98,6 @@ char *basename(const char *); ...@@ -98,8 +98,6 @@ char *basename(const char *);
#endif #endif
#endif #endif
#include "../src/include/string.h"
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -146,8 +146,6 @@ int shm_unlink (const char *); ...@@ -146,8 +146,6 @@ int shm_unlink (const char *);
#define mmap64 mmap #define mmap64 mmap
#endif #endif
#include "../src/include/sys/mman.h"
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -5,6 +5,14 @@ extern "C" { ...@@ -5,6 +5,14 @@ extern "C" {
#endif #endif
#define RB_AUTOBOOT 0x01234567 #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 #ifdef __cplusplus
} }
......
...@@ -20,7 +20,7 @@ extern "C" { ...@@ -20,7 +20,7 @@ extern "C" {
/* FD_SETSIZE is defined in "vfs_config.h" */ /* FD_SETSIZE is defined in "vfs_config.h" */
#else #else
#define FD_SETSIZE 512 #define FD_SETSIZE 1024
#define FD_SET_TOTAL_SIZE FD_SETSIZE #define FD_SET_TOTAL_SIZE FD_SETSIZE
#endif #endif
......
...@@ -6,11 +6,6 @@ extern "C" { ...@@ -6,11 +6,6 @@ extern "C" {
#include <features.h> #include <features.h>
#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_dev_t
#define __NEED_ino_t #define __NEED_ino_t
#define __NEED_mode_t #define __NEED_mode_t
...@@ -19,7 +14,6 @@ extern "C" { ...@@ -19,7 +14,6 @@ extern "C" {
#define __NEED_gid_t #define __NEED_gid_t
#define __NEED_off_t #define __NEED_off_t
#define __NEED_time_t #define __NEED_time_t
#define __NEED_suseconds_t
#define __NEED_blksize_t #define __NEED_blksize_t
#define __NEED_blkcnt_t #define __NEED_blkcnt_t
#define __NEED_struct_timespec #define __NEED_struct_timespec
...@@ -106,13 +100,13 @@ int lchmod(const char *, mode_t); ...@@ -106,13 +100,13 @@ int lchmod(const char *, mode_t);
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
#define stat64 stat #define stat64 stat
int fstat64(int, struct stat64 *);
#define lstat64 lstat #define lstat64 lstat
#define fstatat64 fstatat #define fstatat64 fstatat
#define blkcnt64_t blkcnt_t #define blkcnt64_t blkcnt_t
#define fsblkcnt64_t fsblkcnt_t #define fsblkcnt64_t fsblkcnt_t
#define fsfilcnt64_t fsfilcnt_t #define fsfilcnt64_t fsfilcnt_t
#define ino64_t ino_t #define ino64_t ino_t
int fstat64(int, struct stat64 *);
#endif #endif
#if _REDIR_TIME64 #if _REDIR_TIME64
......
...@@ -172,8 +172,6 @@ __REDIR(timegm, __timegm_time64); ...@@ -172,8 +172,6 @@ __REDIR(timegm, __timegm_time64);
#endif #endif
#endif #endif
#include "../src/include/time.h"
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -73,30 +73,6 @@ int ftruncate(int, off_t); ...@@ -73,30 +73,6 @@ int ftruncate(int, off_t);
int access(const char *, int); int access(const char *, int);
int faccessat(int, const char *, int, 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 chdir(const char *);
int fchdir(int); int fchdir(int);
char *getcwd(char *, size_t); char *getcwd(char *, size_t);
...@@ -216,12 +192,14 @@ ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); ...@@ -216,12 +192,14 @@ ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
#endif #endif
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
#define lockf64 lockf
off64_t lseek64(int, off64_t, int); off64_t lseek64(int, off64_t, int);
ssize_t pread64(int, void *, size_t, off64_t); ssize_t pread64(int, void *, size_t, off64_t);
ssize_t pwrite64(int, const void *, size_t, off64_t); ssize_t pwrite64(int, const void *, size_t, off64_t);
int truncate64(const char *, off64_t); int truncate64(const char *, off64_t);
int ftruncate64(int, 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 #endif
#define POSIX_CLOSE_RESTART 0 #define POSIX_CLOSE_RESTART 0
......
...@@ -15,7 +15,6 @@ extern "C" { ...@@ -15,7 +15,6 @@ extern "C" {
#define __NEED_mbstate_t #define __NEED_mbstate_t
#if __STDC_VERSION__ < 201112L #if __STDC_VERSION__ < 201112L
#define __NEED_off_t
#define __NEED_struct__IO_FILE #define __NEED_struct__IO_FILE
#endif #endif
......
...@@ -39,12 +39,8 @@ MUSL_SRC_COMMON = [ ...@@ -39,12 +39,8 @@ MUSL_SRC_COMMON = [
"$MUSLPORTINGDIR/src/ctype/isxdigit.c", "$MUSLPORTINGDIR/src/ctype/isxdigit.c",
"$MUSLPORTINGDIR/src/ctype/tolower.c", "$MUSLPORTINGDIR/src/ctype/tolower.c",
"$MUSLPORTINGDIR/src/ctype/toupper.c", "$MUSLPORTINGDIR/src/ctype/toupper.c",
"$MUSLPORTINGDIR/src/env/getenv.c",
"$MUSLPORTINGDIR/src/errno/errno.c",
"$MUSLPORTINGDIR/src/errno/strerror.c", "$MUSLPORTINGDIR/src/errno/strerror.c",
"$MUSLPORTINGDIR/src/exit/abort.c",
"$MUSLPORTINGDIR/src/exit/assert.c", "$MUSLPORTINGDIR/src/exit/assert.c",
"$MUSLPORTINGDIR/src/exit/exit.c",
"$MUSLPORTINGDIR/src/fenv/fenv.c", "$MUSLPORTINGDIR/src/fenv/fenv.c",
"$MUSLPORTINGDIR/src/internal/floatscan.c", "$MUSLPORTINGDIR/src/internal/floatscan.c",
"$MUSLPORTINGDIR/src/internal/intscan.c", "$MUSLPORTINGDIR/src/internal/intscan.c",
...@@ -55,7 +51,6 @@ MUSL_SRC_COMMON = [ ...@@ -55,7 +51,6 @@ MUSL_SRC_COMMON = [
"$MUSLPORTINGDIR/src/locale/c_locale.c", "$MUSLPORTINGDIR/src/locale/c_locale.c",
"$MUSLPORTINGDIR/src/locale/langinfo.c", "$MUSLPORTINGDIR/src/locale/langinfo.c",
"$MUSLPORTINGDIR/src/locale/locale_map.c", "$MUSLPORTINGDIR/src/locale/locale_map.c",
"$MUSLPORTINGDIR/src/malloc/malloc.c",
"$MUSLPORTINGDIR/src/math/__cos.c", "$MUSLPORTINGDIR/src/math/__cos.c",
"$MUSLPORTINGDIR/src/math/__cosdf.c", "$MUSLPORTINGDIR/src/math/__cosdf.c",
"$MUSLPORTINGDIR/src/math/__cosl.c", "$MUSLPORTINGDIR/src/math/__cosl.c",
...@@ -294,9 +289,7 @@ MUSL_SRC_COMMON = [ ...@@ -294,9 +289,7 @@ MUSL_SRC_COMMON = [
"$MUSLPORTINGDIR/src/network/htons.c", "$MUSLPORTINGDIR/src/network/htons.c",
"$MUSLPORTINGDIR/src/network/ntohl.c", "$MUSLPORTINGDIR/src/network/ntohl.c",
"$MUSLPORTINGDIR/src/network/ntohs.c", "$MUSLPORTINGDIR/src/network/ntohs.c",
"$MUSLPORTINGDIR/src/prng/rand.c",
"$MUSLPORTINGDIR/src/prng/random.c", "$MUSLPORTINGDIR/src/prng/random.c",
"$MUSLPORTINGDIR/src/sched/sched_yield.c",
"$MUSLPORTINGDIR/src/stdio/__fdopen.c", "$MUSLPORTINGDIR/src/stdio/__fdopen.c",
"$MUSLPORTINGDIR/src/stdio/__fmodeflags.c", "$MUSLPORTINGDIR/src/stdio/__fmodeflags.c",
"$MUSLPORTINGDIR/src/stdio/__lockfile.c", "$MUSLPORTINGDIR/src/stdio/__lockfile.c",
...@@ -390,7 +383,6 @@ MUSL_SRC_COMMON = [ ...@@ -390,7 +383,6 @@ MUSL_SRC_COMMON = [
"$MUSLPORTINGDIR/src/time/mktime.c", "$MUSLPORTINGDIR/src/time/mktime.c",
"$MUSLPORTINGDIR/src/time/strftime.c", "$MUSLPORTINGDIR/src/time/strftime.c",
"$MUSLPORTINGDIR/src/time/strptime.c", "$MUSLPORTINGDIR/src/time/strptime.c",
"$MUSLPORTINGDIR/src/time/time.c",
] ]
MUSL_SRC_ARM = [ MUSL_SRC_ARM = [
......
/*
* 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);
}
...@@ -103,5 +103,3 @@ E(EMEDIUMTYPE, "Wrong medium type") ...@@ -103,5 +103,3 @@ E(EMEDIUMTYPE, "Wrong medium type")
E(EMULTIHOP, "Multihop attempted") E(EMULTIHOP, "Multihop attempted")
E(0, "No error information") E(0, "No error information")
E(ENOSUPP, "Operation not supported")
/*
* 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);
}
}
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
#include <string.h> #include <string.h>
#include "locale_impl.h" #include "locale_impl.h"
#ifdef __cplusplus
extern "C" {
#endif
#define E(a,b) ((unsigned char)a), #define E(a,b) ((unsigned char)a),
static const unsigned char errid[] = { static const unsigned char errid[] = {
#include "__strerror.h" #include "__strerror.h"
...@@ -33,7 +29,3 @@ char *strerror(int e) ...@@ -33,7 +29,3 @@ char *strerror(int e)
} }
weak_alias(__strerror_l, strerror_l); weak_alias(__strerror_l, strerror_l);
#ifdef __cplusplus
}
#endif
/*
* 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
/*
* 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 "assert.h"
#include "los_hwi.h"
#include "los_printf.h" #include "los_printf.h"
#include "los_exc.h" #include "los_exc.h"
#ifdef __cplusplus _Noreturn void __assert_fail(const char *expr, const char *file, int line, const char *func)
extern "C" { {
#endif /* __cplusplus */ PRINT_ERR("%s:%d: %s: assertion \"%s\" failed", file, line, func, expr);
LOS_Panic("__assert error:\n");
void __assert(const char* file, int line, const char* expr) { while (1);
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
} }
#endif /* __cplusplus */
\ No newline at end of file
/*
* 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_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);
}
...@@ -4,12 +4,7 @@ ...@@ -4,12 +4,7 @@
#include "../../include/features.h" #include "../../include/features.h"
#define hidden __attribute__((__visibility__("hidden"))) #define hidden __attribute__((__visibility__("hidden")))
#ifndef weak_alias
#define weak_alias(old, new) \ #define weak_alias(old, new) \
extern __typeof(old) new __attribute__((__weak__, __alias__(#old))) 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
#endif #endif
...@@ -185,7 +185,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po ...@@ -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; x[k] = x[k]/p10 + carry;
carry = 1000000000/p10 * tmp; carry = 1000000000/p10 * tmp;
if (k==a && !x[k]) { if (k==a && !x[k]) {
a = ((a+1) & MASK); a = (a+1 & MASK);
rp -= 9; rp -= 9;
} }
} }
...@@ -197,7 +197,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po ...@@ -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]<th[0])) { while (rp < 9*LD_B1B_DIG || (rp == 9*LD_B1B_DIG && x[a]<th[0])) {
uint32_t carry = 0; uint32_t carry = 0;
e2 -= 29; e2 -= 29;
for (k=((z-1) & MASK); ; k=((k-1) & MASK)) { for (k=(z-1 & MASK); ; k=(k-1 & MASK)) {
uint64_t tmp = ((uint64_t)x[k] << 29) + carry; uint64_t tmp = ((uint64_t)x[k] << 29) + carry;
if (tmp > 1000000000) { if (tmp > 1000000000) {
carry = tmp / 1000000000; carry = tmp / 1000000000;
...@@ -206,15 +206,15 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po ...@@ -206,15 +206,15 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
carry = 0; carry = 0;
x[k] = tmp; 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 (k==a) break;
} }
if (carry) { if (carry) {
rp += 9; rp += 9;
a = ((a-1) & MASK); a = (a-1 & MASK);
if (a == z) { if (a == z) {
z = ((z-1) & MASK); z = (z-1 & MASK);
x[(z-1) & MASK] |= x[z]; x[z-1 & MASK] |= x[z];
} }
x[a] = carry; x[a] = carry;
} }
...@@ -225,39 +225,39 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po ...@@ -225,39 +225,39 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
uint32_t carry = 0; uint32_t carry = 0;
int sh = 1; int sh = 1;
for (i=0; i<LD_B1B_DIG; i++) { for (i=0; i<LD_B1B_DIG; i++) {
k = ((a+i) & MASK); k = (a+i & MASK);
if (k == z || x[k] < th[i]) { if (k == z || x[k] < th[i]) {
i=LD_B1B_DIG; i=LD_B1B_DIG;
break; break;
} }
if (x[(a+i) & MASK] > th[i]) break; if (x[a+i & MASK] > th[i]) break;
} }
if (i==LD_B1B_DIG && rp==9*LD_B1B_DIG) break; if (i==LD_B1B_DIG && rp==9*LD_B1B_DIG) break;
/* FIXME: find a way to compute optimal sh */ /* FIXME: find a way to compute optimal sh */
if (rp > 9+9*LD_B1B_DIG) sh = 9; if (rp > 9+9*LD_B1B_DIG) sh = 9;
e2 += sh; e2 += sh;
for (k=a; k!=z; k=((k+1) & MASK)) { for (k=a; k!=z; k=(k+1 & MASK)) {
uint32_t tmp = x[k] & ((1<<sh)-1); uint32_t tmp = x[k] & (1<<sh)-1;
x[k] = (x[k]>>sh) + carry; x[k] = (x[k]>>sh) + carry;
carry = (1000000000>>sh) * tmp; carry = (1000000000>>sh) * tmp;
if (k==a && !x[k]) { if (k==a && !x[k]) {
a = ((a+1) & MASK); a = (a+1 & MASK);
i--; i--;
rp -= 9; rp -= 9;
} }
} }
if (carry) { if (carry) {
if (((z+1) & MASK) != a) { if ((z+1 & MASK) != a) {
x[z] = carry; x[z] = carry;
z = ((z+1) & MASK); z = (z+1 & MASK);
} else x[(z-1) & MASK] |= 1; } else x[z-1 & MASK] |= 1;
} }
} }
/* Assemble desired bits into floating point variable */ /* Assemble desired bits into floating point variable */
for (y=i=0; i<LD_B1B_DIG; i++) { for (y=i=0; i<LD_B1B_DIG; i++) {
if (((a+i) & MASK)==z) x[(z=((z+1) & MASK))-1] = 0; if ((a+i & MASK)==z) x[(z=(z+1 & MASK))-1] = 0;
y = 1000000000.0L * y + x[(a+i) & MASK]; y = 1000000000.0L * y + x[a+i & MASK];
} }
y *= sign; y *= sign;
...@@ -278,14 +278,14 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po ...@@ -278,14 +278,14 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
} }
/* Process tail of decimal input so it can affect rounding */ /* Process tail of decimal input so it can affect rounding */
if (((a+i) & MASK) != z) { if ((a+i & MASK) != z) {
uint32_t t = x[(a+i) & MASK]; uint32_t t = x[a+i & MASK];
if (t < 500000000 && (t || ((a+i+1) & MASK) != z)) if (t < 500000000 && (t || (a+i+1 & MASK) != z))
frac += 0.25*sign; frac += 0.25*sign;
else if (t > 500000000) else if (t > 500000000)
frac += 0.75*sign; frac += 0.75*sign;
else if (t == 500000000) { else if (t == 500000000) {
if (((a+i+1) & MASK) == z) if ((a+i+1 & MASK) == z)
frac += 0.5*sign; frac += 0.5*sign;
else else
frac += 0.75*sign; frac += 0.75*sign;
...@@ -297,7 +297,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po ...@@ -297,7 +297,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
y += frac; y += frac;
y -= bias; 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 (fabsl(y) >= 2/LDBL_EPSILON) {
if (denormal && bits==LDBL_MANT_DIG+e2-emin) if (denormal && bits==LDBL_MANT_DIG+e2-emin)
denormal = 0; denormal = 0;
......
...@@ -67,7 +67,7 @@ unsigned long long __intscan(FILE *f, unsigned base, int pok, unsigned long long ...@@ -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)) for (y=x; c-'0'<10U && y<=ULLONG_MAX/10 && 10*y<=ULLONG_MAX-(c-'0'); c=shgetc(f))
y = y*10 + (c-'0'); y = y*10 + (c-'0');
if (c-'0'>=10U) goto done; 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]; int bs = "\0\1\2\4\7\3\6\5"[(0x17*base)>>5&7];
for (x=0; val[c]<base && x<=UINT_MAX/32; c=shgetc(f)) for (x=0; val[c]<base && x<=UINT_MAX/32; c=shgetc(f))
x = x<<bs | val[c]; x = x<<bs | val[c];
......
...@@ -20,7 +20,7 @@ int __shgetc(FILE *f) ...@@ -20,7 +20,7 @@ int __shgetc(FILE *f)
{ {
int c; int c;
off_t cnt = shcnt(f); off_t cnt = shcnt(f);
if (((f->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->shcnt = f->buf - f->rpos + cnt;
f->shend = f->rpos; f->shend = f->rpos;
f->shlim = -1; f->shlim = -1;
......
...@@ -16,6 +16,32 @@ ...@@ -16,6 +16,32 @@
#define F_SVB 64 #define F_SVB 64
#define F_APP 128 #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 __stdin_used;
extern hidden FILE *volatile __stdout_used; extern hidden FILE *volatile __stdout_used;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
static inline uint32_t swapc(uint32_t x, int c) 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) const char *__mo_lookup(const void *p, size_t size, const char *s)
......
/*
* 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
...@@ -69,7 +69,7 @@ double acos(double x) ...@@ -69,7 +69,7 @@ double acos(double x)
uint32_t lx; uint32_t lx;
GET_LOW_WORD(lx,x); GET_LOW_WORD(lx,x);
if (((ix-0x3ff00000) | lx) == 0) { if ((ix-0x3ff00000 | lx) == 0) {
/* acos(1)=0, acos(-1)=pi */ /* acos(1)=0, acos(-1)=pi */
if (hx >> 31) if (hx >> 31)
return 2*pio2_hi + 0x1p-120f; return 2*pio2_hi + 0x1p-120f;
......
...@@ -75,7 +75,7 @@ double asin(double x) ...@@ -75,7 +75,7 @@ double asin(double x)
if (ix >= 0x3ff00000) { if (ix >= 0x3ff00000) {
uint32_t lx; uint32_t lx;
GET_LOW_WORD(lx, x); GET_LOW_WORD(lx, x);
if (((ix-0x3ff00000) | lx) == 0) if ((ix-0x3ff00000 | lx) == 0)
/* asin(1) = +-pi/2 with inexact */ /* asin(1) = +-pi/2 with inexact */
return x*pio2_hi + 0x1p-120f; return x*pio2_hi + 0x1p-120f;
return 0/(x-x); return 0/(x-x);
......
...@@ -52,7 +52,7 @@ double atan2(double y, double x) ...@@ -52,7 +52,7 @@ double atan2(double y, double x)
return x+y; return x+y;
EXTRACT_WORDS(ix, lx, x); EXTRACT_WORDS(ix, lx, x);
EXTRACT_WORDS(iy, ly, y); EXTRACT_WORDS(iy, ly, y);
if (((ix-0x3ff00000) | lx) == 0) /* x = 1.0 */ if ((ix-0x3ff00000 | lx) == 0) /* x = 1.0 */
return atan(y); return atan(y);
m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */ m = ((iy>>31)&1) | ((ix>>30)&2); /* 2*sign(x)+sign(y) */
ix = ix & 0x7fffffff; ix = ix & 0x7fffffff;
......
...@@ -69,7 +69,7 @@ double fma(double x, double y, double z) ...@@ -69,7 +69,7 @@ double fma(double x, double y, double z)
if (d > 0) { if (d > 0) {
if (d < 64) { if (d < 64) {
zlo = nz.m<<d; zlo = nz.m<<d;
zhi = nz.m>>(64-d); zhi = nz.m>>64-d;
} else { } else {
zlo = 0; zlo = 0;
zhi = nz.m; zhi = nz.m;
...@@ -77,7 +77,7 @@ double fma(double x, double y, double z) ...@@ -77,7 +77,7 @@ double fma(double x, double y, double z)
d -= 64; d -= 64;
if (d == 0) { if (d == 0) {
} else if (d < 64) { } 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; rhi = rhi>>d;
} else { } else {
rlo = 1; rlo = 1;
...@@ -90,7 +90,7 @@ double fma(double x, double y, double z) ...@@ -90,7 +90,7 @@ double fma(double x, double y, double z)
if (d == 0) { if (d == 0) {
zlo = nz.m; zlo = nz.m;
} else if (d < 64) { } else if (d < 64) {
zlo = nz.m>>d | !!(nz.m<<(64-d)); zlo = nz.m>>d | !!(nz.m<<64-d);
} else { } else {
zlo = 1; zlo = 1;
} }
...@@ -122,7 +122,7 @@ double fma(double x, double y, double z) ...@@ -122,7 +122,7 @@ double fma(double x, double y, double z)
e += 64; e += 64;
d = a_clz_64(rhi)-1; d = a_clz_64(rhi)-1;
/* note: d > 0 */ /* note: d > 0 */
rhi = rhi<<d | rlo>>(64-d) | !!(rlo<<d); rhi = rhi<<d | rlo>>64-d | !!(rlo<<d);
} else if (rlo) { } else if (rlo) {
d = a_clz_64(rlo)-1; d = a_clz_64(rlo)-1;
if (d < 0) if (d < 0)
...@@ -173,7 +173,7 @@ double fma(double x, double y, double z) ...@@ -173,7 +173,7 @@ double fma(double x, double y, double z)
} else { } else {
/* only round once when scaled */ /* only round once when scaled */
d = 10; d = 10;
i = ( rhi>>d | !!(rhi<<(64-d)) ) << d; i = ( rhi>>d | !!(rhi<<64-d) ) << d;
if (sign) if (sign)
i = -i; i = -i;
r = i; r = i;
......
...@@ -105,8 +105,7 @@ static float sin_pi(float x) ...@@ -105,8 +105,7 @@ static float sin_pi(float x)
float __lgammaf_r(float x, int *signgamp) float __lgammaf_r(float x, int *signgamp)
{ {
union {float f; uint32_t i;} u = {x}; union {float f; uint32_t i;} u = {x};
float nadj = 0; float t,y,z,nadj,p,p1,p2,p3,q,r,w;
float t,y,z,p,p1,p2,p3,q,r,w;
uint32_t ix; uint32_t ix;
int i,sign; int i,sign;
......
...@@ -24,21 +24,21 @@ int mbtowc(wchar_t *restrict wc, const char *restrict src, size_t n) ...@@ -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 (n<4 && ((c<<(6*n-6)) & (1U<<31))) goto ilseq;
if (OOB(c,*s)) goto ilseq; if (OOB(c,*s)) goto ilseq;
c = (c<<6) | (*s++-0x80); c = c<<6 | *s++-0x80;
if (!(c&(1U<<31))) { if (!(c&(1U<<31))) {
*wc = c; *wc = c;
return 2; return 2;
} }
if (*s-0x80u >= 0x40) goto ilseq; if (*s-0x80u >= 0x40) goto ilseq;
c = (c<<6) | (*s++-0x80); c = c<<6 | *s++-0x80;
if (!(c&(1U<<31))) { if (!(c&(1U<<31))) {
*wc = c; *wc = c;
return 3; return 3;
} }
if (*s-0x80u >= 0x40) goto ilseq; if (*s-0x80u >= 0x40) goto ilseq;
*wc = (c<<6) | (*s++-0x80); *wc = c<<6 | *s++-0x80;
return 4; return 4;
ilseq: ilseq:
......
/*
* 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 <stdint.h>
void srand(unsigned s)
{
return srandom(s);
}
int rand(void)
{
return random();
}
/*
* 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 <sched.h>
#include "los_process.h"
int sched_yield()
{
(void)LOS_TaskYield();
return 0;
}
#include "stdio_impl.h" #include "stdio_impl.h"
#include <unistd.h> #include <unistd.h>
#ifndef LOSCFG_FS_VFS
#define close(...) (-1)
#endif
int __stdio_close(FILE *f) int __stdio_close(FILE *f)
{ {
......
#include "stdio_impl.h" #include "stdio_impl.h"
#include <unistd.h> #include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#ifdef LOSCFG_FS_VFS
#include <fs/fs.h>
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 __stdio_seek(FILE *f, off_t off, int whence)
{ {
off_t result = 0; off_t result = 0;
return __stdio_lseek64(f->fd, off>>32, off, &result, whence) ? -1 : result; return _lseek64(f->fd, off>>32, off, &result, whence) ? -1 : result;
}
#else
off_t __stdio_seek(FILE *f, off_t off, int whence)
{
return 0;
} }
#endif
#include "stdio_impl.h" #include "stdio_impl.h"
#include <sys/uio.h> #include <sys/uio.h>
#ifndef LOSCFG_FS_VFS
#define writev(...) (-1)
#endif
size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
{ {
struct iovec iovs[2] = { struct iovec iovs[2] = {
......
#include "stdio_impl.h" #include "stdio_impl.h"
#include <sys/ioctl.h> #include <sys/ioctl.h>
#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) size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len)
{ {
struct winsize wsz; struct winsize wsz;
if (!(f->flags & F_SVB) && ioctl(f->fd, TIOCGWINSZ, &wsz)) { f->write = __stdio_write;
f->lbf = EOF; if (!(f->flags & F_SVB) && ioctl(f->fd, TIOCGWINSZ, &wsz))
} f->lbf = EOF;
return __stdio_write(f, buf, len); return __stdio_write(f, buf, len);
} }
...@@ -11,4 +11,9 @@ int __toread(FILE *f) ...@@ -11,4 +11,9 @@ int __toread(FILE *f)
} }
f->rpos = f->rend = f->buf + f->buf_size; f->rpos = f->rend = f->buf + f->buf_size;
return (f->flags & F_EOF) ? EOF : 0; return (f->flags & F_EOF) ? EOF : 0;
} }
\ No newline at end of file
hidden void __toread_needs_stdio_exit()
{
__stdio_exit_needed();
}
...@@ -16,3 +16,8 @@ int __towrite(FILE *f) ...@@ -16,3 +16,8 @@ int __towrite(FILE *f)
return 0; return 0;
} }
hidden void __towrite_needs_stdio_exit()
{
__stdio_exit_needed();
}
#include "stdio_impl.h" #include "stdio_impl.h"
#include <stdlib.h> #include <stdlib.h>
#ifdef LOSCFG_LLTSER
#include "gcov_ser.h"
#endif
static void dummy(FILE *f) { } static void dummy(FILE *f) { }
weak_alias(dummy, __unlist_locked_file); weak_alias(dummy, __unlist_locked_file);
int fclose(FILE *f) int fclose(FILE *f)
{ {
#ifdef LOSCFG_LLTSER
GCOV_FCLOSE(fp);
#endif
int r; int r;
FLOCK(f); FLOCK(f);
......
...@@ -4,15 +4,9 @@ ...@@ -4,15 +4,9 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#ifdef LOSCFG_LLTSER
#include "gcov_ser.h"
#endif
FILE *fopen(const char *restrict filename, const char *restrict mode) FILE *fopen(const char *restrict filename, const char *restrict mode)
{ {
#ifdef LOSCFG_LLTSER
GCOV_FOPEN(filename);
#endif
FILE *f; FILE *f;
int fd; int fd;
int flags; int flags;
......
#include "stdio_impl.h" #include "stdio_impl.h"
#include <string.h> #include <string.h>
#ifdef LOSCFG_LLTSER
#include "gcov_ser.h"
#endif
#define MIN(a,b) ((a)<(b) ? (a) : (b)) #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) ...@@ -13,9 +10,7 @@ size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f)
if (!size) nmemb = 0; if (!size) nmemb = 0;
FLOCK(f); FLOCK(f);
#ifdef LOSCFG_LLTSER
GCOV_FREAD(f, destv, size, nmemb);
#endif
f->mode |= f->mode-1; f->mode |= f->mode-1;
if (f->rpos != f->rend) { if (f->rpos != f->rend) {
......
#include "stdio_impl.h" #include "stdio_impl.h"
#include <string.h> #include <string.h>
#ifdef LOSCFG_LLTSER
#include "gcov_ser.h"
#endif
size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) 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) ...@@ -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) 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; size_t k, l = size*nmemb;
if (!size) nmemb = 0; if (!size) nmemb = 0;
FLOCK(f); FLOCK(f);
......
...@@ -16,5 +16,5 @@ int ungetc(int c, FILE *f) ...@@ -16,5 +16,5 @@ int ungetc(int c, FILE *f)
f->flags &= ~F_EOF; f->flags &= ~F_EOF;
FUNLOCK(f); FUNLOCK(f);
return c; return (unsigned char)c;
} }
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
/* Convenient bit representation for modifier flags, which all fall /* Convenient bit representation for modifier flags, which all fall
* within 31 codepoints of the space character. */ * within 31 codepoints of the space character. */
#define ALT_FORM (1U<<('#'-' ')) #define ALT_FORM (1U<<'#'-' ')
#define ZERO_PAD (1U<<('0'-' ')) #define ZERO_PAD (1U<<'0'-' ')
#define LEFT_ADJ (1U<<('-'-' ')) #define LEFT_ADJ (1U<<'-'-' ')
#define PAD_POS (1U<<(' '-' ')) #define PAD_POS (1U<<' '-' ')
#define MARK_POS (1U<<('+'-' ')) #define MARK_POS (1U<<'+'-' ')
#define GROUPED (1U<<('\''-' ')) #define GROUPED (1U<<'\''-' ')
#define FLAGMASK (ALT_FORM|ZERO_PAD|LEFT_ADJ|PAD_POS|MARK_POS|GROUPED) #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) ...@@ -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; char buf[9+LDBL_MANT_DIG/4], *s;
const char *prefix="-0X+0X 0X-0x+0x 0x"; const char *prefix="-0X+0X 0X-0x+0x 0x";
int pl; int pl;
char ebuf0[3*sizeof(int)], *ebuf=&ebuf0[3*sizeof(int)]; char ebuf0[3*sizeof(int)], *ebuf=&ebuf0[3*sizeof(int)], *estr;
char *estr = NULL;
pl=1; pl=1;
if (signbit(y)) { if (signbit(y)) {
...@@ -297,7 +296,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) ...@@ -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; uint32_t carry=0, *b;
int sh=MIN(9,-e2), need=1+(p+LDBL_MANT_DIG/3U+8)/9; int sh=MIN(9,-e2), need=1+(p+LDBL_MANT_DIG/3U+8)/9;
for (d=a; d<z; d++) { for (d=a; d<z; d++) {
uint32_t rm = *d & ((1<<sh)-1); uint32_t rm = *d & (1<<sh)-1;
*d = (*d>>sh) + carry; *d = (*d>>sh) + carry;
carry = (1000000000>>sh) * rm; carry = (1000000000>>sh) * rm;
} }
...@@ -486,8 +485,8 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, ...@@ -486,8 +485,8 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
} }
/* Read modifier flags */ /* Read modifier flags */
for (fl=0; (unsigned)*s-' '<32 && (FLAGMASK&(1U<<(*s-' '))); s++) for (fl=0; (unsigned)*s-' '<32 && (FLAGMASK&(1U<<*s-' ')); s++)
fl |= 1U<<(*s-' '); fl |= 1U<<*s-' ';
/* Read field width */ /* Read field width */
if (*s=='*') { if (*s=='*') {
......
...@@ -53,4 +53,4 @@ weak_alias(strtoul, __strtoul_internal); ...@@ -53,4 +53,4 @@ weak_alias(strtoul, __strtoul_internal);
weak_alias(strtoll, __strtoll_internal); weak_alias(strtoll, __strtoll_internal);
weak_alias(strtoull, __strtoull_internal); weak_alias(strtoull, __strtoull_internal);
weak_alias(strtoimax, __strtoimax_internal); weak_alias(strtoimax, __strtoimax_internal);
weak_alias(strtoumax, __strtoumax_internal); weak_alias(strtoumax, __strtoumax_internal);
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define ALIGN (sizeof(size_t)-1) #define ALIGN (sizeof(size_t)-1)
#define ONES ((size_t)-1/UCHAR_MAX) #define ONES ((size_t)-1/UCHAR_MAX)
#define HIGHS (ONES * (UCHAR_MAX/2+1)) #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) void *memchr(const void *src, int c, size_t n)
{ {
...@@ -18,7 +18,7 @@ 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; typedef size_t __attribute__((__may_alias__)) word;
const word *w; const word *w;
size_t k = ONES * c; 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; s = (const void *)w;
} }
#endif #endif
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define ALIGN (sizeof(size_t)) #define ALIGN (sizeof(size_t))
#define ONES ((size_t)-1/UCHAR_MAX) #define ONES ((size_t)-1/UCHAR_MAX)
#define HIGHS (ONES * (UCHAR_MAX/2+1)) #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) char *__stpcpy(char *restrict d, const char *restrict s)
{ {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define ALIGN (sizeof(size_t)-1) #define ALIGN (sizeof(size_t)-1)
#define ONES ((size_t)-1/UCHAR_MAX) #define ONES ((size_t)-1/UCHAR_MAX)
#define HIGHS (ONES * (UCHAR_MAX/2+1)) #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) 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) ...@@ -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++); for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++);
if (!n || !*s) goto tail; if (!n || !*s) goto tail;
wd=(void *)d; ws=(const void *)s; 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; n-=sizeof(size_t), ws++, wd++) *wd = *ws;
d=(void *)wd; s=(const void *)ws; d=(void *)wd; s=(const void *)ws;
} }
...@@ -29,3 +29,4 @@ tail: ...@@ -29,3 +29,4 @@ tail:
} }
weak_alias(__stpncpy, stpncpy); weak_alias(__stpncpy, stpncpy);
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define ALIGN (sizeof(size_t)) #define ALIGN (sizeof(size_t))
#define ONES ((size_t)-1/UCHAR_MAX) #define ONES ((size_t)-1/UCHAR_MAX)
#define HIGHS (ONES * (UCHAR_MAX/2+1)) #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) char *__strchrnul(const char *s, int c)
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define ALIGN (sizeof(size_t)-1) #define ALIGN (sizeof(size_t)-1)
#define ONES ((size_t)-1/UCHAR_MAX) #define ONES ((size_t)-1/UCHAR_MAX)
#define HIGHS (ONES * (UCHAR_MAX/2+1)) #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) size_t strlcpy(char *d, const char *s, size_t n)
{ {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define ALIGN (sizeof(size_t)) #define ALIGN (sizeof(size_t))
#define ONES ((size_t)-1/UCHAR_MAX) #define ONES ((size_t)-1/UCHAR_MAX)
#define HIGHS (ONES * (UCHAR_MAX/2+1)) #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) size_t strlen(const char *s)
{ {
......
...@@ -219,7 +219,7 @@ weak_alias(__tzset, tzset); ...@@ -219,7 +219,7 @@ weak_alias(__tzset, tzset);
const char *__tm_to_tzname(const struct tm *tm) const char *__tm_to_tzname(const struct tm *tm)
{ {
const void *p = tm->tm_zone; const void *p = tm->__tm_zone;
LOCK(); LOCK();
do_tzset(); do_tzset();
if (p != __utc && p != __tzname[0] && p != __tzname[1] && if (p != __utc && p != __tzname[0] && p != __tzname[1] &&
......
...@@ -278,4 +278,4 @@ size_t strftime(char *restrict s, size_t n, const char *restrict f, const struct ...@@ -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); return __strftime_l(s, n, f, tm, CURRENT_LOCALE);
} }
weak_alias(__strftime_l, strftime_l); weak_alias(__strftime_l, strftime_l);
\ No newline at end of file
/*
* 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 <time.h>
#include <sys/time.h>
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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册