2020-09-02 10:22:47 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
2021-02-12 02:12:33 +08:00
|
|
|
* 2020-09-01 Meco Man first Version
|
|
|
|
* 2021-02-12 Meco Man move all functions located in <pthread_sleep.c> to this file
|
2020-09-02 10:22:47 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <unistd.h>
|
2021-02-12 02:12:33 +08:00
|
|
|
#include <rtthread.h>
|
|
|
|
#include <rthw.h>
|
2020-09-02 10:22:47 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_POSIX_TERMIOS
|
2020-10-03 00:27:49 +08:00
|
|
|
#include "termios.h"
|
2020-09-08 10:52:02 +08:00
|
|
|
|
2020-09-02 10:22:47 +08:00
|
|
|
int isatty(int fd)
|
|
|
|
{
|
|
|
|
struct termios ts;
|
|
|
|
return(tcgetattr(fd,&ts) != -1);/*true if no error (is a tty)*/
|
|
|
|
}
|
2021-02-12 02:21:30 +08:00
|
|
|
RTM_EXPORT(isatty);
|
2020-09-02 10:22:47 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
char *ttyname(int fd)
|
|
|
|
{
|
|
|
|
return "/dev/tty0"; /*TODO: need to add more specific*/
|
|
|
|
}
|
2021-02-12 02:21:30 +08:00
|
|
|
RTM_EXPORT(ttyname);
|
2021-02-12 02:12:33 +08:00
|
|
|
|
|
|
|
unsigned int sleep(unsigned int seconds)
|
|
|
|
{
|
|
|
|
rt_tick_t delta_tick;
|
|
|
|
|
|
|
|
delta_tick = rt_tick_get();
|
|
|
|
rt_thread_delay(seconds * RT_TICK_PER_SECOND);
|
|
|
|
delta_tick = rt_tick_get() - delta_tick;
|
|
|
|
|
|
|
|
return seconds - delta_tick/RT_TICK_PER_SECOND;
|
|
|
|
}
|
2021-02-12 02:21:30 +08:00
|
|
|
RTM_EXPORT(sleep);
|
2021-02-12 02:12:33 +08:00
|
|
|
|
|
|
|
int usleep(useconds_t usec)
|
|
|
|
{
|
|
|
|
rt_thread_mdelay(usec / 1000u);
|
|
|
|
rt_hw_us_delay(usec % 1000u);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-02-12 02:21:30 +08:00
|
|
|
RTM_EXPORT(usleep);
|
2021-02-21 17:25:36 +08:00
|
|
|
|
2021-02-21 18:01:29 +08:00
|
|
|
pid_t getpid(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
RTM_EXPORT(getpid);
|
|
|
|
|
|
|
|
pid_t getppid(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
RTM_EXPORT(getppid);
|
|
|
|
|
2021-02-21 17:25:36 +08:00
|
|
|
uid_t getuid(void)
|
|
|
|
{
|
2021-02-21 18:01:29 +08:00
|
|
|
return 0;
|
2021-02-21 17:25:36 +08:00
|
|
|
}
|
|
|
|
RTM_EXPORT(getuid);
|
|
|
|
|
2021-02-21 18:01:29 +08:00
|
|
|
uid_t geteuid(void)
|
2021-02-21 17:25:36 +08:00
|
|
|
{
|
2021-02-21 18:01:29 +08:00
|
|
|
return 0;
|
2021-02-21 17:25:36 +08:00
|
|
|
}
|
2021-02-21 18:01:29 +08:00
|
|
|
RTM_EXPORT(geteuid);
|
|
|
|
|
|
|
|
gid_t getgid(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
RTM_EXPORT(getgid);
|
|
|
|
|
|
|
|
gid_t getegid(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
RTM_EXPORT(getegid);
|