diff options
| author | "Steven J. Hill" <sjhill@realitydiluted.com> | 2006-02-28 03:18:23 +0000 |
|---|---|---|
| committer | "Steven J. Hill" <sjhill@realitydiluted.com> | 2006-02-28 03:18:23 +0000 |
| commit | 675d62ac876ffe4719580d45b8c9469934ccf6d7 (patch) | |
| tree | e666bd4a1d816842c070e4928715d66b82655fc2 /libc/sysdeps/linux/common/setrlimit.c | |
| parent | fd666fca933f7241ff75d06ff36c9282fd443335 (diff) | |
| download | uClibc-alpine-675d62ac876ffe4719580d45b8c9469934ccf6d7.tar.bz2 uClibc-alpine-675d62ac876ffe4719580d45b8c9469934ccf6d7.tar.xz | |
Merge from trunk.
Diffstat (limited to 'libc/sysdeps/linux/common/setrlimit.c')
| -rw-r--r-- | libc/sysdeps/linux/common/setrlimit.c | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/libc/sysdeps/linux/common/setrlimit.c b/libc/sysdeps/linux/common/setrlimit.c index 9c5466a09..ba2ea0728 100644 --- a/libc/sysdeps/linux/common/setrlimit.c +++ b/libc/sysdeps/linux/common/setrlimit.c @@ -2,44 +2,69 @@ /* * setrlimit() for uClibc * - * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org> + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> * - * GNU Library General Public License (LGPL) version 2 or later. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ +#define setrlimit64 __hide_setrlimit64 #include "syscalls.h" - -#ifndef __NR_ugetrlimit -/* Only wrap setrlimit if the new ugetrlimit is not present */ - -#define __NR___syscall_setrlimit __NR_setrlimit #include <unistd.h> #include <sys/resource.h> -#define RMIN(x, y) ((x) < (y) ? (x) : (y)) +#undef setrlimit64 + +libc_hidden_proto(setrlimit) + +/* Only wrap setrlimit if the new usetrlimit is not present and setrlimit sucks */ + +#if defined(__NR_usetrlimit) + +/* just call usetrlimit() */ +# define __NR___syscall_usetrlimit __NR_usetrlimit +static 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 attribute_hidden __setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits) + +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 - -#else /* We don't need to wrap setrlimit */ +libc_hidden_def(setrlimit) -#include <unistd.h> -struct rlimit; -#define __NR___setrlimit __NR_setrlimit -attribute_hidden _syscall2(int, __setrlimit, unsigned int, resource, - const struct rlimit *, rlim); +#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64 +strong_alias(setrlimit, setrlimit64) #endif - -strong_alias(__setrlimit,setrlimit) |
