sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Name : nice.cpp sl@0: // Part of : LIBC sl@0: // Contains the source for fchdir sl@0: // Version : 1.0 sl@0: // sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: extern "C" { sl@0: sl@0: /* sl@0: The function nice() increases or decreases the priority value by sl@0: adding the value 'incr' to the current priority. sl@0: It internally uses getpriority and setpriority to set the priority sl@0: to new value. sl@0: It returns the new value of the priority, which shall be in the range sl@0: of -15 to 19. -1 is a legitimate return value, so the user has to check sl@0: the errno to be sure of failure. sl@0: */ sl@0: EXPORT_C int nice(int incr) sl@0: { sl@0: sl@0: int retGetPri = -1; sl@0: int retSetPri = -1; sl@0: int retVal = -1; sl@0: sl@0: if(((retGetPri = getpriority(PRIO_PROCESS, 0)) == -1) && (errno)) sl@0: { sl@0: errno = ENOSYS; sl@0: } sl@0: else sl@0: { sl@0: retSetPri = setpriority(PRIO_PROCESS, 0, retGetPri + incr); sl@0: if(!retSetPri) sl@0: { sl@0: retVal = 0; sl@0: } sl@0: } sl@0: return retVal; sl@0: } sl@0: sl@0: } //extern "C"