Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!oliveb!sun!gorodish!guy
From: guy@gorodish.UUCP
Newsgroups: comp.lang.c
Subject: Re: Inline assembler; a quiz  (long; sorry)
Message-ID: <22801@sun.uucp>
Date: Tue, 7-Jul-87 14:03:35 EDT
Article-I.D.: sun.22801
Posted: Tue Jul  7 14:03:35 1987
Date-Received: Thu, 9-Jul-87 06:27:48 EDT
References: <608@zen.UUCP> <2299@hoptoad.uucp> <21211@sun.uucp> <830@omepd> <4788@columbia.UUCP>
Sender: news@sun.uucp
Lines: 32

> 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'.

You've completely missed Henry's point.  Henry has source and is
quite familiar with the UNIX kernel, so he is certainly aware that
most of the kernel is written in C.  The point is that the code that
USER-mode programs use to make system calls is written in assembler.
The original poster was claiming that you needed to have support for
embedded assembler language in C compilers in order to perform system
calls from C programs under OSes other than UNIX, since the interface
to those system calls involves some code that cannot be expressed in
pure C.  Henry was pointing out that the UNIX system call interface
also generally requires code that cannot be expressed in pure C, but
that UNIX has gotten along quite well now without requiring embedded
assembler language to make system calls; there are small "wrapper"
routines written in assembler language that are called by C code.

> 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.

That's not particularly surprising; many machines have idioms that
can be used to speed up string processing, but it may be hard for a C
compiler to figure out when to use those idioms, or it may be that
the compiler would generate them so infrequently (e.g., only in the
source code to "strcmp" or equivalent code) that it's not worth
teaching the compiler about them.
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com