aboutsummaryrefslogtreecommitdiff
This patch reinstates fallback code when the 'prlimit64' system call is
missing by reverting the relevant part of this upstream commit:

  commit 695d7d138eda449678a1650a8b8b58181033353f
  Author: Joseph Myers <joseph@codesourcery.com>
  Date:   Tue May 9 14:05:09 2017 +0000

      Assume prlimit64 is available.

The fallback code is useful on systems that lack 'prlimit64', such as the
2.6.32-on-steroid kernel found on RHEL 6:

  <https://lists.gnu.org/archive/html/guix-devel/2018-03/msg00349.html>

diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c
index 37c173286f..56af3c0646 100644
--- b/sysdeps/unix/sysv/linux/getrlimit64.c
+++ a/sysdeps/unix/sysv/linux/getrlimit64.c
@@ -35,7 +35,40 @@
 int
 __getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
 {
-  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
+#ifdef __NR_prlimit64
+  int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
+  if (res == 0 || errno != ENOSYS)
+    return res;
+#endif
+
+/* The fallback code only makes sense if the platform supports either
+   __NR_ugetrlimit and/or __NR_getrlimit.  */
+#if defined (__NR_ugetrlimit) || defined (__NR_getrlimit)
+# ifndef __NR_ugetrlimit
+#  define __NR_ugetrlimit __NR_getrlimit
+# endif
+# if __RLIM_T_MATCHES_RLIM64_T
+#  define rlimits32 (*rlimits)
+# else
+  struct rlimit rlimits32;
+# endif
+
+  if (INLINE_SYSCALL_CALL (ugetrlimit, resource, &rlimits32) < 0)
+    return -1;
+
+# if !__RLIM_T_MATCHES_RLIM64_T
+  if (rlimits32.rlim_cur == RLIM_INFINITY)
+    rlimits->rlim_cur = RLIM64_INFINITY;
+  else
+    rlimits->rlim_cur = rlimits32.rlim_cur;
+  if (rlimits32.rlim_max == RLIM_INFINITY)
+    rlimits->rlim_max = RLIM64_INFINITY;
+  else
+    rlimits->rlim_max = rlimits32.rlim_max;
+# endif /* !__RLIM_T_MATCHES_RLIM64_T */
+#endif /* defined (__NR_ugetrlimit) || defined (__NR_getrlimit)  */
+
+  return 0;
 }
 libc_hidden_def (__getrlimit64)
 
diff --git a/sysdeps/unix/sysv/linux/setrlimit.c b/sysdeps/unix/sysv/linux/setrlimit.c
index 01812ac355..8773c78236 100644
--- b/sysdeps/unix/sysv/linux/setrlimit.c
+++ a/sysdeps/unix/sysv/linux/setrlimit.c
@@ -34,6 +34,7 @@
 int
 __setrlimit (enum __rlimit_resource resource, const struct rlimit *rlim)
 {
+# ifdef __NR_prlimit64
   struct rlimit64 rlim64;
 
   if (rlim->rlim_cur == RLIM_INFINITY)
@@ -45,7 +46,11 @@
   else
     rlim64.rlim_max = rlim->rlim_max;
 
-  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
+  int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
+  if (res == 0 || errno != ENOSYS)
+    return res;
+# endif
+  return INLINE_SYSCALL_CALL (setrlimit, resource, rlim);
 }
 
 # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c
index 2dd129d99e..db1960fc18 100644
--- b/sysdeps/unix/sysv/linux/setrlimit64.c
+++ a/sysdeps/unix/sysv/linux/setrlimit64.c
@@ -36,7 +36,36 @@
 int
 __setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
 {
-  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
+  int res;
+
+#ifdef __NR_prlimit64
+  res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
+  if (res == 0 || errno != ENOSYS)
+    return res;
+#endif
+
+/* The fallback code only makes sense if the platform supports
+   __NR_setrlimit.  */
+#ifdef __NR_setrlimit
+# if !__RLIM_T_MATCHES_RLIM64_T
+  struct rlimit rlimits32;
+
+  if (rlimits->rlim_cur >= RLIM_INFINITY)
+    rlimits32.rlim_cur = RLIM_INFINITY;
+  else
+    rlimits32.rlim_cur = rlimits->rlim_cur;
+  if (rlimits->rlim_max >= RLIM_INFINITY)
+    rlimits32.rlim_max = RLIM_INFINITY;
+  else
+    rlimits32.rlim_max = rlimits->rlim_max;
+# else
+#  define rlimits32 (*rlimits)
+# endif
+
+  res = INLINE_SYSCALL_CALL (setrlimit, resource, &rlimits32);
+#endif
+
+  return res;
 }
 weak_alias (__setrlimit64, setrlimit64)
 
