Thumbnail file hits. Based on a patch from D Bera
[beagle.git] / glue / ioprio-glue.c
blob0026209b32e37764b117092133246bd6d815916e
1 /*
2 * ioprio-glue.c - I/O priority wrappers for the big dog
4 * Robert Love <rml@novell.com>
6 * Copyright (C) 2005 Novell, Inc.
7 */
9 #if defined(__i386__)
10 #define __NR_ioprio_set 289
11 #define __NR_ioprio_get 290
12 #elif defined(__powerpc__) || defined(__powerpc64__)
13 #define __NR_ioprio_set 273
14 #define __NR_ioprio_get 274
15 #elif defined(__x86_64__)
16 #define __NR_ioprio_set 251
17 #define __NR_ioprio_get 252
18 #elif defined(__ia64__)
19 #define __NR_ioprio_set 1274
20 #define __NR_ioprio_get 1275
21 #elif defined(__alpha__)
22 #define __NR_ioprio_set 442
23 #define __NR_ioprio_get 443
24 #elif defined(__s390x__) || defined(__s390__)
25 #define __NR_ioprio_set 282
26 #define __NR_ioprio_get 283
27 #elif defined(__SH4__)
28 #define __NR_ioprio_set 288
29 #define __NR_ioprio_get 289
30 #elif defined(__SH5__)
31 #define __NR_ioprio_set 316
32 #define __NR_ioprio_get 317
33 #elif defined(__sparc__) || defined(__sparc64__)
34 #define __NR_ioprio_set 196
35 #define __NR_ioprio_get 218
36 #elif defined(__arm__)
37 #define __NR_ioprio_set 314
38 #define __NR_ioprio_get 315
39 #else
40 #error "Unsupported architecture!"
41 #endif
43 static inline int ioprio_set (int which, int who, int ioprio)
45 return syscall (__NR_ioprio_set, which, who, ioprio);
48 static inline int ioprio_get (int which, int who)
50 return syscall (__NR_ioprio_get, which, who);
53 enum {
54 IOPRIO_CLASS_NONE,
55 IOPRIO_CLASS_RT,
56 IOPRIO_CLASS_BE,
57 IOPRIO_CLASS_IDLE,
60 enum {
61 IOPRIO_WHO_PROCESS = 1,
62 IOPRIO_WHO_PGRP,
63 IOPRIO_WHO_USER,
66 #define IOPRIO_CLASS_SHIFT 13
67 #define IOPRIO_PRIO_MASK 0xff
69 int set_io_priority_idle (void)
71 int ioprio, ioclass;
73 ioprio = 7; /* priority is ignored with idle class */
74 ioclass = IOPRIO_CLASS_IDLE << IOPRIO_CLASS_SHIFT;
76 return ioprio_set (IOPRIO_WHO_PROCESS, 0, ioprio | ioclass);