Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!ucsd!nosc!helios.ee.lbl.gov!pasteur!ames!oliveb!amiga!cbmvax!carolyn From: carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) Newsgroups: comp.sys.amiga.tech Subject: Re: Reentrant Lattice C code Message-ID: <4373@cbmvax.UUCP> Date: 1 Aug 88 15:09:22 GMT References: <3025@cs.utexas.edu> Reply-To: carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) Organization: Commodore Technology, West Chester, PA Lines: 33 In article <3025@cs.utexas.edu> bryan@mothra.cs.utexas.edu writes: > > Is there any way to bully Lattice C 4.0 into producing reentrant >(sharable) code, that is, get rid of all absolute references from the code to >the data segment? I have a couple of versions of reentrant startup code which will appear on the 1.3 Native Developer Update disks when 1.3 is released. These startups can be used in place of Astartup (not Lstartup/c.o). So if you program can be compiled -v and linked with Astartup.obj... LIBRARY Amiga.lib, LC.lib, and you write YOUR code so it is reentrant, you can link with the new reentrant startup code and create executables that can be made resident. (like 1.3 More program, etc.) Making YOUR code reentrant involves having no globals except for constants (like error message strings, etc), and library bases. When doing OpenLibrary(), you must keep your result in a local variable, only store to the global Base if successful, and use your local when you CloseLibrary. If you have a lot of variables that need to be "known" to all of your subroutines, you can put them all in a dynamically allocated and cleared structure, and pass a pointer to that structure to each of your routines. This has a minimal impact on your coding style, and makes it fairly easy to retrofit reentrancy on existing code. -- ========================================================================== Carolyn Scheppner -- CATS Commodore Amiga Technical Support PHONE 215-431-9180 UUCP ...{uunet,allegra,rutgers}!cbmvax!carolyn Calm down. It's just ones and zeros. ==========================================================================