#include <stdio.h>
#include <errno.h>
#define __NR_mysyscall 341
#define _syscall0(type, name) \
type name(void) \
{ \
long __res; \
__asm__ __volatile__("int $0x80":"=a"(__res) :"a"(__NR_##name)); \
if (__res >= 0) \
return (type) __res; \
errno = -__res; \
return -1; \
}
_syscall0(int, mysyscall)
int main(int argc, char* argv[])
{
int res;
res = mysyscall();
if (res < 0)
printf("call mysyscall res=%d, strerror(%d)=%s\n", res, errno, strerror(errno));
else
printf("call mysyscall ok res=%d\n", res);
return 0;
}