diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2005-01-25 22:45:11 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2005-01-25 22:45:11 +0000 |
commit | 72c1491bba149c8fbd9eb81a0a529aa8bad47bb5 (patch) | |
tree | 22544335c6c060175878b8bd05f459cbbe0d3fd0 /winsup/cygwin/syscalls.cc | |
parent | 17923424c4bc8d7f132e174939814baebdbae1a0 (diff) | |
download | cygnal-72c1491bba149c8fbd9eb81a0a529aa8bad47bb5.tar.gz cygnal-72c1491bba149c8fbd9eb81a0a529aa8bad47bb5.tar.bz2 cygnal-72c1491bba149c8fbd9eb81a0a529aa8bad47bb5.zip |
* cygwin.din: Export getpriority and setpriority.
* fork.cc (fork_parent): Copy parent's nice value into child.
* spawn.cc (spawn_guts): Ditto.
* miscfuncs.cc (winprio_to_nice): New function.
(nice_to_winprio): Ditto.
* pinfo.cc (pinfo_init): If parent is not a Cygwin process, set
default nice value according to current Win32 priority class.
* pinfo.h (class _pinfo): Add nice member.
* syscalls.cc (setpriority): New function, only implementing
PRIO_PROCESS for now.
(getpriority): Ditto.
(nice): Just call setpriority.
* wincap.h (wincaps::has_extended_priority_class): New element.
* wincap.cc: Implement above element throughout.
* winsup.h: Add prototypes for winprio_to_nice and nice_to_winprio.
* include/limits.h (NZERO): New define.
* include/cygwin/types.h (id_t): New datatype.
* include/cygwin/version.h: Bump API minor version.
* include/sys/resource.h: Add PRIO_XXX defines and prototypes for
getpriority and setpriority.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 59 |
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)) { |