libc: Add getrusage()
This commit is contained in:
parent
01111442d3
commit
6de90b3c93
@ -26,6 +26,7 @@ set(SOURCES
|
|||||||
src/sys/utsname.cpp
|
src/sys/utsname.cpp
|
||||||
src/sys/mount.cpp
|
src/sys/mount.cpp
|
||||||
src/sys/pstat.cpp
|
src/sys/pstat.cpp
|
||||||
|
src/sys/resource.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${LUNA_ARCH} STREQUAL "x86_64")
|
if(${LUNA_ARCH} STREQUAL "x86_64")
|
||||||
|
20
libc/include/sys/resource.h
Normal file
20
libc/include/sys/resource.h
Normal 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
13
libc/src/sys/resource.cpp
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user