mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
vlib: replace macros that resolve to __builtin_bswapnn calls for tcc (#19305)
The tcc compiler does not have __builtin_bswap64, __builtin_bswap32, and __builtin_bswap16 functions. The various hton and ntoh macros resolve down to these functions. When compiling with tcc, we should be using the analogous functions from net.conv.
This commit is contained in:
parent
bea12e2623
commit
2d4ccf6829
4 changed files with 59 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
|||
module picoev
|
||||
|
||||
import net
|
||||
import net.conv
|
||||
import picohttpparser
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -123,10 +124,23 @@ fn listen(config Config) int {
|
|||
}
|
||||
|
||||
// addr settings
|
||||
|
||||
sin_port := $if tinyc {
|
||||
conv.hton16(u16(config.port))
|
||||
} $else {
|
||||
C.htons(config.port)
|
||||
}
|
||||
|
||||
sin_addr := $if tinyc {
|
||||
conv.hton32(u32(C.INADDR_ANY))
|
||||
} $else {
|
||||
C.htonl(C.INADDR_ANY)
|
||||
}
|
||||
|
||||
mut addr := C.sockaddr_in{
|
||||
sin_family: u8(C.AF_INET)
|
||||
sin_port: C.htons(config.port)
|
||||
sin_addr: C.htonl(C.INADDR_ANY)
|
||||
sin_port: sin_port
|
||||
sin_addr: sin_addr
|
||||
}
|
||||
size := sizeof(C.sockaddr_in)
|
||||
bind_res := C.bind(fd, voidptr(unsafe { &net.Addr(&addr) }), size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue