summaryrefslogtreecommitdiff
path: root/libc/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps')
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_arch_features.h3
-rw-r--r--libc/sysdeps/linux/common/getrlimit.c33
-rw-r--r--libc/sysdeps/linux/common/getrlimit64.c7
-rw-r--r--libc/sysdeps/linux/common/setrlimit.c46
-rw-r--r--libc/sysdeps/linux/common/setrlimit64.c5
-rw-r--r--libc/sysdeps/linux/i386/bits/uClibc_arch_features.h3
-rw-r--r--libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h3
-rw-r--r--libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h3
-rw-r--r--libc/sysdeps/linux/sh/bits/uClibc_arch_features.h3
9 files changed, 86 insertions, 20 deletions
diff --git a/libc/sysdeps/linux/common/bits/uClibc_arch_features.h b/libc/sysdeps/linux/common/bits/uClibc_arch_features.h
index 6780a9dd6..7b666e175 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_arch_features.h
@@ -20,6 +20,9 @@
/* does your target have a broken create_module() ? */
#undef __UCLIBC_BROKEN_CREATE_MODULE__
+/* does your target have to worry about older [gs]etrlimit() ? */
+#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
+
/* does your target prefix all symbols with an _ ? */
#define __UCLIBC_NO_UNDERSCORES__
diff --git a/libc/sysdeps/linux/common/getrlimit.c b/libc/sysdeps/linux/common/getrlimit.c
index 70d038a76..dfaedb3e5 100644
--- a/libc/sysdeps/linux/common/getrlimit.c
+++ b/libc/sysdeps/linux/common/getrlimit.c
@@ -7,25 +7,37 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#define getrlimit64 __hide_getrlimit64
#include "syscalls.h"
#include <unistd.h>
#include <sys/resource.h>
+#undef getrlimit64
libc_hidden_proto(getrlimit)
-#ifdef __NR_ugetrlimit
-# define __NR___ugetrlimit __NR_ugetrlimit
-static inline
-_syscall2(int, __ugetrlimit, enum __rlimit_resource, resource,
- struct rlimit *, rlim);
+/* Only wrap getrlimit if the new ugetrlimit is not present and getrlimit sucks */
+
+#if defined(__NR_ugetrlimit)
+
+/* just call ugetrlimit() */
+# define __NR___syscall_ugetrlimit __NR_ugetrlimit
+static always_inline
+_syscall2(int, __syscall_ugetrlimit, enum __rlimit_resource, resource,
+ struct rlimit *, rlim);
int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
{
- return (__ugetrlimit(resource, rlimits));
+ return (__syscall_ugetrlimit(resource, rlimits));
}
-#else /* __NR_ugetrlimit */
+#elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
+
+/* We don't need to wrap getrlimit() */
+_syscall2(int, getrlimit, __rlimit_resource_t, resource,
+ struct rlimit *, rlim);
-/* Only include the old getrlimit if the new one (ugetrlimit) is not around */
+#else
+
+/* we have to handle old style getrlimit() */
# define __NR___syscall_getrlimit __NR_getrlimit
static inline
_syscall2(int, __syscall_getrlimit, int, resource, struct rlimit *, rlim);
@@ -48,4 +60,9 @@ int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
return result;
}
#endif
+
libc_hidden_def(getrlimit)
+
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias(getrlimit, getrlimit64)
+#endif
diff --git a/libc/sysdeps/linux/common/getrlimit64.c b/libc/sysdeps/linux/common/getrlimit64.c
index 6f670c001..d134287d5 100644
--- a/libc/sysdeps/linux/common/getrlimit64.c
+++ b/libc/sysdeps/linux/common/getrlimit64.c
@@ -33,10 +33,13 @@
#include <sys/types.h>
#include <sys/resource.h>
+#include <bits/wordsize.h>
-libc_hidden_proto(getrlimit)
+/* the regular getrlimit will work just fine for 64bit users */
+
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32
-#if defined __UCLIBC_HAS_LFS__
+libc_hidden_proto(getrlimit)
/* Put the soft and hard limits for RESOURCE in *RLIMITS.
Returns 0 if successful, -1 if not (and sets errno). */
diff --git a/libc/sysdeps/linux/common/setrlimit.c b/libc/sysdeps/linux/common/setrlimit.c
index 7a53e043f..58cfd469f 100644
--- a/libc/sysdeps/linux/common/setrlimit.c
+++ b/libc/sysdeps/linux/common/setrlimit.c
@@ -7,36 +7,64 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#define setrlimit64 __hide_setrlimit64
#include "syscalls.h"
#include <unistd.h>
#include <sys/resource.h>
+#undef setrlimit64
libc_hidden_proto(setrlimit)
-#ifndef __NR_ugetrlimit
-/* Only wrap setrlimit if the new ugetrlimit is not present */
+/* Only wrap setrlimit if the new usetrlimit is not present and setrlimit sucks */
-#define __NR___syscall_setrlimit __NR_setrlimit
-#define RMIN(x, y) ((x) < (y) ? (x) : (y))
+#if defined(__NR_usetrlimit)
+
+/* just call usetrlimit() */
+# define __NR___syscall_usetrlimit __NR_usetrlimit
+static always_inline
+_syscall2(int, __syscall_usetrlimit, enum __rlimit_resource, resource,
+ const struct rlimit *, rlim);
+int setrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
+{
+ return (__syscall_usetrlimit(resource, rlimits));
+}
+
+#elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
+
+/* We don't need to wrap setrlimit() */
+_syscall2(int, setrlimit, __rlimit_resource_t, resource,
+ const struct rlimit *, rlim);
+
+#else
+
+/* we have to handle old style setrlimit() */
+# define __NR___syscall_setrlimit __NR_setrlimit
static inline
_syscall2(int, __syscall_setrlimit, int, resource, const struct rlimit *, rlim);
+
int setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits)
{
struct rlimit rlimits_small;
+ if (rlimits == NULL) {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
/* We might have to correct the limits values. Since the old values
* were signed the new values might be too large. */
+# define RMIN(x, y) ((x) < (y) ? (x) : (y))
rlimits_small.rlim_cur = RMIN((unsigned long int) rlimits->rlim_cur,
RLIM_INFINITY >> 1);
rlimits_small.rlim_max = RMIN((unsigned long int) rlimits->rlim_max,
RLIM_INFINITY >> 1);
+#undef RMIN
return (__syscall_setrlimit(resource, &rlimits_small));
}
+#endif
-#undef RMIN
+libc_hidden_def(setrlimit)
-#else /* We don't need to wrap setrlimit */
-_syscall2(int, setrlimit, __rlimit_resource_t, resource,
- const struct rlimit *, rlim);
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias(setrlimit, setrlimit64)
#endif
-libc_hidden_def(setrlimit)
diff --git a/libc/sysdeps/linux/common/setrlimit64.c b/libc/sysdeps/linux/common/setrlimit64.c
index b0d84de53..9b338f094 100644
--- a/libc/sysdeps/linux/common/setrlimit64.c
+++ b/libc/sysdeps/linux/common/setrlimit64.c
@@ -33,8 +33,11 @@
#include <sys/types.h>
#include <sys/resource.h>
+#include <bits/wordsize.h>
-#if defined __UCLIBC_HAS_LFS__
+/* the regular setrlimit will work just fine for 64bit users */
+
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32
libc_hidden_proto(setrlimit)
diff --git a/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h b/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
index 44ec3efd0..718ab2a9c 100644
--- a/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
@@ -17,6 +17,9 @@
/* does your target have a broken create_module() ? */
#define __UCLIBC_BROKEN_CREATE_MODULE__
+/* does your target have to worry about older [gs]etrlimit() ? */
+#define __UCLIBC_HANDLE_OLDER_RLIMIT__
+
/* does your target prefix all symbols with an _ ? */
#define __UCLIBC_NO_UNDERSCORES__
diff --git a/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h b/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h
index 4ad5fd6cf..a94803749 100644
--- a/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h
@@ -21,6 +21,9 @@
/* does your target have a broken create_module() ? */
#define __UCLIBC_BROKEN_CREATE_MODULE__
+/* does your target have to worry about older [gs]etrlimit() ? */
+#define __UCLIBC_HANDLE_OLDER_RLIMIT__
+
/* does your target prefix all symbols with an _ ? */
#define __UCLIBC_NO_UNDERSCORES__
diff --git a/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h b/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h
index e2505ae04..1e994ec68 100644
--- a/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h
@@ -17,6 +17,9 @@
/* does your target have a broken create_module() ? */
#undef __UCLIBC_BROKEN_CREATE_MODULE__
+/* does your target have to worry about older [gs]etrlimit() ? */
+#define __UCLIBC_HANDLE_OLDER_RLIMIT__
+
/* does your target prefix all symbols with an _ ? */
#define __UCLIBC_NO_UNDERSCORES__
diff --git a/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h b/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h
index 350457979..7b9a0efbb 100644
--- a/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h
@@ -21,6 +21,9 @@
/* does your target have a broken create_module() ? */
#undef __UCLIBC_BROKEN_CREATE_MODULE__
+/* does your target have to worry about older [gs]etrlimit() ? */
+#define __UCLIBC_HANDLE_OLDER_RLIMIT__
+
/* does your target prefix all symbols with an _ ? */
#define __UCLIBC_NO_UNDERSCORES__