This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new d67693aebea include/sys/resource.h: Add the 4.3BSD fields to struct
rusage.
d67693aebea is described below
commit d67693aebea88d295906cafc05046ec3f7d23ab8
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Oct 26 00:30:22 2026 +0100
include/sys/resource.h: Add the 4.3BSD fields to struct rusage.
struct rusage had ru_utime, ru_stime and ru_maxrss only. POSIX
requires ru_utime and ru_stime only, but Linux, macOS and the BSDs have
the 14 fields of 4.3BSD, and programs use them without a check
(uv_getrusage() of libuv, for example). Such programs did not compile.
Add ru_ixrss, ru_idrss, ru_isrss, ru_minflt, ru_majflt, ru_nswap,
ru_inblock, ru_oublock, ru_msgsnd, ru_msgrcv, ru_nsignals, ru_nvcsw and
ru_nivcsw. getrusage() clears the whole structure, so they are zero.
The size of struct rusage changes: programs that use getrusage(),
wait3() or wait4() must be built again.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
include/sys/resource.h | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/include/sys/resource.h b/include/sys/resource.h
index 093455a04ae..23c59164198 100644
--- a/include/sys/resource.h
+++ b/include/sys/resource.h
@@ -124,13 +124,29 @@ struct rlimit
rlim_t rlim_max; /* The hard limit */
};
-/* Minimal, compliant rusage structure */
+/* rusage structure: the fields of 4.3BSD. POSIX requires ru_utime and
+ * ru_stime only. getrusage() sets the fields that NuttX does not count
+ * to zero.
+ */
struct rusage
{
- struct timeval ru_utime; /* User time used */
- struct timeval ru_stime; /* System time used */
- long ru_maxrss; /* maximum resident set size */
+ struct timeval ru_utime; /* User time used */
+ struct timeval ru_stime; /* System time used */
+ long ru_maxrss; /* Maximum resident set size */
+ long ru_ixrss; /* Integral shared memory size */
+ long ru_idrss; /* Integral unshared data size */
+ long ru_isrss; /* Integral unshared stack size */
+ long ru_minflt; /* Page reclaims (soft page faults) */
+ long ru_majflt; /* Page faults (hard page faults) */
+ long ru_nswap; /* Swaps */
+ long ru_inblock; /* Block input operations */
+ long ru_oublock; /* Block output operations */
+ long ru_msgsnd; /* IPC messages sent */
+ long ru_msgrcv; /* IPC messages received */
+ long ru_nsignals; /* Signals received */
+ long ru_nvcsw; /* Voluntary context switches */
+ long ru_nivcsw; /* Involuntary context switches */
};
/****************************************************************************