From 24db03bc3715066c4e53a9ac75604050fd6003d2 Mon Sep 17 00:00:00 2001 From: Ryan McConnell Date: Tue, 20 May 2025 21:52:41 -0400 Subject: [PATCH 1/2] init --- lib/posix/posix.nim | 4 ++++ lib/posix/posix_haiku.nim | 4 ++-- lib/posix/posix_linux_amd64.nim | 2 +- lib/posix/posix_macos_amd64.nim | 4 ++-- lib/posix/posix_nintendoswitch.nim | 2 +- lib/posix/posix_openbsd_amd64.nim | 2 +- lib/posix/posix_other.nim | 4 ++-- lib/std/private/osdirs.nim | 6 +++--- 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index 9239ca1482c0b..4525e469a9aff 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -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: "".} proc aio_error*(a1: ptr Taiocb): cint {.importc, header: "".} diff --git a/lib/posix/posix_haiku.nim b/lib/posix/posix_haiku.nim index 6e325cb6595e5..9f6146196abda 100644 --- a/lib/posix/posix_haiku.nim +++ b/lib/posix/posix_haiku.nim @@ -157,9 +157,9 @@ type Mode* {.importc: "mode_t", header: "".} = ( when defined(android) or defined(macos) or defined(macosx) or (defined(bsd) and not defined(openbsd) and not defined(netbsd)): - uint16 + distinct uint16 else: - uint32 + distinct uint32 ) Nlink* {.importc: "nlink_t", header: "".} = int32 Off* {.importc: "off_t", header: "".} = int64 diff --git a/lib/posix/posix_linux_amd64.nim b/lib/posix/posix_linux_amd64.nim index 7a9126abed618..28b888c3cde25 100644 --- a/lib/posix/posix_linux_amd64.nim +++ b/lib/posix/posix_linux_amd64.nim @@ -144,7 +144,7 @@ type Id* {.importc: "id_t", header: "".} = cuint Ino* {.importc: "ino_t", header: "".} = culong Key* {.importc: "key_t", header: "".} = cint - Mode* {.importc: "mode_t", header: "".} = uint32 + Mode* {.importc: "mode_t", header: "".} = distinct uint32 Nlink* {.importc: "nlink_t", header: "".} = culong Off* {.importc: "off_t", header: "".} = clong Pid* {.importc: "pid_t", header: "".} = cint diff --git a/lib/posix/posix_macos_amd64.nim b/lib/posix/posix_macos_amd64.nim index 2b5dea69f4c51..76c1b4296a7f5 100644 --- a/lib/posix/posix_macos_amd64.nim +++ b/lib/posix/posix_macos_amd64.nim @@ -135,9 +135,9 @@ type Key* {.importc: "key_t", header: "".} = int Mode* {.importc: "mode_t", header: "".} = ( when defined(openbsd) or defined(netbsd): - uint32 + distinct uint32 else: - uint16 + distinct uint16 ) Nlink* {.importc: "nlink_t", header: "".} = uint16 Off* {.importc: "off_t", header: "".} = int64 diff --git a/lib/posix/posix_nintendoswitch.nim b/lib/posix/posix_nintendoswitch.nim index fdc4e590e4c2e..59686338575c9 100644 --- a/lib/posix/posix_nintendoswitch.nim +++ b/lib/posix/posix_nintendoswitch.nim @@ -123,7 +123,7 @@ type Id* {.importc: "id_t", header: "".} = cuint Ino* {.importc: "ino_t", header: "".} = culong Key* {.importc: "key_t", header: "".} = cint - Mode* {.importc: "mode_t", header: "".} = uint16 + Mode* {.importc: "mode_t", header: "".} = distinct uint16 Nlink* {.importc: "nlink_t", header: "".} = culong Off* {.importc: "off_t", header: "".} = clong Pid* {.importc: "pid_t", header: "".} = cint diff --git a/lib/posix/posix_openbsd_amd64.nim b/lib/posix/posix_openbsd_amd64.nim index 9244ce78ccc2a..eb0a05e002742 100644 --- a/lib/posix/posix_openbsd_amd64.nim +++ b/lib/posix/posix_openbsd_amd64.nim @@ -142,7 +142,7 @@ type Id* {.importc: "id_t", header: "".} = int Ino* {.importc: "ino_t", header: "".} = int Key* {.importc: "key_t", header: "".} = int - Mode* {.importc: "mode_t", header: "".} = uint32 + Mode* {.importc: "mode_t", header: "".} = distinct uint32 Nlink* {.importc: "nlink_t", header: "".} = uint32 Off* {.importc: "off_t", header: "".} = int64 Pid* {.importc: "pid_t", header: "".} = int32 diff --git a/lib/posix/posix_other.nim b/lib/posix/posix_other.nim index 6301216d4c0cb..aff65af7b2d4e 100644 --- a/lib/posix/posix_other.nim +++ b/lib/posix/posix_other.nim @@ -160,9 +160,9 @@ type Mode* {.importc: "mode_t", header: "".} = ( when defined(android) or defined(macos) or defined(macosx) or (defined(bsd) and not defined(openbsd) and not defined(netbsd)): - uint16 + distinct uint16 else: - uint32 + distinct uint32 ) Nlink* {.importc: "nlink_t", header: "".} = int Off* {.importc: "off_t", header: "".} = int64 diff --git a/lib/std/private/osdirs.nim b/lib/std/private/osdirs.nim index 5c6aa3e4d9514..e82f548316a7b 100644 --- a/lib/std/private/osdirs.nim +++ b/lib/std/private/osdirs.nim @@ -362,7 +362,7 @@ 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}: @@ -370,7 +370,7 @@ proc rawCreateDir(dir: string): bool {.noWeirdTarget.} = 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: @@ -378,7 +378,7 @@ proc rawCreateDir(dir: string): bool {.noWeirdTarget.} = 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: From 825be45a90193497cce726d6688e2fbdffd67632 Mon Sep 17 00:00:00 2001 From: Ryan McConnell Date: Tue, 20 May 2025 22:02:40 -0400 Subject: [PATCH 2/2] k --- lib/posix/posix_haiku.nim | 6 +++--- lib/posix/posix_macos_amd64.nim | 6 +++--- lib/posix/posix_other.nim | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/posix/posix_haiku.nim b/lib/posix/posix_haiku.nim index 9f6146196abda..704c9e23ad30d 100644 --- a/lib/posix/posix_haiku.nim +++ b/lib/posix/posix_haiku.nim @@ -154,12 +154,12 @@ type Id* {.importc: "id_t", header: "".} = int32 Ino* {.importc: "ino_t", header: "".} = int64 Key* {.importc: "key_t", header: "".} = int32 - Mode* {.importc: "mode_t", header: "".} = ( + Mode* {.importc: "mode_t", header: "".} = distinct ( when defined(android) or defined(macos) or defined(macosx) or (defined(bsd) and not defined(openbsd) and not defined(netbsd)): - distinct uint16 + uint16 else: - distinct uint32 + uint32 ) Nlink* {.importc: "nlink_t", header: "".} = int32 Off* {.importc: "off_t", header: "".} = int64 diff --git a/lib/posix/posix_macos_amd64.nim b/lib/posix/posix_macos_amd64.nim index 76c1b4296a7f5..6591eb11e9e4f 100644 --- a/lib/posix/posix_macos_amd64.nim +++ b/lib/posix/posix_macos_amd64.nim @@ -133,11 +133,11 @@ type Id* {.importc: "id_t", header: "".} = int Ino* {.importc: "ino_t", header: "".} = int Key* {.importc: "key_t", header: "".} = int - Mode* {.importc: "mode_t", header: "".} = ( + Mode* {.importc: "mode_t", header: "".} = distinct ( when defined(openbsd) or defined(netbsd): - distinct uint32 + uint32 else: - distinct uint16 + uint16 ) Nlink* {.importc: "nlink_t", header: "".} = uint16 Off* {.importc: "off_t", header: "".} = int64 diff --git a/lib/posix/posix_other.nim b/lib/posix/posix_other.nim index aff65af7b2d4e..012eeeddd5e61 100644 --- a/lib/posix/posix_other.nim +++ b/lib/posix/posix_other.nim @@ -157,12 +157,12 @@ type Id* {.importc: "id_t", header: "".} = int Ino* {.importc: "ino_t", header: "".} = int Key* {.importc: "key_t", header: "".} = int - Mode* {.importc: "mode_t", header: "".} = ( + Mode* {.importc: "mode_t", header: "".} = distinct ( when defined(android) or defined(macos) or defined(macosx) or (defined(bsd) and not defined(openbsd) and not defined(netbsd)): - distinct uint16 + uint16 else: - distinct uint32 + uint32 ) Nlink* {.importc: "nlink_t", header: "".} = int Off* {.importc: "off_t", header: "".} = int64