Skip to content

Commit

Permalink
Fix for windows-specific syscall
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Crawford committed Dec 23, 2020
1 parent bb91f77 commit 2334f98
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 1 addition & 3 deletions music/tracked/mod/util.go
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
}
8 changes: 8 additions & 0 deletions music/tracked/mod/util_linux.go
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)
}
10 changes: 10 additions & 0 deletions music/tracked/mod/util_win.go
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)
}

0 comments on commit 2334f98

Please sign in to comment.