libc: Add getrusage()

This commit is contained in:
apio 2023-05-20 12:48:17 +02:00
parent 01111442d3
commit 6de90b3c93
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 34 additions and 0 deletions

View File

@ -26,6 +26,7 @@ set(SOURCES
src/sys/utsname.cpp
src/sys/mount.cpp
src/sys/pstat.cpp
src/sys/resource.cpp
)
if(${LUNA_ARCH} STREQUAL "x86_64")

View File

@ -0,0 +1,20 @@
/* sys/resource.h: System resource management. */
#ifndef _SYS_RESOURCE_H
#define _SYS_RESOURCE_H
#include <bits/rusage.h>
#ifdef __cplusplus
extern "C"
{
#endif
/* Get this process or its children's resource usage. */
int getrusage(int who, struct rusage* ru);
#ifdef __cplusplus
}
#endif
#endif

13
libc/src/sys/resource.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <bits/errno-return.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <unistd.h>
extern "C"
{
int getrusage(int who, struct rusage* ru)
{
long rc = syscall(SYS_getrusage, who, ru);
__errno_return(rc, int);
}
}