getrlimit.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Linux getrlimit implementation (32 bits rlim_t).
  2. Copyright (C) 2016-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <errno.h>
  16. #include <sys/resource.h>
  17. #include <sys/types.h>
  18. #include <shlib-compat.h>
  19. #if !__RLIM_T_MATCHES_RLIM64_T
  20. /* The __NR_getrlimit compatibility implementation is required iff
  21. __NR_ugetrlimit is also defined (meaning an old broken RLIM_INFINITY
  22. definition). */
  23. # ifndef __NR_ugetrlimit
  24. # define __NR_ugetrlimit __NR_getrlimit
  25. # undef SHLIB_COMPAT
  26. # define SHLIB_COMPAT(a, b, c) 0
  27. # endif
  28. int
  29. __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim)
  30. {
  31. return INLINE_SYSCALL_CALL (ugetrlimit, resource, rlim);
  32. }
  33. weak_alias (__new_getrlimit, __getrlimit)
  34. hidden_weak (__getrlimit)
  35. # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
  36. /* Back compatible 2Gig limited rlimit. */
  37. int
  38. __old_getrlimit (enum __rlimit_resource resource, struct rlimit *rlim)
  39. {
  40. return INLINE_SYSCALL_CALL (getrlimit, resource, rlim);
  41. }
  42. compat_symbol (libc, __old_getrlimit, getrlimit, GLIBC_2_0);
  43. versioned_symbol (libc, __new_getrlimit, getrlimit, GLIBC_2_2);
  44. # else
  45. weak_alias (__new_getrlimit, getrlimit)
  46. # endif
  47. #endif /* __RLIM_T_MATCHES_RLIM64_T */