Skip to content

Commit 6f8aef1

Browse files
committed
add 32-bit build support for freebsd
Signed-off-by: Hakan Sariman <[email protected]>
1 parent a9ab227 commit 6f8aef1

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

internal/wgfreebsd/client_freebsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (c *Client) ConfigureDevice(name string, cfg wgtypes.Config) error {
194194
data := wgh.WGDataIO{
195195
Name: dname,
196196
Data: mem,
197-
Size: uint64(sz),
197+
Size: uint32(sz),
198198
}
199199

200200
if err := c.ioctlWGDataIO(wgh.SIOCSWG, &data); err != nil {

internal/wgfreebsd/internal/nv/decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
// Unmarshal decodes a FreeBSD name-value list (nv(9)) to a Go map
1515
func Unmarshal(d []byte, out List) error {
16-
sz := C.ulong(len(d))
16+
sz := C.size_t(len(d))
1717
dp := unsafe.Pointer(&d[0])
1818
nvl := C.nvlist_unpack(dp, sz, 0)
1919

internal/wgfreebsd/internal/nv/encode.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func marshal(m List) (nvl *C.struct_nvlist, err error) {
4444
C.nvlist_add_bool(nvl, ckey, C.bool(value))
4545

4646
case uint64:
47-
C.nvlist_add_number(nvl, ckey, C.ulong(value))
47+
C.nvlist_add_number(nvl, ckey, C.uint64_t(value))
4848

4949
case []byte:
5050
sz := len(value)
@@ -55,7 +55,8 @@ func marshal(m List) (nvl *C.struct_nvlist, err error) {
5555
case []List:
5656
sz := len(value)
5757
buf := C.malloc(C.size_t(C.sizeof_nvlist_ptr * sz))
58-
items := (*[1<<30 - 1]*C.struct_nvlist)(buf)
58+
p := (**C.struct_nvlist)(buf)
59+
items := unsafe.Slice(p, sz)
5960

6061
for i, val := range value {
6162
if items[i], err = marshal(val); err != nil {

0 commit comments

Comments
 (0)