Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ritcv.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!pyramid!ut-sally!seismo!rochester!ritcv!spw2562 From: spw2562@ritcv.UUCP (Fishhook) Newsgroups: net.unix-wizards Subject: Re: Prepending _ in C external names necessary? Message-ID: <9113@ritcv.UUCP> Date: Wed, 4-Dec-85 15:28:54 EST Article-I.D.: ritcv.9113 Posted: Wed Dec 4 15:28:54 1985 Date-Received: Sat, 7-Dec-85 03:14:20 EST References: <200@brl-tgr.ARPA> <174@altos86.UUCP> Reply-To: spw2562@ritcv.UUCP (Fishhook) Distribution: net Organization: Rochester Institute of Technology, Rochester, NY Lines: 47 Summary: _write or write? [munch crunch] I don't know if this is tru for all systems, but one system I worked on passed parameters to system calls using specific registers. Paremeters to C functions are passed on the stack. Therefore, for the compiler to call user functions and system calls, it has to know what all the system calls are. UNLESS... The system I worked on treated all system calls as function calls and had function stubs which moved the stack parameters to the proper registers then performed the actual system call. Naturally, these stubs are written in assembly. For this to be possible, the system call has to be different from the function call. Answer? Prepend every C function call with an underline, prepend all the function stubs with an underline, DON'T prepend system calls. Therefore, ... write(fd,&data,bytes) in C becomes ... ... pushl fd,-@sp or whatever, push the args to stack ... calls _write and call the function ... And the library _write function stub is ... _write: address of function movl +@sp,d1 or whatever, move function args from ... stack to proper registers calls write do the actual system call - no '_' ... and do the stuff to return the value it gets from the system call Without underscore prepending this would not be possible. ============================================================================== Steve Wall @ Rochester Institute of Technology USnail: 6675 Crosby Rd, Lockport, NY 14094, USA Usenet: ..!rochester!ritcv!spw2562 (Fishhook) Unix 4.2 BSD BITNET: SPW2562@RITVAXC (Snoopy) VAX/VMS 4.2 Voice: Yell "Hey Steve!" Disclaimer: What I just said may or may not have anything to do with what I was actually thinking...