Skip to content

make posix.Mode distinct #24964

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

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions lib/posix/posix.nim
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ else:
## Nanosecond-granularity time of last data modification.
result.tv_sec = s.st_ctime

proc `and`*(x, y: Mode): Mode {.borrow.}
proc `or`*(x, y: Mode): Mode {.borrow.}
proc `==`*(x, y: Mode): bool {.borrow.}

when hasAioH:
proc aio_cancel*(a1: cint, a2: ptr Taiocb): cint {.importc, header: "<aio.h>".}
proc aio_error*(a1: ptr Taiocb): cint {.importc, header: "<aio.h>".}
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/posix_haiku.nim
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ type
Id* {.importc: "id_t", header: "<sys/types.h>".} = int32
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int64
Key* {.importc: "key_t", header: "<sys/types.h>".} = int32
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = (
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = distinct (
when defined(android) or defined(macos) or defined(macosx) or
(defined(bsd) and not defined(openbsd) and not defined(netbsd)):
uint16
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/posix_linux_amd64.nim
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type
Id* {.importc: "id_t", header: "<sys/types.h>".} = cuint
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = culong
Key* {.importc: "key_t", header: "<sys/types.h>".} = cint
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint32
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = distinct uint32
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = culong
Off* {.importc: "off_t", header: "<sys/types.h>".} = clong
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = cint
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/posix_macos_amd64.nim
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type
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>".} = (
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = distinct (
when defined(openbsd) or defined(netbsd):
uint32
else:
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/posix_nintendoswitch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type
Id* {.importc: "id_t", header: "<sys/types.h>".} = cuint
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = culong
Key* {.importc: "key_t", header: "<sys/types.h>".} = cint
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint16
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = distinct uint16
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = culong
Off* {.importc: "off_t", header: "<sys/types.h>".} = clong
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = cint
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/posix_openbsd_amd64.nim
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ type
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
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = distinct uint32
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
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/posix_other.nim
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ type
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>".} = (
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = distinct (
when defined(android) or defined(macos) or defined(macosx) or
(defined(bsd) and not defined(openbsd) and not defined(netbsd)):
uint16
Expand Down
6 changes: 3 additions & 3 deletions lib/std/private/osdirs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -362,23 +362,23 @@ proc rawCreateDir(dir: string): bool {.noWeirdTarget.} =
# This is a thin wrapper over mkDir (or alternatives on other systems),
# so in case of a pre-existing path we don't check that it is a directory.
when defined(solaris):
let res = mkdir(dir, 0o777)
let res = mkdir(dir, Mode(0o777))
if res == 0'i32:
result = true
elif errno in {EEXIST, ENOSYS}:
result = false
else:
raiseOSError(osLastError(), dir)
elif defined(haiku):
let res = mkdir(dir, 0o777)
let res = mkdir(dir, Mode(0o777))
if res == 0'i32:
result = true
elif errno == EEXIST or errno == EROFS:
result = false
else:
raiseOSError(osLastError(), dir)
elif defined(posix):
let res = mkdir(dir, 0o777)
let res = mkdir(dir, Mode(0o777))
if res == 0'i32:
result = true
elif errno == EEXIST:
Expand Down
Loading