1 /* vi: set sw=4 ts=4: */
5 * Copyright (C) 2005 by Manuel Novoa III <mjn3@codepoet.org>
6 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
8 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
11 #include <sys/syscall.h>
13 #include <sys/resource.h>
18 # define __NR___syscall_nice __NR_nice
19 static __inline__ _syscall1(int, __syscall_nice, int, incr)
26 static __inline__ int int_add_no_wrap(int a, int b)
39 static __inline__ int __syscall_nice(int incr)
43 /* This should never fail. */
44 old_priority = getpriority(PRIO_PROCESS, 0);
46 /* But if you want to be paranoid... */
51 old_priority = getpriority(PRIO_PROCESS, 0);
52 if ((old_priority == -1) && errno) {
55 __set_errno(old_errno);
58 if (setpriority(PRIO_PROCESS, 0, int_add_no_wrap(old_priority, incr))) {
59 __set_errno(EPERM); /* SUSv3 mandates EPERM for nice failure. */
70 if (__syscall_nice(incr)) {
74 return getpriority(PRIO_PROCESS, 0);