[klibc] [klibc:time64] resource: Avoid using

klibc-bot for Ben Hutchings
Sat, 14 Jan 2023 22:03:08 -0000

Commit-ID:  d4ab7343978bbec7141f8462236ba6a47574205f
Gitweb:
http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=d4ab7343978bbec7141f8462236ba6a47574205f
Author:     Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Sat, 14 Jan 2023 03:15:20 +0100
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 14 Jan 2023 18:09:28 +0100

[klibc] resource: Avoid using <linux/resource.h>

Our <sys/resource.h> includes <linux/resource.h>, which includes
<linux/time.h>, which conflicts with 64-bit time definitions.

Copy the definitions we actually need instead of including
<linux/resource.h>.

Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/include/sys/resource.h | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/usr/include/sys/resource.h b/usr/include/sys/resource.h
index 5d8bd525..94ed28a5 100644
--- a/usr/include/sys/resource.h
+++ b/usr/include/sys/resource.h
@@ -6,8 +6,39 @@
 #define _SYS_RESOURCE_H

 #include <klibc/extern.h>
-#include <sys/types.h>		/* MUST be included before linux/resource.h */
-#include <linux/resource.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+#define RUSAGE_SELF	0
+#define RUSAGE_CHILDREN	(-1)
+#define RUSAGE_BOTH	(-2)
+#define RUSAGE_THREAD	1
+
+struct	rusage {
+	struct timeval ru_utime;	/* user time used */
+	struct timeval ru_stime;	/* system time used */
+	__kernel_long_t	ru_maxrss;	/* maximum resident set size */
+	__kernel_long_t	ru_ixrss;	/* integral shared memory size */
+	__kernel_long_t	ru_idrss;	/* integral unshared data size */
+	__kernel_long_t	ru_isrss;	/* integral unshared stack size */
+	__kernel_long_t	ru_minflt;	/* page reclaims */
+	__kernel_long_t	ru_majflt;	/* page faults */
+	__kernel_long_t	ru_nswap;	/* swaps */
+	__kernel_long_t	ru_inblock;	/* block input operations */
+	__kernel_long_t	ru_oublock;	/* block output operations */
+	__kernel_long_t	ru_msgsnd;	/* messages sent */
+	__kernel_long_t	ru_msgrcv;	/* messages received */
+	__kernel_long_t	ru_nsignals;	/* signals received */
+	__kernel_long_t	ru_nvcsw;	/* voluntary context switches */
+	__kernel_long_t	ru_nivcsw;	/* involuntary " */
+};
+
+#define PRIO_MIN	(-20)
+#define PRIO_MAX	20
+
+#define PRIO_PROCESS	0
+#define PRIO_PGRP	1
+#define PRIO_USER	2

 __extern int getpriority(int, int);
 __extern int setpriority(int, int, int);