bryan@cs.utexas.edu (Bryan Bayerdorffer) (07/20/88)
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?
______________________________________________________________________________
/_____/_____/_____/_____/_____/_____/_____/_____/_____/_____/_____/_____/_____/
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
_No dark sarcasm in the classroom|_____|_____|_____|_____|_____|_____|_____|___
carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) (08/01/88)
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. ==========================================================================
limonce@pilot.njin.net (Tom Limoncelli) (08/05/88)
In Article <4373@cbmvax.UUCP> carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) writes: >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.) > [ Much deleted about making your code reentrant by having no globals, etc ] > You are talking about reentrant code, right? Not resident? I would hate to have to go through all that to make my stuff "pure". (I'm one of the few people in the world without an illegal copy of 1.3 gamma 99999 )-: ) Could someone go over what it takes to make code RESIDENT? I was sort-of-hopeing that most well-behaved programs that don't modify string constants (that are in the code segment), etc should work... right? Thanks in advance, Tom -- Tom Limoncelli Currently using crutches and in great pain, but still available at: limonce@pilot.njin.net "Remember all the great times we had?" tlimonce@drew.bitnet "Yeah... was that *you*?" tlimonce%drew@cunyvm.cuny.edu "The opinions expressed above are mine... just mine." (Hey Eric! Remember when I was so proud to finally be on a net and your reply was, "Bitnet? Ok... tell me when you get on a real net"? Well, look at the new signature! A real net! Right on the internet! See! See! It's also reachable via limonce@njin.rutgers.edu. Ok Eric? )
carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) (08/10/88)
In article <Aug.4.19.20.35.1988.6604@pilot.njin.net> limonce@pilot.njin.net (Tom Limoncelli) writes: >> >>[ Much deleted about making your code reentrant by having no globals, >>etc ] >> > >You are talking about reentrant code, right? Not resident? I would >hate to have to go through all that to make my stuff "pure". (I'm one >of the few people in the world without an illegal copy of 1.3 gamma >99999 )-: ) > >Could someone go over what it takes to make code RESIDENT? I was >sort-of-hopeing that most well-behaved programs that don't modify >string constants (that are in the code segment), etc should work... >right? The Amiga 1.3 Workbench resident command just loadsegs the code and sticks it on the DOS resident list. It does not attempt to clone data segments or do anything similar since it would be quite impossible with unknown code generated by an unknown compiler or assembler. i.e. - If you want your program to work with Amiga RESIDENT, either YOU or your compiler must make that code pure. So pure that it is re-executable, reentrant, etc. So that lots of tasks could all use that code at the SAME time with no problem. I am providing a way for YOU to write pure code NOW. Your compiler might offer something better which is compiler-specific. If so, use it. -- ========================================================================== Carolyn Scheppner -- CATS Commodore Amiga Technical Support PHONE 215-431-9180 UUCP ...{uunet,allegra,rutgers}!cbmvax!carolyn If you find my mind, please email it to me. I seem to have mislaid it. ==========================================================================