mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Minor changes to vendor:ENet
This commit is contained in:
Vendored
+13
-13
@@ -22,17 +22,17 @@ VERSION_MAJOR :: u8(1)
|
|||||||
VERSION_MINOR :: u8(3)
|
VERSION_MINOR :: u8(3)
|
||||||
VERSION_PATCH :: u8(17)
|
VERSION_PATCH :: u8(17)
|
||||||
|
|
||||||
VERSION_CREATE :: #force_inline proc(major, minor, patch: u8) -> u32 {
|
VERSION_CREATE :: #force_inline proc "contextless" (major, minor, patch: u8) -> u32 {
|
||||||
return (u32(major) << 16) | (u32(minor) << 8) | u32(patch)
|
return (u32(major) << 16) | (u32(minor) << 8) | u32(patch)
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSION_GET_MAJOR :: #force_inline proc(version: u32) -> u8 {
|
VERSION_GET_MAJOR :: #force_inline proc "contextless" (version: u32) -> u8 {
|
||||||
return u8((version >> 16) & 0xff)
|
return u8((version >> 16) & 0xff)
|
||||||
}
|
}
|
||||||
VERSION_GET_MINOR :: #force_inline proc(version: u32) -> u8 {
|
VERSION_GET_MINOR :: #force_inline proc "contextless" (version: u32) -> u8 {
|
||||||
return u8((version >> 8) & 0xff)
|
return u8((version >> 8) & 0xff)
|
||||||
}
|
}
|
||||||
VERSION_GET_PATCH :: #force_inline proc(version: u32) -> u8 {
|
VERSION_GET_PATCH :: #force_inline proc "contextless" (version: u32) -> u8 {
|
||||||
return u8(version & 0xff)
|
return u8(version & 0xff)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,19 +44,19 @@ VERSION :: (u32(VERSION_MAJOR) << 16) | (u32(VERSION_MINOR) << 8) | u32(VERSION_
|
|||||||
// Network byte order is always Big Endian. Instead of using the method ENet
|
// Network byte order is always Big Endian. Instead of using the method ENet
|
||||||
// uses (leveraging {n,h}to{n,h}{s,l}), we can just use Odin's endianess types
|
// uses (leveraging {n,h}to{n,h}{s,l}), we can just use Odin's endianess types
|
||||||
// to get the correct byte swaps, if any.
|
// to get the correct byte swaps, if any.
|
||||||
HOST_TO_NET_16 :: #force_inline proc(value: u16) -> u16 {
|
HOST_TO_NET_16 :: #force_inline proc "contextless" (value: u16) -> u16 {
|
||||||
return transmute(u16)u16be(value)
|
return transmute(u16)u16be(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
HOST_TO_NET_32 :: #force_inline proc(value: u32) -> u32 {
|
HOST_TO_NET_32 :: #force_inline proc "contextless" (value: u32) -> u32 {
|
||||||
return transmute(u32)u32be(value)
|
return transmute(u32)u32be(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
NET_TO_HOST_16 :: #force_inline proc(value: u16) -> u16 {
|
NET_TO_HOST_16 :: #force_inline proc "contextless" (value: u16) -> u16 {
|
||||||
return u16(transmute(u16be)value)
|
return u16(transmute(u16be)value)
|
||||||
}
|
}
|
||||||
|
|
||||||
NET_TO_HOST_32 :: #force_inline proc(value: u32) -> u32 {
|
NET_TO_HOST_32 :: #force_inline proc "contextless" (value: u32) -> u32 {
|
||||||
return u32(transmute(u32be)value)
|
return u32(transmute(u32be)value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ PacketFreeCallback :: proc "c" (packet: ^Packet)
|
|||||||
Packet :: struct {
|
Packet :: struct {
|
||||||
referenceCount: uint,
|
referenceCount: uint,
|
||||||
flags: u32,
|
flags: u32,
|
||||||
data: [^]u8,
|
data: [^]u8 `fmt:"v,dataLength"`,
|
||||||
dataLength: uint,
|
dataLength: uint,
|
||||||
freeCallback: PacketFreeCallback,
|
freeCallback: PacketFreeCallback,
|
||||||
userData: rawptr,
|
userData: rawptr,
|
||||||
@@ -148,7 +148,7 @@ IncomingCommand :: struct {
|
|||||||
command: Protocol,
|
command: Protocol,
|
||||||
fragmentCount: u32,
|
fragmentCount: u32,
|
||||||
fragmentsRemaining: u32,
|
fragmentsRemaining: u32,
|
||||||
fragments: [^]u32,
|
fragments: [^]u32 `fmt:"v,fragmentCount"`,
|
||||||
packet: ^Packet,
|
packet: ^Packet,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ Peer :: struct {
|
|||||||
address: Address,
|
address: Address,
|
||||||
data: rawptr,
|
data: rawptr,
|
||||||
state: PeerState,
|
state: PeerState,
|
||||||
channels: [^]Channel,
|
channels: [^]Channel `fmt:"v,channelCount"`,
|
||||||
channelCount: uint,
|
channelCount: uint,
|
||||||
incomingBandwidth: u32,
|
incomingBandwidth: u32,
|
||||||
outgoingBandwidth: u32,
|
outgoingBandwidth: u32,
|
||||||
@@ -292,7 +292,7 @@ Host :: struct {
|
|||||||
mtu: u32,
|
mtu: u32,
|
||||||
randomSeed: u32,
|
randomSeed: u32,
|
||||||
recalculateBandwidthLimits: i32,
|
recalculateBandwidthLimits: i32,
|
||||||
peers: [^]Peer,
|
peers: [^]Peer `fmt:"v,peerCount"`,
|
||||||
peerCount: uint,
|
peerCount: uint,
|
||||||
channelLimit: uint,
|
channelLimit: uint,
|
||||||
serviceTime: u32,
|
serviceTime: u32,
|
||||||
@@ -308,7 +308,7 @@ Host :: struct {
|
|||||||
compressor: Compressor,
|
compressor: Compressor,
|
||||||
packetData: [2][PROTOCOL_MAXIMUM_MTU]u8,
|
packetData: [2][PROTOCOL_MAXIMUM_MTU]u8,
|
||||||
receivedAddress: Address,
|
receivedAddress: Address,
|
||||||
receivedData: [^]u8,
|
receivedData: [^]u8 `fmt:"v,receivedDataLength"`,
|
||||||
receivedDataLength: uint,
|
receivedDataLength: uint,
|
||||||
totalSentData: u32,
|
totalSentData: u32,
|
||||||
totalSentPackets: u32,
|
totalSentPackets: u32,
|
||||||
|
|||||||
Vendored
+5
-5
@@ -2,22 +2,22 @@ package ENet
|
|||||||
|
|
||||||
TIME_OVERFLOW :: u32(86400000)
|
TIME_OVERFLOW :: u32(86400000)
|
||||||
|
|
||||||
TIME_LESS :: #force_inline proc(a, b: u32) -> bool {
|
TIME_LESS :: #force_inline proc "contextless" (a, b: u32) -> bool {
|
||||||
return a - b >= TIME_OVERFLOW
|
return a - b >= TIME_OVERFLOW
|
||||||
}
|
}
|
||||||
|
|
||||||
TIME_GREATER :: #force_inline proc(a, b: u32) -> bool {
|
TIME_GREATER :: #force_inline proc "contextless" (a, b: u32) -> bool {
|
||||||
return b - a >= TIME_OVERFLOW
|
return b - a >= TIME_OVERFLOW
|
||||||
}
|
}
|
||||||
|
|
||||||
TIME_LESS_EQUAL :: #force_inline proc(a, b: u32) -> bool {
|
TIME_LESS_EQUAL :: #force_inline proc "contextless" (a, b: u32) -> bool {
|
||||||
return !TIME_GREATER(a, b)
|
return !TIME_GREATER(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
TIME_GREATER_EQUAL :: #force_inline proc(a, b: u32) -> bool {
|
TIME_GREATER_EQUAL :: #force_inline proc "contextless" (a, b: u32) -> bool {
|
||||||
return TIME_LESS(a, b)
|
return TIME_LESS(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
TIME_DIFFERENCE :: #force_inline proc(a, b: u32) -> u32 {
|
TIME_DIFFERENCE :: #force_inline proc "contextless" (a, b: u32) -> u32 {
|
||||||
return a - b >= TIME_OVERFLOW ? b - a : a - b
|
return a - b >= TIME_OVERFLOW ? b - a : a - b
|
||||||
}
|
}
|
||||||
Vendored
+8
-8
@@ -12,21 +12,21 @@ import "core:c"
|
|||||||
fds_bits: [FD_SETSIZE / 8 / size_of(c.long)]c.ulong,
|
fds_bits: [FD_SETSIZE / 8 / size_of(c.long)]c.ulong,
|
||||||
}
|
}
|
||||||
|
|
||||||
@(private="file") FD_ZERO :: #force_inline proc(s: ^fd_set) {
|
@(private="file") FD_ZERO :: #force_inline proc "contextless" (s: ^fd_set) {
|
||||||
for i := size_of(fd_set) / size_of(c.long); i != 0; i -= 1 {
|
for i := size_of(fd_set) / size_of(c.long); i != 0; i -= 1 {
|
||||||
s.fds_bits[i] = 0
|
s.fds_bits[i] = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@(private="file") FD_SET :: #force_inline proc(d: i32, s: ^fd_set) {
|
@(private="file") FD_SET :: #force_inline proc "contextless" (d: i32, s: ^fd_set) {
|
||||||
s.fds_bits[d / (8 * size_of(c.long))] |= c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong)))
|
s.fds_bits[d / (8 * size_of(c.long))] |= c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@(private="file") FD_CLR :: #force_inline proc(d: i32, s: ^fd_set) {
|
@(private="file") FD_CLR :: #force_inline proc "contextless" (d: i32, s: ^fd_set) {
|
||||||
s.fds_bits[d / (8 * size_of(c.long))] &~= c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong)))
|
s.fds_bits[d / (8 * size_of(c.long))] &~= c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@(private="file") FD_ISSET :: #force_inline proc(d: i32, s: ^fd_set) -> bool {
|
@(private="file") FD_ISSET :: #force_inline proc "contextless" (d: i32, s: ^fd_set) -> bool {
|
||||||
return (s.fds_bits[d / (8 * size_of(c.long))] & c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong)))) != 0
|
return (s.fds_bits[d / (8 * size_of(c.long))] & c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong)))) != 0
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
@@ -42,18 +42,18 @@ Buffer :: struct {
|
|||||||
|
|
||||||
SocketSet :: distinct fd_set
|
SocketSet :: distinct fd_set
|
||||||
|
|
||||||
SOCKETSET_EMPTY :: #force_inline proc(sockset: ^SocketSet) {
|
SOCKETSET_EMPTY :: #force_inline proc "contextless" (sockset: ^SocketSet) {
|
||||||
FD_ZERO(cast(^fd_set)sockset)
|
FD_ZERO(cast(^fd_set)sockset)
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKETSET_ADD :: #force_inline proc(sockset: ^SocketSet, socket: Socket) {
|
SOCKETSET_ADD :: #force_inline proc "contextless" (sockset: ^SocketSet, socket: Socket) {
|
||||||
FD_SET(i32(socket), cast(^fd_set)sockset)
|
FD_SET(i32(socket), cast(^fd_set)sockset)
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKETSET_REMOVE :: #force_inline proc(sockset: ^SocketSet, socket: Socket) {
|
SOCKETSET_REMOVE :: #force_inline proc "contextless" (sockset: ^SocketSet, socket: Socket) {
|
||||||
FD_CLR(i32(socket), cast(^fd_set)sockset)
|
FD_CLR(i32(socket), cast(^fd_set)sockset)
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKSET_CHECK :: #force_inline proc(sockset: ^SocketSet, socket: Socket) -> bool {
|
SOCKSET_CHECK :: #force_inline proc "contextless" (sockset: ^SocketSet, socket: Socket) -> bool {
|
||||||
return FD_ISSET(i32(socket), cast(^fd_set)sockset)
|
return FD_ISSET(i32(socket), cast(^fd_set)sockset)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+8
-8
@@ -20,7 +20,7 @@ foreign WinSock2 {
|
|||||||
fd_array: [FD_SETSIZE]SOCKET,
|
fd_array: [FD_SETSIZE]SOCKET,
|
||||||
}
|
}
|
||||||
|
|
||||||
@(private="file") FD_CLR :: proc(fd: SOCKET, s: ^fd_set) {
|
@(private="file") FD_CLR :: proc "contextless" (fd: SOCKET, s: ^fd_set) {
|
||||||
for i := u32(0); i < s.fd_count; i += 1 {
|
for i := u32(0); i < s.fd_count; i += 1 {
|
||||||
if s.fd_array[i] == fd {
|
if s.fd_array[i] == fd {
|
||||||
for i < s.fd_count - 1 {
|
for i < s.fd_count - 1 {
|
||||||
@@ -33,7 +33,7 @@ foreign WinSock2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@(private="file") FD_SET :: proc(fd: SOCKET, s: ^fd_set) {
|
@(private="file") FD_SET :: proc "contextless" (fd: SOCKET, s: ^fd_set) {
|
||||||
for i := u32(0); i < s.fd_count; i += 1 {
|
for i := u32(0); i < s.fd_count; i += 1 {
|
||||||
if s.fd_array[i] == fd {
|
if s.fd_array[i] == fd {
|
||||||
return
|
return
|
||||||
@@ -46,11 +46,11 @@ foreign WinSock2 {
|
|||||||
s.fd_count += 1
|
s.fd_count += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@(private="file") FD_ZERO :: #force_inline proc (s: ^fd_set) {
|
@(private="file") FD_ZERO :: #force_inline proc "contextless" (s: ^fd_set) {
|
||||||
s.fd_count = 0
|
s.fd_count = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@(private="file") FD_ISSET :: #force_inline proc (fd: SOCKET, s: ^fd_set) -> bool {
|
@(private="file") FD_ISSET :: #force_inline proc "contextless" (fd: SOCKET, s: ^fd_set) -> bool {
|
||||||
return __WSAFDIsSet(fd, s) != 0
|
return __WSAFDIsSet(fd, s) != 0
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
@@ -66,18 +66,18 @@ Buffer :: struct {
|
|||||||
|
|
||||||
SocketSet :: distinct fd_set
|
SocketSet :: distinct fd_set
|
||||||
|
|
||||||
SOCKETSET_EMPTY :: #force_inline proc(sockset: ^SocketSet) {
|
SOCKETSET_EMPTY :: #force_inline proc "contextless" (sockset: ^SocketSet) {
|
||||||
FD_ZERO(cast(^fd_set)sockset)
|
FD_ZERO(cast(^fd_set)sockset)
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKETSET_ADD :: #force_inline proc(sockset: ^SocketSet, socket: Socket) {
|
SOCKETSET_ADD :: #force_inline proc "contextless" (sockset: ^SocketSet, socket: Socket) {
|
||||||
FD_SET(SOCKET(socket), cast(^fd_set)sockset)
|
FD_SET(SOCKET(socket), cast(^fd_set)sockset)
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKETSET_REMOVE :: #force_inline proc(sockset: ^SocketSet, socket: Socket) {
|
SOCKETSET_REMOVE :: #force_inline proc "contextless" (sockset: ^SocketSet, socket: Socket) {
|
||||||
FD_CLR(SOCKET(socket), cast(^fd_set)sockset)
|
FD_CLR(SOCKET(socket), cast(^fd_set)sockset)
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKSET_CHECK :: #force_inline proc(sockset: ^SocketSet, socket: Socket) -> bool {
|
SOCKSET_CHECK :: #force_inline proc "contextless" (sockset: ^SocketSet, socket: Socket) -> bool {
|
||||||
return FD_ISSET(SOCKET(socket), cast(^fd_set)sockset)
|
return FD_ISSET(SOCKET(socket), cast(^fd_set)sockset)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user