sys/resource.h: add rusage compatibility fields, set to zero
POSIX defines this structure but specifies only two fields (which we already implement). However, both the *BSD and Linux have agreed on some more fields, which are often assumed to be there by applications. The benefice of having compatibility fields is greater as having to patch every other software at HaikuPorts. Change-Id: Ie28ca2e348aa16b4c57eb3498eb62175100d9b9d Reviewed-on: https://review.haiku-os.org/c/haiku/+/4083 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Niels Sascha Reedijk <[email protected]> Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
@@ -44,6 +44,22 @@ struct rlimit {
|
|||||||
struct rusage {
|
struct rusage {
|
||||||
struct timeval ru_utime; /* user time used */
|
struct timeval ru_utime; /* user time used */
|
||||||
struct timeval ru_stime; /* system time used */
|
struct timeval ru_stime; /* system time used */
|
||||||
|
|
||||||
|
/* unused, only for compatibility with other systems */
|
||||||
|
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
|
#define RUSAGE_SELF 0
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
|
|||||||
local architectureObject ;
|
local architectureObject ;
|
||||||
for architectureObject in [ MultiArchSubDirSetup ] {
|
for architectureObject in [ MultiArchSubDirSetup ] {
|
||||||
on $(architectureObject) {
|
on $(architectureObject) {
|
||||||
|
SetVersionScript [ MultiArchDefaultGristFiles libbsd.so ] :
|
||||||
|
libbsd_versions ;
|
||||||
|
|
||||||
SharedLibrary [ MultiArchDefaultGristFiles libbsd.so ] :
|
SharedLibrary [ MultiArchDefaultGristFiles libbsd.so ] :
|
||||||
daemon.c
|
daemon.c
|
||||||
err.c
|
err.c
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
LIBBSD_BASE {
|
||||||
|
};
|
||||||
|
|
||||||
|
LIBBSD_1_BETA3 {
|
||||||
|
} LIBBSD_BASE;
|
||||||
+39
-3
@@ -15,16 +15,23 @@
|
|||||||
extern pid_t _waitpid(pid_t pid, int* _status, int options,
|
extern pid_t _waitpid(pid_t pid, int* _status, int options,
|
||||||
team_usage_info *usage_info);
|
team_usage_info *usage_info);
|
||||||
|
|
||||||
|
// prototypes for the compiler
|
||||||
|
pid_t _wait3_base(int *status, int options, struct rusage *rusage);
|
||||||
|
pid_t _wait4_base(pid_t pid, int *status, int options, struct rusage *rusage);
|
||||||
|
pid_t _wait3_current(int *status, int options, struct rusage *rusage);
|
||||||
|
pid_t _wait4_current(pid_t pid, int *status, int options,
|
||||||
|
struct rusage *rusage);
|
||||||
|
|
||||||
|
|
||||||
pid_t
|
pid_t
|
||||||
wait3(int *status, int options, struct rusage *rusage)
|
_wait3_base(int *status, int options, struct rusage *rusage)
|
||||||
{
|
{
|
||||||
return wait4(-1, status, options, rusage);
|
return _wait4_base(-1, status, options, rusage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pid_t
|
pid_t
|
||||||
wait4(pid_t pid, int *status, int options, struct rusage *rusage)
|
_wait4_base(pid_t pid, int *status, int options, struct rusage *rusage)
|
||||||
{
|
{
|
||||||
team_usage_info info;
|
team_usage_info info;
|
||||||
pid_t waitPid = _waitpid(pid, status, options,
|
pid_t waitPid = _waitpid(pid, status, options,
|
||||||
@@ -40,3 +47,32 @@ wait4(pid_t pid, int *status, int options, struct rusage *rusage)
|
|||||||
return waitPid;
|
return waitPid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
_wait3_current(int *status, int options, struct rusage *rusage)
|
||||||
|
{
|
||||||
|
return _wait4_current(-1, status, options, rusage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
_wait4_current(pid_t pid, int *status, int options, struct rusage *rusage)
|
||||||
|
{
|
||||||
|
pid_t waitPid = _wait4_base(pid, status, options, rusage);
|
||||||
|
if (waitPid != -1 && rusage != NULL) {
|
||||||
|
memset(&rusage->ru_maxrss, 0, sizeof(struct rusage) -
|
||||||
|
offsetof(struct rusage, ru_maxrss));
|
||||||
|
}
|
||||||
|
|
||||||
|
return waitPid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define DEFINE_LIBBSD_SYMBOL_VERSION(function, symbol, version) \
|
||||||
|
B_DEFINE_SYMBOL_VERSION(function, symbol "LIBBSD_" version)
|
||||||
|
|
||||||
|
DEFINE_LIBBSD_SYMBOL_VERSION("_wait3_base", "wait3@", "BASE");
|
||||||
|
DEFINE_LIBBSD_SYMBOL_VERSION("_wait4_base", "wait4@", "BASE");
|
||||||
|
DEFINE_LIBBSD_SYMBOL_VERSION("_wait3_current", "wait3@@", "1_BETA3");
|
||||||
|
DEFINE_LIBBSD_SYMBOL_VERSION("_wait4_current", "wait4@@", "1_BETA3");
|
||||||
|
|
||||||
|
|||||||
@@ -9,3 +9,6 @@ LIBROOT_1_ALPHA4 {
|
|||||||
|
|
||||||
LIBROOT_1_ALPHA5 {
|
LIBROOT_1_ALPHA5 {
|
||||||
} LIBROOT_1_ALPHA4;
|
} LIBROOT_1_ALPHA4;
|
||||||
|
|
||||||
|
LIBROOT_1_BETA3 {
|
||||||
|
} LIBROOT_1_ALPHA5;
|
||||||
|
|||||||
@@ -9,10 +9,16 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <errno_private.h>
|
#include <errno_private.h>
|
||||||
|
#include <symbol_versioning.h>
|
||||||
|
|
||||||
|
|
||||||
|
// prototypes for the compiler
|
||||||
|
int _getrusage_base(int who, struct rusage *rusage);
|
||||||
|
int _getrusage_current(int who, struct rusage *rusage);
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
getrusage(int who, struct rusage *rusage)
|
_getrusage_base(int who, struct rusage *rusage)
|
||||||
{
|
{
|
||||||
team_usage_info info;
|
team_usage_info info;
|
||||||
|
|
||||||
@@ -30,3 +36,19 @@ getrusage(int who, struct rusage *rusage)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_getrusage_current(int who, struct rusage *rusage)
|
||||||
|
{
|
||||||
|
int err = _getrusage_base(who, rusage);
|
||||||
|
if (err != -1) {
|
||||||
|
memset(&rusage->ru_maxrss, 0, sizeof(struct rusage) -
|
||||||
|
offsetof(struct rusage, ru_maxrss));
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("_getrusage_base", "getrusage@", "BASE");
|
||||||
|
DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("_getrusage_current", "getrusage@@",
|
||||||
|
"1_BETA3");
|
||||||
|
|||||||
Reference in New Issue
Block a user