diff --git a/headers/posix/sys/resource.h b/headers/posix/sys/resource.h index c27cfda0d9..95de2b7ae4 100644 --- a/headers/posix/sys/resource.h +++ b/headers/posix/sys/resource.h @@ -44,6 +44,22 @@ struct rlimit { struct rusage { struct timeval ru_utime; /* user 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 diff --git a/src/libs/bsd/Jamfile b/src/libs/bsd/Jamfile index 3ec438e8c7..0b3c70d046 100644 --- a/src/libs/bsd/Jamfile +++ b/src/libs/bsd/Jamfile @@ -5,6 +5,9 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ; local architectureObject ; for architectureObject in [ MultiArchSubDirSetup ] { on $(architectureObject) { + SetVersionScript [ MultiArchDefaultGristFiles libbsd.so ] : + libbsd_versions ; + SharedLibrary [ MultiArchDefaultGristFiles libbsd.so ] : daemon.c err.c diff --git a/src/libs/bsd/libbsd_versions b/src/libs/bsd/libbsd_versions new file mode 100644 index 0000000000..dd0872b33b --- /dev/null +++ b/src/libs/bsd/libbsd_versions @@ -0,0 +1,5 @@ +LIBBSD_BASE { +}; + +LIBBSD_1_BETA3 { +} LIBBSD_BASE; diff --git a/src/libs/bsd/wait.c b/src/libs/bsd/wait.c index 57fc328992..15f0181de3 100644 --- a/src/libs/bsd/wait.c +++ b/src/libs/bsd/wait.c @@ -15,16 +15,23 @@ extern pid_t _waitpid(pid_t pid, int* _status, int options, 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 -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 -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; pid_t waitPid = _waitpid(pid, status, options, @@ -34,9 +41,38 @@ wait4(pid_t pid, int *status, int options, struct rusage *rusage) rusage->ru_utime.tv_usec = info.user_time % 1000000; rusage->ru_stime.tv_sec = info.kernel_time / 1000000; - rusage->ru_stime.tv_usec = info.kernel_time % 1000000; + rusage->ru_stime.tv_usec = info.kernel_time % 1000000; } - + 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"); + diff --git a/src/system/libroot/libroot_versions b/src/system/libroot/libroot_versions index 4d8340247e..4478f27143 100644 --- a/src/system/libroot/libroot_versions +++ b/src/system/libroot/libroot_versions @@ -9,3 +9,6 @@ LIBROOT_1_ALPHA4 { LIBROOT_1_ALPHA5 { } LIBROOT_1_ALPHA4; + +LIBROOT_1_BETA3 { +} LIBROOT_1_ALPHA5; diff --git a/src/system/libroot/posix/sys/getrusage.c b/src/system/libroot/posix/sys/getrusage.c index df56ece99a..1d8b4e0d51 100644 --- a/src/system/libroot/posix/sys/getrusage.c +++ b/src/system/libroot/posix/sys/getrusage.c @@ -9,10 +9,16 @@ #include #include +#include + + +// prototypes for the compiler +int _getrusage_base(int who, struct rusage *rusage); +int _getrusage_current(int who, struct rusage *rusage); int -getrusage(int who, struct rusage *rusage) +_getrusage_base(int who, struct rusage *rusage) { team_usage_info info; @@ -30,3 +36,19 @@ getrusage(int who, struct rusage *rusage) 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");