bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Yuta Saito <kateinoigakukun@gmail.com>
To: bug-gnulib@gnu.org
Cc: Yuta Saito <kateinoigakukun@gmail.com>
Subject: [PATCH] getdtablesize: support systems without getrlimit like WASI
Date: Sat,  4 May 2024 13:59:44 +0000	[thread overview]
Message-ID: <20240504135944.1411505-1-kateinoigakukun@gmail.com> (raw)

* lib/getdtablesize.c (getdtablesize): Return INT_MAX if getrlimit
  is not available. This is the case for WASI, WebAssembly System
  Interface.
* m4/getdtablesize.m4 (gl_PREREQ_GETDTABLESIZE): Check for getrlimit.
---
 ChangeLog           | 8 ++++++++
 lib/getdtablesize.c | 2 ++
 m4/getdtablesize.m4 | 6 ++++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 96b29b7fc4..1ef678a316 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-05-04 Yuta Saito <kateinoigakukun@gmail.com>
+
+	getdtablesize: support systems without getrlimit like WASI
+	* lib/getdtablesize.c (getdtablesize): Return INT_MAX if getrlimit
+	is not available. This is the case for WASI, WebAssembly System
+	Interface.
+	* m4/getdtablesize.m4 (gl_PREREQ_GETDTABLESIZE): Check for getrlimit.
+
 2024-05-03  Collin Funk  <collin.funk1@gmail.com>
 
 	gnulib-tool.py: Fix an undefined function name.
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
index 762c100b38..fca937a39a 100644
--- a/lib/getdtablesize.c
+++ b/lib/getdtablesize.c
@@ -109,6 +109,7 @@ getdtablesize (void)
 int
 getdtablesize (void)
 {
+# if HAVE_GETRLIMIT
   struct rlimit lim;
 
   if (getrlimit (RLIMIT_NOFILE, &lim) == 0
@@ -117,6 +118,7 @@ getdtablesize (void)
       && lim.rlim_cur != RLIM_SAVED_CUR
       && lim.rlim_cur != RLIM_SAVED_MAX)
     return lim.rlim_cur;
+# endif
 
   return INT_MAX;
 }
diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4
index aaefe9b298..7059eb933e 100644
--- a/m4/getdtablesize.m4
+++ b/m4/getdtablesize.m4
@@ -1,5 +1,5 @@
 # getdtablesize.m4
-# serial 8
+# serial 9
 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -61,4 +61,6 @@ AC_DEFUN([gl_FUNC_GETDTABLESIZE],
 ])
 
 # Prerequisites of lib/getdtablesize.c.
-AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:])
+AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [
+  AC_CHECK_FUNCS_ONCE([getrlimit])
+])
-- 
2.43.2



             reply	other threads:[~2024-05-04 14:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-04 13:59 Yuta Saito [this message]
2024-05-04 15:01 ` [PATCH] getdtablesize: support systems without getrlimit like WASI Bruno Haible
2024-05-04 17:15   ` Yuta Saito

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240504135944.1411505-1-kateinoigakukun@gmail.com \
    --to=kateinoigakukun@gmail.com \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).