ci: fix failing conv_test.v on windows
parent
4c8094d0d9
commit
9a4dbc25ca
|
@ -1,21 +1,21 @@
|
|||
module conv
|
||||
|
||||
// host to net 32 (htonl)
|
||||
pub fn htn32(host &u32) u32 {
|
||||
pub fn htn32(host u32) u32 {
|
||||
return C.htonl(host)
|
||||
}
|
||||
|
||||
// host to net 16 (htons)
|
||||
pub fn htn16(host &u16) u16 {
|
||||
pub fn htn16(host u16) u16 {
|
||||
return C.htons(host)
|
||||
}
|
||||
|
||||
// net to host 32 (ntohl)
|
||||
pub fn nth32(host &u32) u32 {
|
||||
pub fn nth32(host u32) u32 {
|
||||
return C.ntohl(host)
|
||||
}
|
||||
|
||||
// net to host 16 (ntohs)
|
||||
pub fn nth16(host &u16) u16 {
|
||||
pub fn nth16(host u16) u16 {
|
||||
return C.ntohs(host)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ union LongLong {
|
|||
}
|
||||
|
||||
// host to net 64 (htonll)
|
||||
pub fn htn64(host &u64) u64 {
|
||||
pub fn htn64(host u64) u64 {
|
||||
mut ll := LongLong{
|
||||
ll: host
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ pub fn htn64(host &u64) u64 {
|
|||
}
|
||||
|
||||
// net to host 64 (ntohll)
|
||||
pub fn nth64(net &u64) u64 {
|
||||
pub fn nth64(net u64) u64 {
|
||||
mut ll := LongLong{
|
||||
ll: net
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import net.conv
|
||||
|
||||
fn check<T>(f fn (a &T) T, finv fn (b &T) T, x T) {
|
||||
fn check<T>(f fn (a T) T, finv fn (b T) T, x T) {
|
||||
a := f(x)
|
||||
b := finv(a)
|
||||
assert b == x
|
||||
|
|
|
@ -2,20 +2,22 @@ module conv
|
|||
|
||||
#include <winsock2.h>
|
||||
|
||||
#flag -lws2_32
|
||||
|
||||
fn C.htonll(host u64) u64
|
||||
fn C.htonl(host u32) u32
|
||||
fn C.htons(host u16) u16
|
||||
|
||||
fn C.ntohll(net u32) u32
|
||||
fn C.ntohll(net u64) u64
|
||||
fn C.ntohl(net u32) u32
|
||||
fn C.ntohs(net u16) u16
|
||||
|
||||
// host to net 64 (htonll)
|
||||
pub fn htn64(host &u64) u64 {
|
||||
pub fn htn64(host u64) u64 {
|
||||
return C.htonll(host)
|
||||
}
|
||||
|
||||
// net to host 64 (htonll)
|
||||
pub fn nth64(host &u64) u64 {
|
||||
pub fn nth64(host u64) u64 {
|
||||
return C.ntohll(host)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue