Mesa (staging/22.1): nine: replace ulimit with sysconf call

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 27 18:15:08 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 2e7de0bfaa65bab0217bb2ebec4010508365f1e4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2e7de0bfaa65bab0217bb2ebec4010508365f1e4

Author: newbluemoon <blaumolch at mailbox.org>
Date:   Mon Jul 11 21:21:35 2022 +0200

nine: replace ulimit with sysconf call

__UL_GETOPENMAX seems to be glibc specific and not portable.
In glibc’s sysdeps/posix/ulimit.c it is assigned the return
value of sysconf(_SC_OPEN_MAX). So use the latter in the first place.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5176
CC: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17471>
(cherry picked from commit 6a4fc6f6ca78ef0d2a546f9c1156ac14e9ac9691)

---

 .pick_status.json                               | 2 +-
 src/gallium/frontends/nine/nine_memory_helper.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 6365f114dc9..9fb859ad822 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -6187,7 +6187,7 @@
         "description": "nine: replace ulimit with sysconf call",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/frontends/nine/nine_memory_helper.c b/src/gallium/frontends/nine/nine_memory_helper.c
index 1c52a5e0838..f7249ea2ebe 100644
--- a/src/gallium/frontends/nine/nine_memory_helper.c
+++ b/src/gallium/frontends/nine/nine_memory_helper.c
@@ -1009,7 +1009,7 @@ nine_allocator_create(struct NineDevice9 *device, int memfd_virtualsizelimit)
     allocator->device = device;
     allocator->page_size = sysconf(_SC_PAGESIZE);
     assert(allocator->page_size == 4 << 10);
-    allocator->num_fd_max = (memfd_virtualsizelimit >= 0) ? MIN2(128, ulimit(__UL_GETOPENMAX)) : 0;
+    allocator->num_fd_max = (memfd_virtualsizelimit >= 0) ? MIN2(128, sysconf(_SC_OPEN_MAX)) : 0;
     allocator->min_file_size = DIVUP(100 * (1 << 20), allocator->page_size) * allocator->page_size; /* 100MB files */
     allocator->total_allocations = 0;
     allocator->total_locked_memory = 0;



More information about the mesa-commit mailing list