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

Issue 93 fix: correctly set fd mask bit 31 to make swift happy #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/SystemLibrary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct SystemLibrary {
static func fdSet(fd: Int32, set: inout fd_set) {
let intOffset = Int(fd / 32)
let bitOffset = fd % 32
let mask = Int32(1 << bitOffset)
let mask = Int32((1 << bitOffset) * (bitOffset == 31 ? -1 : 1))
switch intOffset {
case 0: set.fds_bits.0 = set.fds_bits.0 | mask
case 1: set.fds_bits.1 = set.fds_bits.1 | mask
Expand Down Expand Up @@ -155,7 +155,7 @@ struct SystemLibrary {
static func fdIsSet(fd: Int32, set: inout fd_set) -> Bool {
let intOffset = Int(fd / 32)
let bitOffset = fd % 32
let mask = Int32(1 << bitOffset)
let mask = Int32((1 << bitOffset) * (bitOffset == 31 ? -1 : 1))
switch intOffset {
case 0: return set.fds_bits.0 & mask != 0
case 1: return set.fds_bits.1 & mask != 0
Expand Down