This commit is contained in:
cinap_lenrek 2011-06-04 00:29:51 +00:00
commit 75edd13d78
4 changed files with 30 additions and 0 deletions

View file

@ -13,6 +13,7 @@ extern int errno;
#define E2BIG 1
#define EACCES 2
#define EAGAIN 3
#define EWOULDBLOCK 3
#define EBADF 4
#define EBUSY 5
#define ECHILD 6

View file

@ -52,6 +52,12 @@ extern char *ctime_r(const time_t *, char *);
#ifdef _POSIX_SOURCE
extern void tzset(void);
struct timespec {
time_t tv_sec;
long tv_nsec;
};
extern int nanosleep(const struct timespec *req, struct timespec *rem);
#endif
#ifdef __cplusplus

View file

@ -10,6 +10,7 @@ OFILES=\
sigset.$O\
sysconf.$O\
tzset.$O\
nanosleep.$O\
</sys/src/cmd/mksyslib

View file

@ -0,0 +1,22 @@
#define _PLAN9_SOURCE
#include "../plan9/lib.h"
#include <sys/types.h>
#include <time.h>
#include "../plan9/sys9.h"
int
nanosleep(struct timespec *req, struct timespec *rem)
{
int ms;
ms = req->tv_sec * 1000 + (req->tv_nsec + 999999) / 1000000;
if(_SLEEP(ms) < 0) {
if(rem) {
rem->tv_sec = rem->tv_nsec = 0; /* needs better handling */
}
return -1;
}
if(rem)
rem->tv_sec = rem->tv_nsec = 0;
return 0;
}