ci: fix failing conv_test.v on windows

pull/12042/head
Delyan Angelov 2021-10-02 15:51:41 +03:00
parent 4c8094d0d9
commit 9a4dbc25ca
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
4 changed files with 12 additions and 10 deletions

View File

@ -1,21 +1,21 @@
module conv module conv
// host to net 32 (htonl) // host to net 32 (htonl)
pub fn htn32(host &u32) u32 { pub fn htn32(host u32) u32 {
return C.htonl(host) return C.htonl(host)
} }
// host to net 16 (htons) // host to net 16 (htons)
pub fn htn16(host &u16) u16 { pub fn htn16(host u16) u16 {
return C.htons(host) return C.htons(host)
} }
// net to host 32 (ntohl) // net to host 32 (ntohl)
pub fn nth32(host &u32) u32 { pub fn nth32(host u32) u32 {
return C.ntohl(host) return C.ntohl(host)
} }
// net to host 16 (ntohs) // net to host 16 (ntohs)
pub fn nth16(host &u16) u16 { pub fn nth16(host u16) u16 {
return C.ntohs(host) return C.ntohs(host)
} }

View File

@ -20,7 +20,7 @@ union LongLong {
} }
// host to net 64 (htonll) // host to net 64 (htonll)
pub fn htn64(host &u64) u64 { pub fn htn64(host u64) u64 {
mut ll := LongLong{ mut ll := LongLong{
ll: host ll: host
} }
@ -33,7 +33,7 @@ pub fn htn64(host &u64) u64 {
} }
// net to host 64 (ntohll) // net to host 64 (ntohll)
pub fn nth64(net &u64) u64 { pub fn nth64(net u64) u64 {
mut ll := LongLong{ mut ll := LongLong{
ll: net ll: net
} }

View File

@ -1,6 +1,6 @@
import net.conv 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) a := f(x)
b := finv(a) b := finv(a)
assert b == x assert b == x

View File

@ -2,20 +2,22 @@ module conv
#include <winsock2.h> #include <winsock2.h>
#flag -lws2_32
fn C.htonll(host u64) u64 fn C.htonll(host u64) u64
fn C.htonl(host u32) u32 fn C.htonl(host u32) u32
fn C.htons(host u16) u16 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.ntohl(net u32) u32
fn C.ntohs(net u16) u16 fn C.ntohs(net u16) u16
// host to net 64 (htonll) // host to net 64 (htonll)
pub fn htn64(host &u64) u64 { pub fn htn64(host u64) u64 {
return C.htonll(host) return C.htonll(host)
} }
// net to host 64 (htonll) // net to host 64 (htonll)
pub fn nth64(host &u64) u64 { pub fn nth64(host u64) u64 {
return C.ntohll(host) return C.ntohll(host)
} }