e44f2d4da20e9ad9ac44b983e5e5853'>gnu: Add rust-wayland-protocols-0.28....* gnu/packages/crates-graphics.scm (rust-wayland-protocols-0.28): New variable. (rust-wayland-protocols-0.23): Inherit from above. Nicolas Goaziou 2021-01-31gnu: Add rust-wayland-server-0.28....* gnu/packages/crates-graphics.scm (rust-wayland-server-0.28): New variable. (rust-wayland-server-0.23): Inherit from above. Nicolas Goaziou 2021-01-31gnu: Add rust-wayland-commons-0.28....* gnu/packages/crates-graphics.scm (rust-wayland-commons-0.28): New variable. (rust-wayland-commons-0.23): Inherit from above. Nicolas Goaziou 2021-01-31gnu: Add rust-x11-clipboard-0.5....* gnu/packages/crates-graphics.scm (rust-x11-clipboard-0.5): New variable. (rust-x11-clipboard-0.4): Inherit from above. Nicolas Goaziou 2021-01-31gnu: Add rust-glutin-0.26....* gnu/packages/crates-graphics.scm (rust-glutin-0.26): New variable. (rust-glutin-0.22): Inherit from above. Nicolas Goaziou 2021-01-31gnu: Add rust-core-graphics-types-0.1....* gnu/packages/crates-graphics.scm (rust-core-graphics-types-0.1): New variable. Nicolas Goaziou 2021-01-31gnu: rust-glutin-emscripten-sys-0.1: Update to 0.1.1....* gnu/packages/crates-graphics.scm (rust-glutin-emscripten-sys-0.1): Update to 0.1.1. [arguments]: Skip build. Nicolas Goaziou 2021-01-31gnu: rust-glutin-gles2-sys-0.1: Update to 0.1.5....* gnu/packages/crates-graphics.scm (rust-glutin-gles2-sys-0.1): Update to 0.1.5. [arguments]: Skip build. Nicolas Goaziou 2021-01-31gnu: rust-glutin-glx-sys-0.1: Update to 0.1.7....* gnu/packages/crates-graphics.scm (rust-glutin-glx-sys-0.1): Update to 0.1.7. [arguments]: Skip build. Nicolas Goaziou 2021-01-31gnu: rust-glutin-wgl-sys-0.1: Update to 0.1.5....* gnu/packages/crates-graphics.scm (rust-glutin-wgl-sys-0.1): Update to 0.1.5. [arguments]: Skip build. Nicolas Goaziou 2021-01-31gnu: Add rust-wayland-egl-0.28....* gnu/packages/crates-graphics.scm (rust-wayland-egl-0.28): New variable. Nicolas Goaziou 2021-01-31gnu: Add rust-winit-0.24....* gnu/packages/crates-graphics.scm (rust-winit-0.24): New variable. (rust-winit-0.20): Inherit from above. Nicolas Goaziou 2021-01-31gnu: rust-core-video-sys-0.1: Update to 0.1.4....* gnu/packages/crates-graphics.scm (rust-core-video-sys-0.1): Update to 0.1.4. Nicolas Goaziou 2021-01-31gnu: Add rust-core-graphics-0.19....* gnu/packages/crates-graphics.scm (rust-core-graphics-0.19): New variable. Nicolas Goaziou 2021-01-31gnu: Add rust-core-graphics-0.21....* gnu/packages/crates-graphics.scm (rust-core-graphics-0.21): New variable. (rust-core-graphics-0.17): Inherit from above. Nicolas Goaziou 2021-01-31gnu: rust-png-0.16: Update to 0.16.8....* gnu/packages/crates-graphics.scm (rust-png-0.16): Update to 0.16.8. Nicolas Goaziou 2021-01-30gnu: rust-downcast-rs-1: Drop minor version from name....* gnu/packages/crates-io.scm (rust-downcast-rs-1): Drop minor version from name. * gnu/packages/crates-graphics.scm (rust-wayland-client-0.23): (rust-wayland-client-0.21): (rust-wayland-server-0.23): (rust-wayland-server-0.21): Apply renaming. Nicolas Goaziou 2021-01-30gnu: rust-downcast-rs-1.1: Remove variable....* gnu/packages/crates-io.scm (rust-downcast-rs-1.1): Remove variable. * gnu/packages/crates-graphics.scm (rust-wayland-client-0.23): (rust-wayland-client-0.21): (rust-wayland-server-0.23): (rust-wayland-server-0.21): Refer to rust-downcast-rs-1.2 instead. Nicolas Goaziou 2021-01-23gnu: rust-xdg-2: Drop minor version from variable name....* gnu/packages/crates-io.scm (rust-xdg-2): Renamed from rust-xdg-2.2. (rust-afl-0.8): (rust-afl-0.5): * gnu/packages/terminals.scm (alacritty): * gnu/packages/crates-graphics.scm (rust-andrew-0.2): Apply renaming. Nicolas Goaziou 2020-12-07gnu: Add rust-aom-sys-0.2....* gnu/packages/crates-graphics.scm (rust-aom-sys-0.2): New variable. (rust-aom-sys-0.1): Inherit from rust-aom-sys-0.2. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Antoine Côté 2020-12-04gnu: rust-x11-2: Update to 2.18.2....* gnu/packages/crates-graphics.scm (rust-x11-2): Update to 2.18.2. [home-page]: Drop ".git" suffix. [description]: Make it a full sentence. [license]: Update license to expat. Nicolas Goaziou 2020-11-22build-system/cargo: Set libclang environment variable when available....* guix/build/cargo-build-system.scm (configure): When clang is available in the build environment set the LIBCLANG_PATH variable. * gnu/packages/crates-graphics.scm (rust-aom-sys-0.1, uust-dav1d-sys-0.3), * gnu/packages/crates-io.scm (rust-bindgen-0.55, rust-bindgen-0.54, rust-bindgen-0.53, rust-bindgen-0.52, rust-cexpr-0.4, rust-cexpr-0.3, rust-cexpr-0.2, rust-clang-sys-1, rust-clang-sys-0.29, rust-clang-sys-0.26, rust-clang-sys-0.22, rust-clang-sys-0.11, rust-libpijul-0.12, rust-nettle-7, rust-nettle-sys-2, rust-sequoia-openpgp-0.9)[arguments]: Remove phases which set an environment variable to find clang. [inputs]: Rename instances of libclang with clang. Efraim Flashner 2020-10-12gnu: rust-percent-encoding-2.1: Remove minor version from variable name....* gnu/packages/crates-io.scm (rust-percent-encoding-2.1): Rename to rust-percent-encoding-2. Arun Isaac 2020-10-12gnu: rust-crc32fast-1.2: Remove minor version from variable name....* gnu/packages/crates-io.scm (rust-crc32fast-1.2): Rename to rust-crc32fast-1. Arun Isaac 2020-10-12gnu: rust-byteorder-1.3: Remove minor version from variable name....* gnu/packages/crates-io.scm (rust-byteorder-1.3): Rename to rust-byteorder-1. Arun Isaac 2020-10-05gnu: Move graphics crates to crates-graphics.scm....* gnu/packages/crates-graphics.scm: New module. Move rust-andrew-0.2, rust-ansi-colours-1, rust-ansi-term-0.12, rust-ansi-term-0.11, rust-ansi-term-0.10, rust-aom-sys-0.1, rust-ascii-canvas-2, rust-cgl-0.3, rust-cgl-0.2, rust-cgmath-0.17, rust-cglmath-0.16, rust-core-graphics-0.17, rust-core-video-sys-0.1, rust-dav1d-sys-0.3, rust-euclid-0.20, rust-gfx-0.18, rust-gfx-core-0.9, rust-gfx-device-gl-0.16, rust-gfx-gl-0.6, rust-gif-0.10, rust-gl-0.11, rust-gl-generator-0.14, rust-gl-generator-0.13, rust-gl-generator-0.11, rust-gl-generator-0.10, rust-gleam-0.6, rust-glutin-0.22, rust-glutin-0.21, rust-glutin-egl-sys-0.1, rust-glutin-emscripten-sys-0.1, rust-glutin-gles2-sys-0.1, rust-glutin-glx-sys-0.1, rust-glutin-wayland-sys-0.1, rust-image-0.23, rust-image-0.22, rust-image-0.21, rust-image-0.20, rust-jpeg-decoder-0.1, rust-line-drawing-0.7, rust-lyon-geom-0.14, rust-lyon-path-0.14, rust-osmesa-sys-0.1, rust-piston-0.49, rust-piston-float-1.0, rust-piston-gfx-texture-0.40, rust-piston-graphics-api-version-0.2, rust-piston-shaders-graphics2d-0.3, rust-piston-texture-0.8, rust-piston-viewport-1.0, rust-piston-window-0.105, rust-piston2d-gfx-graphics-0.66, rust-pison2d-graphics-0.35, rust-piston-event-loop-0.49, rust-pistoncore-glutin-window-0.63, rust-pistoncore-input-0.28, rust-pistoncore-window-0.44, rust-png-0.16, rust-png-0.15, rust-png-0.14, rust-png-0.12, rust-raw-window-handle-0.3, rust-resize-0.3, rust-rgb-0.8, rust-smithay-client-toolkit-0.6, rust-smithay-client-toolkit-0.4, rust-smithay-clipboard-0.3, rust-tiff-0.5, rust-tiff-0.3, rust-tiff-0.2, rust-wayland-client-0.23, rust-wayland-client-0.21, rust-wayland-commons-0.23, rust-wayland-commons-0.21, rust-wayland-protocols-0.23, rust-wayland-protocols-0.21, rust-wayland-scanner-0.23, rust-wayland-scanner-0.21, rust-wayland-server-0.23, rust-wayland-server-0.21, rust-wayland-sys-0.23, rust-wayland-sys-0.21, rust-winit-0.20, rust-winit-0.19, rust-x11-2, rust-x11-clipboard-0.4, rust-x11-dl-2, rust-y4m-0.5 to here. * gnu/packages/crates-io.scm: ... from here. * gnu/local.mk (GNU_SYSTEM_MODULES): Register new module. * gnu/packages/crates-io.scm, gnu/packages/crates-gtk.scm, gnu/packages/gnome.scm, gnu/packages/rust-apps.scm, gnu/packages/terminals.scm, gnu/packages/video.scm: Adjust for package movement. Efraim Flashner