summaryrefslogtreecommitdiff
path: root/m68k-unknown-amigaos/recipes/files/gcc/gcc/doc/gcc-amigaos.texi
blob: 481c67675c87966c8ec9d188dcbab896d17dcfd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
\input texinfo.tex  @c -*-texinfo-*-
@c %**start of header
@setfilename gcc-amigaos.info
@settitle AmigaOS-only features of GCC
@set lastupdate Nov 5th, 2003
@c %**end of header

@ifinfo
This document describes implementation specific features of the GCC
compiler collection port for the AmigaOS.

@copying
Copyright @copyright{} 1996, 1997 Kamil Iskra

Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
@end copying
@end ifinfo

@titlepage
@sp 10
@center @titlefont{GCC Amiga}
@subtitle Description of the AmigaOS-only features of GCC
@subtitle @value{lastupdate}
@author Kamil Iskra
@page
@end titlepage

@ifinfo
@node Top, Introduction, (dir), (dir)
This document describes the AmigaOS-only features of the @samp{GCC}
compiler collection.

Last updated @value{lastupdate}.
@end ifinfo

@menu
* Introduction::  Purpose of this document.

* Invocation::    Command line options.
* Attributes::    Variable and function attributes.
* Defines::       Preprocessor symbols.
* Miscellaneous:: Uncategorizable.

* Index::         Concept index.
@end menu

@node Introduction, Invocation, Top, Top
@chapter Introduction
@cindex Introduction
@cindex Purpose of this document

This document is supposed to be an addendum to the baseline @samp{GCC}
documentation.
Note that given email addresses and urls might be obsolete!

It focuses on the features that are visible by users and are important
to them. It is not supposed to document the internals of the AmigaOS
port of @samp{GCC}.

It describes features implemented in the @samp{Geek Gadgets GCC} port.
For more information about @samp{Geek Gadgets}, please refer to:

@format
http://www.geekgadgets.org/
ftp://ftp.geekgadgets.org/pub/geekgadgets/README
@end format

This document focuses on @samp{GCC}. It does not describe the
AmigaOS-only features of other @samp{GNU} packages, such as
@samp{binutils}, unless they are very closely connected to @samp{GCC}.

This means, that, unless stated otherwise, when we talk about the
``compiler'', we mean the @file{gcc}, @file{cpp} and @file{cc1}
executables, i.e., the executables that convert @samp{C} source code
to assembly source code. The assembler and linker are generally beyond
the scope of this document.

The primary source of information used to create this document was the
@samp{GCC} source code. Some parts of this document are based on:

@itemize @bullet
@item
The @samp{LibNIX} manual, written by Matthias Fleischer and Gunther
Nikl:

@format
fleischr@@izfm.uni-stuttgart.de
gnikl@@informatik.uni-rostock.de
@end format

@item
The @samp{A2IXLibrary} manual, written by Hans Verkuil:

@format
hans@@wyst.hobby.nl
@end format

@item
The @samp{README} file, maintained by Rask Ingemann Lambertsen:

@format
gc948374@@gbar.dtu.dk
http://www.gbar.dtu.dk/~c948374/GNU/
@end format

@item
The @samp{Geek Gadgets FAQ}, maintained by Lynn Winebarger:

@format
owinebar@@indiana.edu
http://nickel.ucs.indiana.edu/~owinebar/interests/amiga/amiga.html
@end format

@item
The @samp{FAQ for g++ and libg++}, written by Joe Buck:

@format
jbuck@@synopsys.com
http://www.cygnus.com/misc/g++FAQ_toc.html
@end format

@item
Discussions on the @samp{Geek Gadgets} mailing list:

@format
gg@@geekgadgets.org
@end format
@end itemize

This document was created by Kamil Iskra. Please email any questions,
suggestions etc. to <iskra@@student.uci.agh.edu.pl> or, even better,
to the <gg@@geekgadgets.org> mailing list.

The author would like to thank Kriton Kyrimis <kyrimis@@cti.gr> and
Lars Hecking <lhecking@@nmrc.ucc.ie> for correcting an awful lot of
language mistakes in this document.

@node Invocation, Attributes, Introduction, Top
@chapter Invocation
@cindex Invocation
@cindex Command line options

The AmigaOS port of @samp{GCC} supports the following non-standard
command line options:

@menu
* -noixemul::           Link with @samp{LibNIX}.

* -fbaserel::           Produce @samp{a4}-relative data.
* -resident::           Produce a @samp{pure} executable.
* -fbaserel32::         Produce @samp{a4}-relative data with no size limits.
* -resident32::         Produce a @samp{pure} executable with no size limits.
* -msmall-code::        Produce @samp{PC}-relative code.

