home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-12 | 33.4 KB | 1,200 lines |
- Because some people asked me how to use gcc with own startup-code
- (and how to use gcc with Amiga-only programs), here is my environment
- for gcc on the Amiga. Everything falls under GNU-Licence, please read
- section 14 for more informations on the copyright.
-
-
-
-
-
- Gandalf's
-
- GCC-gerlib
-
-
- Version 0.8b
-
-
- (Sun Dec 12 16:59:26 1993)
-
-
-
-
-
- Now it's time to give some of my knowledge to - YOU.
-
- you have: - the gcc 2.3.3 compiler
-
- WARNING: GCC 2.4.5 - Gcc 2.5.4 (and perhaps above)
- wasn't ported by M.Wild, it has
- some serious bugs, please don't use it !
-
- - an Amiga (500/600/1000/1200/2000/3000/4000)
- with kick 2.04 or above
- - a harddisc
- - a LOT of ram (about 6? MB or more)
- - knowledge of C/C++
-
- you probably have:
-
- - some knowledge about the Amiga
- - some knowledge of assembly language (680x0)
- - a debugger like PowerVisor 1.42 or above
- - an assembler like Devpac
-
- you want to:
-
- - write fantastic good programs for our only love
- in C or C++
-
-
- WARNING: this stuff is NOT for beginners!
-
-
- WARNING: this documenatation is just in the beginning.
- If you have any additions/improvements, write
- me a message!
-
- WARNING: my English is not the best, but I hope it will
- be more useful than only a german documentation
-
-
- WARNING: please read the HOLE document before you try
- to use this package!
-
-
- HINT: I'm using a tabsize of 4. Please use it, or you
- will have trouble reading this document
-
-
- 1. Introduction
- ---------------
-
- The GNU-gcc compiler is one of the best compilers available
- for the Amiga. It is the only real C++-compiler (except for
- M*xon C++, which is (in my opinion) a desaster, but not a compiler).
- One problem with Markus Wild's implementation of GCC on the Amiga is
- that all executables need the ixemul.library, which is often
- unneccessary for small projects.
-
- So I decided to write my own
-
- - startup code
-
- - support library (not shared, I mean link-library)
-
-
- which I now give to the public, e.g. to you.
-
-
-
-
- 1.1 Why?
- --------
-
- With the gcc v2.3.3 (ported by M. Wild), it is easy to port
- programs from UNIX to Amiga. It is NOT made to write short,
- Amiga-only programs.
-
-
- Here my package tries to help you.
-
- I program only for the Amiga, I don't plan to port my programs to
- another OS/Computer. All I want is
-
- - a simple (but complete), easy to use, short startup code
-
- - only the necessary support routines (e.g. string-functions)
- I don't need all ANSI-C-functions, often there are equivalent
- or better functions in the OS.
-
- - the ability to write resident programs (even with amiga.lib
- support functions !) (Not fully tested yet, but no errors known)
-
- - the ability to debug programs with a debugger, for e.g. PowerVisor.
- This is NOT possible with any program that uses ixemul.library
-
- - the possibility to code in C++
-
-
- What I don't need is
-
- - support of all ANSI-C functions
-
- - UNIX-functions (I only port Unix programs, I don't write new ones)
-
- - ixemul.library for every small program
-
-
-
- 1.2 What did I do?
- ------------------
-
- - I wrote new startup code in assembler for maximum speed and minimum
- size.
-
- - I disassembled parts of amiga.lib to write real resident programs
-
- - I wrote this text with dozens of hints
-
- - I wrote some C++-specific functions that enable the use of
- C++ in standard programs
-
- - I wrote some functions/classes that makes life easier with C++ on
- the Amiga
-
- - I wrote some C++-example programms that shows some things not mentioned
- here. Please have a look at them!
-
- - I compiled libg++ v2.4 (now you can use real iostreams, printf with
- floating-point numbers etc.)
-
-
- There are two parts of gerlibv:
-
- - the user part (all things you need to work with gerlibv)
-
- - the developer part (with all sourcecodes and not needed additional
- files)
-
- All parts that are in the developer part are marked with (+) in this
- manual
-
-
- Here's a brief overview over the supplied files:
-
- (file) execute_before_recompile (+) needed if you want to recompile libger.a
- (file) makeall (+) makes everything that can be made
- (file) makelibrary (+) makes new libger.a
-
- (dir) Documentation The documentation over my system is here
- (you are reading it...). Also the GNU-
- Licence can be found here.
- Additional docs in amigaguide-format are
- - gcc v2.3.3 / cpp
- - libg++ v2.4
- - iostream
-
- (dir) amiga (+) contain
- (dir) string (+) some
- (dir) Bonus (+) parts
- (dir) gnulib (+) of
- (dir) not_equal (+) libger.a
-
- (dir) startup contains the new startup-code
-
- (dir) amiga_lib (+) everything you need to recompile libamiga.a
-
- (dir) support/mui contains file that is needed if you want to
- recompile
- the examples that come along with mui 1.3
- (dir) lib here libamiga.a libger.a and libgpp
- are stored, copy them to lib: to use them
- also the startup-code for the compiler is
- stored.
- (dir) blib here base-relative libamiga.a libger.a and
- libgpp are stored, copy them to blib: to use
- (dir) unix/local my dmake-startup-files. Copy them
- to gcc:unix/local
- (dir) os-include some additional files for your os-includes-
- directory (also needed for mui-support)
-
- (file) examples/DemoSource.cc a very complete demo-C++-Programm. Please have
- a look at it
- (dir) add/ some additional useful classes and functions.
- Needed for DemoSource.cc
- (dir) test/ Some test-executables, especially how to
- handle startup-things
- (dir) libg++/* (+) a nearly full implemention of GNU libg++ 2.4
-
-
-
- 2. Installation
- ---------------
-
- Some things are different in the include-files distributed with this
- package compared to the one form m.wild. So, I decided to use different
- directories. You can switch between my environment and the one from
- standard gcc using the scriptfile "switchgcc". This scripfile renames
- some directories.
-
- To install my package, type in the following commands:
-
- ;First rename some directories:
-
- rename gcc:g++-include gcc:gcc_g++-include
- rename gcc:include gcc:gcc_include
- rename gcc:lib gcc:gcc_lib
- rename gcc:blib gcc:gcc_blib
-
- ;and make some new directories
-
- makedir gcc:include
- makedir gcc:lib
- makedir gcc:blib
- makedir gcc:g++-include
-
- ; copy the old contents of include
-
- copy gcc:gcc_include gcc:include ALL
-
- ; copy the distributed files in the new directories
-
- copy gerlib/support/g++-include gcc:g++-include ALL
- copy gerlib/support/include gcc:include ALL
- copy gerlib/support/lib gcc:lib ALL
- copy gerlib/support/blib gcc:blib ALL
- copy gerlib/support/os-include/ gcc:os-include ALL
-
- ; copy the startup files
-
- copy gerlib/startup/#?.o gcc:lib ALL
-
- ; and eventually
-
- copy gerlib/support/unix/local local:
-
- ; if you want to use my make and dmake config files
-
-
-
- 3. What is libger.a and libamiga.a
- ----------------------------------------
-
- The main result of my work are to linker-libraries:
-
- gcc:lib/libger.a and gcc:blib/libger.a
-
- In these two libraries all the needed functions you possible need
- are stored.
-
- The first one is for large-data, the secound one for small(base-relative)
- data.
-
- With small data only 64k of global data can be accessed. The advantage
- is that is that small-data programs are a little bit smaller and faster
- than large-data ones. And, what is perhaps even more important, you
- can write quite easy residentable programs if you use small-data.
- Small-data uses a base-register (a4) to access all global variables.
-
- Here is a small example how to call gcc with the right options for large data/
- small data and residentable programs. The file that should be compiled is
- called 'test.c'.
-
- For the complete option-list plese refer to the gcc-documentation (also
- stored in the directory you found this text here, AmigaGuide-format).
-
- a) Large data:
-
- gcc test.c -c
-
- (leaves test.o)
-
- gcc -o test -lger -lamiga
- ^ ^ ^ ^ ^use library libamiga.a
- | ---| |
- name of | |---- use library libger.a
- the com- |
- piler |
- |
- |
- |
- the name of the executable
- to create. Predefined: a.out
-
-
- b) small-data
-
- gcc test.c -c -fbaserel -msmall-code
-
- gcc -o test test.o -lger -lamiga -fbaserel
-
-
- c) resident programs
-
- gcc test.c -c -resident
-
- gcc -o test test.o -lbger -lbamiga -resident
-
- Yes, it is so easy to to create a residentable program !
-
-
- Here all the important options in an overview:
-
- used
- option startup-m. gerlib amiga.lib
- ----------------------------------------------------------------
- large data: crt0.o -lger -lamiga (uses gcc:lib/)
- small data:-fbaserel -msmall-code bcrt0.o -lger -lamiga (uses gcc:blib/)
- resident : -resident rcrt0.o -lger -lamiga (uses gcc:blib/)
-
-
- The same results for the c++-linker-libraries libgpp.a
-
- It is not possible to write a program that is partly large data
- or partly small data. All modules have to be compiled with
- "-resident" or "-fbaserel" if you want to write a residentable
- program. Yoo HAVE to link with -resident if you want to have a
- residentable program, tough.
-
- Two useful options for gcc are "-O" (optimize) and "-O2" (optimize even
- more). But be careful, optimization needs some time and memory. So use
- them only for your final compilations.
-
-
-
- 4. The startup-code
- -------------------
-
- The startup-code is the code that initializes a lot of things before
- the actual C/C++-program gets executed.
-
- My startup-code is available in different forms:
-
- crt0.o - normal startup-code
-
- bcrt0.o - base-relative startup-code (sometimes faster, but
- only limited global variable-size)
-
- rcrt0.o - resident base-relative startup code
-
-
- The correct one is selected from gcc through the options "-fbaserel" or
- "-resident"
-
- I didn't wrote auto-detach startup-code, because I don't see any use for
- it. Everybody should be able to start a program with
-
- run >NIL: <NIL: SomeProgram
-
- I don't see any need for it, but probably I (or you ?) will write
- auto-detach startup-code.
-
-
-
-
- 4.1 What is done in the startup-code ?
- --------------------------------------
-
- The startup-code does everything necessary except command-line parsing.
- Command-line parsing is not always necessary, so I provide only
- demo-source how to obtain good command-line parsing.
- The things that are done in the startup-code (look also at the RKRM
- Libraries) are:
-
- - handling base-relative and resident specific stuff (if necessary)
-
- - handling of workbench and cli startup
-
- - initializing _SysBase and _DOSBase
-
- - initializing of the FPU if necessary
-
- - giving control to main() with
-
- WB-Startup: argc=0
- argv pointing to a struct WBStartup
-
- CLI : argc=length of command line (without program name !)
- argv=pointer to command line
- On CLI-startup argv and argc are exactly the a0 and
- d0 which are passed to your program as command line
- arguments by DOS
-
- Note: the names argc and argv are probably confusing, as argc is
- now the length of the arguement-string and argv is a pointer
- to a string. The names argc and argv were kept for historical
- reasons only.
-
- if you need standard argc and argv, look at the provided examples
- in test/startup/xxx, they demonstrate how to implement this.
-
- - providing clean exit via the "_exit()"-function.
-
- - initializing stdin and stdout with Input() and Output().
- This means if the program is called via WB they are both zero!
-
-
- The startup-code is the same for C and C++. It has to be linked
- always as the !!first!! module. (Automatically done by gcc)
-
- In bcrt0.o the function geta4() is provided which reloads a4 with
- the correct value. It is guaranteed that no other register is altered.
-
-
-
- 5. gcc-specific functions
- -------------------------
-
- To be able to use gcc as a C/C++-Compiler on the Amiga I re-wrote some
- functions:
-
- void exit();
- default_new_handler();
- void *__builtin_new();
- void __builtin_delete();
- __set_new_handler();
- void *malloc();
- void free();
- int atexit();
-
- and some more.
-
- These functions were written with Amiga-OS in mind, so no overhead is created
- when using this functions.
-
- The C-functions
-
- bcmp(), bcopy(), bzero(), ffs(), index(), strchr(), memccpy(), memchr(),
- memcmp(), memcpy(), memset(), rindex(), strrchr(), strcasecmp(), stricmp(),
- strncasecmp(), strnicmp(), strcat(), strcmp(), strcoll(), strcpy(),
- strcspn(), strdup(), strerror(), strlen(), strmode(), strncat(), strncmp(),
- strncpy(), strpbrk(), strsep(), strspn(), strstr(), strxfrm(), swab(),
- memmove(), strtod(), atof(), atoi(), atol(), bsearch(), labs(), ldexp(),
- ldiv(), strtoul(), rand(), radixsort(), heapsort(), abort(), strtol(), qsort()
-
- are also provided for convenience (I'm sure this list is not complete :-)).
-
- Also some math-functions (mostly for the internal datatypes like float, double,
- long long etc.) are provided, I hope they are complete.
-
- As I don't use floating point variables ver often, they are not tested very
- well.
-
-
- 6. Amiga.lib
- ------------
-
- One of my goals was to be able to produce resident programs with gcc.
- This was a little bit complicated with amiga.lib, because some
- functions (I mean not the stubs, they can easily be created through
- the inline-code) made a direct access to stdin, stdout, SysBase etc.
-
- So I disassembled this functions, made them base-relative and thus
- useable in resident programs.
-
- The baserel amiga.lib is in gcc:blib/libamiga.a
-
- While disassembling amiga.lib I discovered a bug in
- hunk2gcc or ld. The functions that are not o.k. are:
-
- ArgArrayInit()/ArgArrayDone()
-
- They produce, when used from the original provided amiga.lib, a nice
- CRASH. So be careful when converting objectcode with hunk2gcc!
- The problem are the instructions of the form
-
- jsr (xxxx,pc) (new Motorola syntax)
-
- They jump, but not to the correct location.
- I did't have the time to check every amiga.lib-module, if you find
- other problems, please send me a bug-report.
-
- I provide the large-data object-file
-
- ArgArrayInitDone.o
-
- for your convenience to have a correct version of them.
-
- The easier way is to use the libamiga.a that comes along with this
- package. There I removed the faulty module above and replaced it with
- a correct one.
-
-
-
- 7. Programming in C++
- ---------------------
-
- The standard os-include-files are not fully compatible with C++.
- A standard C++-Header looks like for example
- (examples/test/examples_doc/example_dok1.cc):
-
- /* "hide" the original class and template, they are keywords in C++ */
- #define class _class
- #define template _template
-
- extern "C" {
- void volatile exit (int);
- #include <exec/types.h>
- /* if you want to use the functions of <clib/alib_stdio_protos.h>, do this: */
- #include <clib/alib_stdio_defines.h>
- #ifdef __OPTIMIZE__ /* need lot of time & memory, is selected by -O2 */
- #include <inline/exec.h>
- #include <inline/dos.h>
- #else
- #include <clib/exec_protos.h> /* faster and easier to debug */
- #include <clib/dos_protos.h> /* but code is worse */
- #include <clib/tagdefines.h> /* file that has defines for xxxTags-Calls */
- #endif
- }
-
- #undef template
- #undef class
-
- /* standard C++-Programm */
- int main(void)
- {
- // do someting useful here
- return 0;
- }
-
-
- One problem occurres when a libary should be closed:
-
- extern "C" {
- #include <intuition/intuitionbase.h> /* struct IntuitionBase { ... }; */
- }
-
- extern "C" {
- IntuitionBase *IntuitionBase;
- }
-
- int main(void)
- {
- if(IntuitionBase=(IntuitionBase *)OpenLibrary((UBYTE *)"intuition.library",37))
- {
- // do someting useful here
-
- CloseLibrary((struct Library *)IntuitionBase);
- }
- return 0;
- }
-
- The compiler is not able to distinguish between the type "IntuitionBase"
- and the variable "IntuitionBase" if it is not used in an definite expression,
- so it gives the warning (and following error)
-
- warning: name `IntuitionBase' could be type or expression;
- compiler assuming type
- parse error before `;'
-
- in the line with CloseLibrary(). So we can only use clear expressions:
-
- struct Library *dummy=(struct Library *)IntuitionBase;
- CloseLibrary(dummy);
-
- This works, here the compiler does what we expect him to do.
- (examples/test/examples_doc/example_dok2.cc)
-
- If you need no direct access to IntuitionBase, you can avoid this problem
- by declaring IntuitionBase as Library *. But don't do this if you want
- to use gcc:os-include/inline/xx.h, then you would get lots of errors.
-
-
- 7.1 Using Classes
- -----------------
-
- If you are using classes, be sure you leave the compiler the ability
- to call the destructors!
-
- Don't write things like
-
- int main()
- {
- dummyclass du;
-
- exit(0); // destructor of du is never called !!
- }
-
- However,
-
- int main()
- {
-
- {
- dummyclass du;
- //...
-
-
- } // destructor of du is called here
-
- exit(0);
- }
-
- is OK.
-
- Don't call exit() if you are not sure if all classes are "destructed".
- Global destructors are called via exit() (and after all functions that
- were remembered to call via atexit()), so the call of the global
- destructors is no problem.
-
- The easiest way is, however, not to use the exit() function at all,
- and return from main with a return(<number>);-statement, this is
- better ("cleaner") than a call of exit(<number>);
-
- If you want to have a look at some sample code, try to understand
- the provided example.
-
-
- 8. mathematical functions
- -------------------------
-
- Data types like float, double, long long etc. cause the compiler to
- generate function calls to some functions provided in libger.a.
- These functions sometimes need the Amiga mathematical libraries.
- So the linker will complain:
-
- gcc:lib/libger.a(fixsfsi.o):
- Undefined symbol _MathTransBase referenced from text segment
- gcc:lib/libger.a(fixsfsi.o):
- Undefined symbol _MathBase referenced from text segment
-
- or something else.
-
- There is a solutions for the problem: open the needed libraries 'manually'.
-
- e.g. the Program testmath.c compiled with
-
- gcc testmath.o -lger -lamiga
-
- int main(void )
- {
- float pi=3.14159265;
- float e=2.71;
- return e*pi;
- }
-
- will result in
-
- gcc:lib/libger.a(fixsfsi.o):
- Undefined symbol _MathTransBase referenced from text segment
- gcc:lib/libger.a(fixsfsi.o):
- Undefined symbol _MathBase referenced from text segment
- gcc:lib/libger.a(mulsf3.o):
- Undefined symbol _MathTransBase referenced from text segment
- gcc:lib/libger.a(mulsf3.o):
- Undefined symbol _MathBase referenced from text segment
- gcc:lib/libger.a(mulsf3.o):
- Undefined symbol _MathTransBase referenced from text segment
-
- Now we try (examples/test/examples_doc/example_dok3.c):
-
- #include <exec/types.h>
- #include <inline/exec.h>
- #include <clib/dos_protos.h>
- struct Library *MathTransBase;
- struct Library *MathBase;
- struct Library *MathIeeeDoubBasBase;
- struct Library *MathIeeeDoubTransBase;
-
- void close_math(void)
- {
- struct Library *lib;
-
- if(MathBase)
- { lib=(struct Library *)MathBase; CloseLibrary(lib); }
- if(MathTransBase)
- { lib=(struct Library *)MathTransBase; CloseLibrary(lib); }
- if(MathIeeeDoubBasBase)
- { lib=(struct Library *)MathIeeeDoubBasBase; CloseLibrary(lib); }
- if(MathIeeeDoubTransBase)
- { lib=(struct Library *)MathIeeeDoubTransBase; CloseLibrary(lib); }
- }
-
- BOOL init_math(void)
- {
- atexit(close_math);
-
- MathBase = OpenLibrary((STRPTR)"mathffp.library",0L);
- MathTransBase = OpenLibrary((STRPTR)"mathtrans.library",0L);
- MathIeeeDoubTransBase = OpenLibrary((STRPTR)"mathieeedoubtrans.library",0L);
- MathIeeeDoubBasBase = OpenLibrary((STRPTR)"mathieeedoubbas.library",0L);
-
- if(MathBase && MathTransBase && MathIeeeDoubTransBase && MathIeeeDoubBasBase)
- return TRUE;
- else return FALSE;
- }
-
-
- int main(void )
- {
- float pi=3.14159265;
- float e=2.71;
- if(init_math())
- {
- /* now we can calculate something */
-
- return e*pi; /* will be truncated to an int */
- }
- else
- {
- Printf("Not able to open all math-libraries !\n");
- return 20;
- }
- }
-
-
- gcc mathtest.o -o mathtest -lger -lamiga
-
- And everything is ok.
-
- Because we don't use the ixemul printf/sprintf, we can't use them to
- print float/double etc. variables.
-
- If you want to use printf/sprintf etc. with floating-point variables,
- you can #include <stdio.h> and link with "-lgpp -lger -lamiga",
- but your program will get a lot bigger (about 60 kb).
-
- As mentioned above, I don't use floats very much, so don't rely on them
- beeing correct.
-
-
-
- 9. MUI and GCC or how Hook calls can be done using gcc
- ------------------------------------------------------
-
- It is possible to use gcc to compile MUI-programs. You have to make
- only a few changes, especially if you want to use hooks:
-
- a) Use the supplied support/mui/demo.h File instead of the one that
- comes along with MUI 1.3
-
- b) Hooks
-
- Gcc lacks one feature that are standard on other Amiga compilers:
- register parameters.
-
- We can solve this problem in 2 ways:
-
-
- b.1) use assembler inline functions to get the result in the registers
-
- (Taken from AppWindow.c and modified)
- Example:
-
- LONG AppMsgFunc(REG(a2) APTR obj, REG(a1) struct AppMessage **x)
- {
- /*register struct Hook *a0 __asm("a0"); */ /* not needed in this function */
- register APTR a2 __asm("a2");
- register struct AppMessage **a1 __asm("a1");
- /*struct Hook *hook = a0; */
-
- APTR object = a2;
- struct AppMessage *amsg = *a1;
-
- /* ... */
- }
-
- This works only if you are not using base-relative code!
- (GCC has nothing like __saveds that calls geta4() automatically)
-
-
- b.2) Using stub functions
-
- Standard Hook functions have the ability to provide a high language
- entry point (h_SubEntry) and a low-level assembler entry point
- (h_Entry).
-
- Now we can tell our marveless OS to call first the assembler entry
- point (here we can put the registers on the stack, and, if needed,
- reload a4) which calls the C-function.
-
- I provided two different assembler functions which do just this
- for you.
-
-
- (void *) hookEntrya1a2()
-
- This variant puts only a2 and a1 on the stack, that means it is
- usable for Hooks which need only two parameters (like the example
- supplied above)
-
-
- (void *) hookEntry()
-
- This variant puts a0, a2 and a1 on the stack. It is needed for
- all Hooks which need all parameters (like the example
- broker_list_confunc() in MUI-Exchange.c)
-
- To get the stubs called, a small patch has to be made in the
- definition of the hook. Here is an example:
-
- you have to write:
-
- static const struct Hook AppMsgHook =
- { { NULL,NULL },(VOID *)hookEntrya1a2,(VOID *)AppMsgFunc,NULL };
- /* ^^^^^^^^^^^^^ call correct Hook-Subentry
- that moves the registers on the stack, provided in libger.a */
-
- instead of
-
- static const struct Hook AppMsgHook =
- { { NULL,NULL },(VOID *)AppMsgFunc,NULL,NULL };
-
-
- If you want to compile base-relative, you have to use this stubs.
- They relode a4 correctly, so you have acces to your global variables.
-
-
- b.3) Using Hooks with resident code
-
- NOTE: due to a bug in gcc it is not possible to use the inline code
- for the calls of the MUIMaster.library together with the switch
- -resident or -fbaserel. So these comments are only for completeness.
-
- If you want to write "pure" or resident-able programs, things get a
- litte more difficult. The problem is that it is not so easy to
- get a4, because we have no function geta4() that could tell us
- where our global-variable-pointer a4 points to, because a hook
- is called from within the intuition or gadtools or whatelse
- environment.
-
- So we have to store a4 in a Hook BEFORE it gets called.
-
- For you, that means that you have to use the stubs
-
- hookEntryRes
- hookEntryResa1a2
-
- and store a4 in Hook.h_Data with the supplied function aska4()
- (see demo.h) like this:
-
- (from within a function)
-
- struct Hook AppMsgHook = { { NULL,NULL },(VOID *)hookEntryResa1a2,
- (VOID *)AppMsgFunc,aska4() };
-
-
- If you want to use global Hooks, you have to initialize them BEFORE
- they are (possibly) called.
-
- static struct Hook DestructHook = {
- {NULL, NULL},
- (void *)hookEntryRes,
- (void *)DestructFunc, NULL
- };
-
- f()
- {
- DestructHook.h_Data=aska4();
-
- /* now we can use the hook DestructHook */
- }
-
-
-
- b.4) Make GCC-things #definable
-
- If you want to be able to compile the source with different compilers,
- define the variant you are using:
-
- #ifdef __GNUC__ /* use __GNUG__ if you are programming in C++ */
- /* our stub called */
- #else
- /* compiler has regargs */
- #endif
-
-
- c) __aligned
-
- GCC doesn't support the __aligned keyword. It is most needed for DOS objects
- (e.g. FileInfoBlock). They should be on an 4 byte boundary. What you can do
- instead is to use the Dos function AllocDosObject().
-
-
-
- 10. Provided C-Functions and C++-Classes
- ----------------------------------------
-
- This part is under development, I don't know if I found all bugs...
-
- Directory "examples/Add/normal" (and /baserel)
- add.h the Include-File for the C-Functions
- CED_Support.c Code that makes it easier to communicate with CED
- CED_Support.h Version 3.5+
- ced_support.o
- cina.cc A Class that emulates the standard "cin" with
- cina.h Amiga-functions
- cina.o
- couta.cc A Class that emulates the standard "cout" with
- couta.h Amiga-functions
- couta.o
- editfile.cc A Class that makes it easier to read a file into memory
- editfile.h
- editfile.o
- GetFileSize1.cc A C++-Function that returns the length of a file
- (filename given)
- getfilesize1.o
- GetFileSize2.cc A C++-Function that returns the length of a file
- (BPTR given)
- getfilesize2.o
- ltostr.cc A C-function that converts a long to a string (any base)
- ltostr.o
- makefile Makefile for all files in this directory
- OwnError.cc A Class that makes it easier to remember errors in classes
- OwnError.h
- ownerror.o
- ShowRequest.c A C-Function that makes it easy to show a nice Requester
- showrequest.o
- TextClipSupport.c A C-Functions that makes it easier to read and write strings
- textclipsupport.o to the clipboard
-
- Directory "libg++"
- etc/ (+) Some examples compiled with my package. I didn't test
- if the results are the ones expected.
- gperf/ (+) A program to gererate a perfect hast function. Also
- only compiled, not checked.
- iostream/ (+) the implementation of the iostreams library with
- only a few small changes to compile on the amiga
- src (+) the rest of libg++ V2.4 package
- make_links (+) (only used if you want to recompile libg++)
- makegpp (+) (only used if you want to recompile libg++)
- AMIGA_README.txt Some implemention details of my libg++-port
- libg++.texi Documentation to libg++ in ".texi"-format
- ger_add (+) some functions that were needed to compile libg++ on
- the amiga
-
-
-
-
- 11 compiling assembler-files with a standard assembler
- ------------------------------------------------------
-
- The syntax of the assembler-opcodes is different from the standard
- MOTOROLA-conventions on the Amiga. If you find this annoying,
- you can use another assembler as well.
-
- Add this to your dmake-makefile:
-
- %$O : %.asm
- Genam $< -l -d # add your favourite assembler here,
- hunk2gcc $(<:b).o # -l : prodoce linkable objectfile,
- delete $(<:b).o # -d : produce debugging informations
- rename obj.* $(<:b).o
-
- With this you are able to use your own assembler-sourcecode (with extension
- .asm) within normal makefiles.
-
- An example is provided in b:test/startup/: program Ger_Test uses an .asm-
- file
-
-
-
- 12 Troubleshooting
- ------------------
-
- Before writing programs in C/C++ with gcc, please look at the provided
- DemoSources in examples and examples/test. There a lot of things are
- shown which are not described elsewhere.
-
- Please also have a look at the makefiles.
-
- If you want to debug you programs, you can use every standard amiga-
- debugger, as gcc places standard amiga debug hunks in every executable.
- A very good debugger is PowerVisor, I use the Version 1.42.
-
- If you want to distribute/sell/publish your programs, strip the debug-
- hunks (for example with PowerPacker (HunkLab/Process File...)). So the
- files will get shorter and it is harder to disassemble your program.
-
- Use tools like Enforcer or Mungwall, they helped me a lot.
- One hint for Mungwall: you can use a terminal program like NComm
- to see the output, you don't have to run sushi. (Of course, you must have
- a modem) To find any memory leek use mungwall like this:
-
- run Mungwall TASK <YourProgramName> SNOOP
-
- Then all AllocMems and FreeMems (rsp. AllocVec/FreeVec etc.) are shown.
-
-
-
- 12.1 Known problems/bugs
- ------------------------
-
- - nm: shows only files in an object file which length is not longer
- than 16 chars (nm bug)
-
- - gcc has problems with the options -resident/-baserel with the file
- inline/mui_master.h (gcc bug)
-
- - the linker has a problem with libauto.a, I was not able to recompile
- it in such a way that the resulting programs would work properly.
- This seems to be a bug in ld, as, if they are linked manually
- (not linked as a linker-library), everything works. Because of this,
- I did not provide any 'libauto.a' or something like that.
-
- This also means, if you want to use libgpp.a, you HAVE to link the
- libraries in the following sequence:
-
- -lgpp -lger -lamiga
-
-
-
- 12.2 Possible future improvements
- ---------------------------------
-
- - split math functions in gnulib/xx/gnulib2.o
- (would save space in executables that need not all the functions)
-
- - minimize the standard-includes
-
- - write a better documentation
-
- - don't call Input() or Output() if stdin/stdout is used
- (with #include <clib/alib_stdio_defines.h>)
-
- - state clearly in all files that they are under the GNU licence
-
- - use pool-functions for new/delete/malloc/free etc.
-
- - write german doc-file
-
- - clear up the startup-code through an assember-guru
-
- - delete all files in this distribution that are not needed
-
- - rewrite gerlib/libg++/ger_add/normal/Unix_readwrite.c
- (I am sure that there are bugs in it)
-
-
-
- 13.1 If you want to recompile gcc:blib/libger.a (+)
- ---------------------------------------------------
-
- Hint: sometimes I use the assign g: as a shorthand for gcc:
-
- All files are provided which are necessary to recompile libger.a.
-
- Before you recompile the first time, execute the script
- "execute_before_recompile", this will copy the normal .s/.c-files
- in a baserel-directory.
-
- Then type
- makelibrary
-
- and gcc:lib/libger.a / gcc:blib/libbger.a will be recreated and copied
- to lib:
-
-
-
- 13.2 If you want to recompile libamiga.a (+)
- --------------------------------------------
-
- This is normally not necessary. If you really want to (perhaps
- there is a new amiga.lib out there etc.), be warned. You will
- need a LOT of memory and time. On my Amiga 4000/40 it took
- more than 40 minutes to create gcc:blib/libamiga.a.
-
- Read the file "amiga_lib/HowToRecompile" for further instructions.
-
-
-
- 13.3 If you want to recompile libgpp.a (+)
- ------------------------------------------
-
- This is normally not necessary. If you really want to (perhaps
- you found a bug), be warned. You will need a LOT of memory and
- time. On my Amiga 4000/40 it took some hours to create libgpp.a.
-
-
- Cd to the directory libg++.
-
- Only necessary before the first compilation: to make links from
- the normal/xx files to the baserel/xx-files, enter
- "make_links"
-
- To recompile, enter "libgpp". After some hours or so you get the
- new libgpp.a in gcc:lib and gcc:blib.
-
-
-
- 14. Copyright
- -------------
-
- This program/documentation/etc. falls under the GNU-Licence.
- Please look at the file COPYING for more informations about the copyright.
- Please read there the sections 11 and 12, they are important...
-
- It is ok to modify everything here for your own purpose. But please
- don't distribute your modified package. The better solution is to
- write me your improvements, and I will make them available to others.
-
-
-
- 15. Acknowledgements
- --------------------
-
- The whole work here bases on the port done by Markus M. Wild.
- Thanks a lot! I hope he's not too angry that I took some of
- his sourcecodes from ixemul.library.
-
- Some people that helped me with the documentation and gave me good
- ideas:
-
- - Stefan Hochmuth (corrected lots of mistakes)
- - Alexander Görig (my fido-boss)
- - Christian Ohlendorf (corrected this documentation)
- - Stefan Micko (corrected this documentation)
- - a unknown gerlib user who told me that the startup code crashes
- on a plain 68000 :-(
-
- So, I hope this information makes it easier for you to write programs
- for the Amiga with gcc.
-
- Sorry for my bad English, my native language is German.
-
- I used an Amiga 4000/40/14/1,2GB with CED 3.5 to write this
- documentation and all the programs. The software was tested
- with Enforcer and Mungwall (but not full on a plain 68000 or
- a WB less than 3.0)
-
-
-
- 16. How to reach the author
- ---------------------------
-
- Send ideas, improvements and bugreports to:
-
- Gerhard Müller
- Klarweinstr. 32
- 81247 München
-
- Germany
-
- or
-
- Fido-Net:
-
- Gerhard Mueller at 2:247/3508.38
- (this can change in the near future)
-
- In Germany I can also be reached via Z-Netz:
-
- GANDALF@AMC.ZER
-
- or internet:
-
- muellerg@informatik.tu-muenchen.de
-
- I prefer email.
-
-
-
-
-
- 17. History
- -----------
-
- V0.7 (Mon Sep 27 1993) :
-
- first official release
-
-
- V0.8 (Fri Nov 26 1993)
-
- added libg++ v2.4
- added some necessary functions
- removed some bugs
- changed layout
-
- V0.8b
-
- Important bug fix in the startup code, works now unter 68000
- relinked all executables
-
- From now on the distribution is splitted in a user part and a
- developer part
-
- look at the file "Changes" for detailed history
-
-