Merge pull request #111 from tianon/fix-cross

Fix 386 and arm cross-compile
This commit is contained in:
Victor Marmol 2014-07-18 15:19:44 -07:00
commit cf45d141db
5 changed files with 30 additions and 4 deletions

View File

@ -3,7 +3,6 @@ package netlink
import (
"encoding/binary"
"fmt"
"math/rand"
"net"
"sync/atomic"
"syscall"
@ -949,7 +948,7 @@ func setBridgeMacAddress(s int, name string) error {
copy(ifr.IfrnName[:], name)
for i := 0; i < 6; i++ {
ifr.IfruHwaddr.Data[i] = int8(rand.Intn(255))
ifr.IfruHwaddr.Data[i] = randIfrDataByte()
}
ifr.IfruHwaddr.Data[0] &^= 0x1 // clear multicast bit

View File

@ -0,0 +1,9 @@
package netlink
import (
"math/rand"
)
func randIfrDataByte() uint8 {
return uint8(rand.Intn(255))
}

View File

@ -0,0 +1,11 @@
// +build !arm
package netlink
import (
"math/rand"
)
func randIfrDataByte() int8 {
return int8(rand.Intn(255))
}

View File

@ -4,10 +4,9 @@ package system
/*
#include <unistd.h>
int get_hz(void) { return sysconf(_SC_CLK_TCK); }
*/
import "C"
func GetClockTicks() int {
return int(C.get_hz())
return int(C.sysconf(C._SC_CLK_TCK))
}

View File

@ -0,0 +1,8 @@
// +build linux,!cgo
package system
func GetClockTicks() int {
// TODO figure out a better alternative for platforms where we're missing cgo
return 100
}