* -mstackcheck::        Produce stack-checking code.
* -mstackextend::       Produce stack-extending code.
* -mfixedstack::        Produce plain code.

* -mrestore-a4::        Reload @samp{a4} in public functions.
* -malways-restore-a4:: Reload @samp{a4} in all functions.

* -mregparm::           Pass function arguments in registers.

* -frepo::              Enable @samp{C++} Template Repository.
@end menu

Accordingly, the AmigaOS port of @samp{GCC} supports several flavors
of linker libraries. @xref{Library flavors, Relation between library
flavors and compile-time options}.

@node -noixemul, -fbaserel, Invocation, Invocation
@section -noixemul
@cindex -noixemul
@cindex Link with LibNIX

@cindex IXEmul
By default, the executables created with @samp{GCC} require
@samp{ixemul.library} to run. This has its advantages (easy porting of
@samp{UN*X} programs, resource tracking, debugging, profiling, etc)
and disadvantages (@samp{UN*X}-style pathnames, large shared library,
etc).

@cindex LibNIX
If @samp{-noixemul} is specified on the @samp{GCC} command line, the
executable created will not require @samp{ixemul.library} --- it will
use the static linker library @samp{LibNIX} instead. This library is
very Amiga-like and @samp{SAS/C}-like, so it is convenient for the
AmigaOS-specific development.

@quotation
@emph{Note}: There is no great mystery about the @samp{-noixemul}
option. It has absolutely no effect on the code generated by the
compiler, only instructing the @samp{gcc} driver to pass different
options to the linker and preprocessor (@pxref{Options information},
@pxref{Library flavors}).

This option has no negative form.
@end quotation

For more information, please refer to the @samp{LibNIX} documentation.

@node -fbaserel, -resident, -noixemul, Invocation
@section -fbaserel
@cindex -fbaserel
@cindex Produce a4-relative data

By default, the code generated by @samp{GCC} references data using
32-bit, absolute addressing.

@cindex a4
@cindex 64 KB data limit
The @samp{-fbaserel} option will make @samp{GCC} generate code that
references data with 16 bit offsets relative to the @samp{a4} address
register. This makes executables smaller and faster. Unfortunately,
the size of the data section cannot exceed 64 KB, so this option
cannot be used for large programs, like @samp{GCC} itself.

@quotation
@emph{Note}: For a base-relative executable, @samp{-fbaserel} needs to
be specified for compiling @emph{and} linking. Base-relative programs
require special startup code and special versions of linker libraries.
Since not all linker libraries are available in both plain and base
relative versions, the usefulness of this option is limited. It is
important to note that when the base-relative library is missing, the
linker will attempt to use the plain one. This might result in strange
link-time or even run-time errors.

@cindex -fpic
This option is the AmigaOS equivalent of the standard @samp{GCC}
option @samp{-fpic}, which is not supported by the AmigaOS port.
@samp{-fpic} generates code that references data indirectly, through a
@dfn{global offset table}. The special addressing modes available on
the @samp{m68k} processor family allow for a much more efficient
implementation with @samp{-fbaserel}.

The negative form of @samp{-fbaserel} is @samp{-fno-baserel}, and is
on by default.
@end quotation

For more information, please refer to the @samp{LibNIX} documentation.

@node -resident, -fbaserel32, -fbaserel, Invocation
@section -resident
@cindex -resident
@cindex Produce a pure executable

Executables produced with the @samp{-resident} option are @dfn{pure},
so they can be made @dfn{resident} using the AmigaShell
@samp{resident} command. @samp{resident} executables are loaded to
memory just once, and several concurrent instances share the code
section.

@quotation
@emph{Note}: The compiler generates the same code for @samp{-resident}
as for @samp{-fbaserel} (@pxref{-fbaserel}). Only the linking stage is
different (special startup code is linked).

This option has no negative form.
@end quotation

For more information, please refer to the @samp{LibNIX} documentation.

@node -fbaserel32, -resident32, -resident, Invocation
@section -fbaserel32
@cindex -fbaserel32
@cindex Produce a4-relative data with no size limits

The difference between the @samp{-fbaserel32} and @samp{-fbaserel}
options (@pxref{-fbaserel}) is the same as between the standard
@samp{GCC} options @samp{-fPIC} and @samp{-fpic}.

Code generated with @samp{-fbaserel32} references data with 32 bit
offsets relative to the @samp{a4} address register. In contrast to the
@samp{-fbaserel} (@pxref{-fbaserel}) option, there is no 64 KB size
limit. Unfortunately, the addressing modes with 32 bit offsets are
only available on 68020 and higher processors. Therefore, it is
necessary to specify @samp{-m68020} or higher to use this option.

