🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #6591

Re: Lattice C : pragma? Whats all this then?

#6591
From: markv
Date: Tue, 13 Nov 1990 17:21
62 lines
3769 bytes
> It is the responsibility of the applications code to define these. Some time
> back Lattice added them to the standard run-time library to help eliminate
> confusion when the same base was defined in multiple modules, especially when
> they were compiled with different options. (Note that ExecBase is hard-wired
> at location 0x0004, and DosBase is defined in c.o). CStringsBase was left
> out because this library is not supported (or even available, if memory
> serves me).

Lattice defines several bases in their libraries including DosBase,
SysBase, MathBase, GfxBase, IntuitionBase, etc.  DosBase and SysBase
are always valid (the OS gives these to a program when it runs).  The 
MathXXXBase's are opened depending on the floating point options.  All
other bases you need to open and close yourself.  One easy way to
check if your not sure is something like:

	if (!MathTransBase) {
		MathTransBase = OpenLibrary("mathtrans.library", 33L);
		MathTransOpened = TRUE;
	}
	...
	if (MathTrasOpened) {
		CloseLibrary(MathTransBase);
	}

This works since library bases start out as null because they are
global data.  The only place this would be a problem is the math
libraries since they may or may not be opened and if you want to call
them directly they need to be, but you dont want to open/close them if
the startup code has.
 
>>Also what difference do Pramgas make? Is it done so that I can link to less
>>things? IE use my own c.o and miss out amiga.lib and lc.lib, (all in the
>>search for smaller code :-) ).
 
>#pragma support makes your code smaller and faster (in general). Without them,
> calls to Amiga libraries actually call stub routines that save the registers,
> load arguments off the stack into appropriate registers (Amiga libraries take
> arguments in registers), load the library base vector into A6, and branch to
> the real routine.
>With #pragmas,the compilergenerates the code to load the appropriate registers
>in-line,and directly calls the library routine based on thelibrary basevector.
> This eliminates the argument pushing and popping ... smaller.

Actually the code can be a lot smaller, especially with the optimizer.
Every parameter that doesn't have to be pushed is 4-8 bytes of
savings.  Multiply that by every parameter and every function call and
it adds up.  Also you dont need to clean up the stack afterwords.
Another important thing is that none of the code, stub or pragma
checks to be sure the library base is valid.  If it isnt, can you say
jump in space?  Most times with pragmas are you can skip amiga.lib
completely, unless you need some of the constants (like ciaa, etc) or
a function that doesn't work with pragmas (like NewModifyProp() under
5.0X).
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Gooderum			Only...		\    Good Cheer !!!
Academic Computing Services	       ///	  \___________________________
University of Kansas		     ///  /|         __    _
Bix:	  markgood	      \\\  ///  /__| |\/| | | _   /_\  makes it
Bitnet:   MARKV@UKANVAX		\/\/  /    | |  | | |__| /   \ possible...
Internet: markv@kuhub.cc.ukans.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Technical Details
Message-ID: <26892.273fe53b@kuhub.cc.ukans.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!julius.cs.uiuc.edu!zaphod.mps.ohio-state.edu!caen!kuhub.cc.ukans.edu!markv
References: <1990Nov10.001056.9736@canterbury.ac.nz> <63@oregon.oacis.org>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!julius.cs.uiuc.edu!zaphod.mps.ohio-state.edu!caen!kuhub.cc.ukans.edu!markv
From: markv@kuhub.cc.ukans.edu
Newsgroups: comp.sys.amiga.tech
Subject: Re: Lattice C : pragma? Whats all this then?
Message-ID: <26892.273fe53b@kuhub.cc.ukans.edu>
Date: 13 Nov 90 17:21:14 GMT
References: <1990Nov10.001056.9736@canterbury.ac.nz> <63@oregon.oacis.org>
Organization: University of Kansas Academic Computing Services
Lines: 62