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
// 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)
}

View File

@ -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
}

View File

@ -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

View File

@ -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)
}