@quotation
@emph{Note}: This option used to be called @samp{-flarge-baserel}
before @samp{Geek Gadgets} snapshot @samp{970109}. Since it was not
functional then, this should not cause any compatibility problems.

The negative form of @samp{-fbaserel32} is @samp{-fno-baserel32}, and
is on by default.
@end quotation

@node -resident32, -msmall-code, -fbaserel32, Invocation
@section -resident32
@cindex -resident32
@cindex Produce a pure executable with no size limits

This option is an improved version of @samp{-resident}
(@pxref{-resident}) --- it does not impose any limits on data section
size. Unfortunately, just like @samp{-fbaserel32}
(@pxref{-fbaserel32}), it is only available for 68020 or higher
processors. Therefore, it is necessary to specify @samp{-m68020} or
higher to use this option.

@quotation
@emph{Note}: This option was first made available in the @samp{GCC}
2.7.2.1, @samp{Geek Gadgets} snapshot @samp{970109}.

This option has no negative form.
@end quotation

@node -msmall-code, -mstackcheck, -resident32, Invocation
@section -msmall-code
@cindex -msmall-code
@cindex Produce PC-relative code

By default, the code generated by the compiler references functions
using 32-bit, absolute addressing.

@cindex 32 KB code limit
Code generated by @samp{GCC} with the @samp{-msmall-code} option
references symbols in the code section with 16 bit offsets, relative
to the @samp{PC} (@dfn{program counter}). This makes executables
smaller and faster. Unfortunately, the size of the code section is
generally limited to 32 KB, so this option can only be used for
relatively small programs.

@quotation
@emph{Note}: Actually, the compiler always generates 32-bit code
references. If the assembler can calculate the offset between the
referencing instruction and the referenced symbol (in other words, if
the referenced symbol is in the same source file), it replaces the
32-bit reference with the @samp{PC}-relative one. External references
are left intact, unless @samp{-msmall-code} is used, in which case the
assembler generates @samp{PC}-relative references, and the exact
offsets are calculated by the linker.

This option has no negative form.
@end quotation

For more information, please refer to the @samp{LibNIX} documentation.

@node -mstackcheck, -mstackextend, -msmall-code, Invocation
@section -mstackcheck
@cindex -mstackcheck
@cindex Produce stack-checking code

By default, the code generated by @samp{GCC} does not check if there
is enough stack available before performing stack-consuming
operations. This is generally not necessary on @samp{UN*X} systems,
where the stack is extended automagically whenever needed.

Unfortunately, the AmigaOS provides tasks with a static, fixed size
stack.

However, if a program is compiled with @samp{-mstackcheck}, it will
check if there is enough stack available before performing any
stack-hungry operations. If there is a danger of stack overflow, the
program will abort and the user will be notified.

Needless to say, stack checking increases the executable size and the
execution time.

@quotation
@emph{Note}: Stack checking cannot be used for functions that might be
called from outside your task. This includes interrupt handlers,
shared library functions, hooks etc. In such cases, you should either
avoid using @samp{-mstackcheck} for files containing such functions,
or use @code{__attribute__((interrupt))} (@pxref{interrupt}).

It is safe to call a function that performs stack checking from one
that does not, and vice versa.

The negative form of @samp{-mstackcheck} is @samp{-mno-stackcheck},
and is on by default.

@emph{Warning}: @samp{-mno-stackcheck} used to be called
@samp{-mnostackcheck} before @samp{Geek Gadgets} snapshot
@samp{961012}.
@end quotation

For more information, please refer to the @samp{LibNIX} documentation.

@node -mstackextend, -mfixedstack, -mstackcheck, Invocation
@section -mstackextend
@cindex -mstackextend
@cindex Produce stack-extending code

@samp{-mstackextend} is very similar to @samp{-mstackcheck}
(@pxref{-mstackcheck}).

The main difference is that when a program runs out of stack, it is
not aborted, but a new stack area is allocated and the program
continues to run.

@quotation
@emph{Note}: Stack extension can slow down programs significantly. It
is advised that programs are written in such a way that they do not
require too much stack. This can generally be achieved by explicitly
allocating memory for large structures and arrays using functions like
@samp{malloc()} or @samp{AllocMem()}, instead of creating them as
local variables. Another method is replacing recursion with iteration.
In addition, it might be considered to use stack extension only for
selected, ``dangerous'' functions (@pxref{stackext}), not for all
functions in a given program.

The negative form of @samp{-mstackextend} is @samp{-mno-stackextend},
and is on by default.

@emph{Warning}: @samp{-mno-stackextend} used to be called
@samp{-mnostackextend} before @samp{Geek Gadgets} snapshot
@samp{961012}.
@end quotation

For more information, please refer to the @samp{LibNIX} documentation.

