syscall(2) function

Paul Gluckauf Haahr haahr at phoenix.Princeton.EDU
Tue Feb 28 12:50:13 AEST 1989


kerchen at iris.ucdavis.edu (Paul Kerchen) writes:
> Is the system call "syscall()" necessary?

as doug points out, it's just a library function not a system call.
all it provides is a (portable) C callable interface to the assembly
language glue that traps to the operating system.  it is the moral
equivalent of an inline asm directive for a "chmk" or "trap #0" or
"syscall" instruction.

on some systems i've seen, the system calls that can be implemented
as calls to syscall() are.  (things like wait() and pipe() often are hard
to do)  this makes it easy to write the syscalls directly in c.

gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) responds:
> It's not a system call, just a library function.
> Of course it is not necessary in any logical sense.
> I don't even think it's particularly useful these days;
> the last time I saw it used was on a Sixth Edition UNIX system.

it can be useful if one is spoofing other system calls.  i have code,
for example, that replaces read() and write() with functions that
somewhere down the road do real syscalls.
with syscall() declared as
	int syscall(int, ...);
one can conveniently use
	#define	_read(fd, buf, n) syscall(SYS_read, fd, buf, n)

[ to do this in an ansi c environment, one would probably have to
spoof out _SYS_read as well. ]

paul haahr
princeton!haahr	  haahr at princeton.edu	haahr at pucc.bitnet



More information about the Comp.unix.wizards mailing list