1 2 #include <stdint.h> 3 4 #include <sys/cdefs.h> 5 #include <sys/wait.h> 6 #include <sys/syscall.h> 7 #include <unistd.h> 8 #include <errno.h> 9 #include <syscall.h> 10 11 unsigned int sleep(unsigned int seconds)12sleep(unsigned int seconds) 13 { 14 OSThreadSleep(seconds); 15 16 // Should return left over time if woke up early 17 return 0; 18 } 19 20 pid_t spawn(const char * path,const char * argv[])21spawn(const char *path, const char *argv[]) 22 { 23 uint64_t status = OSSpawn(path, argv); 24 25 if (SYSCALL_ERRCODE(status) != 0) { 26 errno = SYSCALL_ERRCODE(status); 27 return -1; 28 } 29 30 return (pid_t)SYSCALL_VALUE(status); 31 } 32 33 pid_t waitpid(pid_t pid,int * status,UNUSED int options)34waitpid(pid_t pid, int *status, UNUSED int options) 35 { 36 uint64_t wstatus = OSWait(pid); 37 38 if (SYSCALL_ERRCODE(wstatus) != 0) { 39 errno = SYSCALL_ERRCODE(wstatus); 40 return -1; 41 } 42 43 *status = SYSCALL_VALUE(wstatus) & 0x0000ffff; 44 45 return WGETPID(SYSCALL_VALUE(wstatus)); 46 } 47 48 pid_t wait(int * status)49wait(int *status) 50 { 51 return waitpid(WAIT_ANY, status, 0); 52 } 53 54