Add copyright notices and new function String.chomp
[ocaml.git] / otherlibs / unix / nice.c
blob6018af0c2b721ecd4587c3037b580bae9e22db16
1 /***********************************************************************/
2 /* */
3 /* Objective Caml */
4 /* */
5 /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 /* */
7 /* Copyright 1996 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../../LICENSE. */
11 /* */
12 /***********************************************************************/
14 /* $Id$ */
16 #include <mlvalues.h>
17 #include "unixsupport.h"
18 #include <errno.h>
20 #ifdef HAS_GETPRIORITY
22 #include <sys/types.h>
23 #include <sys/time.h>
24 #include <sys/resource.h>
26 CAMLprim value unix_nice(value incr)
28 int prio;
29 errno = 0;
30 prio = getpriority(PRIO_PROCESS, 0);
31 if (prio == -1 && errno != 0)
32 uerror("nice", Nothing);
33 prio += Int_val(incr);
34 if (setpriority(PRIO_PROCESS, 0, prio) == -1)
35 uerror("nice", Nothing);
36 return Val_int(prio);
39 #else
41 CAMLprim value unix_nice(value incr)
43 int ret;
44 errno = 0;
45 ret = nice(Int_val(incr));
46 if (ret == -1 && errno != 0) uerror("nice", Nothing);
47 return Val_int(ret);
50 #endif