Skip to content

Commit

Permalink
add posix uint changes to changelog + fix Nlink, Dev on FreeBSD (nim-…
Browse files Browse the repository at this point in the history
…lang#24088)

refs nim-lang#24078, refs nim-lang#24076

Since these changes are potentially breaking, add them to changelog,
also add Nlink as mentioned in
nim-lang#24076 (comment).
  • Loading branch information
metagn authored Sep 9, 2024
1 parent 3a55bae commit 2177176
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
const bar = a # error
let baz = a # error
```
- The following POSIX wrappers have had their types changed from signed to
unsigned types on OSX and FreeBSD/OpenBSD to correct codegen errors:
- `Gid` (was `int32`, is now `uint32`)
- `Uid` (was `int32`, is now `uint32`)
- `Dev` (was `int32`, is now `uint32` on FreeBSD)
- `Nlink` (was `int16`, is now `uint32` on OpenBSD and `uint16` on OSX/other BSD)
- `sin6_flowinfo` and `sin6_scope_id` fields of `Sockaddr_in6`
(were `int32`, are now `uint32`)
- `n_net` field of `Tnetent` (was `int32`, is now `uint32`)


## Standard library additions and changes
Expand Down
8 changes: 6 additions & 2 deletions lib/posix/posix_macos_amd64.nim
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ type
## used for block sizes
Clock* {.importc: "clock_t", header: "<sys/types.h>".} = int
ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int
Dev* {.importc: "dev_t", header: "<sys/types.h>".} = int32
Dev* {.importc: "dev_t", header: "<sys/types.h>".} = (
when defined(freebsd):
uint32
else:
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>".} = uint32
Expand All @@ -135,7 +139,7 @@ type
else:
uint16
)
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int16
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = uint16
Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
Pthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>".} = int
Expand Down
8 changes: 6 additions & 2 deletions lib/posix/posix_openbsd_amd64.nim
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,19 @@ type
## used for block sizes
Clock* {.importc: "clock_t", header: "<sys/types.h>".} = int
ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int
Dev* {.importc: "dev_t", header: "<sys/types.h>".} = int32
Dev* {.importc: "dev_t", header: "<sys/types.h>".} = (
when defined(freebsd):
uint32
else:
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>".} = 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
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint32
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int16
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = uint32
Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
Pthread_attr* {.importc: "pthread_attr_t", header: "<pthread.h>".} = int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ when defined(macosx) or defined(freebsd) or defined(openbsd) or defined(netbsd):
var y: uint32
let myUid = geteuid()
discard myUid == uid(y)
proc dev(x: uint32): Dev = Dev(x)
let myDev = 1.Dev
discard myDev == dev(y)
proc nlink(x: uint32): Nlink = Nlink(x)
let myNlink = 1.Nlink
discard myNlink == nlink(y)

0 comments on commit 2177176

Please sign in to comment.