* Re: [gentoo-user] Re: _syscallX isn't in linux-headers-2.6.20 ??
@ 2007-02-08 7:01 99% ` Iain Buchanan
0 siblings, 0 replies; 1+ results
From: Iain Buchanan @ 2007-02-08 7:01 UTC (permalink / raw
To: gentoo-user
On Thu, 2007-02-08 at 16:10 +1100, Christian Marie wrote:
> On Thu, Feb 08, 2007 at 10:23:09AM +0930, Iain Buchanan wrote:
> > Hi all,
> >
> > I'm trying to use:
> >
> > _syscall3(int, ioprio_set, int, which, int, who, int, ioprio);
> > _syscall2(int, ioprio_get, int, which, int, who);
> >
> > and supposedly I just
> >
> > #include <linux/unistd.h>
> >
> > but I'm getting these error from gcc:
> >
> > error: syntax error before "ioprio_set"
> > warning: data definition has no type or storage class
> > error: syntax error before "ioprio_get"
> > warning: data definition has no type or storage class
>
> Hi,
>
> It would be helpful to provide us with the failing code as we have no
> clue what you could be doing wrong.
sure - my question was more "where has the define for _syscall2 gone?",
but here is the code. It comes
from /usr/src/linux/Documentation/block/ioprio.txt. I compile it with:
$ gcc -o ionice ionice.c
ionice.c:36: error: syntax error before "ioprio_set"
ionice.c:36: warning: data definition has no type or storage class
ionice.c:37: error: syntax error before "ioprio_get"
ionice.c:37: warning: data definition has no type or storage class
------begin ionice.c------
//
// Sample ionice utility copied from
// /usr/src/linux/Documentation/block/ioprio.txt from gentoo kernel version
// 2.6.19-suspend2-r1. Probably (C) Jens Axboe <axboe@suse.de> and GPL'd?
//
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <getopt.h>
#include <unistd.h>
#include <sys/ptrace.h>
extern int sys_ioprio_set(int, int, int);
extern int sys_ioprio_get(int, int);
#if defined(__i386__)
#define __NR_ioprio_set 289
#define __NR_ioprio_get 290
#elif defined(__ppc__)
#define __NR_ioprio_set 273
#define __NR_ioprio_get 274
#elif defined(__x86_64__)
#define __NR_ioprio_set 251
#define __NR_ioprio_get 252
#elif defined(__ia64__)
#define __NR_ioprio_set 1274
#define __NR_ioprio_get 1275
#else
#error "Unsupported arch"
#endif
int ioprio_get(int which, int who);
int ioprio_set(int which, int who, int ioprio);
_syscall3(int, ioprio_set, int, which, int, who, int, ioprio);
_syscall2(int, ioprio_get, int, which, int, who);
enum {
IOPRIO_CLASS_NONE,
IOPRIO_CLASS_RT,
IOPRIO_CLASS_BE,
IOPRIO_CLASS_IDLE,
};
enum {
IOPRIO_WHO_PROCESS = 1,
IOPRIO_WHO_PGRP,
IOPRIO_WHO_USER,
};
#define IOPRIO_CLASS_SHIFT 13
const char *to_prio[] = { "none", "realtime", "best-effort", "idle", };
int main(int argc, char *argv[])
{
int ioprio = 4, set = 0, ioprio_class = IOPRIO_CLASS_BE;
int c, pid = 0;
while ((c = getopt(argc, argv, "+n:c:p:")) != EOF) {
switch (c) {
case 'n':
ioprio = strtol(optarg, NULL, 10);
set = 1;
break;
case 'c':
ioprio_class = strtol(optarg, NULL, 10);
set = 1;
break;
case 'p':
pid = strtol(optarg, NULL, 10);
break;
}
}
switch (ioprio_class) {
case IOPRIO_CLASS_NONE:
ioprio_class = IOPRIO_CLASS_BE;
break;
case IOPRIO_CLASS_RT:
case IOPRIO_CLASS_BE:
break;
case IOPRIO_CLASS_IDLE:
ioprio = 7;
break;
default:
printf("bad prio class %d\n", ioprio_class);
return 1;
}
if (!set) {
if (!pid && argv[optind])
pid = strtol(argv[optind], NULL, 10);
ioprio = ioprio_get(IOPRIO_WHO_PROCESS, pid);
printf("pid=%d, %d\n", pid, ioprio);
if (ioprio == -1)
perror("ioprio_get");
else {
ioprio_class = ioprio >> IOPRIO_CLASS_SHIFT;
ioprio = ioprio & 0xff;
printf("%s: prio %d\n", to_prio[ioprio_class], ioprio);
}
} else {
if (ioprio_set(IOPRIO_WHO_PROCESS, pid, ioprio | ioprio_class << IOPRIO_CLASS_SHIFT) == -1) {
perror("ioprio_set");
return 1;
}
if (argv[optind])
execvp(argv[optind], &argv[optind]);
}
return 0;
}
------end ionice.c------
thanks,
--
Iain Buchanan <iaindb at netspace dot net dot au>
Progress might have been all right once, but it's gone on too long.
-- Ogden Nash
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2007-02-08 0:53 [gentoo-user] _syscallX isn't in linux-headers-2.6.20 ?? Iain Buchanan
2007-02-08 5:10 ` [gentoo-user] " Christian Marie
2007-02-08 7:01 99% ` Iain Buchanan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox