-
-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handled distinctive NFDBits and func index's return values according to
different architectures. Signed-off-by: xchenan <xchenan@gmail.com>
- Loading branch information
Showing
5 changed files
with
31 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
package sys | ||
|
||
import ( | ||
"syscall" | ||
) | ||
import "syscall" | ||
|
||
type FdSet syscall.FdSet | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// +build darwin 386,freebsd arm,freebsd 386,linux arm,linux netbsd openbsd | ||
|
||
// Differnt architectures lead to different bits of uint | ||
// and different types of FdSet.Bits[]. | ||
// Hence, NFDBits and types of func index's return values | ||
// have to be specified from case to case. | ||
|
||
package sys | ||
|
||
const NFDBits = 32 | ||
|
||
func index(fd int) (idx uint, bit int32) { | ||
u := uint(fd) | ||
return u / NFDBits, 1 << (u % NFDBits) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// +build amd64,dragonfly amd64,freebsd amd64,linux arm64,linux | ||
|
||
// Differnt architectures lead to different bits of uint | ||
// and different types of FdSet.Bits[]. | ||
// Hence, NFDBits and types of func index's return values | ||
// have to be specified from case to case. | ||
|
||
package sys | ||
|
||
const NFDBits = 64 | ||
|
||
func index(fd int) (idx uint, bit int64) { | ||
u := uint(fd) | ||
return u / NFDBits, 1 << (u % NFDBits) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters