-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jason Crawford
committed
Dec 23, 2020
1 parent
bb91f77
commit 2334f98
Showing
3 changed files
with
19 additions
and
3 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,12 +1,10 @@ | ||
package mod | ||
|
||
import "syscall" | ||
|
||
// WordLength is a count of WORD (uint16) sized values, stored in BigEndian format | ||
type WordLength uint16 | ||
|
||
// Value returns the actual length described by this WordLength | ||
func (m WordLength) Value() int { | ||
v := syscall.Ntohs(uint16(m)) | ||
v := BE16ToLE16(uint16(m)) | ||
return int(v) << 1 | ||
} |
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,8 @@ | ||
// +build linux | ||
|
||
package mod | ||
|
||
// BE16ToLE16 converts a big-endian uint16 to a little-endian uint16 | ||
func BE16ToLE16(be uint16) uint16 { | ||
return uint16(be>>8) | (be << 8) | ||
} |
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,10 @@ | ||
// +build windows | ||
|
||
package mod | ||
|
||
import "syscall" | ||
|
||
// BE16ToLE16 converts a big-endian uint16 to a little-endian uint16 | ||
func BE16ToLE16(be uint16) uint16 { | ||
return syscall.Ntohs(be) | ||
} |