[klibc] [PATCH] get rid of asm/page.h usage
Olaf Hering
olh at suse.de
Mon Feb 14 05:33:22 PST 2005
On Mon, Feb 14, Olaf Hering wrote:
> On Mon, Feb 14, Olaf Hering wrote:
>
> >
> > I think there is no need to special case some archs, just get the thing
> > during runtime on all archs.
>
> Another user of asm/page.h is linux/resource.h,
> #define MLOCK_LIMIT (8 * PAGE_SIZE)
>
> I think klibc should use its own defines in include/sys/resource.h and
> provide a include/arch/*/klibc/archresource.h with defines for a few
> archs which define __ARCH_RLIMIT_ORDER.
Here is a patch which implements this:
Index: include/arch/arm/klibc/archresource.h
===================================================================
--- include/arch/arm/klibc/archresource.h (revision 0)
+++ include/arch/arm/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/arm/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/parisc/klibc/archresource.h
===================================================================
--- include/arch/parisc/klibc/archresource.h (revision 0)
+++ include/arch/parisc/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/parisc/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/ppc/klibc/archresource.h
===================================================================
--- include/arch/ppc/klibc/archresource.h (revision 0)
+++ include/arch/ppc/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/ppc/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/mips64/klibc/archresource.h
===================================================================
--- include/arch/mips64/klibc/archresource.h (revision 0)
+++ include/arch/mips64/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/mips64/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/sparc64/klibc/archresource.h
===================================================================
--- include/arch/sparc64/klibc/archresource.h (revision 0)
+++ include/arch/sparc64/klibc/archresource.h (revision 0)
@@ -0,0 +1,32 @@
+/*
+ * arch/sparc64/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/*
+ * Resource limits
+ */
+
+#define RLIMIT_CPU 0 /* CPU time in ms */
+#define RLIMIT_FSIZE 1 /* Maximum filesize */
+#define RLIMIT_DATA 2 /* max data size */
+#define RLIMIT_STACK 3 /* max stack size */
+#define RLIMIT_CORE 4 /* max core file size */
+#define RLIMIT_RSS 5 /* max resident set size */
+#define RLIMIT_NOFILE 6 /* max number of open files */
+#define RLIMIT_NPROC 7 /* max number of processes */
+#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */
+#define RLIMIT_AS 9 /* address space limit */
+#define RLIMIT_LOCKS 10 /* maximum file locks held */
+#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
+#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
+
+#define RLIM_NLIMITS 13
+#define __ARCH_RLIMIT_ORDER
+
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/m32r/klibc/archresource.h
===================================================================
--- include/arch/m32r/klibc/archresource.h (revision 0)
+++ include/arch/m32r/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/m32r/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/alpha/klibc/archresource.h
===================================================================
--- include/arch/alpha/klibc/archresource.h (revision 0)
+++ include/arch/alpha/klibc/archresource.h (revision 0)
@@ -0,0 +1,39 @@
+/*
+ * arch/alpha/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/*
+ * Resource limits
+ */
+
+#define RLIMIT_CPU 0 /* CPU time in ms */
+#define RLIMIT_FSIZE 1 /* Maximum filesize */
+#define RLIMIT_DATA 2 /* max data size */
+#define RLIMIT_STACK 3 /* max stack size */
+#define RLIMIT_CORE 4 /* max core file size */
+#define RLIMIT_RSS 5 /* max resident set size */
+#define RLIMIT_NOFILE 6 /* max number of open files */
+#define RLIMIT_AS 7 /* address space limit(?) */
+#define RLIMIT_NPROC 8 /* max number of processes */
+#define RLIMIT_MEMLOCK 9 /* max locked-in-memory address space */
+#define RLIMIT_LOCKS 10 /* maximum file locks held */
+#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
+#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
+
+#define RLIM_NLIMITS 13
+#define __ARCH_RLIMIT_ORDER
+
+/*
+ * SuS says limits have to be unsigned. Fine, it's unsigned, but
+ * we retain the old value for compatibility, especially with DU.
+ * When you run into the 2^63 barrier, you call me.
+ */
+#define RLIM_INFINITY 0x7ffffffffffffffful
+
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/m68k/klibc/archresource.h
===================================================================
--- include/arch/m68k/klibc/archresource.h (revision 0)
+++ include/arch/m68k/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/m68k/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/s390x/klibc/archresource.h
===================================================================
--- include/arch/s390x/klibc/archresource.h (revision 0)
+++ include/arch/s390x/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/s390x/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/i386/klibc/archresource.h
===================================================================
--- include/arch/i386/klibc/archresource.h (revision 0)
+++ include/arch/i386/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/i386/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/ppc64/klibc/archresource.h
===================================================================
--- include/arch/ppc64/klibc/archresource.h (revision 0)
+++ include/arch/ppc64/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/ppc64/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/x86_64/klibc/archresource.h
===================================================================
--- include/arch/x86_64/klibc/archresource.h (revision 0)
+++ include/arch/x86_64/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/x86_64/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/s390/klibc/archresource.h
===================================================================
--- include/arch/s390/klibc/archresource.h (revision 0)
+++ include/arch/s390/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/s390/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/cris/klibc/archresource.h
===================================================================
--- include/arch/cris/klibc/archresource.h (revision 0)
+++ include/arch/cris/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/cris/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/ia64/klibc/archresource.h
===================================================================
--- include/arch/ia64/klibc/archresource.h (revision 0)
+++ include/arch/ia64/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/ia64/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/mips/klibc/archresource.h
===================================================================
--- include/arch/mips/klibc/archresource.h (revision 0)
+++ include/arch/mips/klibc/archresource.h (revision 0)
@@ -0,0 +1,36 @@
+/*
+ * arch/mips/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/*
+ * Resource limits
+ */
+#define RLIMIT_CPU 0 /* CPU time in ms */
+#define RLIMIT_FSIZE 1 /* Maximum filesize */
+#define RLIMIT_DATA 2 /* max data size */
+#define RLIMIT_STACK 3 /* max stack size */
+#define RLIMIT_CORE 4 /* max core file size */
+#define RLIMIT_NOFILE 5 /* max number of open files */
+#define RLIMIT_AS 6 /* mapped memory */
+#define RLIMIT_RSS 7 /* max resident set size */
+#define RLIMIT_NPROC 8 /* max number of processes */
+#define RLIMIT_MEMLOCK 9 /* max locked-in-memory address space */
+#define RLIMIT_LOCKS 10 /* maximum file locks held */
+#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
+#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
+
+#define RLIM_NLIMITS 13 /* Number of limit flavors. */
+#define __ARCH_RLIMIT_ORDER
+
+/*
+ * SuS says limits have to be unsigned.
+ * Which makes a ton more sense anyway.
+ */
+#define RLIM_INFINITY 0x7fffffffUL
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/sparc/klibc/archresource.h
===================================================================
--- include/arch/sparc/klibc/archresource.h (revision 0)
+++ include/arch/sparc/klibc/archresource.h (revision 0)
@@ -0,0 +1,38 @@
+/*
+ * arch/sparc/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/*
+ * Resource limits
+ */
+
+#define RLIMIT_CPU 0 /* CPU time in ms */
+#define RLIMIT_FSIZE 1 /* Maximum filesize */
+#define RLIMIT_DATA 2 /* max data size */
+#define RLIMIT_STACK 3 /* max stack size */
+#define RLIMIT_CORE 4 /* max core file size */
+#define RLIMIT_RSS 5 /* max resident set size */
+#define RLIMIT_NOFILE 6 /* max number of open files */
+#define RLIMIT_NPROC 7 /* max number of processes */
+#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */
+#define RLIMIT_AS 9 /* address space limit */
+#define RLIMIT_LOCKS 10 /* maximum file locks held */
+#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
+#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
+
+#define RLIM_NLIMITS 13
+#define __ARCH_RLIMIT_ORDER
+
+/*
+ * SuS says limits have to be unsigned.
+ * We make this unsigned, but keep the
+ * old value.
+ */
+#define RLIM_INFINITY 0x7fffffff
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/arch/sh/klibc/archresource.h
===================================================================
--- include/arch/sh/klibc/archresource.h (revision 0)
+++ include/arch/sh/klibc/archresource.h (revision 0)
@@ -0,0 +1,12 @@
+/*
+ * arch/sh/klibc/archresource.h
+ *
+ * Architecture-specific resource definitions
+ */
+
+#ifndef _KLIBC_ARCHRESOURCE_H
+#define _KLIBC_ARCHRESOURCE_H
+
+/* No special resource definitions for this architecture */
+
+#endif /* _KLIBC_ARCHRESOURCE_H */
Index: include/sys/resource.h
===================================================================
--- include/sys/resource.h (revision 1010)
+++ include/sys/resource.h (working copy)
@@ -6,9 +6,74 @@
#define _SYS_RESOURCE_H
#include <klibc/extern.h>
-#include <sys/types.h> /* MUST be included before linux/resource.h */
-#include <linux/resource.h>
+#include <klibc/archresource.h>
+#include <sys/types.h>
+#include <linux/time.h>
+/*
+ * Resource limits
+ */
+
+/* Allow arch to control resource order */
+#ifndef __ARCH_RLIMIT_ORDER
+#define RLIMIT_CPU 0 /* CPU time in ms */
+#define RLIMIT_FSIZE 1 /* Maximum filesize */
+#define RLIMIT_DATA 2 /* max data size */
+#define RLIMIT_STACK 3 /* max stack size */
+#define RLIMIT_CORE 4 /* max core file size */
+#define RLIMIT_RSS 5 /* max resident set size */
+#define RLIMIT_NPROC 6 /* max number of processes */
+#define RLIMIT_NOFILE 7 /* max number of open files */
+#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */
+#define RLIMIT_AS 9 /* address space limit */
+#define RLIMIT_LOCKS 10 /* maximum file locks held */
+#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
+#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
+
+#define RLIM_NLIMITS 13
+#endif
+
+/*
+ * SuS says limits have to be unsigned.
+ * Which makes a ton more sense anyway.
+ */
+#ifndef RLIM_INFINITY
+#define RLIM_INFINITY (~0UL)
+#endif
+
+#ifndef _STK_LIM_MAX
+#define _STK_LIM_MAX RLIM_INFINITY
+#endif
+
+
+struct rusage {
+ 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 */
+ long ru_majflt; /* page faults */
+ long ru_nswap; /* swaps */
+ long ru_inblock; /* block input operations */
+ long ru_oublock; /* block output operations */
+ long ru_msgsnd; /* messages sent */
+ long ru_msgrcv; /* messages received */
+ long ru_nsignals; /* signals received */
+ long ru_nvcsw; /* voluntary context switches */
+ long ru_nivcsw; /* involuntary " */
+};
+
+struct rlimit {
+ unsigned long rlim_cur;
+ unsigned long rlim_max;
+};
+
+#define PRIO_PROCESS 0
+#define PRIO_PGRP 1
+#define PRIO_USER 2
+
__extern int getpriority(int, int);
__extern int setpriority(int, int, int);
More information about the klibc
mailing list