Re: PROBLEM: using _syscall4 to call sys_futex with -fPIC won't compile

From: Chris Friesen
Date: Mon Jul 05 2004 - 11:18:33 EST


Andreas Schwab wrote:
Benjamin Collar <benjamin.collar@xxxxxxxxxxx> writes:

> Greetings
>
> [1.]
> If I use _syscall4 in order to call sys_futex and compile with -fPIC, I
> receive this compiler error:
> "can't find a register in class `BREG' while reloading `asm'"

Don't do that then.

> [2.]
> I'm using futexes in a project and I have to build a shared library;
> thus I need to use -fPIC when compiling. When doing so, I get the error
> mentioned in [1.].

Don't use kernel headers in user space. Use syscall(3) instead.

The "_syscallx" macros are in the userspace versions of the kernel headers, and as such should be fair game. Also, you need to get a list of syscall numbers somehow, and those numbers are generally defined in the same file that contains the "_syscallx" macros.

syscall() doesn't work for all system calls. The man page explicitly warns that it doesn't work for pipe(2). Interestingly, the glibc manual doesn't have that warning. Wonder which is correct...

Chris
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/