Skip to content

Commit

Permalink
fixup: SC_GETPW_R_SIZE_MAX undefined on MacOS,freertos
Browse files Browse the repository at this point in the history
  • Loading branch information
litlighilit committed Jan 31, 2025
1 parent ac22f7c commit aff357e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/std/private/osappdirs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ when defined(unix): # XXX: suitable?
##
# replace "~username" with `pwd.getpwnam(username).pw_dir`
# translated from CPython's pwd.getpwnam, a.k.a. pwd_getpwnam_impl in Modules/pwdmodule.c
var bufsize = sysconf(SC_GETPW_R_SIZE_MAX)
if bufsize == -1:
bufsize = DEFAULT_BUFFER_SIZE

let name_chars = cstring username

var
nomem = false
p: ptr Passwd = nil
buf: cstring = nil
when declared(getpwnam_r) and declared(reallocShared):

when declared(getpwnam_r) and declared(SC_GETPW_R_SIZE_MAX) and
declared(reallocShared):
var bufsize = sysconf(SC_GETPW_R_SIZE_MAX)
if bufsize == -1:
bufsize = DEFAULT_BUFFER_SIZE

var pwd: Passwd
while true:
let buf2 = cast[cstring](reallocShared(buf, bufsize))
Expand Down

0 comments on commit aff357e

Please # to comment.