Skip to content

Commit 327ddef

Browse files
committed
fixup: SC_GETPW_R_SIZE_MAX undefined on MacOS,freertos
1 parent ac22f7c commit 327ddef

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/std/private/osappdirs.nim

+9-6
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@ when defined(unix): # XXX: suitable?
2929
##
3030
# replace "~username" with `pwd.getpwnam(username).pw_dir`
3131
# translated from CPython's pwd.getpwnam, a.k.a. pwd_getpwnam_impl in Modules/pwdmodule.c
32-
var bufsize = sysconf(SC_GETPW_R_SIZE_MAX)
33-
if bufsize == -1:
34-
bufsize = DEFAULT_BUFFER_SIZE
35-
3632
let name_chars = cstring username
3733

3834
var
3935
nomem = false
4036
p: ptr Passwd = nil
41-
buf: cstring = nil
42-
when declared(getpwnam_r) and declared(reallocShared):
37+
38+
when declared(getpwnam_r) and declared(SC_GETPW_R_SIZE_MAX) and
39+
declared(reallocShared):
40+
var
41+
buf: cstring = nil
42+
bufsize = sysconf(SC_GETPW_R_SIZE_MAX)
43+
if bufsize == -1:
44+
bufsize = DEFAULT_BUFFER_SIZE
45+
4346
var pwd: Passwd
4447
while true:
4548
let buf2 = cast[cstring](reallocShared(buf, bufsize))

0 commit comments

Comments
 (0)