Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!ncar!boulder!sunybcs!rutgers!njin!princeton!phoenix!haahr From: haahr@phoenix.Princeton.EDU (Paul Gluckauf Haahr) Newsgroups: comp.unix.wizards Subject: Re: syscall(2) function Message-ID: <6710@phoenix.Princeton.EDU> Date: 28 Feb 89 02:50:13 GMT References: <3740@ucdavis.ucdavis.edu> <9742@smoke.BRL.MIL> Reply-To: haahr@princeton.edu (Paul Gluckauf Haahr) Organization: Princeton University, Princeton NJ Lines: 32 kerchen@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@brl.arpa (Doug Gwyn (VLD/VMB) ) 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@princeton.edu haahr@pucc.bitnet