@node -mfixedstack, -mrestore-a4, -mstackextend, Invocation
@section -mfixedstack
@cindex -mfixedstack
@cindex Produce plain code

This option makes @samp{GCC} generate plain code, that does neither
stack checking nor extension. Since this is the default, there is
generally no need to use this option.

@quotation
@emph{Note}: This option has no negative form.
@end quotation

@node -mrestore-a4, -malways-restore-a4, -mfixedstack, Invocation
@section -mrestore-a4
@cindex -mrestore-a4
@cindex Reload a4 in public functions

This option is used to create the @samp{IXEmul} shared libraries
(those @file{*.ixlibrary} files).

It sets @samp{a4} to the appropriate value in the prologues of all
public functions (i.e., functions with external linkage). This is
necessary if these functions are called from the code of application.

@quotation
@emph{Note}: This option should not be used except for the creation of
an @samp{IXEmul} shared library.

This option was first made available in the @samp{GCC} 2.7.2,
@samp{Geek Gadgets} snapshot @samp{960902}. It used to be called
@samp{-frestore-a4}, and was relabeled to its current name in the
@samp{GCC} 2.7.2.1, @samp{Geek Gadgets} snapshot @samp{961012}.

The negative form of @samp{-mrestore-a4} is @samp{-mno-restore-a4},
and is on by default.
@end quotation

For more information, please refer to the @samp{A2IXLibrary}
documentation.

@node -malways-restore-a4, -mregparm, -mrestore-a4, Invocation
@section -malways-restore-a4
@cindex -malways-restore-a4
@cindex Reload a4 in all functions

This option is very similar to @samp{-mrestore-a4}
(@pxref{-mrestore-a4}).

The only difference is that it sets @samp{a4} in all functions,
including private ones (i.e., functions with internal linkage,
@samp{static}). This is safer than @samp{-mrestore-a4}
(@pxref{-mrestore-a4}), but is also slower.

@quotation
@emph{Note}: This option should not be used except for the creation of
an @samp{IXEmul} shared library.

This option was first made available in the @samp{GCC} 2.7.2,
@samp{Geek Gadgets} snapshot @samp{960902}. It used to be called
@samp{-falways-restore-a4}, and was relabeled to its current name in
the @samp{GCC} 2.7.2.1, @samp{Geek Gadgets} snapshot @samp{961012}.

The negative form of @samp{-malways-restore-a4} is
@samp{-mno-always-restore-a4}, and is on by default.
@end quotation

For more information, please refer to the @samp{A2IXLibrary}
documentation.

@node -mregparm, -frepo, -malways-restore-a4, Invocation
@section -mregparm
@cindex -mregparm
@cindex Pass function arguments in registers

On the @samp{m68k} architecture, @samp{GCC} passes function arguments
on the stack by default.

@samp{-mregparm} allows for passing arguments in registers. This can
be slightly faster than the standard method of passing arguments on
the stack.

The full syntax of this option is:

@format
-mregparm[=<value>]
@end format

@samp{value} should be an integer ranging from 1 to 4. If no
@samp{value} is provided, 2 will be used.

Four types of function arguments are recognized:

@table @samp
@item Integer
Integer numbers (this includes enumerations, small structures and
@samp{bool} in @samp{C++}, but excludes @samp{long long}, which is too
large). They are passed in data registers, starting from @samp{d0}.

@item Pointer
Pointers to objects or functions (this includes @samp{C++} references
and the implicit @samp{this} argument). They are passed in address
registers, starting from @samp{a0}.

@item Float
Floating point numbers. If the floating point code generation is
enabled, they are passed in floating point registers, starting from
@samp{fp0}. Otherwise, they are handled like the next type.

@item Other
All the other types of arguments, like large structures, pointers to
class methods in @samp{C++}, etc. They are always passed on the stack.
@end table

The value given for @samp{-mregparm} indicates how many arguments of
each of the above first three types should be passed in registers.

Example: @samp{GCC} is invoked with @samp{-mregparm} (without any
value, so 2 will be used) to compile a source containing the function:

@example
void fun(int a, char *str, char b, int c);
@end example

@samp{a} and @samp{b} will be passed in @samp{d0} and @samp{d1},
respectively, @samp{str} will be passed in @samp{a0}, and @samp{c}
will be passed on the stack.

@quotation
@emph{Note}: To use this option properly, it is very important that
all sources are fully prototyped. There may be very serious problems
if they are not, since @samp{GCC} will have to ``guess'' where to put
arguments, potentially making a wrong decission. Example:

@example
[in file1.c]
void f(void)
@{
   g(0); /* Call to a function with no prototype.  The argument
            will be put in d0, since it is an integer.  */
@}

