ref: 75edd13d7805b54bbf447022d391ce5141c55d01
parent: 0accb94ff0cb8ef52a3ffea24b20524e393cecf2
parent: 97d3ff1bee2a737ce334ecf1ac962bb74de9df75
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Fri Jun 3 20:29:51 EDT 2011
merge
--- a/sys/include/ape/errno.h
+++ b/sys/include/ape/errno.h
@@ -13,6 +13,7 @@
#define E2BIG 1
#define EACCES 2
#define EAGAIN 3
+#define EWOULDBLOCK 3
#define EBADF 4
#define EBUSY 5
#define ECHILD 6
--- a/sys/include/ape/time.h
+++ b/sys/include/ape/time.h
@@ -52,6 +52,12 @@
#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
--- a/sys/src/ape/lib/ap/posix/mkfile
+++ b/sys/src/ape/lib/ap/posix/mkfile
@@ -10,6 +10,7 @@
sigset.$O\
sysconf.$O\
tzset.$O\
+ nanosleep.$O\
</sys/src/cmd/mksyslib
--- /dev/null
+++ b/sys/src/ape/lib/ap/posix/nanosleep.c
@@ -1,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;
+}