aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/Unix/Process.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/Unix/Process.inc')
-rw-r--r--lib/Support/Unix/Process.inc22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/Support/Unix/Process.inc b/lib/Support/Unix/Process.inc
index 4e1bd5db14..cbd9d41ce7 100644
--- a/lib/Support/Unix/Process.inc
+++ b/lib/Support/Unix/Process.inc
@@ -35,6 +35,8 @@
# include <termios.h>
#endif
+#include <sys/unistd.h>
+
//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only generic UNIX code that
//=== is guaranteed to work on *all* UNIX variants.
@@ -53,9 +55,10 @@ Process::GetPageSize()
const int page_size = 0x1000;
#elif defined(HAVE_GETPAGESIZE)
const int page_size = ::getpagesize();
-#elif defined(HAVE_SYSCONF)
+#elif defined(HAVE_SYSCONF) && !defined(__native_client__)
long page_size = ::sysconf(_SC_PAGE_SIZE);
#else
+ const int page_size = 0;
#warning Cannot get the page size on this machine
#endif
return static_cast<unsigned>(page_size);
@@ -110,7 +113,7 @@ Process::GetTimeUsage(TimeValue& elapsed, TimeValue& user_time,
TimeValue& sys_time)
{
elapsed = TimeValue::now();
-#if defined(HAVE_GETRUSAGE)
+#if defined(HAVE_GETRUSAGE) && !defined(__native_client__)
struct rusage usage;
::getrusage(RUSAGE_SELF, &usage);
user_time = TimeValue(
@@ -131,11 +134,23 @@ Process::GetTimeUsage(TimeValue& elapsed, TimeValue& user_time,
}
int Process::GetCurrentUserId() {
+#if !defined(__native_client__)
return getuid();
+#else // (__native_client__)
+// TODO(abetul): What the proper return value should be for this function?
+// What about having a reserved user_id or the user "nobody" for PNACL?
+ return -1;
+#endif // (__native_client__)
}
int Process::GetCurrentGroupId() {
+#if !defined(__native_client__)
return getgid();
+#else // (__native_client__)
+// TODO(abetul): What the proper return value should be for this function?
+// What about having a reserved/unused group_id?
+ return -1;
+#endif // (__native_client__)
}
#if defined(HAVE_MACH_MACH_H) && !defined(__GNU__)
@@ -329,3 +344,6 @@ unsigned llvm::sys::Process::GetRandomNumber() {
return ::rand();
#endif
}
+
+#if !defined(__native_client__)
+#endif \ No newline at end of file