[in file2.c]
void g(char *a) /* The argument is expected in a0, since it is
                   a pointer.  */
@{
@}
@end example

@samp{-Wimplicit -Wstrict-prototypes} should be used to ensure that
there are no prototypes missing.

In case of @samp{stdargs} functions, such as @samp{printf}, all
arguments are passed on the stack.

As of this writing, @samp{-mregparm} is supported by neither
@samp{IXEmul} nor @samp{LibNIX}, so its usefulness is very limited.

This option was first made available in the @samp{GCC} 2.7.2.1,
@samp{Geek Gadgets} snapshot @samp{961012}.

The negative form of @samp{-mregparm} is @samp{-mno-regparm}, and is
on by default.
@end quotation

@node -frepo, , -mregparm, Invocation
@section -frepo
@cindex -frepo
@cindex Enable C++ Template Repository

The AmigaOS port of @samp{GCC} includes @samp{C++} @dfn{Template
Repository} patch, so-called @samp{repo} patch.

In order to activate it, please compile @samp{C++} source files with
@samp{-frepo}. The compiler will not generate unnecessary
@samp{template} code, and will create @samp{.rpo} files that contain
information about @samp{template} symbols used in each source file.
Afterwards, during linking stage, a special tool called
@samp{collect2} will make sure that every required instantiation of
each @samp{template} is linked into the executable, recompiling some
source files if necessary.

@quotation
@emph{Note}: This option was first made available in the @samp{GCC}
2.7.2.1, @samp{Geek Gadgets} snapshot @samp{970109}.

This option is not specific to the AmigaOS port of
@samp{GCC}, nevertheless it is not fully supported in the baseline
sources.

This patch has been created in Cygnus Support, a company that is a
major contributor to the @samp{GNU} project. It has not been
integrated into the baseline sources due to design disagreements.

The negative form of @samp{-frepo} is @samp{-fno-repo}, and is on by
default.
@end quotation

For more information, please refer to the @samp{G++ FAQ}.

@node Attributes, Defines, Invocation, Top
@chapter Attributes
@cindex Attributes
@cindex Variable and function attributes

The following non-standard attributes are available in the AmigaOS
port of @samp{GCC}:

@menu
Variable attributes:
* chip::      Put object in @samp{chip} memory.

Function attributes:
* saveds::    Reload @samp{a4}.
* interrupt:: Do not mess with the stack.
* stackext::  Generate stack extension.
* regparm::   Pass arguments in registers.
* stkparm::   Pass arguments on the stack.
@end menu

@node chip, saveds, Attributes, Attributes
@section chip
@cindex chip
@cindex Put object in chip memory

Amiga hardware requires some data to be located in @samp{chip} memory.

Typically, if an initialized buffer is required (containing a picture
bitmap, for example), a plain, statically initialized buffer is used,
and the data is copied into a dynamically allocated @samp{MEMF_CHIP}
buffer.

This is not necessary with the @samp{chip} attribute. If this
attribute is specified for an initialized, static variable, it will be
allocated in @samp{chip} memory automagically by the AmigaOS.

A small example:

@example
UWORD __attribute__((chip)) bitmap1[] = @{ ... @};
@end example

@quotation
@emph{Note}: For compatibility with other AmigaOS @samp{C} compilers,
a preprocessor symbol @samp{__chip} is available, which expands to
@code{__attribute__((chip))} (@pxref{Keyword macros}).

All the @samp{chip} attribute does is specifying that data should go
to a section called @samp{.datachip}. Therefore, the standard
@samp{GCC} feature @code{__attribute__((section(".datachip")))} can be
used instead.

This attribute was first made available in the @samp{GCC} 2.7.2.1,
@samp{Geek Gadgets} snapshot @samp{970328}.

For proper operation, this attribute requires a special version of the
assembler, which generates standard AmigaOS object files. This version
is not yet available in @samp{Geek Gadgets} in binary form, since
support for this object files format is not yet complete.
@end quotation

@format
This attribute is not supported with @samp{GCC} 3.3 or newer!
@end format

@node saveds, interrupt, chip, Attributes
@section saveds
@cindex saveds
@cindex Reload a4

This attribute is ignored, unless base-relative data
(@pxref{-fbaserel}) is compiled.

To improve speed, programs compiled with the AmigaOS port of
@samp{GCC} set the @samp{a4} register to the appropriate value only
once, in the startup code. Code generated with the standard @samp{GCC}
option @samp{-fpic}, in contrast, sets the @samp{a4} register in every
function which references global data.

This is only safe as long as all function calls are performed from
within your own code. Things become ``tricky'' if callback functions,
like the AmigaOS hooks, interrupt handlers etc. are used. If global
data is referenced in such functions, @samp{a4} has to be set
properly.

