Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken poll and nfds_t bindings #24331

Merged
merged 1 commit into from
Oct 20, 2024
Merged

Fix broken poll and nfds_t bindings #24331

merged 1 commit into from
Oct 20, 2024

Commits on Oct 20, 2024

  1. Fix broken poll and nfds_t bindings

    This fixes several cases of the Nim binding of nfds_t being inconsistent
    with the target platform signedness and/or size.
    
    Additionally, it fixes poll's third argument (timeout) being set to
    Nim "int" when it should have been "cint".
    
    The former is the same issue that nim-lang#23045 had attempted to fix, but
    failed because it only considered Linux. (Also, it was only applied to
    version 2.0, so the two branches now have incompatible versions of the
    same bug.)
    
    Notes:
    
    * SVR4's original "unsigned long" definition is cloned by Linux and
      Haiku. Nim got this right for Haiku and Linux-amd64, but it was wrong
      on non-amd64 Linux.
    * Zephyr does not have nfds_t, but simply uses (signed) "int". This
      was already correctly reflected by Nim.
    * OpenBSD poll.h uses "unsigned int", and other BSD derivatives follow
      suit.
      This being the most commonly copied definition, the fallback case now
      returns cuint. (This also seems to be correct for the OS X headers I
      could find on the web.)
    * This changes Nintendo Switch nfds_t to cuint from culong. It is
      purportedly a FreeBSD derivative, so I *think* this is correct, but I
      can't tell because I don't have access to the Nintendo Switch headers.
    
    I have also moved the platform-specific Tnfds to posix.nim so that we
    can reuse the fallback logic on all platforms. (e.g. specifying the size
    in posix_linux_amd64 only to then use when defined(linux) in posix_other
    seems redundant.)
    bptato committed Oct 20, 2024
    Configuration menu
    Copy the full SHA
    527aa75 View commit details
    Browse the repository at this point in the history