Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
0c64a71b
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0c64a71b
编写于
3月 17, 2022
作者:
W
weicheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update liteos_m porting
Signed-off-by:
weicheng
<
xu.wc@outlook.com
>
上级
5501bf88
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
474 addition
and
0 deletion
+474
-0
porting/liteos_m/kernel/musl.gni
porting/liteos_m/kernel/musl.gni
+7
-0
porting/liteos_m/kernel/src/multibyte/mbrtowc.c
porting/liteos_m/kernel/src/multibyte/mbrtowc.c
+51
-0
porting/liteos_m/kernel/src/multibyte/mbsinit.c
porting/liteos_m/kernel/src/multibyte/mbsinit.c
+6
-0
porting/liteos_m/kernel/src/stdio/__string_read.c
porting/liteos_m/kernel/src/stdio/__string_read.c
+16
-0
porting/liteos_m/kernel/src/stdio/sscanf.c
porting/liteos_m/kernel/src/stdio/sscanf.c
+14
-0
porting/liteos_m/kernel/src/stdio/vfscanf.c
porting/liteos_m/kernel/src/stdio/vfscanf.c
+336
-0
porting/liteos_m/kernel/src/stdio/vscanf.c
porting/liteos_m/kernel/src/stdio/vscanf.c
+9
-0
porting/liteos_m/kernel/src/stdio/vsscanf.c
porting/liteos_m/kernel/src/stdio/vsscanf.c
+17
-0
porting/liteos_m/kernel/src/stdlib/strtol.c
porting/liteos_m/kernel/src/stdlib/strtol.c
+6
-0
porting/liteos_m/kernel/src/string/strtok_r.c
porting/liteos_m/kernel/src/string/strtok_r.c
+12
-0
未找到文件。
porting/liteos_m/kernel/musl.gni
浏览文件 @
0c64a71b
...
...
@@ -57,6 +57,8 @@ MUSL_LIBC_SRC = [
"$MUSLPORTINGDIR/src/misc/dirname.c",
"$MUSLPORTINGDIR/src/misc/realpath.c",
"$MUSLPORTINGDIR/src/multibyte/internal.c",
"$MUSLPORTINGDIR/src/multibyte/mbrtowc.c",
"$MUSLPORTINGDIR/src/multibyte/mbsinit.c",
"$MUSLPORTINGDIR/src/multibyte/mbtowc.c",
"$MUSLPORTINGDIR/src/multibyte/wcrtomb.c",
"$MUSLPORTINGDIR/src/multibyte/wctomb.c",
...
...
@@ -79,6 +81,7 @@ MUSL_LIBC_SRC = [
"$MUSLPORTINGDIR/src/stdio/__stdio_seek.c",
"$MUSLPORTINGDIR/src/stdio/__stdio_write.c",
"$MUSLPORTINGDIR/src/stdio/__stdout_write.c",
"$MUSLPORTINGDIR/src/stdio/__string_read.c",
"$MUSLPORTINGDIR/src/stdio/__toread.c",
"$MUSLPORTINGDIR/src/stdio/__towrite.c",
"$MUSLPORTINGDIR/src/stdio/__uflow.c",
...
...
@@ -102,13 +105,16 @@ MUSL_LIBC_SRC = [
"$MUSLPORTINGDIR/src/stdio/remove.c",
"$MUSLPORTINGDIR/src/stdio/rewind.c",
"$MUSLPORTINGDIR/src/stdio/snprintf.c",
"$MUSLPORTINGDIR/src/stdio/sscanf.c",
"$MUSLPORTINGDIR/src/stdio/stderr.c",
"$MUSLPORTINGDIR/src/stdio/stdin.c",
"$MUSLPORTINGDIR/src/stdio/stdout.c",
"$MUSLPORTINGDIR/src/stdio/ungetc.c",
"$MUSLPORTINGDIR/src/stdio/vfprintf.c",
"$MUSLPORTINGDIR/src/stdio/vfscanf.c",
"$MUSLPORTINGDIR/src/stdio/vsnprintf.c",
"$MUSLPORTINGDIR/src/stdio/vsprintf.c",
"$MUSLPORTINGDIR/src/stdio/vsscanf.c",
"$MUSLPORTINGDIR/src/stdlib/abs.c",
"$MUSLPORTINGDIR/src/stdlib/atof.c",
"$MUSLPORTINGDIR/src/stdlib/atoi.c",
...
...
@@ -144,6 +150,7 @@ MUSL_LIBC_SRC = [
"$MUSLPORTINGDIR/src/string/strspn.c",
"$MUSLPORTINGDIR/src/string/strstr.c",
"$MUSLPORTINGDIR/src/string/strtok.c",
"$MUSLPORTINGDIR/src/string/strtok_r.c",
"$MUSLPORTINGDIR/src/string/wcschr.c",
"$MUSLPORTINGDIR/src/string/wcslen.c",
"$MUSLPORTINGDIR/src/time/__month_to_secs.c",
...
...
porting/liteos_m/kernel/src/multibyte/mbrtowc.c
0 → 100644
浏览文件 @
0c64a71b
#include <stdlib.h>
#include <wchar.h>
#include <errno.h>
#include "internal.h"
size_t
mbrtowc
(
wchar_t
*
restrict
wc
,
const
char
*
restrict
src
,
size_t
n
,
mbstate_t
*
restrict
st
)
{
static
unsigned
internal_state
;
unsigned
c
;
const
unsigned
char
*
s
=
(
const
void
*
)
src
;
const
unsigned
N
=
n
;
wchar_t
dummy
;
if
(
!
st
)
st
=
(
void
*
)
&
internal_state
;
c
=
*
(
unsigned
*
)
st
;
if
(
!
s
)
{
if
(
c
)
goto
ilseq
;
return
0
;
}
else
if
(
!
wc
)
wc
=
&
dummy
;
if
(
!
n
)
return
-
2
;
if
(
!
c
)
{
if
(
*
s
<
0x80
)
return
!!
(
*
wc
=
*
s
);
if
(
MB_CUR_MAX
==
1
)
return
(
*
wc
=
CODEUNIT
(
*
s
)),
1
;
if
(
*
s
-
SA
>
SB
-
SA
)
goto
ilseq
;
c
=
bittab
[
*
s
++-
SA
];
n
--
;
}
if
(
n
)
{
if
(
OOB
(
c
,
*
s
))
goto
ilseq
;
loop:
c
=
c
<<
6
|
*
s
++-
0x80
;
n
--
;
if
(
!
(
c
&
(
1U
<<
31
)))
{
*
(
unsigned
*
)
st
=
0
;
*
wc
=
c
;
return
N
-
n
;
}
if
(
n
)
{
if
(
*
s
-
0x80u
>=
0x40
)
goto
ilseq
;
goto
loop
;
}
}
*
(
unsigned
*
)
st
=
c
;
return
-
2
;
ilseq:
*
(
unsigned
*
)
st
=
0
;
errno
=
EILSEQ
;
return
-
1
;
}
porting/liteos_m/kernel/src/multibyte/mbsinit.c
0 → 100644
浏览文件 @
0c64a71b
#include <wchar.h>
int
mbsinit
(
const
mbstate_t
*
st
)
{
return
!
st
||
!*
(
unsigned
*
)
st
;
}
porting/liteos_m/kernel/src/stdio/__string_read.c
0 → 100644
浏览文件 @
0c64a71b
#include "stdio_impl.h"
#include <string.h>
size_t
__string_read
(
FILE
*
f
,
unsigned
char
*
buf
,
size_t
len
)
{
char
*
src
=
f
->
cookie
;
size_t
k
=
len
+
256
;
char
*
end
=
memchr
(
src
,
0
,
k
);
if
(
end
)
k
=
end
-
src
;
if
(
k
<
len
)
len
=
k
;
memcpy
(
buf
,
src
,
len
);
f
->
rpos
=
(
void
*
)(
src
+
len
);
f
->
rend
=
(
void
*
)(
src
+
k
);
f
->
cookie
=
src
+
k
;
return
len
;
}
porting/liteos_m/kernel/src/stdio/sscanf.c
0 → 100644
浏览文件 @
0c64a71b
#include <stdio.h>
#include <stdarg.h>
int
sscanf
(
const
char
*
restrict
s
,
const
char
*
restrict
fmt
,
...)
{
int
ret
;
va_list
ap
;
va_start
(
ap
,
fmt
);
ret
=
vsscanf
(
s
,
fmt
,
ap
);
va_end
(
ap
);
return
ret
;
}
weak_alias
(
sscanf
,
__isoc99_sscanf
);
porting/liteos_m/kernel/src/stdio/vfscanf.c
0 → 100644
浏览文件 @
0c64a71b
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <wchar.h>
#include <wctype.h>
#include <limits.h>
#include <string.h>
#include <stdint.h>
#include "stdio_impl.h"
#include "shgetc.h"
#include "intscan.h"
#include "floatscan.h"
#define SIZE_hh -2
#define SIZE_h -1
#define SIZE_def 0
#define SIZE_l 1
#define SIZE_L 2
#define SIZE_ll 3
static
void
store_int
(
void
*
dest
,
int
size
,
unsigned
long
long
i
)
{
if
(
!
dest
)
return
;
switch
(
size
)
{
case
SIZE_hh
:
*
(
char
*
)
dest
=
i
;
break
;
case
SIZE_h
:
*
(
short
*
)
dest
=
i
;
break
;
case
SIZE_def
:
*
(
int
*
)
dest
=
i
;
break
;
case
SIZE_l
:
*
(
long
*
)
dest
=
i
;
break
;
case
SIZE_ll
:
*
(
long
long
*
)
dest
=
i
;
break
;
}
}
static
void
*
arg_n
(
va_list
ap
,
unsigned
int
n
)
{
void
*
p
;
unsigned
int
i
;
va_list
ap2
;
va_copy
(
ap2
,
ap
);
for
(
i
=
n
;
i
>
1
;
i
--
)
va_arg
(
ap2
,
void
*
);
p
=
va_arg
(
ap2
,
void
*
);
va_end
(
ap2
);
return
p
;
}
int
vfscanf
(
FILE
*
restrict
f
,
const
char
*
restrict
fmt
,
va_list
ap
)
{
int
width
;
int
size
;
int
alloc
;
int
base
;
const
unsigned
char
*
p
;
int
c
,
t
;
char
*
s
;
wchar_t
*
wcs
;
mbstate_t
st
;
void
*
dest
=
NULL
;
int
invert
;
int
matches
=
0
;
unsigned
long
long
x
;
long
double
y
;
off_t
pos
=
0
;
unsigned
char
scanset
[
257
];
size_t
i
,
k
;
wchar_t
wc
;
FLOCK
(
f
);
for
(
p
=
(
const
unsigned
char
*
)
fmt
;
*
p
;
p
++
)
{
alloc
=
0
;
if
(
isspace
(
*
p
))
{
while
(
isspace
(
p
[
1
]))
p
++
;
shlim
(
f
,
0
);
while
(
isspace
(
shgetc
(
f
)));
shunget
(
f
);
pos
+=
shcnt
(
f
);
continue
;
}
if
(
*
p
!=
'%'
||
p
[
1
]
==
'%'
)
{
shlim
(
f
,
0
);
if
(
*
p
==
'%'
)
{
p
++
;
while
(
isspace
((
c
=
shgetc
(
f
))));
}
else
{
c
=
shgetc
(
f
);
}
if
(
c
!=*
p
)
{
shunget
(
f
);
if
(
c
<
0
)
goto
input_fail
;
goto
match_fail
;
}
pos
+=
shcnt
(
f
);
continue
;
}
p
++
;
if
(
*
p
==
'*'
)
{
dest
=
0
;
p
++
;
}
else
if
(
isdigit
(
*
p
)
&&
p
[
1
]
==
'$'
)
{
dest
=
arg_n
(
ap
,
*
p
-
'0'
);
p
+=
2
;
}
else
{
dest
=
va_arg
(
ap
,
void
*
);
}
for
(
width
=
0
;
isdigit
(
*
p
);
p
++
)
{
width
=
10
*
width
+
*
p
-
'0'
;
}
if
(
*
p
==
'm'
)
{
wcs
=
0
;
s
=
0
;
alloc
=
!!
dest
;
p
++
;
}
else
{
alloc
=
0
;
}
size
=
SIZE_def
;
switch
(
*
p
++
)
{
case
'h'
:
if
(
*
p
==
'h'
)
p
++
,
size
=
SIZE_hh
;
else
size
=
SIZE_h
;
break
;
case
'l'
:
if
(
*
p
==
'l'
)
p
++
,
size
=
SIZE_ll
;
else
size
=
SIZE_l
;
break
;
case
'j'
:
size
=
SIZE_ll
;
break
;
case
'z'
:
case
't'
:
size
=
SIZE_l
;
break
;
case
'L'
:
size
=
SIZE_L
;
break
;
case
'd'
:
case
'i'
:
case
'o'
:
case
'u'
:
case
'x'
:
case
'a'
:
case
'e'
:
case
'f'
:
case
'g'
:
case
'A'
:
case
'E'
:
case
'F'
:
case
'G'
:
case
'X'
:
case
's'
:
case
'c'
:
case
'['
:
case
'S'
:
case
'C'
:
case
'p'
:
case
'n'
:
p
--
;
break
;
default:
goto
fmt_fail
;
}
t
=
*
p
;
/* C or S */
if
((
t
&
0x2f
)
==
3
)
{
t
|=
32
;
size
=
SIZE_l
;
}
switch
(
t
)
{
case
'c'
:
if
(
width
<
1
)
width
=
1
;
case
'['
:
break
;
case
'n'
:
store_int
(
dest
,
size
,
pos
);
/* do not increment match count, etc! */
continue
;
default:
shlim
(
f
,
0
);
while
(
isspace
(
shgetc
(
f
)));
shunget
(
f
);
pos
+=
shcnt
(
f
);
}
shlim
(
f
,
width
);
if
(
shgetc
(
f
)
<
0
)
goto
input_fail
;
shunget
(
f
);
switch
(
t
)
{
case
's'
:
case
'c'
:
case
'['
:
if
(
t
==
'c'
||
t
==
's'
)
{
memset
(
scanset
,
-
1
,
sizeof
scanset
);
scanset
[
0
]
=
0
;
if
(
t
==
's'
)
{
scanset
[
1
+
'\t'
]
=
0
;
scanset
[
1
+
'\n'
]
=
0
;
scanset
[
1
+
'\v'
]
=
0
;
scanset
[
1
+
'\f'
]
=
0
;
scanset
[
1
+
'\r'
]
=
0
;
scanset
[
1
+
' '
]
=
0
;
}
}
else
{
if
(
*++
p
==
'^'
)
p
++
,
invert
=
1
;
else
invert
=
0
;
memset
(
scanset
,
invert
,
sizeof
scanset
);
scanset
[
0
]
=
0
;
if
(
*
p
==
'-'
)
p
++
,
scanset
[
1
+
'-'
]
=
1
-
invert
;
else
if
(
*
p
==
']'
)
p
++
,
scanset
[
1
+
']'
]
=
1
-
invert
;
for
(;
*
p
!=
']'
;
p
++
)
{
if
(
!*
p
)
goto
fmt_fail
;
if
(
*
p
==
'-'
&&
p
[
1
]
&&
p
[
1
]
!=
']'
)
for
(
c
=
p
++
[
-
1
];
c
<*
p
;
c
++
)
scanset
[
1
+
c
]
=
1
-
invert
;
scanset
[
1
+*
p
]
=
1
-
invert
;
}
}
wcs
=
0
;
s
=
0
;
i
=
0
;
k
=
t
==
'c'
?
width
+
1U
:
31
;
if
(
size
==
SIZE_l
)
{
if
(
alloc
)
{
wcs
=
malloc
(
k
*
sizeof
(
wchar_t
));
if
(
!
wcs
)
goto
alloc_fail
;
}
else
{
wcs
=
dest
;
}
st
=
(
mbstate_t
){
0
};
while
(
scanset
[(
c
=
shgetc
(
f
))
+
1
])
{
switch
(
mbrtowc
(
&
wc
,
&
(
char
){
c
},
1
,
&
st
))
{
case
-
1
:
goto
input_fail
;
case
-
2
:
continue
;
}
if
(
wcs
)
wcs
[
i
++
]
=
wc
;
if
(
alloc
&&
i
==
k
)
{
k
+=
k
+
1
;
wchar_t
*
tmp
=
realloc
(
wcs
,
k
*
sizeof
(
wchar_t
));
if
(
!
tmp
)
goto
alloc_fail
;
wcs
=
tmp
;
}
}
if
(
!
mbsinit
(
&
st
))
goto
input_fail
;
}
else
if
(
alloc
)
{
s
=
malloc
(
k
);
if
(
!
s
)
goto
alloc_fail
;
while
(
scanset
[(
c
=
shgetc
(
f
))
+
1
])
{
s
[
i
++
]
=
c
;
if
(
i
==
k
)
{
k
+=
k
+
1
;
char
*
tmp
=
realloc
(
s
,
k
);
if
(
!
tmp
)
goto
alloc_fail
;
s
=
tmp
;
}
}
}
else
if
((
s
=
dest
))
{
while
(
scanset
[(
c
=
shgetc
(
f
))
+
1
])
s
[
i
++
]
=
c
;
}
else
{
while
(
scanset
[(
c
=
shgetc
(
f
))
+
1
]);
}
shunget
(
f
);
if
(
!
shcnt
(
f
))
goto
match_fail
;
if
(
t
==
'c'
&&
shcnt
(
f
)
!=
width
)
goto
match_fail
;
if
(
alloc
)
{
if
(
size
==
SIZE_l
)
*
(
wchar_t
**
)
dest
=
wcs
;
else
*
(
char
**
)
dest
=
s
;
}
if
(
t
!=
'c'
)
{
if
(
wcs
)
wcs
[
i
]
=
0
;
if
(
s
)
s
[
i
]
=
0
;
}
break
;
case
'p'
:
case
'X'
:
case
'x'
:
base
=
16
;
goto
int_common
;
case
'o'
:
base
=
8
;
goto
int_common
;
case
'd'
:
case
'u'
:
base
=
10
;
goto
int_common
;
case
'i'
:
base
=
0
;
int_common:
x
=
__intscan
(
f
,
base
,
0
,
ULLONG_MAX
);
if
(
!
shcnt
(
f
))
goto
match_fail
;
if
(
t
==
'p'
&&
dest
)
*
(
void
**
)
dest
=
(
void
*
)(
uintptr_t
)
x
;
else
store_int
(
dest
,
size
,
x
);
break
;
case
'a'
:
case
'A'
:
case
'e'
:
case
'E'
:
case
'f'
:
case
'F'
:
case
'g'
:
case
'G'
:
y
=
__floatscan
(
f
,
size
,
0
);
if
(
!
shcnt
(
f
))
goto
match_fail
;
if
(
dest
)
switch
(
size
)
{
case
SIZE_def
:
*
(
float
*
)
dest
=
y
;
break
;
case
SIZE_l
:
*
(
double
*
)
dest
=
y
;
break
;
case
SIZE_L
:
*
(
long
double
*
)
dest
=
y
;
break
;
}
break
;
}
pos
+=
shcnt
(
f
);
if
(
dest
)
matches
++
;
}
if
(
0
)
{
fmt_fail:
alloc_fail:
input_fail:
if
(
!
matches
)
matches
--
;
match_fail:
if
(
alloc
)
{
free
(
s
);
free
(
wcs
);
}
}
FUNLOCK
(
f
);
return
matches
;
}
weak_alias
(
vfscanf
,
__isoc99_vfscanf
);
porting/liteos_m/kernel/src/stdio/vscanf.c
0 → 100644
浏览文件 @
0c64a71b
#include <stdio.h>
#include <stdarg.h>
int
vscanf
(
const
char
*
restrict
fmt
,
va_list
ap
)
{
return
vfscanf
(
stdin
,
fmt
,
ap
);
}
weak_alias
(
vscanf
,
__isoc99_vscanf
);
porting/liteos_m/kernel/src/stdio/vsscanf.c
0 → 100644
浏览文件 @
0c64a71b
#include "stdio_impl.h"
static
size_t
do_read
(
FILE
*
f
,
unsigned
char
*
buf
,
size_t
len
)
{
return
__string_read
(
f
,
buf
,
len
);
}
int
vsscanf
(
const
char
*
restrict
s
,
const
char
*
restrict
fmt
,
va_list
ap
)
{
FILE
f
=
{
.
buf
=
(
void
*
)
s
,
.
cookie
=
(
void
*
)
s
,
.
read
=
do_read
,
.
lock
=
-
1
};
return
vfscanf
(
&
f
,
fmt
,
ap
);
}
weak_alias
(
vsscanf
,
__isoc99_vsscanf
);
porting/liteos_m/kernel/src/stdlib/strtol.c
浏览文件 @
0c64a71b
...
...
@@ -23,6 +23,11 @@ unsigned long long strtoull(const char *restrict s, char **restrict p, int base)
return
strtox
(
s
,
p
,
base
,
ULLONG_MAX
);
}
long
long
strtoll
(
const
char
*
restrict
s
,
char
**
restrict
p
,
int
base
)
{
return
strtox
(
s
,
p
,
base
,
LLONG_MIN
);
}
unsigned
long
strtoul
(
const
char
*
restrict
s
,
char
**
restrict
p
,
int
base
)
{
return
strtox
(
s
,
p
,
base
,
ULONG_MAX
);
...
...
@@ -34,5 +39,6 @@ long strtol(const char *restrict s, char **restrict p, int base)
}
weak_alias
(
strtol
,
__strtol_internal
);
weak_alias
(
strtoll
,
__strtoll_internal
);
weak_alias
(
strtoul
,
__strtoul_internal
);
weak_alias
(
strtoull
,
__strtoull_internal
);
porting/liteos_m/kernel/src/string/strtok_r.c
0 → 100644
浏览文件 @
0c64a71b
#include <string.h>
char
*
strtok_r
(
char
*
restrict
s
,
const
char
*
restrict
sep
,
char
**
restrict
p
)
{
if
(
!
s
&&
!
(
s
=
*
p
))
return
NULL
;
s
+=
strspn
(
s
,
sep
);
if
(
!*
s
)
return
*
p
=
0
;
*
p
=
s
+
strcspn
(
s
,
sep
);
if
(
**
p
)
*
(
*
p
)
++
=
0
;
else
*
p
=
0
;
return
s
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录