kernel: posix: move sleep and usleep functions into c file.

Currently sleep and usleep functions are into unistd.h file.
unistd includes toold chain secific unistd.h file and this file
too has declaration for these functions. This is in conflict when
posix specific unistd.h is included.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
This commit is contained in:
Youvedeep Singh 2018-03-27 13:54:01 +05:30 committed by Anas Nashif
commit f762fdf482
3 changed files with 38 additions and 28 deletions

View file

@ -10,39 +10,16 @@
extern "C" {
#endif
#include_next <unistd.h>
#ifdef CONFIG_PTHREAD_IPC
#include "sys/types.h"
/**
* @brief Sleep for a specified number of seconds.
*
* See IEEE 1003.1
*/
static inline unsigned sleep(unsigned int seconds)
{
k_sleep(K_SECONDS(seconds));
return 0;
}
/**
* @brief Suspend execution for microsecond intervals.
*
* See IEEE 1003.1
*/
static inline int usleep(useconds_t useconds)
{
if (useconds < USEC_PER_MSEC) {
k_busy_wait(useconds);
} else {
k_sleep(useconds / USEC_PER_MSEC);
}
#ifndef __ZEPHYR__
#include_next <unistd.h>
#endif
return 0;
}
unsigned sleep(unsigned int seconds);
int usleep(useconds_t useconds);
#endif
#ifdef __cplusplus
}
#endif
#endif /* __POSIX_UNISTD_H__ */