未验证 提交 d7c70443 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #4644 from mysterywolf/libc-unity

[libc][unistd] complete unistd.c
......@@ -66,13 +66,11 @@
#endif
int isatty (int fd);
char * ttyname (int desc);
unsigned int sleep(unsigned int seconds);
int usleep(useconds_t usec);
pid_t gettid(void);
pid_t getpid(void);
pid_t getppid(void);
uid_t getuid(void);
......
......@@ -15,18 +15,29 @@
#ifdef RT_USING_POSIX_TERMIOS
#include "termios.h"
int isatty(int fd)
{
struct termios ts;
return(tcgetattr(fd,&ts) != -1);/*true if no error (is a tty)*/
return(tcgetattr(fd, &ts) != -1); /*true if no error (is a tty)*/
}
#else
int isatty(int fd)
{
if (fd >=0 && fd < 3)
{
return 1;
}
else
{
return 0;
}
}
RTM_EXPORT(isatty);
#endif
RTM_EXPORT(isatty);
char *ttyname(int fd)
{
return "/dev/tty0"; /*TODO: need to add more specific*/
return "/dev/tty"; /*TODO: need to add more specific*/
}
RTM_EXPORT(ttyname);
......@@ -50,11 +61,16 @@ int usleep(useconds_t usec)
}
RTM_EXPORT(usleep);
pid_t getpid(void)
pid_t gettid(void)
{
/*TODO*/
return 0;
}
pid_t getpid(void)
{
return gettid();
}
RTM_EXPORT(getpid);
pid_t getppid(void)
......
......@@ -98,6 +98,7 @@ _isatty_r(struct _reent *ptr, int fd)
return 0;
}
}
int
_kill_r(struct _reent *ptr, int pid, int sig)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册