Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ihbai
rt-thread
提交
0f288416
R
rt-thread
项目概览
ihbai
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
0f288416
编写于
2月 23, 2021
作者:
B
Bernard Xiong
提交者:
GitHub
2月 23, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4364 from mysterywolf/unistd
[libc][unistd] add getxxid() functions
上级
88d3bb7d
19c8cab8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
100 addition
and
30 deletion
+100
-30
components/libc/compilers/armlibc/sys/types.h
components/libc/compilers/armlibc/sys/types.h
+3
-1
components/libc/compilers/armlibc/sys/unistd.h
components/libc/compilers/armlibc/sys/unistd.h
+7
-0
components/libc/compilers/common/unistd.c
components/libc/compilers/common/unistd.c
+37
-0
components/libc/compilers/dlib/sys/types.h
components/libc/compilers/dlib/sys/types.h
+3
-1
components/libc/compilers/dlib/sys/unistd.h
components/libc/compilers/dlib/sys/unistd.h
+7
-0
components/libc/compilers/newlib/syscalls.c
components/libc/compilers/newlib/syscalls.c
+43
-28
未找到文件。
components/libc/compilers/armlibc/sys/types.h
浏览文件 @
0f288416
...
...
@@ -15,7 +15,9 @@
typedef
int32_t
clockid_t
;
typedef
int32_t
key_t
;
/* Used for interprocess communication. */
typedef
int32_t
pid_t
;
/* Used for process IDs and process group IDs. */
typedef
int
pid_t
;
/* Used for process IDs and process group IDs. */
typedef
unsigned
short
uid_t
;
typedef
unsigned
short
gid_t
;
#ifndef ARCH_CPU_64BIT
typedef
signed
int
ssize_t
;
/* Used for a count of bytes or an error indication. */
#else
...
...
components/libc/compilers/armlibc/sys/unistd.h
浏览文件 @
0f288416
...
...
@@ -73,4 +73,11 @@ char * ttyname (int desc);
unsigned
int
sleep
(
unsigned
int
seconds
);
int
usleep
(
useconds_t
usec
);
pid_t
getpid
(
void
);
pid_t
getppid
(
void
);
uid_t
getuid
(
void
);
uid_t
geteuid
(
void
);
gid_t
getgid
(
void
);
gid_t
getegid
(
void
);
#endif
/* _SYS_UNISTD_H */
components/libc/compilers/common/unistd.c
浏览文件 @
0f288416
...
...
@@ -49,3 +49,40 @@ int usleep(useconds_t usec)
return
0
;
}
RTM_EXPORT
(
usleep
);
pid_t
getpid
(
void
)
{
/*TODO*/
return
0
;
}
RTM_EXPORT
(
getpid
);
pid_t
getppid
(
void
)
{
return
0
;
}
RTM_EXPORT
(
getppid
);
uid_t
getuid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
getuid
);
uid_t
geteuid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
geteuid
);
gid_t
getgid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
getgid
);
gid_t
getegid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
getegid
);
components/libc/compilers/dlib/sys/types.h
浏览文件 @
0f288416
...
...
@@ -14,7 +14,9 @@
typedef
int32_t
clockid_t
;
typedef
int32_t
key_t
;
/* Used for interprocess communication. */
typedef
int32_t
pid_t
;
/* Used for process IDs and process group IDs. */
typedef
int
pid_t
;
/* Used for process IDs and process group IDs. */
typedef
unsigned
short
uid_t
;
typedef
unsigned
short
gid_t
;
#ifndef ARCH_CPU_64BIT
typedef
signed
int
ssize_t
;
/* Used for a count of bytes or an error indication. */
#else
...
...
components/libc/compilers/dlib/sys/unistd.h
浏览文件 @
0f288416
...
...
@@ -47,4 +47,11 @@ char * ttyname (int desc);
unsigned
int
sleep
(
unsigned
int
seconds
);
int
usleep
(
useconds_t
usec
);
pid_t
getpid
(
void
);
pid_t
getppid
(
void
);
uid_t
getuid
(
void
);
uid_t
geteuid
(
void
);
gid_t
getgid
(
void
);
gid_t
getegid
(
void
);
#endif
/* _SYS_UNISTD_H */
components/libc/compilers/newlib/syscalls.c
浏览文件 @
0f288416
...
...
@@ -7,12 +7,13 @@
* Date Author Notes
* 2021-02-11 Meco Man remove _gettimeofday_r() and _times_r()
* 2020-02-13 Meco Man re-implement exit() and abort()
* 2020-02-21 Meco Man improve and beautify syscalls
*/
#include <reent.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <errno.h>
#include <stdio.h>
#include <sys/time.h>
#include <rtthread.h>
...
...
@@ -34,11 +35,19 @@ __errno ()
}
#endif
int
_getpid_r
(
struct
_reent
*
ptr
)
{
return
0
;
}
int
_close_r
(
struct
_reent
*
ptr
,
int
fd
)
{
#ifndef RT_USING_DFS
return
0
;
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
#else
return
close
(
fd
);
#endif
...
...
@@ -76,20 +85,14 @@ _fstat_r(struct _reent *ptr, int fd, struct stat *pstat)
return
-
1
;
}
int
_getpid_r
(
struct
_reent
*
ptr
)
{
return
0
;
}
int
_isatty_r
(
struct
_reent
*
ptr
,
int
fd
)
{
if
(
fd
>=
0
&&
fd
<
3
)
return
1
;
if
(
fd
>=
0
&&
fd
<
3
)
return
1
;
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
ptr
->
_errno
=
ENOTTY
;
return
0
;
}
int
...
...
@@ -112,7 +115,9 @@ _off_t
_lseek_r
(
struct
_reent
*
ptr
,
int
fd
,
_off_t
pos
,
int
whence
)
{
#ifndef RT_USING_DFS
return
0
;
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
#else
_off_t
rc
;
...
...
@@ -125,7 +130,9 @@ int
_mkdir_r
(
struct
_reent
*
ptr
,
const
char
*
name
,
int
mode
)
{
#ifndef RT_USING_DFS
return
0
;
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
#else
int
rc
;
...
...
@@ -138,7 +145,9 @@ int
_open_r
(
struct
_reent
*
ptr
,
const
char
*
file
,
int
flags
,
int
mode
)
{
#ifndef RT_USING_DFS
return
0
;
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
#else
int
rc
;
...
...
@@ -151,7 +160,9 @@ _ssize_t
_read_r
(
struct
_reent
*
ptr
,
int
fd
,
void
*
buf
,
size_t
nbytes
)
{
#ifndef RT_USING_DFS
return
0
;
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
#else
_ssize_t
rc
;
...
...
@@ -164,7 +175,9 @@ int
_rename_r
(
struct
_reent
*
ptr
,
const
char
*
old
,
const
char
*
new
)
{
#ifndef RT_USING_DFS
return
0
;
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
#else
int
rc
;
...
...
@@ -184,7 +197,9 @@ int
_stat_r
(
struct
_reent
*
ptr
,
const
char
*
file
,
struct
stat
*
pstat
)
{
#ifndef RT_USING_DFS
return
0
;
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
#else
int
rc
;
...
...
@@ -197,6 +212,8 @@ int
_unlink_r
(
struct
_reent
*
ptr
,
const
char
*
file
)
{
#ifndef RT_USING_DFS
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
#else
return
unlink
(
file
);
...
...
@@ -211,11 +228,11 @@ _wait_r(struct _reent *ptr, int *status)
return
-
1
;
}
#ifdef RT_USING_DEVICE
_ssize_t
_write_r
(
struct
_reent
*
ptr
,
int
fd
,
const
void
*
buf
,
size_t
nbytes
)
{
#ifndef RT_USING_DFS
#ifdef RT_USING_DEVICE
if
(
fileno
(
stdout
)
==
fd
)
{
rt_device_t
console
;
...
...
@@ -225,7 +242,11 @@ _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
}
return
0
;
#else
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
#endif
/*RT_USING_DEVICE*/
#else
_ssize_t
rc
;
...
...
@@ -233,7 +254,6 @@ _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
return
rc
;
#endif
}
#endif
/* Memory routine */
void
*
...
...
@@ -304,11 +324,6 @@ void __libc_init_array(void)
/* we not use __libc init_aray to initialize C++ objects */
}
uid_t
getuid
(
void
)
{
return
0
;
}
mode_t
umask
(
mode_t
mask
)
{
return
022
;
...
...
@@ -320,7 +335,7 @@ int flock(int fd, int operation)
}
/*
These functions
will b
e implemented and replaced by the 'common/time.c' file
These functions
ar
e implemented and replaced by the 'common/time.c' file
int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp);
_CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms);
*/
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录