home *** CD-ROM | disk | FTP | other *** search
-
- SHARED_LIB EXAMPLE CODE
-
- This is a fully compilable shared library implemented for DICE
- demonstrating how one can write their very own shared library. Some
- knowledge in shared libraries is required to understand the code..
- the basic thing to remember is (1) that a shared library is NOT a
- normal C program, and (2) the interface calls MUST be reentrant...
- i.e. multiple tasks can make a library call simultaniously.
-
- The only limitation with this example is that I use -mRR which turns on
- registered arguments. The limitation is that currently DICE will only
- generated registered functions for those routines that take no more
- than 2 integers and 2 pointers. Routines that take more than that
- limit or take other types (structures, floating pt, etc...) will
- not have a registered entry point.
-
- SHARED LIBRARY
-
- DEFS.H contains header stuff
- TAG.A library independant basic code
- LIB.C library independant basic code
- INIT.C library dependant initialization routines
- FUNCS.C library dependant routines
-
- TAG.A and LIB.C are almost self contained with only a few modifications
- required to use them for other library projects... basically the
- name of the library in TAG.A and the function list in LIB.C
-
- TAG.A contains a subset of the standard startup code, LIB/AMIGA/C.A,
- and assumes non-resident compilation (i.e. you cannot use the -r
- option). This isn't a problem since the -r option doesn't gain you
- anything as far as shared libraries go.
-
- The individual library interface routines are declared with the LibCall
- macro, defined in DEFS.H, which ensures the small-data pointer is set
- up for all interface calls allowing use of the small-data model.
-
- LIBRARY INTERFACE
-
- LIB.FD The .FD file must match library prototypes. The first two
- integer arguments are stuck in D0 & D1 while the first
- two pointer arguments are stuck in A0 & A1.
-
- AUTO.A This is extremely DICE specific in that it gives programs
- that link with the interface .lib (link library) the
- capability to auto-open & close test.library without
- having to explicitly do so in main().
-
- Notice that test.c doesn't explicitly OpenLibrary() or
- CloseLibrary() "test.library". DICE provides such
- capabilities for most standard amiga libraries in the
- same fashion.
-
- ---
-
- To compile, be sure that -2.0 is specified in your DCCOPTS an the
- 2.0 registered libraries are unpacked:
-
- DLIB:amigasr20.lib
- DLIB:cr.lib
-
- DINCLUDE:AMIGA20/*/*.h
-
- Create a temporary directory to hold the resulting objects and the
- resulting .lib tag library. The resulting .library file will be placed
- in LIBS: and the test program will be T:test
-
- DTMP:sharlib/ (to hold the objects & .lib file)
-
- Note that you will get warnings from FDTOLIB, these can be ignored. A
- non-registered and registered version of the interface link library
- required when linking TEST.C is generated, and two versions of TEST.C
- are included to show what is required to compile either a normal
- program or registered-args program that talks to the registered-args
- library.
-
- 1> dmake
- ... compiles it all ...
- 1> test.script
-
-
- THE LINK LIB
-
- You will notice that the test program must be linked with test.lib
- from DTMP:sharlib/ .. this is the library interface tag library
- which interfaces C calls to a shared library. Under DICE, a twist
- is added in the form of a special auto-open module appended to the
- .lib file.
-
- This auto-open module allows the TEST program to make library calls
- without explicitly openning the shared library! This greatly simplifies
- the complication that using shared libraries generally adds.
-
- If you are interested, you should run 'DOBJ DTMP:SHARLIB/TEST.LIB' to
- see how the link library works.
-
-