summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc59
1 files changed, 27 insertions, 32 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 889d0c782..7ea36273b 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2443,46 +2443,41 @@ memccpy (_PTR out, const _PTR in, int c, size_t len)
}
extern "C" int
-nice (int incr)
+setpriority (int which, id_t who, int value)
{
- DWORD priority[] =
+ /* TODO: Support PRIO_PGRP and PRIO_USER. */
+ if (which != PRIO_PROCESS || (who != 0 && (pid_t) who != myself->pid))
{
- IDLE_PRIORITY_CLASS,
- IDLE_PRIORITY_CLASS,
- NORMAL_PRIORITY_CLASS,
- HIGH_PRIORITY_CLASS,
- REALTIME_PRIORITY_CLASS,
- REALTIME_PRIORITY_CLASS
- };
- int curr = 2;
-
- switch (GetPriorityClass (hMainProc))
+ set_errno (EINVAL);
+ return -1;
+ }
+ DWORD prio = nice_to_winprio (value);
+ if (SetPriorityClass (hMainProc, prio) == FALSE)
{
- case IDLE_PRIORITY_CLASS:
- curr = 1;
- break;
- case NORMAL_PRIORITY_CLASS:
- curr = 2;
- break;
- case HIGH_PRIORITY_CLASS:
- curr = 3;
- break;
- case REALTIME_PRIORITY_CLASS:
- curr = 4;
- break;
+ __seterrno ();
+ return -1;
}
- if (incr > 0)
- incr = -1;
- else if (incr < 0)
- incr = 1;
+ myself->nice = value;
+ debug_printf ("Set nice to %d", myself->nice);
+ return 0;
+}
- if (SetPriorityClass (hMainProc, priority[curr + incr]) == FALSE)
+extern "C" int
+getpriority (int which, id_t who)
+{
+ /* TODO: Support PRIO_PGRP and PRIO_USER. */
+ if (which != PRIO_PROCESS || (who != 0 && (pid_t) who != myself->pid))
{
- __seterrno ();
+ set_errno (EINVAL);
return -1;
}
+ return myself->nice;
+}
- return 0;
+extern "C" int
+nice (int incr)
+{
+ return setpriority (PRIO_PROCESS, myself->pid, myself->nice + incr);
}
/*
@@ -2588,7 +2583,7 @@ endutent ()
}
extern "C" void
-utmpname (_CONST char *file)
+utmpname (const char *file)
{
if (check_null_empty_str (file))
{