fix int32's that should be uint32 on BSD & OSX (#24078)

fixes #24076

As described in #24076, misannotating these types causes codegen errors.
Sources for the types are https://github.com/openbsd/src/blob/master/sys
for BSD and https://opensource.apple.com/source/Libinfo/Libinfo-391/ and
[_types.h](https://opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/sys/_types.h.auto.html)
for OSX.

(cherry picked from commit 7de4ace949)
This commit is contained in:
metagn
2024-09-09 10:46:47 +03:00
committed by narimiran
parent d51236e9cc
commit 56e7c75e03
3 changed files with 18 additions and 10 deletions

View File

@@ -125,7 +125,7 @@ type
Dev* {.importc: "dev_t", header: "<sys/types.h>".} = int32
Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int
Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int
Gid* {.importc: "gid_t", header: "<sys/types.h>".} = int32
Gid* {.importc: "gid_t", header: "<sys/types.h>".} = uint32
Id* {.importc: "id_t", header: "<sys/types.h>".} = int
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
Key* {.importc: "key_t", header: "<sys/types.h>".} = int
@@ -167,7 +167,7 @@ type
Trace_event_set* {.importc: "trace_event_set_t",
header: "<sys/types.h>".} = int
Trace_id* {.importc: "trace_id_t", header: "<sys/types.h>".} = int
Uid* {.importc: "uid_t", header: "<sys/types.h>".} = int32
Uid* {.importc: "uid_t", header: "<sys/types.h>".} = uint32
Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = int
Utsname* {.importc: "struct utsname",
@@ -462,9 +462,9 @@ type
header: "<netinet/in.h>".} = object ## struct sockaddr_in6
sin6_family*: TSa_Family ## AF_INET6.
sin6_port*: InPort ## Port number.
sin6_flowinfo*: int32 ## IPv6 traffic class and flow information.
sin6_flowinfo*: uint32 ## IPv6 traffic class and flow information.
sin6_addr*: In6Addr ## IPv6 address.
sin6_scope_id*: int32 ## Set of interfaces for a scope.
sin6_scope_id*: uint32 ## Set of interfaces for a scope.
Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final,
header: "<netinet/in.h>".} = object ## struct ipv6_mreq
@@ -491,7 +491,7 @@ type
## alternative network names, terminated by a
## null pointer.
n_addrtype*: cint ## The address type of the network.
n_net*: int32 ## The network number, in host byte order.
n_net*: uint32 ## The network number, in host byte order.
Protoent* {.importc: "struct protoent", pure, final,
header: "<netdb.h>".} = object ## struct protoent

View File

@@ -134,7 +134,7 @@ type
Dev* {.importc: "dev_t", header: "<sys/types.h>".} = int32
Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int
Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int
Gid* {.importc: "gid_t", header: "<sys/types.h>".} = int32
Gid* {.importc: "gid_t", header: "<sys/types.h>".} = uint32
Id* {.importc: "id_t", header: "<sys/types.h>".} = int
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
Key* {.importc: "key_t", header: "<sys/types.h>".} = int
@@ -171,7 +171,7 @@ type
Trace_event_set* {.importc: "trace_event_set_t",
header: "<sys/types.h>".} = int
Trace_id* {.importc: "trace_id_t", header: "<sys/types.h>".} = int
Uid* {.importc: "uid_t", header: "<sys/types.h>".} = int32
Uid* {.importc: "uid_t", header: "<sys/types.h>".} = uint32
Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = int
Utsname* {.importc: "struct utsname",
@@ -446,9 +446,9 @@ type
header: "<netinet/in.h>".} = object ## struct sockaddr_in6
sin6_family*: TSa_Family ## AF_INET6.
sin6_port*: InPort ## Port number.
sin6_flowinfo*: int32 ## IPv6 traffic class and flow information.
sin6_flowinfo*: uint32 ## IPv6 traffic class and flow information.
sin6_addr*: In6Addr ## IPv6 address.
sin6_scope_id*: int32 ## Set of interfaces for a scope.
sin6_scope_id*: uint32 ## Set of interfaces for a scope.
Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final,
header: "<netinet/in.h>".} = object ## struct ipv6_mreq
@@ -475,7 +475,7 @@ type
## alternative network names, terminated by a
## null pointer.
n_addrtype*: cint ## The address type of the network.
n_net*: int32 ## The network number, in host byte order.
n_net*: uint32 ## The network number, in host byte order.
Protoent* {.importc: "struct protoent", pure, final,
header: "<netdb.h>".} = object ## struct protoent

View File

@@ -0,0 +1,8 @@
# issue #24076
when defined(macosx) or defined(freebsd) or defined(openbsd) or defined(netbsd):
import std/posix
proc uid(x: uint32): Uid = Uid(x)
var y: uint32
let myUid = geteuid()
discard myUid == uid(y)