This is exactly what the @samp{saveds} attribute does: it initializes
@samp{a4} in the function prologue, and restores it to its original
value in the function epilogue.

@quotation
@emph{Note}: For compatibility with other AmigaOS @samp{C} compilers,
a preprocessor symbol @samp{__saveds} is available, which expands to
@code{__attribute__((saveds))} (@pxref{Keyword macros}).

Please do not use this attribute in pure executables
(@pxref{-resident}, @pxref{-resident32}). This is because several
invocations of pure executables can run concurrently, each one having
its own data section, and there is no way to find out to which of
these sections should @samp{a4} be set.

The @samp{saveds} attribute is not necessary in function declarations
(prototypes).
@end quotation

This attribute was first made available in the @samp{GCC} 2.7.2.1,
@samp{Geek Gadgets} snapshot @samp{961012}.

@node interrupt, stackext, saveds, Attributes
@section interrupt
@cindex interrupt
@cindex Do not mess with the stack

This attribute should be used for any kind of callback functions that
can be called from outside your task. This includes interrupt
handlers, shared library functions, etc.

Most often, the @samp{interrupt} attribute is only necessary if a
program is compiled with stack checking or extension
(@pxref{-mstackcheck}, @pxref{-mstackextend}). It will prevent the
compiler from generating stack checking or extension code for the
function it was specified for.

Additionally, it will set @samp{CC} (@dfn{condition codes register})
in the function epilogue to return value, by performing @code{tstl
d0}.

@quotation
@emph{Note}: For compatibility with other AmigaOS @samp{C} compilers,
a preprocessor symbol @samp{__interrupt} is available, which expands
to @code{__attribute__((interrupt))} (@pxref{Keyword macros}).

The @samp{interrupt} attribute is mutually exclusive with the
@samp{stackext} attribute (@pxref{stackext}).

This attribute is not necessary in function declarations (prototypes).
@end quotation

This attribute was first made available in the @samp{GCC} 2.7.2.1,
@samp{Geek Gadgets} snapshot @samp{961012}.

@node stackext, regparm, interrupt, Attributes
@section stackext
@cindex stackext
@cindex Generate stack extension

This attribute makes @samp{GCC} generate stack extension code for the
function for which it was used (@pxref{-mstackextend}). This makes it
possible to use stack extension selectively, only for the
``dangerous'' functions --- recursive functions, functions with large
local variables, etc.

@quotation
@emph{Note}: For compatibility with other AmigaOS @samp{C} compilers,
a preprocessor symbol @samp{__stackext} is available, which expands to
@code{__attribute__((stackext))} (@pxref{Keyword macros}).

The @samp{stackext} attribute is mutually exclusive with the
@samp{interrupt} attribute (@pxref{interrupt}).

This attribute is not necessary in function declarations (prototypes).
@end quotation

This attribute was first made available in the @samp{GCC} 2.7.2.1,
@samp{Geek Gadgets} snapshot @samp{961012}.

@node regparm, stkparm, stackext, Attributes
@section regparm
@cindex regparm
@cindex Pass arguments in registers

The @samp{regparm} attribute, together with the @samp{stkparm}
attribute (@pxref{stkparm}), can be used to fine-tune the way
arguments are passed. It makes @samp{GCC} pass arguments in registers
for the function for which it was used, regardless of whether the
global @samp{-mregparm} option was used or not (@pxref{-mregparm}).

An optional integer argument ranging from 1 to 4 indicates how many
arguments of each type should be passed in registers
(@pxref{-mregparm}). The syntax is the following:

@example
void __attribute__((regparm(3))) fun(int a, char *str, char b, int c);
@end example

This will make @samp{GCC} pass @samp{a}, @samp{b} and @samp{c} in
@samp{d0}, @samp{d1} and @samp{d2}, respectively, and @samp{str} in
@samp{a0}.

If the argument is not provided, the value given for @samp{-mregparm}
will be used (or 2 if that option was not specified,
@pxref{-mregparm}).

@quotation
@emph{Note}: There is generally no need to use this attribute unless
files compiled with different calling conventions are linked together.

For compatibility with other AmigaOS @samp{C} compilers, a
preprocessor symbol @samp{__regargs} is available, which expands to
@code{__attribute__((regparm))} (@pxref{Keyword macros}).

The @samp{regparm} attribute is mutually exclusive with the
@samp{stkparm} attribute (@pxref{stkparm}).

This attribute is necessary both in function declarations (prototypes)
and definitions (function code).
@end quotation

This attribute was first made available in the @samp{GCC} 2.7.2.1,
@samp{Geek Gadgets} snapshot @samp{961012}.

