diff --git a/core/sys/posix/netdb.odin b/core/sys/posix/netdb.odin index a8c83d83a..ff1cb9d4c 100644 --- a/core/sys/posix/netdb.odin +++ b/core/sys/posix/netdb.odin @@ -352,15 +352,28 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS // The highest reserved port number. IPPORT_RESERVED :: 1024 - addrinfo :: struct { - ai_flags: Addrinfo_Flags, /* [PSX] input flags */ - ai_family: AF, /* [PSX] address family of socket */ - ai_socktype: Sock, /* [PSX] socket type */ - ai_protocol: Protocol, /* [PSX] protocol of socket */ - ai_addrlen: socklen_t, /* [PSX] length of socket address */ - ai_canonname: cstring, /* [PSX] canonical name of service location */ - ai_addr: ^sockaddr, /* [PSX] binary address */ - ai_next: ^addrinfo, /* [PSX] pointer to next in list */ + when ODIN_OS == .Linux || ODIN_OS == .OpenBSD { + addrinfo :: struct { + ai_flags: Addrinfo_Flags, /* [PSX] input flags */ + ai_family: AF, /* [PSX] address family of socket */ + ai_socktype: Sock, /* [PSX] socket type */ + ai_protocol: Protocol, /* [PSX] protocol of socket */ + ai_addrlen: socklen_t, /* [PSX] length of socket address */ + ai_addr: ^sockaddr, /* [PSX] binary address */ + ai_canonname: cstring, /* [PSX] canonical name of service location */ + ai_next: ^addrinfo, /* [PSX] pointer to next in list */ + } + } else { + addrinfo :: struct { + ai_flags: Addrinfo_Flags, /* [PSX] input flags */ + ai_family: AF, /* [PSX] address family of socket */ + ai_socktype: Sock, /* [PSX] socket type */ + ai_protocol: Protocol, /* [PSX] protocol of socket */ + ai_addrlen: socklen_t, /* [PSX] length of socket address */ + ai_canonname: cstring, /* [PSX] canonical name of service location */ + ai_addr: ^sockaddr, /* [PSX] binary address */ + ai_next: ^addrinfo, /* [PSX] pointer to next in list */ + } } when ODIN_OS == .Darwin { diff --git a/tests/core/sys/posix/structs/structs.c b/tests/core/sys/posix/structs/structs.c index 396de579e..995c1a8c0 100644 --- a/tests/core/sys/posix/structs/structs.c +++ b/tests/core/sys/posix/structs/structs.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -70,6 +71,7 @@ int main(int argc, char *argv[]) printf("protoent %zu %zu\n", sizeof(struct protoent), _Alignof(struct protoent)); printf("servent %zu %zu\n", sizeof(struct servent), _Alignof(struct servent)); printf("addrinfo %zu %zu\n", sizeof(struct addrinfo), _Alignof(struct addrinfo)); + printf("ai_canonname %zu\n", offsetof(struct addrinfo, ai_canonname)); printf("pollfd %zu %zu\n", sizeof(struct pollfd), _Alignof(struct pollfd)); diff --git a/tests/core/sys/posix/structs/structs.odin b/tests/core/sys/posix/structs/structs.odin index a05137e87..f2bead5ba 100644 --- a/tests/core/sys/posix/structs/structs.odin +++ b/tests/core/sys/posix/structs/structs.odin @@ -38,6 +38,7 @@ main :: proc() { fmt.println("protoent", size_of(posix.protoent), align_of(posix.protoent)) fmt.println("servent", size_of(posix.servent), align_of(posix.servent)) fmt.println("addrinfo", size_of(posix.addrinfo), align_of(posix.addrinfo)) + fmt.println("ai_canonname", offset_of(posix.addrinfo, ai_canonname)) fmt.println("pollfd", size_of(posix.pollfd), align_of(posix.pollfd)) fmt.println("passwd", size_of(posix.passwd), align_of(posix.passwd))