Add fork, wait, waitpid for all Linux targets, & execl for linux386.
This commit is contained in:
parent
7e2adfb692
commit
84a25b0526
|
@ -13,6 +13,7 @@ addheader("ack/fcntl.h")
|
|||
addheader("ack/signal.h")
|
||||
addheader("sys/ioctl.h")
|
||||
addheader("sys/types.h")
|
||||
addheader("sys/wait.h")
|
||||
|
||||
|
||||
acklibrary {
|
||||
|
|
19
plat/linux/include/sys/wait.h
Normal file
19
plat/linux/include/sys/wait.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef _SYS_WAIT_H
|
||||
#define _SYS_WAIT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
extern pid_t wait(int *__wstatus);
|
||||
extern pid_t waitpid(pid_t __pid, int *__wstatus, int __options);
|
||||
|
||||
#define WNOHANG (1 << 0)
|
||||
#define WUNTRACED (1 << 1)
|
||||
#define WSTOPPED WUNTRACED
|
||||
#define WEXITED (1 << 2)
|
||||
#define WCONTINUED (1 << 3)
|
||||
#define WNOWAIT (1 << 24)
|
||||
#define __WNOTHREAD (1 << 29)
|
||||
#define __WALL (1 << 30)
|
||||
#define __WCLONE (1 << 31)
|
||||
|
||||
#endif
|
8
plat/linux/libsys/fork.c
Normal file
8
plat/linux/libsys/fork.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "libsys.h"
|
||||
|
||||
pid_t fork(void)
|
||||
{
|
||||
return (pid_t) _syscall(__NR_fork, 0, 0, 0);
|
||||
}
|
7
plat/linux/libsys/wait.c
Normal file
7
plat/linux/libsys/wait.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <sys/wait.h>
|
||||
#include "libsys.h"
|
||||
|
||||
pid_t wait(int *wstatus)
|
||||
{
|
||||
return (pid_t) _syscall(__NR_waitpid, -1, (quad) wstatus, 0);
|
||||
}
|
7
plat/linux/libsys/waitpid.c
Normal file
7
plat/linux/libsys/waitpid.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <sys/wait.h>
|
||||
#include "libsys.h"
|
||||
|
||||
pid_t waitpid(pid_t pid, int *wstatus, int options)
|
||||
{
|
||||
return (pid_t) _syscall(__NR_waitpid, pid, (quad) wstatus, options);
|
||||
}
|
29
plat/linux386/libsys/execl.s
Normal file
29
plat/linux386/libsys/execl.s
Normal file
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .text
|
||||
|
||||
__NR_execve = 11
|
||||
|
||||
! Perform a execl by invoking Linux's execve system call.
|
||||
|
||||
.define _execl
|
||||
|
||||
_execl:
|
||||
lea eax, 8(esp)
|
||||
push (_environ) ! envp
|
||||
push eax ! argv
|
||||
push -4(eax) ! pathname
|
||||
push __NR_execve
|
||||
call __syscall
|
||||
add esp, 16
|
||||
ret
|
|
@ -7,6 +7,7 @@ acklibrary {
|
|||
"plat/linux/libsys/close.c",
|
||||
"plat/linux/libsys/creat.c",
|
||||
"plat/linux/libsys/execve.c",
|
||||
"plat/linux/libsys/fork.c",
|
||||
"plat/linux/libsys/getpid.c",
|
||||
"plat/linux/libsys/gettimeofday.c",
|
||||
"plat/linux/libsys/ioctl.c",
|
||||
|
@ -19,6 +20,8 @@ acklibrary {
|
|||
"plat/linux/libsys/signal.c",
|
||||
"plat/linux/libsys/sigprocmask.c",
|
||||
"plat/linux/libsys/unlink.c",
|
||||
"plat/linux/libsys/wait.c",
|
||||
"plat/linux/libsys/waitpid.c",
|
||||
"plat/linux/libsys/write.c",
|
||||
},
|
||||
deps = {
|
||||
|
|
|
@ -8,6 +8,7 @@ acklibrary {
|
|||
"plat/linux/libsys/_hol0.s",
|
||||
"plat/linux/libsys/close.c",
|
||||
"plat/linux/libsys/creat.c",
|
||||
"plat/linux/libsys/fork.c",
|
||||
"plat/linux/libsys/execve.c",
|
||||
"plat/linux/libsys/getpid.c",
|
||||
"plat/linux/libsys/gettimeofday.c",
|
||||
|
@ -21,6 +22,8 @@ acklibrary {
|
|||
-- omit signal.c
|
||||
"plat/linux/libsys/sigprocmask.c",
|
||||
"plat/linux/libsys/unlink.c",
|
||||
"plat/linux/libsys/wait.c",
|
||||
"plat/linux/libsys/waitpid.c",
|
||||
"plat/linux/libsys/write.c",
|
||||
},
|
||||
deps = {
|
||||
|
|
Loading…
Reference in a new issue