build, util: Add `HAVE_PTHREAD_SETNAME_NP_2ARG` configuration macro #396

pull hebasto wants to merge 2 commits into bitcoin-core:master from hebasto:261115-setname_np2 changing 3 files +15 −4
  1. hebasto commented at 5:27 PM on November 15, 2026: member

    On platforms that provide only the 2-argument pthread_setname_np() function, such as illumos, none of the branches in SetOsThreadName() matches, so threads are left unnamed. As pthread_getname_np() is available there, the thread name tests fail.

    Introduce the HAVE_PTHREAD_SETNAME_NP_2ARG configuration macro, which represents the availability of that function, and use it in SetOsThreadName().

    Platforms already handled by another branch are not affected.

    Additionally, the first commit documents the platforms for every branch in SetOsThreadName(), as suggested by ryanofsky in #324.

  2. DrahtBot commented at 5:27 PM on November 15, 2026: none

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK ryanofsky

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. util: Document platforms in `SetOsThreadName()` branches 7690c229b1
  4. hebasto force-pushed on Nov 15, 2026
  5. hebasto force-pushed on Nov 15, 2026
  6. hebasto force-pushed on Nov 15, 2026
  7. in src/mp/util.cpp:190 in 1a59d5d0a8
     188 | +    pthread_setname_np(pthread_self(), "%s", const_cast<char*>(name)); // NetBSD
     189 |  #elif defined(HAVE_PTHREAD_GETTHREADID_NP)
     190 | -    pthread_set_name_np(pthread_self(), name);
     191 | +    pthread_set_name_np(pthread_self(), name); // FreeBSD
     192 | +#elif defined(HAVE_PTHREAD_SETNAME_NP_2ARG)
     193 | +    pthread_setname_np(pthread_self(), name); // illumos
    


    ryanofsky commented at 7:10 PM on November 16, 2026:

    In commit "build, util: Add HAVE_PTHREAD_SETNAME_NP_2ARG configuration macro" (1a59d5d0a82620f8ec748b05e203316a79feb806)

    Could #393 be based on this PR? This PR's CI has no illumos job, so nothing here runs the new branch. With this PR underneath, the illumos job should run the thread name tests and pass them.


    ryanofsky commented at 7:10 PM on November 16, 2026:

    In commit "build, util: Add HAVE_PTHREAD_SETNAME_NP_2ARG configuration macro" (1a59d5d0a82620f8ec748b05e203316a79feb806)

    Nit: glibc and musl have this 2-argument pthread_setname_np() too, so HAVE_PTHREAD_SETNAME_NP_2ARG will also be defined on Linux, and it only works there because the PR_SET_NAME branch comes first. That ordering matters, since glibc's version fails for names longer than 15 characters while prctl truncates them. Maybe worth saying so in the comment, so the branches don't get reordered later:

    pthread_setname_np(pthread_self(), name); // illumos (glibc also has this, but Linux uses PR_SET_NAME above, which truncates long names instead of failing)
    

    hebasto commented at 7:47 PM on November 16, 2026:

    Thanks! The comment has been improved.


    hebasto commented at 7:49 PM on November 16, 2026:

    Could #393 be based on this PR?

    Done.

  8. ryanofsky approved
  9. ryanofsky commented at 7:23 PM on November 16, 2026: collaborator

    Code review ACK 1a59d5d0a82620f8ec748b05e203316a79feb806. This fixes the "has OS thread name" tests on illumos, which have failed there since #324 added them: SetOsThreadName() had no branch for illumos's 2-argument pthread_setname_np(), so threads were left unnamed, while the tests still ran because pthread_getname_np() is available.

    Thanks for adding the comments from #324, too!

  10. build, util: Add `HAVE_PTHREAD_SETNAME_NP_2ARG` configuration macro
    On platforms that provide only the 2-argument `pthread_setname_np()`
    function, such as illumos, none of the branches in `SetOsThreadName()`
    matches, so threads are left unnamed. As `pthread_getname_np()` is
    available there, the thread name tests fail.
    
    Introduce the `HAVE_PTHREAD_SETNAME_NP_2ARG` configuration macro, which
    represents the availability of that function, and use it in
    `SetOsThreadName()`.
    
    Platforms already handled by another branch are not affected.
    fb0e194f9c
  11. hebasto force-pushed on Nov 16, 2026
  12. ryanofsky approved
  13. ryanofsky commented at 8:41 PM on November 16, 2026: collaborator

    Code review ACK fb0e194f9c8cfe545d274def331083756e23c425. This fixes the "has OS thread name" tests on illumos, confirmed by the OpenIndiana job in #393, which is now based on this PR and passes all three tests (its remaining failure is the unrelated listen test).

    The only change since my last review is the expanded illumos comment, thanks!

  14. ryanofsky merged this on Nov 16, 2026
  15. ryanofsky closed this on Nov 16, 2026

  16. hebasto deleted the branch on Nov 16, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-17 18:30 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me