Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb] Check for sched_getaffinity in configure
Date: Thu, 17 Sep 2026 14:40:42 +0200	[thread overview]
Message-ID: <20260917124042.3215076-1-tdevries@suse.de> (raw)

A post-commit review comment [1] on commit 8ea833b7067 ("[gdb] Exclude
unavailable hardware threads in default worker-threads") mentioned that we
should:
- check for the presence of sched_getaffinity in configure
- remove the todo comment.

Implement these two.

[1] https://sourceware.org/pipermail/gdb-patches/2026-September/230415.html
---
 gdb/config.in    | 3 +++
 gdb/configure    | 1 +
 gdb/configure.ac | 1 +
 gdb/maint.c      | 6 ++----
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/config.in b/gdb/config.in
index 74745665d4d..0e5a6637c2b 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -430,6 +430,9 @@
 /* Define to 1 if you have the `sbrk' function. */
 #undef HAVE_SBRK
 
+/* Define to 1 if you have the `sched_getaffinity' function. */
+#undef HAVE_SCHED_GETAFFINITY
+
 /* Define to 1 if you have the `setlocale' function. */
 #undef HAVE_SETLOCALE
 
diff --git a/gdb/configure b/gdb/configure
index f411113ea66..810e9ed7a37 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -30161,6 +30161,7 @@ for ac_func in  \
   pread64 \
   pwrite \
   resize_term \
+  sched_getaffinity \
   setlocale \
   setrlimit \
   setsid \
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 5d8e2d6628f..0d88a280b16 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1542,6 +1542,7 @@ AC_CHECK_FUNCS([ \
   pread64 \
   pwrite \
   resize_term \
+  sched_getaffinity \
   setlocale \
   setrlimit \
   setsid \
diff --git a/gdb/maint.c b/gdb/maint.c
index 800cf7e0cda..ed57b34eab5 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -47,7 +47,7 @@
 #include "cli/cli-style.h"
 #include "cli/cli-cmds.h"
 
-#if defined (__linux__) || defined (__CYGWIN__)
+#if HAVE_SCHED_GETAFFINITY
 #include <sched.h>
 #endif
 
@@ -891,13 +891,11 @@ update_thread_pool_size ()
 	{
 	  /* Exclude unavailable hardware threads (for instance made
 	     unavailable using taskset).  */
-#if (defined (__linux__) || defined (__CYGWIN__)) && defined (_GNU_SOURCE)
+#if HAVE_SCHED_GETAFFINITY
 	  cpu_set_t cpus;
 	  int res = sched_getaffinity (getpid (), sizeof (cpu_set_t), &cpus);
 	  if (res == 0)
 	    n_threads = std::min (n_threads, CPU_COUNT (&cpus));
-#else
-	  /* Todo: handle other platforms.  */
 #endif
 	}
     }

base-commit: 4c733e49e3da1eab7991ab64c5bb75c7a56bf48a
-- 
2.51.0


                 reply	other threads:[~2026-09-17 12:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=20260917124042.3215076-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.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