Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!hao!gatech!seismo!columbia!cheshire.columbia.edu!francus From: francus@cheshire.columbia.edu.UUCP Newsgroups: comp.lang.c Subject: Re: Inline assembler; a quiz (long; sorry) Message-ID: <4788@columbia.UUCP> Date: Tue, 7-Jul-87 09:03:29 EDT Article-I.D.: columbia.4788 Posted: Tue Jul 7 09:03:29 1987 Date-Received: Thu, 9-Jul-87 04:55:55 EDT References: <608@zen.UUCP> <2299@hoptoad.uucp> <21211@sun.uucp> <830@omepd> <239@sugar.UUCP> <8253@utzoo.UUCP> Sender: nobody@columbia.UUCP Reply-To: francus@cheshire.columbia.edu.UUCP (Yoseff Francus) Organization: Columbia University CS Department Lines: 40 In article <8253@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes: >> Not all C compilers are running on UNIX. >> >> Some operating systems require heavy assembly language glue around >> system calls. It's so much easier to put this glue in asm statements >> in 'C' source. > >I have news for you: Unix systems generally require assembly-language glue >around system calls too, since virtually no Unix system does system calls >exactly the same way it does function calls. (If nothing else, the actual >call instruction almost invariably differs.) The standard solution, used >by the original Unix and still used by most Unixes, is that the "system >call" in C is just an ordinary function call, and the function that's called >is written in assembler and does the actual system call. > >The original PDP-11 Unixes had grossly non-C system-call conventions and >worked fine despite a C compiler that never supported "asm" at all. >-- >Mars must wait -- we have un- Henry Spencer @ U of Toronto Zoology >finished business on the Moon. {allegra,ihnp4,decvax,pyramid}!utzoo!henry Well, if you look at the source code, if you have source, you'll notice that most - if not all - of the system call found in Section 2 of the manual are written in 'C'. In fact even kernel system calls like namei are written in 'C'. (By kernel system call I simply mean that the user does not have access to these functions.) WHat is interesting is that the strcmp family, section 3 functions, are written in assembly on many macines, the Amdahl UTS is one that comes to mind. Yoseff ****************************************************************** yf In Xanadu did Kubla Khan a stately pleasure dome decree But only if the NFL to a franchise would agree. ARPA: francus@cs.columbia.edu UUCP: seismo!columbia!francus