Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] fixes in stdlib for -d:checkAbi #13941

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/posix/posix_other.nim
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,15 @@ 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>".} = int
Dev* {.importc: "dev_t", header: "<sys/types.h>".} = uint64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fork this file into posix_linux_i386, or you can adapt posix_linux_amd64 to work for 32bit. I'd say posix_other should just be kept as a template for future OSes.

Also following Linux's definition is not wise, especially since this file is used by many other OS that doesn't have their own dedicated version.

Ideally we need a tool to auto-detect these types (complementary to tools/detect) so that contributors can add support for other POSIX OS faster.

# WAS: int. Probably not correct but more correct than previous definition
# https://lists.debian.org/debian-mips/2011/11/msg00006.html
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>".} = int
Id* {.importc: "id_t", header: "<sys/types.h>".} = int
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = cuint
## BUGFIX: was int; probably still somewhat incorrect
Key* {.importc: "key_t", header: "<sys/types.h>".} = int
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = (
when defined(android) or defined(macos) or defined(macosx) or
Expand All @@ -155,7 +158,10 @@ type
uint32
)
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int
Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
Off* {.importc: "off_t", header: "<sys/types.h>".} = cint
# WAS: int64 but this broke on CI in 32bit; a but underspecified, see
# https://stackoverflow.com/questions/9073667/where-to-find-the-complete-definition-of-off-t-type
# and https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.1.0/com.ibm.zos.v2r1.cbcpx01/datatypesize64.htm
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
Pthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>".} = int
Pthread_barrier* {.importc: "pthread_barrier_t",
Expand Down
8 changes: 4 additions & 4 deletions lib/system/io.nim
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,12 @@ const
# should not be translated.

when defined(posix) and not defined(nimscript):
type
Mode {.importc: "mode_t", header: "<sys/types.h>".} = cushort
# BUGFIX: was cint

when defined(linux) and defined(amd64):
type
Mode {.importc: "mode_t", header: "<sys/types.h>".} = cint

# fillers ensure correct size & offsets
Stat {.importc: "struct stat",
header: "<sys/stat.h>", final, pure.} = object ## struct stat
Expand All @@ -524,8 +526,6 @@ when defined(posix) and not defined(nimscript):

else:
type
Mode {.importc: "mode_t", header: "<sys/types.h>".} = cint

Stat {.importc: "struct stat",
header: "<sys/stat.h>", final, pure.} = object ## struct stat
st_mode: Mode ## Mode of file
Expand Down