lib: linux: Add wait4.
* lib/linux/waitpid.c (waitpid): Factor-out wait4 call to... * lib/linux/wait4.c: ...new file here. * include/sys/wait.h (wait4): Add prototype. Include sys/resource.h. * include/sys/resource.h (struct rusage): Remove gratuitous "int" for M2-Planet. * build-aux/configure-lib.sh (libc_SOURCES): Add it. * kaem.run, simple.make (M2_SOURCES), simple.sh: Likewise. Also add resource.h.
This commit is contained in:
parent
cbea14f843
commit
6bc6e8354e
|
@ -215,6 +215,7 @@ lib/linux/malloc.c
|
|||
lib/linux/_read.c
|
||||
lib/linux/time.c
|
||||
lib/linux/unlink.c
|
||||
lib/linux/wait4.c
|
||||
lib/linux/waitpid.c
|
||||
lib/linux/$mes_cpu-mes-$compiler/syscall.c
|
||||
lib/linux/getpid.c
|
||||
|
|
|
@ -32,20 +32,20 @@ struct rusage
|
|||
{
|
||||
struct timeval ru_utime;
|
||||
struct timeval ru_stime;
|
||||
long int ru_maxrss;
|
||||
long int ru_ixrss;
|
||||
long int ru_idrss;
|
||||
long int ru_isrss;
|
||||
long int ru_minflt;
|
||||
long int ru_majflt;
|
||||
long int ru_nswap;
|
||||
long int ru_inblock;
|
||||
long int ru_oublock;
|
||||
long int ru_msgsnd;
|
||||
long int ru_msgrcv;
|
||||
long int ru_nsignals;
|
||||
long int ru_nvcsw;
|
||||
long int ru_nivcsw;
|
||||
long ru_maxrss;
|
||||
long ru_ixrss;
|
||||
long ru_idrss;
|
||||
long ru_isrss;
|
||||
long ru_minflt;
|
||||
long ru_majflt;
|
||||
long ru_nswap;
|
||||
long ru_inblock;
|
||||
long ru_oublock;
|
||||
long ru_msgsnd;
|
||||
long ru_msgrcv;
|
||||
long ru_nsignals;
|
||||
long ru_nvcsw;
|
||||
long ru_nivcsw;
|
||||
};
|
||||
|
||||
#define RUSAGE_SELF 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -20,6 +20,8 @@
|
|||
#ifndef __MES_SYS_WAIT_H
|
||||
#define __MES_SYS_WAIT_H 1
|
||||
|
||||
#include <sys/resource.h>
|
||||
|
||||
#if SYSTEM_LIBC
|
||||
#undef __MES_SYS_WAIT_H
|
||||
#include_next <sys/wait.h>
|
||||
|
@ -35,6 +37,8 @@ typedef int pid_t;
|
|||
|
||||
pid_t waitpid (pid_t pid, int *status_ptr, int options);
|
||||
pid_t wait (int *status_ptr);
|
||||
pid_t wait4 (pid_t pid, int *wstatus, int options,
|
||||
struct rusage *rusage);
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
|
|
2
kaem.run
2
kaem.run
|
@ -98,6 +98,8 @@ M2-Planet \
|
|||
-f lib/linux/fork.c \
|
||||
-f lib/m2/execve.c \
|
||||
-f lib/m2/execv.c \
|
||||
-f include/sys/resource.h \
|
||||
-f lib/linux/wait4.c \
|
||||
-f lib/linux/waitpid.c \
|
||||
-f lib/linux/gettimeofday.c \
|
||||
-f lib/linux/clock_gettime.c \
|
||||
|
|
36
lib/linux/wait4.c
Normal file
36
lib/linux/wait4.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <arch/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
pid_t
|
||||
wait4 (pid_t pid, int *status_ptr, int options, struct rusage *rusage)
|
||||
{
|
||||
long long_pid = pid;
|
||||
long long_status_ptr = cast_voidp_to_long (status_ptr);
|
||||
long long_options = options;
|
||||
long long_rusage = cast_voidp_to_long (rusage);
|
||||
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options,
|
||||
long_rusage);
|
||||
}
|
|
@ -18,9 +18,11 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <arch/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
pid_t
|
||||
waitpid (pid_t pid, int *status_ptr, int options)
|
||||
|
@ -28,10 +30,10 @@ waitpid (pid_t pid, int *status_ptr, int options)
|
|||
long long_pid = pid;
|
||||
long long_status_ptr = cast_voidp_to_long (status_ptr);
|
||||
long long_options = options;
|
||||
#if __i386__
|
||||
#if defined (SYS_waitpid)
|
||||
return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
|
||||
#elif __x86_64__ || __arm__
|
||||
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options, 0);
|
||||
#elif defined (SYS_wait4)
|
||||
return wait4 (pid, status_ptr, options, 0);
|
||||
#else
|
||||
#error arch not supported
|
||||
#endif
|
||||
|
|
|
@ -130,6 +130,7 @@ M2_SOURCES = \
|
|||
lib/linux/fork.c \
|
||||
lib/m2/execve.c \
|
||||
lib/m2/execv.c \
|
||||
lib/linux/wait4.c \
|
||||
lib/linux/waitpid.c \
|
||||
lib/linux/gettimeofday.c \
|
||||
lib/linux/clock_gettime.c \
|
||||
|
@ -193,12 +194,14 @@ M2_PLANET_INCLUDES = \
|
|||
include/linux/x86/syscall.h \
|
||||
include/time.h \
|
||||
include/sys/time.h \
|
||||
include/m2/types.h \
|
||||
include/sys/types.h \
|
||||
include/stdio.h \
|
||||
include/limits.h \
|
||||
include/sys/stat.h \
|
||||
include/fcntl.h \
|
||||
include/signal.h \
|
||||
include/sys/resource.h \
|
||||
include/mes/mes.h \
|
||||
include/mes/builtins.h \
|
||||
include/mes/constants.h \
|
||||
|
|
Loading…
Reference in a new issue