Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!cuae2!ltuxa!ttrdc!levy
From: levy@ttrdc.UUCP
Newsgroups: comp.lang.c
Subject: Re: Asm glue for UNIX system calls
Message-ID: <1806@ttrdc.UUCP>
Date: Wed, 8-Jul-87 23:29:06 EDT
Article-I.D.: ttrdc.1806
Posted: Wed Jul  8 23:29:06 1987
Date-Received: Sat, 11-Jul-87 16:49:45 EDT
References: <608@zen.UUCP> <2299@hoptoad.uucp> <21211@sun.uucp> <830@omepd> <4788@columbia.UUCP>
Organization: AT&T, Skokie, IL
Lines: 37

In article <4788@columbia.UUCP>, francus@cheshire.columbia.edu (Yoseff Francus) writes:
> >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.
> >Henry Spencer @ U of Toronto Zoology
> 
> 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'.

Gee whiz, they're all in asm on this machine (3b20):

$ ls -C /usr/src/lib/libC/u3b/sys
access.s   dup.s      getpid.s   mount.s    read.s     stime.s    umount.s
acct.s     execve.s   getppid.s  msgsys.s   sbrk.s     stty.s     uname.s
alarm.s    exit.s     getuid.s   nice.s     semsys.s   sync.s     unlink.s
chdir.s    fcntl.s    gtty.s     open.s     setgid.s   sys3b.s    ustat.s
chmod.s    fork.s     ioctl.s    pause.s    setpgrp.s  syscall.s  utime.s
chown.s    fstat.s    kill.s     pipe.s     setuid.s   time.s     wait.s
chroot.s   getegid.s  link.s     plock.s    shmsys.s   times.s    write.s
close.s    geteuid.s  lseek.s    profil.s   signal.s   ulimit.s
creat.s    getgid.s   mknod.s    ptrace.s   stat.s     umask.s

and for good reason.  The way you get into the guts of a system call in the
first place is via a special instruction (e.g., "gate" on the 3B2) which is
your magic trap door into the kernel for the system call you are invoking from
your process.  Nothing says that communication between the code on the near
and far sides of that door has to abide by the semantics of an ordinary
procedure call.  It could be through designated machine registers.  How do
the system calls on your machine handle this "trap door" instruction from
C--by asm statements?  That's okay, but you've at least got to have one
such special asm instruction per call.
-- 
|------------dan levy------------|  path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
|         an engihacker @        |		vax135}!ttrdc!ttrda!levy
|    at&t data systems division  |  disclaimer:  i am not a yvel nad
|--------skokie, illinois--------|