[PATCH] Introduce llvm::sys::path::home_directory.
David Majnemer
david.majnemer at gmail.com
Sun Nov 17 03:53:59 PST 2013
================
Comment at: lib/Support/Unix/Path.inc:805
@@ +804,3 @@
+
+ return false;
+}
----------------
Have you considered falling back to `getpwuid_r` on SUSv3? Something like:
bufsize = 2048;
#ifdef _SC_GETPW_R_SIZE_MAX
if ((getpw_r_size_max = sysconf(_SC_GETPW_R_SIZE_MAX)) > 0)
bufsize = (size_t)getpw_r_size_max;
#endif
uid = getuid();
buf = NULL;
do {
if ((tbuf = realloc(buf, bufsize)) == NULL) {
free(buf);
return false;
}
buf = tbuf;
err = getpwuid_r(uid, &pw, buf, bufsize, &tpw);
bufsize *= 2;
} while (err == ERANGE);
if (err) {
free(buf);
return false;
}
if (!tpw || !pw.pw_dir)
return false;
result.append(pw.pw_dir, pw.pw_dir + strlen(pw.pw_dir));
return true;
http://llvm-reviews.chandlerc.com/D2199
More information about the llvm-commits
mailing list