@node stkparm, , regparm, Attributes
@section stkparm
@cindex stkparm
@cindex Pass arguments on the stack

The @samp{stkparm} attribute, together with the @samp{regparm}
attribute (@pxref{regparm}), can be used to fine-tune the way
arguments are passed. It makes @samp{GCC} pass arguments on stack for
the function for which it was used, regardless of whether the global
@samp{-mregparm} option was used or not (@pxref{-mregparm}).

@quotation
@emph{Note}: There is generally no need to use this attribute unless
files compiled with different calling conventions are linked together.

For compatibility with other AmigaOS @samp{C} compilers, a
preprocessor symbol @samp{__stdargs} is available, which expands to
@code{__attribute__((stkparm))} (@pxref{Keyword macros}).

The @samp{stkparm} attribute is mutually exclusive with the
@samp{regparm} attribute (@pxref{regparm}).

This attribute is necessary both in function declarations (prototypes)
and definitions (function code).
@end quotation

This attribute was first made available in the @samp{GCC} 2.7.2.1,
@samp{Geek Gadgets} snapshot @samp{961012}.

@node Defines, Miscellaneous, Attributes, Top
@chapter Defines
@cindex Defines
@cindex Preprocessor symbols

The AmigaOS-specific preprocessor symbols available in @samp{GCC} can
be divided into three groups:

@menu
* Identifying machine:: What machine is this?
* Options information:: Which options have been specified?
* Keyword macros::      Compatibility with other compilers.
@end menu

@node Identifying machine, Options information, Defines, Defines
@section Symbols identifying machine
@cindex Symbols identifying machine
@cindex What machine is this

The following machine-identifying preprocessor symbols are available:

@table @samp
@item mc68000
This macro identifies the machine as having a CPU from the Motorola
68000 family.

@item amiga
@item amigaos
@item amigados
These macros identify the machine as being an Amiga, running the
AmigaOS.

@item AMIGA
@item MCH_AMIGA
These macros are provided for compatibility with other AmigaOS
@samp{C} compilers.
@end table

@quotation
@emph{Note}: These symbols are available in three groups: plain (as
specified above), with two leading underscores, and with two leading
and two tailing underscores. The plain ones are not available when
compiling with the @samp{-ansi} option.

The @samp{amigados} symbol is obsolete and will be removed in future.
Please use @samp{amigaos}, which was first made available in the
@samp{GCC} 2.7.2.1, @samp{Geek Gadgets} snapshot @samp{961012}.
@end quotation

@node Options information, Keyword macros, Identifying machine, Defines
@section Symbols identifying specified options
@cindex Symbols identifying specified options
@cindex Symbols identifying CPU
@cindex Symbols identifying ixemul
@cindex Which CPU model options have been specified

@samp{GCC} has several options to choose the CPU model that the code
should be generated for. The following preprocessor symbols identify
which options have been specified on the command line:

@table @samp
@item mc68020
Either one of @samp{-m68020}, @samp{-mc68020} or @samp{-mc68020-40}
has been specified.

@item mc68030
@samp{-m68030} has been specified.

@item mc68040
@samp{-m68040} has been specified.

@item mc68060
@samp{-m68060} @emph{[EXPERIMENTAL]} has been specified.

@item __HAVE_68881__
@samp{-m68881} has been specified.
@end table

@quotation
@emph{Note}: The symbols beginning with @samp{mc} are available in
three groups: plain (as specified above), with two leading
underscores, and with two leading and two tailing underscores. The
plain ones are not available when compiling with the @samp{-ansi}
option. The ``underscored'' ones were first made available in the
@samp{GCC} 2.7.2.1, @samp{Geek Gadgets} snapshot @samp{970109}.

@samp{mc68000} is defined regardless of which @samp{-m680x0} options
have been used.
@end quotation

In addition to the above, a preprocessor symbol @samp{ixemul}
(together with the ``underscored'' versions) is available when not
compiling with @samp{-noixemul} (@pxref{-noixemul}) and identifies the
runtime environment as @samp{IXEmul}. This symbol was first made
available in the @samp{GCC} 2.7.2.1, @samp{Geek Gadgets} snapshot
@samp{970328}.

@node Keyword macros, , Options information, Defines
@section ``Keyword'' macros
@cindex Keyword macros
@cindex Compatibility with other compilers

Most AmigaOS-specific @samp{C} compilers have special ``custom
keywords'', which make the AmigaOS-specific development easier.
Unfortunately, the idea of ``custom keywords'' is not available in
@samp{GCC}. However, @samp{attributes} are available, and they provide
virtually identical functionality. For compatibility with other
AmigaOS @samp{C} compilers, preprocessor symbols are provided, which
expand to the appropriate @samp{attributes} (@pxref{Attributes}).

