25 int getrlimit(
int type, rlimit* dst) {
26 if (type == RLIMIT_STACK) {
27 NT_TIB* tib = (NT_TIB*)NtCurrentTeb();
28 dst->rlim_cur = (size_t)tib->StackBase - (
size_t)tib->StackLimit;
29 dst->rlim_max = dst->rlim_cur;
35 int getrusage(
int , rusage* usage) {
37 ZeroMemory(usage,
sizeof(rusage));
41 int setrlimit(
int , rlimit* ) {
47 int getpriority(
int which,
int who) {
48 if (which != PRIO_PROCESS || who != 0) {
53 auto ret = GetPriorityClass(GetCurrentProcess());
58 case IDLE_PRIORITY_CLASS:
60 case BELOW_NORMAL_PRIORITY_CLASS:
62 case NORMAL_PRIORITY_CLASS:
64 case ABOVE_NORMAL_PRIORITY_CLASS:
66 case HIGH_PRIORITY_CLASS:
68 case REALTIME_PRIORITY_CLASS:
79 int setpriority(
int which,
int who,
int value) {
80 if (which != PRIO_PROCESS || who != 0) {
85 auto newClass = [
value] {
87 return IDLE_PRIORITY_CLASS;
88 }
else if (value >= 30) {
89 return BELOW_NORMAL_PRIORITY_CLASS;
90 }
else if (value >= 20) {
91 return NORMAL_PRIORITY_CLASS;
92 }
else if (value >= 10) {
93 return ABOVE_NORMAL_PRIORITY_CLASS;
95 return HIGH_PRIORITY_CLASS;
99 if (!SetPriorityClass(GetCurrentProcess(), newClass)) {
static const char *const value