Commit 0bf43926 authored by Ivan Egorov's avatar Ivan Egorov Committed by Facebook GitHub Bot

Minimum port of `SysResource.h`

Reviewed By: yfeldblum

Differential Revision: D27260808

fbshipit-source-id: b15bcfea70f0ad5d92df3b1143ef417eb2b4adf9
parent c8206faf
......@@ -17,6 +17,7 @@
#include <folly/portability/SysResource.h>
#include <cerrno>
#include <cstring>
#ifdef _WIN32
#include <folly/portability/Windows.h>
......@@ -103,4 +104,41 @@ int setpriority(int which, int who, int value) {
return 0;
}
}
#elif defined(__XROS__)
#include <xr/thread.h> // @manual
extern "C" {
int getrlimit(int type, rlimit* dst) {
if (type == RLIMIT_STACK) {
// NOTE: This limit is a conservative estimate.
dst->rlim_cur = c_xr_thread_default_stack_size;
dst->rlim_max = c_xr_thread_default_stack_size;
return 0;
}
return -1;
}
int getrusage(int /* who */, rusage* usage) {
std::memset(usage, 0, sizeof(rusage));
return 0;
}
int setrlimit(int /* type */, rlimit* /* src */) {
return 0;
}
int getpriority(int /* which */, int /* who */) {
// 20 is the default `nice` priority, report it.
return 20;
}
int setpriority(int /* which */, int /* who */, int /* value */) {
return -1;
}
}
#endif
......@@ -16,7 +16,7 @@
#pragma once
#ifndef _WIN32
#if !defined(_WIN32) && !defined(__XROS__)
#include <sys/resource.h>
#else
#include <cstdint>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment