[PATCH 078/114] Add <sys/resource.h> header for Phoenix.
Jakub Sejdak
jakub.sejdak@phoesys.com
Mon Apr 11 10:36:00 GMT 2016
From: Kuba Sejdak <jakub.sejdak@phoesys.com>
---
newlib/libc/sys/phoenix/sys/resource.h | 115 +++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
create mode 100644 newlib/libc/sys/phoenix/sys/resource.h
diff --git a/newlib/libc/sys/phoenix/sys/resource.h b/newlib/libc/sys/phoenix/sys/resource.h
new file mode 100644
index 0000000..4c5d332
--- /dev/null
+++ b/newlib/libc/sys/phoenix/sys/resource.h
@@ -0,0 +1,115 @@
+/* Copyright (C) 2012-2016 Phoenix Systems (http://www.phoesys.com/).
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_RESOURCE_H
+#define _SYS_RESOURCE_H
+
+#include <sys/time.h>
+#include <sys/types.h>
+
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN (-1)
+#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */
+#define RUSAGE_THREAD 1 /* Only the calling thread */
+
+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 */
+};
+
+typedef unsigned long rlim_t;
+
+struct rlimit {
+ rlim_t rlim_cur;
+ rlim_t rlim_max;
+};
+
+#define RLIM64_INFINITY (~0ULL)
+
+struct rlimit64 {
+ uint64_t rlim_cur;
+ uint64_t rlim_max;
+};
+
+#define PRIO_MIN (-20)
+#define PRIO_MAX 20
+#define PRIO_PROCESS 0
+#define PRIO_PGRP 1
+#define PRIO_USER 2
+
+/*
+ * Limit the stack by to some sane default: root can always
+ * increase this limit if needed. 8MB seems reasonable.
+ */
+#define _STK_LIM (8 * 1024 * 1024)
+
+/*
+ * GPG2 wants 64kB of mlocked memory, to make sure pass phrases
+ * and other sensitive information are never written to disk.
+ */
+#define MLOCK_LIMIT ((PAGE_SIZE > 64 * 1024) ? PAGE_SIZE : 64 * 1024)
+
+#define RLIMIT_CPU 0 /* CPU time in sec */
+#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_OFILE RLIMIT_NOFILE
+#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 RLIMIT_NICE 13 /* Max nice prio allowed to raise to 0-39 for nice level 19 .. -20 */
+#define RLIMIT_RTPRIO 14 /* Maximum realtime priority */
+#define RLIMIT_RTTIME 15 /* Timeout for RT tasks in us */
+#define RLIM_NLIMITS 16
+
+#ifndef RLIM_INFINITY
+#define RLIM_INFINITY (~0UL)
+#endif
+
+/* RLIMIT_STACK default maximum - some architectures override it. */
+#ifndef _STK_LIM_MAX
+#define _STK_LIM_MAX RLIM_INFINITY
+#endif
+
+int getpriority(int which, id_t who);
+int setpriority(int which, id_t who, int prio);
+int getrlimit(int resource, struct rlimit *rlim);
+int setrlimit(int resource, const struct rlimit *rlim);
+int getrusage(int who, struct rusage *usage);
+
+#endif
--
2.5.0
More information about the Newlib
mailing list