Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ucbvax!jade!eris!mwm From: mwm@eris.BERKELEY.EDU (Mike (My watch has windows) Meyer) Newsgroups: comp.lang.c Subject: Re: Pragmas Message-ID: <6477@jade.BERKELEY.EDU> Date: 7 Jan 88 09:16:04 GMT References: <17196@topaz.rutgers.edu> <1620005@hpcilzb.HP.COM> <5724@ccv.bbn.COM> Sender: usenet@jade.BERKELEY.EDU Reply-To: mwm@eris.BERKELEY.EDU (Mike (My watch has windows) Meyer) Organization: Missionaria Phonibalonica Lines: 49 In article <5724@ccv.bbn.COM> kgregory@ccv.bbn.com (Keith D. Gregory) writes: , ; arguments movea.l SomeLibrary,a0 ; address table jsr offset(a0) ; and go there To use these things from C (vital - the OS interface looks like shared libraries), it's normally done the same way as Unix: a stub routine in assembler that takes the C arguments, puts them in the right registers, and then jmps/jsrs to the real routine. The latest version of the Lattice C compiler has a pragma for dealing with shared libraries. It basically looks like: #pragma routinename libraryname offset registers This makes it generate an inline-call as the above, rather than a call to a C stub that does the above. This means you get faster code, and possibly slightly smaller code (depends on the details of code generation & calling sequences I haven't looked at closely - going to find out, though). What makes the useage "good" is that when you include the header file with the prototypes for the functions in a library, you get pragmas for all the functions, too. This means that I can use the feature, and the code will work on compilers that don't support this feature without change. Or if they support it in another (though similar) way, it should work. I can't see a good way to do this without something similar to pragmas. Wiring the names into the compiler means you can't get your own libraries done that way (and is probably much nastier than the above) without changing the compiler. Not good.