Skip to content

Commit aff357e

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

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/std/private/osappdirs.nim

+7-5
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ 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
4137
buf: cstring = nil
42-
when declared(getpwnam_r) and declared(reallocShared):
38+
39+
when declared(getpwnam_r) and declared(SC_GETPW_R_SIZE_MAX) and
40+
declared(reallocShared):
41+
var bufsize = sysconf(SC_GETPW_R_SIZE_MAX)
42+
if bufsize == -1:
43+
bufsize = DEFAULT_BUFFER_SIZE
44+
4345
var pwd: Passwd
4446
while true:
4547
let buf2 = cast[cstring](reallocShared(buf, bufsize))

0 commit comments

Comments
 (0)