Fix 386 and arm cross-compile

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
Tianon Gravi 2014-07-18 16:08:54 -06:00
parent 818628ad11
commit 6fca833e4d
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
}