@table @samp
@item __chip
@xref{chip}.

@item __saveds
@xref{saveds}.

@item __interrupt
@xref{interrupt}.

@item __stackext
@xref{stackext}.

@item __regargs
@xref{regparm}.

@item __stdargs
@xref{stkparm}.

@item __aligned
This expands to the standard @samp{GCC}
@samp{__attribute__((aligned(4)))}.
@end table

@quotation
@emph{Note}: With @samp{SAS/C}, these keywords may be specified either
before or after the type, so the following declaration is correct:

@example
__saveds void func(void);
@end example

Unfortunately, the syntax rules of @samp{GCC} 2.7.2.1 do not allow to
specify the attributes before the type, so the above example must be
changed to:

@example
void __saveds func(void);
@end example

This will be fixed in @samp{GCC} 2.8.0.
@end quotation

@node Miscellaneous, Index, Defines, Top
@chapter Miscellaneous
@cindex Miscellaneous
@cindex Uncategorizable

The following ``hard to categorize'' features are available in the
AmigaOS port of @samp{GCC}:

@menu
* Explicit register specification:: Specify registers for arguments.
* Case sensitive CPP::              <String.h> is not the same as <string.h>
* Library flavors::                 Linker libraries.
@end menu

@node Explicit register specification, Case sensitive CPP, Miscellaneous, Miscellaneous
@section Explicit register specification
@cindex Explicit register specification
@cindex Specify registers for arguments

In certain situations, like writing callback hooks, ``patchers'',
standard shared libraries, etc., functions have to receive arguments
in particular registers.

@samp{-mregparm} (@pxref{-mregparm}) is not appropriate in this case,
since it does not give the programmer enough control on @emph{which}
registers will be used.

To overcome this problem in the AmigaOS port of @samp{GCC}, explicit
register specification has been extended to be available for function
arguments, as well:

@example
void myhook(struct Hook* hook __asm("a0"), APTR object __asm("a2"),
            APTR message __asm("a1"))
@{
	...
@}
@end example

@quotation
@emph{Note}: This feature is currently not available in @samp{G++}.

Only the @samp{ANSI}-style declarations (prototypes) are supported.

Registers have to be specified both in function declarations
(prototypes) and definitions (function code).
@end quotation

This feature was first made available in the @samp{GCC} 2.7.2.1,
@samp{Geek Gadgets} snapshot @samp{961012}.

@node Case sensitive CPP, Library flavors, Explicit register specification, Miscellaneous
@section Case sensitive CPP
@cindex Case sensitive CPP
@cindex <String.h> is not the same as <string.h>

The preprocessor available in the AmigaOS port of @samp{GCC} is case
sensitive. This means, that the header names provided in the
@code{#include} directives have to be correct, including upper and
lower case letters. This affects only the way the preprocessor works.
Currently available native AmigaOS file systems are case insensitive.

@quotation
@emph{Note}: This might seem like a horrible hack and a crazy attempt
to implement a ``ridiculous'' UNIX feature on Amiga. However, this
feature has been introduced to terminate the endless @samp{G++}
problems with a standard @samp{ANSI C} header @file{string.h}: under
the AmigaOS, a @samp{C++} header @file{String.h} would be included,
instead.
@end quotation

@node Library flavors, , Case sensitive CPP, Miscellaneous
@section Library flavors
@cindex Library flavors
@cindex Linker libraries

The AmigaOS port of @samp{GCC} may use different linker libraries
depending upon the options used while invoking the compiler. These
libraries reside in subdirectories of the standard locations, such as
@file{GG:lib/} or, with @samp{GCC} 2.7.2.1,
@file{GG:lib/gcc-lib/m68k-amigaos/2.7.2.1/}.

If you invoke @code{gcc} with @samp{-v}, you'll see the precise flavor
of libraries used as a @samp{-fl} option in the @code{ld} invocation.
Here is a list of the available flavors (and hence the subdirectories
names):

@itemize @bullet
@item 
@file{libb} corresponds to the @ref{-fbaserel} option.
@item
@file{libb32} corresponds to the @ref{-fbaserel32} option.
@item
@file{libm020} corresponds to the @samp{-m68020} (or higher) options.
@item
@file{libm881} corresponds to the @samp{-m68881} option.
@item
@file{libnix} corresponds to the @ref{-noixemul} option.
@end itemize

More than one flavor can be specified simultaneously. For example,
when both @ref{-fbaserel} and @samp{-m68020} are specified, the
libraries will be searched in @file{libb/libm020} subdirectory (as
well as in @file{libb} subdirectory and in the standard location).

@node Index, , Miscellaneous, Top
@chapter Index
@printindex cp

@contents
@bye