OSDN Git Service

* config.gcc: Add an extra_header for ARM targets.
[pf3gnuchains/gcc-fork.git] / gcc / libgcc2.c
1 /* More subroutines needed by GCC output code on some machines.  */
2 /* Compile this one with gcc.  */
3 /* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4    2000, 2001, 2002, 2003  Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
11 version.
12
13 In addition to the permissions in the GNU General Public License, the
14 Free Software Foundation gives you unlimited permission to link the
15 compiled version of this file into combinations with other programs,
16 and to distribute those combinations without any restriction coming
17 from the use of this file.  (The General Public License restrictions
18 do apply in other respects; for example, they cover modification of
19 the file, and distribution when not linked into a combine
20 executable.)
21
22 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
23 WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25 for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with GCC; see the file COPYING.  If not, write to the Free
29 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
30 02111-1307, USA.  */
31
32
33 /* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
34    supposedly valid even though this is a "target" file.  */
35 #include "auto-host.h"
36
37 /* It is incorrect to include config.h here, because this file is being
38    compiled for the target, and hence definitions concerning only the host
39    do not apply.  */
40 #include "tconfig.h"
41 #include "tsystem.h"
42 #include "coretypes.h"
43 #include "tm.h"
44
45 /* Don't use `fancy_abort' here even if config.h says to use it.  */
46 #ifdef abort
47 #undef abort
48 #endif
49
50 #ifdef HAVE_GAS_HIDDEN
51 #define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
52 #else
53 #define ATTRIBUTE_HIDDEN
54 #endif
55
56 #include "libgcc2.h"
57 \f
58 #ifdef DECLARE_LIBRARY_RENAMES
59   DECLARE_LIBRARY_RENAMES
60 #endif
61
62 #if defined (L_negdi2)
63 DWtype
64 __negdi2 (DWtype u)
65 {
66   DWunion w;
67   DWunion uu;
68
69   uu.ll = u;
70
71   w.s.low = -uu.s.low;
72   w.s.high = -uu.s.high - ((UWtype) w.s.low > 0);
73
74   return w.ll;
75 }
76 #endif
77
78 #ifdef L_addvsi3
79 Wtype
80 __addvsi3 (Wtype a, Wtype b)
81 {
82   Wtype w;
83
84   w = a + b;
85
86   if (b >= 0 ? w < a : w > a)
87     abort ();
88
89   return w;
90 }
91 #endif
92 \f
93 #ifdef L_addvdi3
94 DWtype
95 __addvdi3 (DWtype a, DWtype b)
96 {
97   DWtype w;
98
99   w = a + b;
100
101   if (b >= 0 ? w < a : w > a)
102     abort ();
103
104   return w;
105 }
106 #endif
107 \f
108 #ifdef L_subvsi3
109 Wtype
110 __subvsi3 (Wtype a, Wtype b)
111 {
112 #ifdef L_addvsi3
113   return __addvsi3 (a, (-b));
114 #else
115   DWtype w;
116
117   w = a - b;
118
119   if (b >= 0 ? w > a : w < a)
120     abort ();
121
122   return w;
123 #endif
124 }
125 #endif
126 \f
127 #ifdef L_subvdi3
128 DWtype
129 __subvdi3 (DWtype a, DWtype b)
130 {
131 #ifdef L_addvdi3
132   return __addvdi3 (a, (-b));
133 #else
134   DWtype w;
135
136   w = a - b;
137
138   if (b >= 0 ? w > a : w < a)
139     abort ();
140
141   return w;
142 #endif
143 }
144 #endif
145 \f
146 #ifdef L_mulvsi3
147 Wtype
148 __mulvsi3 (Wtype a, Wtype b)
149 {
150   DWtype w;
151
152   w = a * b;
153
154   if (((a >= 0) == (b >= 0)) ? w < 0 : w > 0)
155     abort ();
156
157   return w;
158 }
159 #endif
160 \f
161 #ifdef L_negvsi2
162 Wtype
163 __negvsi2 (Wtype a)
164 {
165   Wtype w;
166
167   w  = -a;
168
169   if (a >= 0 ? w > 0 : w < 0)
170     abort ();
171
172    return w;
173 }
174 #endif
175 \f
176 #ifdef L_negvdi2
177 DWtype
178 __negvdi2 (DWtype a)
179 {
180   DWtype w;
181
182   w  = -a;
183
184   if (a >= 0 ? w > 0 : w < 0)
185     abort ();
186
187   return w;
188 }
189 #endif
190 \f
191 #ifdef L_absvsi2
192 Wtype
193 __absvsi2 (Wtype a)
194 {
195   Wtype w = a;
196
197   if (a < 0)
198 #ifdef L_negvsi2
199     w = __negvsi2 (a);
200 #else
201     w = -a;
202
203   if (w < 0)
204     abort ();
205 #endif
206
207    return w;
208 }
209 #endif
210 \f
211 #ifdef L_absvdi2
212 DWtype
213 __absvdi2 (DWtype a)
214 {
215   DWtype w = a;
216
217   if (a < 0)
218 #ifdef L_negvsi2
219     w = __negvsi2 (a);
220 #else
221     w = -a;
222
223   if (w < 0)
224     abort ();
225 #endif
226
227   return w;
228 }
229 #endif
230 \f
231 #ifdef L_mulvdi3
232 DWtype
233 __mulvdi3 (DWtype u, DWtype v)
234 {
235   DWtype w;
236
237   w = u * v;
238
239   if (((u >= 0) == (v >= 0)) ? w < 0 : w > 0)
240     abort ();
241
242   return w;
243 }
244 #endif
245 \f
246
247 /* Unless shift functions are defined with full ANSI prototypes,
248    parameter b will be promoted to int if word_type is smaller than an int.  */
249 #ifdef L_lshrdi3
250 DWtype
251 __lshrdi3 (DWtype u, word_type b)
252 {
253   DWunion w;
254   word_type bm;
255   DWunion uu;
256
257   if (b == 0)
258     return u;
259
260   uu.ll = u;
261
262   bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
263   if (bm <= 0)
264     {
265       w.s.high = 0;
266       w.s.low = (UWtype) uu.s.high >> -bm;
267     }
268   else
269     {
270       UWtype carries = (UWtype) uu.s.high << bm;
271
272       w.s.high = (UWtype) uu.s.high >> b;
273       w.s.low = ((UWtype) uu.s.low >> b) | carries;
274     }
275
276   return w.ll;
277 }
278 #endif
279
280 #ifdef L_ashldi3
281 DWtype
282 __ashldi3 (DWtype u, word_type b)
283 {
284   DWunion w;
285   word_type bm;
286   DWunion uu;
287
288   if (b == 0)
289     return u;
290
291   uu.ll = u;
292
293   bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
294   if (bm <= 0)
295     {
296       w.s.low = 0;
297       w.s.high = (UWtype) uu.s.low << -bm;
298     }
299   else
300     {
301       UWtype carries = (UWtype) uu.s.low >> bm;
302
303       w.s.low = (UWtype) uu.s.low << b;
304       w.s.high = ((UWtype) uu.s.high << b) | carries;
305     }
306
307   return w.ll;
308 }
309 #endif
310
311 #ifdef L_ashrdi3
312 DWtype
313 __ashrdi3 (DWtype u, word_type b)
314 {
315   DWunion w;
316   word_type bm;
317   DWunion uu;
318
319   if (b == 0)
320     return u;
321
322   uu.ll = u;
323
324   bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
325   if (bm <= 0)
326     {
327       /* w.s.high = 1..1 or 0..0 */
328       w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
329       w.s.low = uu.s.high >> -bm;
330     }
331   else
332     {
333       UWtype carries = (UWtype) uu.s.high << bm;
334
335       w.s.high = uu.s.high >> b;
336       w.s.low = ((UWtype) uu.s.low >> b) | carries;
337     }
338
339   return w.ll;
340 }
341 #endif
342 \f
343 #ifdef L_ffssi2
344 #undef int
345 extern int __ffsSI2 (UWtype u);
346 int
347 __ffsSI2 (UWtype u)
348 {
349   UWtype count;
350
351   if (u == 0)
352     return 0;
353
354   count_trailing_zeros (count, u);
355   return count + 1;
356 }
357 #endif
358 \f
359 #ifdef L_ffsdi2
360 #undef int
361 extern int __ffsDI2 (DWtype u);
362 int
363 __ffsDI2 (DWtype u)
364 {
365   DWunion uu;
366   UWtype word, count, add;
367
368   uu.ll = u;
369   if (uu.s.low != 0)
370     word = uu.s.low, add = 0;
371   else if (uu.s.high != 0)
372     word = uu.s.high, add = BITS_PER_UNIT * sizeof (Wtype);
373   else
374     return 0;
375
376   count_trailing_zeros (count, word);
377   return count + add + 1;
378 }
379 #endif
380 \f
381 #ifdef L_muldi3
382 DWtype
383 __muldi3 (DWtype u, DWtype v)
384 {
385   DWunion w;
386   DWunion uu, vv;
387
388   uu.ll = u,
389   vv.ll = v;
390
391   w.ll = __umulsidi3 (uu.s.low, vv.s.low);
392   w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high
393                + (UWtype) uu.s.high * (UWtype) vv.s.low);
394
395   return w.ll;
396 }
397 #endif
398 \f
399 #if (defined (L_udivdi3) || defined (L_divdi3) || \
400      defined (L_umoddi3) || defined (L_moddi3))
401 #if defined (sdiv_qrnnd)
402 #define L_udiv_w_sdiv
403 #endif
404 #endif
405
406 #ifdef L_udiv_w_sdiv
407 #if defined (sdiv_qrnnd)
408 #if (defined (L_udivdi3) || defined (L_divdi3) || \
409      defined (L_umoddi3) || defined (L_moddi3))
410 static inline __attribute__ ((__always_inline__))
411 #endif
412 UWtype
413 __udiv_w_sdiv (UWtype *rp, UWtype a1, UWtype a0, UWtype d)
414 {
415   UWtype q, r;
416   UWtype c0, c1, b1;
417
418   if ((Wtype) d >= 0)
419     {
420       if (a1 < d - a1 - (a0 >> (W_TYPE_SIZE - 1)))
421         {
422           /* dividend, divisor, and quotient are nonnegative */
423           sdiv_qrnnd (q, r, a1, a0, d);
424         }
425       else
426         {
427           /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d */
428           sub_ddmmss (c1, c0, a1, a0, d >> 1, d << (W_TYPE_SIZE - 1));
429           /* Divide (c1*2^32 + c0) by d */
430           sdiv_qrnnd (q, r, c1, c0, d);
431           /* Add 2^31 to quotient */
432           q += (UWtype) 1 << (W_TYPE_SIZE - 1);
433         }
434     }
435   else
436     {
437       b1 = d >> 1;                      /* d/2, between 2^30 and 2^31 - 1 */
438       c1 = a1 >> 1;                     /* A/2 */
439       c0 = (a1 << (W_TYPE_SIZE - 1)) + (a0 >> 1);
440
441       if (a1 < b1)                      /* A < 2^32*b1, so A/2 < 2^31*b1 */
442         {
443           sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
444
445           r = 2*r + (a0 & 1);           /* Remainder from A/(2*b1) */
446           if ((d & 1) != 0)
447             {
448               if (r >= q)
449                 r = r - q;
450               else if (q - r <= d)
451                 {
452                   r = r - q + d;
453                   q--;
454                 }
455               else
456                 {
457                   r = r - q + 2*d;
458                   q -= 2;
459                 }
460             }
461         }
462       else if (c1 < b1)                 /* So 2^31 <= (A/2)/b1 < 2^32 */
463         {
464           c1 = (b1 - 1) - c1;
465           c0 = ~c0;                     /* logical NOT */
466
467           sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
468
469           q = ~q;                       /* (A/2)/b1 */
470           r = (b1 - 1) - r;
471
472           r = 2*r + (a0 & 1);           /* A/(2*b1) */
473
474           if ((d & 1) != 0)
475             {
476               if (r >= q)
477                 r = r - q;
478               else if (q - r <= d)
479                 {
480                   r = r - q + d;
481                   q--;
482                 }
483               else
484                 {
485                   r = r - q + 2*d;
486                   q -= 2;
487                 }
488             }
489         }
490       else                              /* Implies c1 = b1 */
491         {                               /* Hence a1 = d - 1 = 2*b1 - 1 */
492           if (a0 >= -d)
493             {
494               q = -1;
495               r = a0 + d;
496             }
497           else
498             {
499               q = -2;
500               r = a0 + 2*d;
501             }
502         }
503     }
504
505   *rp = r;
506   return q;
507 }
508 #else
509 /* If sdiv_qrnnd doesn't exist, define dummy __udiv_w_sdiv.  */
510 UWtype
511 __udiv_w_sdiv (UWtype *rp __attribute__ ((__unused__)),
512                UWtype a1 __attribute__ ((__unused__)),
513                UWtype a0 __attribute__ ((__unused__)),
514                UWtype d __attribute__ ((__unused__)))
515 {
516   return 0;
517 }
518 #endif
519 #endif
520 \f
521 #if (defined (L_udivdi3) || defined (L_divdi3) || \
522      defined (L_umoddi3) || defined (L_moddi3))
523 #define L_udivmoddi4
524 #endif
525
526 #ifdef L_clz
527 const UQItype __clz_tab[] =
528 {
529   0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
530   6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
531   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
532   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
533   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
534   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
535   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
536   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
537 };
538 #endif
539 \f
540 #ifdef L_clzsi2
541 #undef int
542 extern int __clzSI2 (UWtype x);
543 int
544 __clzSI2 (UWtype x)
545 {
546   Wtype ret;
547
548   count_leading_zeros (ret, x);
549
550   return ret;
551 }
552 #endif
553 \f
554 #ifdef L_clzdi2
555 #undef int
556 extern int __clzDI2 (UDWtype x);
557 int
558 __clzDI2 (UDWtype x)
559 {
560   DWunion uu;
561   UWtype word;
562   Wtype ret, add;
563
564   uu.ll = x;
565   if (uu.s.high)
566     word = uu.s.high, add = 0;
567   else
568     word = uu.s.low, add = W_TYPE_SIZE;
569
570   count_leading_zeros (ret, word);
571   return ret + add;
572 }
573 #endif
574 \f
575 #ifdef L_ctzsi2
576 #undef int
577 extern int __ctzSI2 (UWtype x);
578 int
579 __ctzSI2 (UWtype x)
580 {
581   Wtype ret;
582
583   count_trailing_zeros (ret, x);
584
585   return ret;
586 }
587 #endif
588 \f
589 #ifdef L_ctzdi2
590 #undef int
591 extern int __ctzDI2 (UDWtype x);
592 int
593 __ctzDI2 (UDWtype x)
594 {
595   DWunion uu;
596   UWtype word;
597   Wtype ret, add;
598
599   uu.ll = x;
600   if (uu.s.low)
601     word = uu.s.low, add = 0;
602   else
603     word = uu.s.high, add = W_TYPE_SIZE;
604
605   count_trailing_zeros (ret, word);
606   return ret + add;
607 }
608 #endif
609
610 #if (defined (L_popcountsi2) || defined (L_popcountdi2) \
611      || defined (L_popcount_tab))
612 extern const UQItype __popcount_tab[] ATTRIBUTE_HIDDEN;
613 #endif
614
615 #ifdef L_popcount_tab
616 const UQItype __popcount_tab[] =
617 {
618     0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
619     1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
620     1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
621     2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
622     1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
623     2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
624     2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
625     3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,
626 };
627 #endif
628 \f
629 #ifdef L_popcountsi2
630 #undef int
631 extern int __popcountSI2 (UWtype x);
632 int
633 __popcountSI2 (UWtype x)
634 {
635   UWtype i, ret = 0;
636
637   for (i = 0; i < W_TYPE_SIZE; i += 8)
638     ret += __popcount_tab[(x >> i) & 0xff];
639
640   return ret;
641 }
642 #endif
643 \f
644 #ifdef L_popcountdi2
645 #undef int
646 extern int __popcountDI2 (UDWtype x);
647 int
648 __popcountDI2 (UDWtype x)
649 {
650   UWtype i, ret = 0;
651
652   for (i = 0; i < 2*W_TYPE_SIZE; i += 8)
653     ret += __popcount_tab[(x >> i) & 0xff];
654
655   return ret;
656 }
657 #endif
658 \f
659 #ifdef L_paritysi2
660 #undef int
661 extern int __paritySI2 (UWtype x);
662 int
663 __paritySI2 (UWtype x)
664 {
665 #if W_TYPE_SIZE > 64
666 # error "fill out the table"
667 #endif
668 #if W_TYPE_SIZE > 32
669   x ^= x >> 32;
670 #endif
671 #if W_TYPE_SIZE > 16
672   x ^= x >> 16;
673 #endif
674   x ^= x >> 8;
675   x ^= x >> 4;
676   x &= 0xf;
677   return (0x6996 >> x) & 1;
678 }
679 #endif
680 \f
681 #ifdef L_paritydi2
682 #undef int
683 extern int __parityDI2 (UDWtype x);
684 int
685 __parityDI2 (UDWtype x)
686 {
687   DWunion uu;
688   UWtype nx;
689
690   uu.ll = x;
691   nx = uu.s.low ^ uu.s.high;
692
693 #if W_TYPE_SIZE > 64
694 # error "fill out the table"
695 #endif
696 #if W_TYPE_SIZE > 32
697   nx ^= nx >> 32;
698 #endif
699 #if W_TYPE_SIZE > 16
700   nx ^= nx >> 16;
701 #endif
702   nx ^= nx >> 8;
703   nx ^= nx >> 4;
704   nx &= 0xf;
705   return (0x6996 >> nx) & 1;
706 }
707 #endif
708
709 #ifdef L_udivmoddi4
710
711 #if (defined (L_udivdi3) || defined (L_divdi3) || \
712      defined (L_umoddi3) || defined (L_moddi3))
713 static inline __attribute__ ((__always_inline__))
714 #endif
715 UDWtype
716 __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
717 {
718   DWunion ww;
719   DWunion nn, dd;
720   DWunion rr;
721   UWtype d0, d1, n0, n1, n2;
722   UWtype q0, q1;
723   UWtype b, bm;
724
725   nn.ll = n;
726   dd.ll = d;
727
728   d0 = dd.s.low;
729   d1 = dd.s.high;
730   n0 = nn.s.low;
731   n1 = nn.s.high;
732
733 #if !UDIV_NEEDS_NORMALIZATION
734   if (d1 == 0)
735     {
736       if (d0 > n1)
737         {
738           /* 0q = nn / 0D */
739
740           udiv_qrnnd (q0, n0, n1, n0, d0);
741           q1 = 0;
742
743           /* Remainder in n0.  */
744         }
745       else
746         {
747           /* qq = NN / 0d */
748
749           if (d0 == 0)
750             d0 = 1 / d0;        /* Divide intentionally by zero.  */
751
752           udiv_qrnnd (q1, n1, 0, n1, d0);
753           udiv_qrnnd (q0, n0, n1, n0, d0);
754
755           /* Remainder in n0.  */
756         }
757
758       if (rp != 0)
759         {
760           rr.s.low = n0;
761           rr.s.high = 0;
762           *rp = rr.ll;
763         }
764     }
765
766 #else /* UDIV_NEEDS_NORMALIZATION */
767
768   if (d1 == 0)
769     {
770       if (d0 > n1)
771         {
772           /* 0q = nn / 0D */
773
774           count_leading_zeros (bm, d0);
775
776           if (bm != 0)
777             {
778               /* Normalize, i.e. make the most significant bit of the
779                  denominator set.  */
780
781               d0 = d0 << bm;
782               n1 = (n1 << bm) | (n0 >> (W_TYPE_SIZE - bm));
783               n0 = n0 << bm;
784             }
785
786           udiv_qrnnd (q0, n0, n1, n0, d0);
787           q1 = 0;
788
789           /* Remainder in n0 >> bm.  */
790         }
791       else
792         {
793           /* qq = NN / 0d */
794
795           if (d0 == 0)
796             d0 = 1 / d0;        /* Divide intentionally by zero.  */
797
798           count_leading_zeros (bm, d0);
799
800           if (bm == 0)
801             {
802               /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
803                  conclude (the most significant bit of n1 is set) /\ (the
804                  leading quotient digit q1 = 1).
805
806                  This special case is necessary, not an optimization.
807                  (Shifts counts of W_TYPE_SIZE are undefined.)  */
808
809               n1 -= d0;
810               q1 = 1;
811             }
812           else
813             {
814               /* Normalize.  */
815
816               b = W_TYPE_SIZE - bm;
817
818               d0 = d0 << bm;
819               n2 = n1 >> b;
820               n1 = (n1 << bm) | (n0 >> b);
821               n0 = n0 << bm;
822
823               udiv_qrnnd (q1, n1, n2, n1, d0);
824             }
825
826           /* n1 != d0...  */
827
828           udiv_qrnnd (q0, n0, n1, n0, d0);
829
830           /* Remainder in n0 >> bm.  */
831         }
832
833       if (rp != 0)
834         {
835           rr.s.low = n0 >> bm;
836           rr.s.high = 0;
837           *rp = rr.ll;
838         }
839     }
840 #endif /* UDIV_NEEDS_NORMALIZATION */
841
842   else
843     {
844       if (d1 > n1)
845         {
846           /* 00 = nn / DD */
847
848           q0 = 0;
849           q1 = 0;
850
851           /* Remainder in n1n0.  */
852           if (rp != 0)
853             {
854               rr.s.low = n0;
855               rr.s.high = n1;
856               *rp = rr.ll;
857             }
858         }
859       else
860         {
861           /* 0q = NN / dd */
862
863           count_leading_zeros (bm, d1);
864           if (bm == 0)
865             {
866               /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
867                  conclude (the most significant bit of n1 is set) /\ (the
868                  quotient digit q0 = 0 or 1).
869
870                  This special case is necessary, not an optimization.  */
871
872               /* The condition on the next line takes advantage of that
873                  n1 >= d1 (true due to program flow).  */
874               if (n1 > d1 || n0 >= d0)
875                 {
876                   q0 = 1;
877                   sub_ddmmss (n1, n0, n1, n0, d1, d0);
878                 }
879               else
880                 q0 = 0;
881
882               q1 = 0;
883
884               if (rp != 0)
885                 {
886                   rr.s.low = n0;
887                   rr.s.high = n1;
888                   *rp = rr.ll;
889                 }
890             }
891           else
892             {
893               UWtype m1, m0;
894               /* Normalize.  */
895
896               b = W_TYPE_SIZE - bm;
897
898               d1 = (d1 << bm) | (d0 >> b);
899               d0 = d0 << bm;
900               n2 = n1 >> b;
901               n1 = (n1 << bm) | (n0 >> b);
902               n0 = n0 << bm;
903
904               udiv_qrnnd (q0, n1, n2, n1, d1);
905               umul_ppmm (m1, m0, q0, d0);
906
907               if (m1 > n1 || (m1 == n1 && m0 > n0))
908                 {
909                   q0--;
910                   sub_ddmmss (m1, m0, m1, m0, d1, d0);
911                 }
912
913               q1 = 0;
914
915               /* Remainder in (n1n0 - m1m0) >> bm.  */
916               if (rp != 0)
917                 {
918                   sub_ddmmss (n1, n0, n1, n0, m1, m0);
919                   rr.s.low = (n1 << b) | (n0 >> bm);
920                   rr.s.high = n1 >> bm;
921                   *rp = rr.ll;
922                 }
923             }
924         }
925     }
926
927   ww.s.low = q0;
928   ww.s.high = q1;
929   return ww.ll;
930 }
931 #endif
932
933 #ifdef L_divdi3
934 DWtype
935 __divdi3 (DWtype u, DWtype v)
936 {
937   word_type c = 0;
938   DWunion uu, vv;
939   DWtype w;
940
941   uu.ll = u;
942   vv.ll = v;
943
944   if (uu.s.high < 0)
945     c = ~c,
946     uu.ll = -uu.ll;
947   if (vv.s.high < 0)
948     c = ~c,
949     vv.ll = -vv.ll;
950
951   w = __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) 0);
952   if (c)
953     w = -w;
954
955   return w;
956 }
957 #endif
958
959 #ifdef L_moddi3
960 DWtype
961 __moddi3 (DWtype u, DWtype v)
962 {
963   word_type c = 0;
964   DWunion uu, vv;
965   DWtype w;
966
967   uu.ll = u;
968   vv.ll = v;
969
970   if (uu.s.high < 0)
971     c = ~c,
972     uu.ll = -uu.ll;
973   if (vv.s.high < 0)
974     vv.ll = -vv.ll;
975
976   (void) __udivmoddi4 (uu.ll, vv.ll, &w);
977   if (c)
978     w = -w;
979
980   return w;
981 }
982 #endif
983
984 #ifdef L_umoddi3
985 UDWtype
986 __umoddi3 (UDWtype u, UDWtype v)
987 {
988   UDWtype w;
989
990   (void) __udivmoddi4 (u, v, &w);
991
992   return w;
993 }
994 #endif
995
996 #ifdef L_udivdi3
997 UDWtype
998 __udivdi3 (UDWtype n, UDWtype d)
999 {
1000   return __udivmoddi4 (n, d, (UDWtype *) 0);
1001 }
1002 #endif
1003 \f
1004 #ifdef L_cmpdi2
1005 word_type
1006 __cmpdi2 (DWtype a, DWtype b)
1007 {
1008   DWunion au, bu;
1009
1010   au.ll = a, bu.ll = b;
1011
1012   if (au.s.high < bu.s.high)
1013     return 0;
1014   else if (au.s.high > bu.s.high)
1015     return 2;
1016   if ((UWtype) au.s.low < (UWtype) bu.s.low)
1017     return 0;
1018   else if ((UWtype) au.s.low > (UWtype) bu.s.low)
1019     return 2;
1020   return 1;
1021 }
1022 #endif
1023
1024 #ifdef L_ucmpdi2
1025 word_type
1026 __ucmpdi2 (DWtype a, DWtype b)
1027 {
1028   DWunion au, bu;
1029
1030   au.ll = a, bu.ll = b;
1031
1032   if ((UWtype) au.s.high < (UWtype) bu.s.high)
1033     return 0;
1034   else if ((UWtype) au.s.high > (UWtype) bu.s.high)
1035     return 2;
1036   if ((UWtype) au.s.low < (UWtype) bu.s.low)
1037     return 0;
1038   else if ((UWtype) au.s.low > (UWtype) bu.s.low)
1039     return 2;
1040   return 1;
1041 }
1042 #endif
1043 \f
1044 #if defined(L_fixunstfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
1045 #define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
1046 #define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
1047
1048 DWtype
1049 __fixunstfDI (TFtype a)
1050 {
1051   TFtype b;
1052   UDWtype v;
1053
1054   if (a < 0)
1055     return 0;
1056
1057   /* Compute high word of result, as a flonum.  */
1058   b = (a / HIGH_WORD_COEFF);
1059   /* Convert that to fixed (but not to DWtype!),
1060      and shift it into the high word.  */
1061   v = (UWtype) b;
1062   v <<= WORD_SIZE;
1063   /* Remove high part from the TFtype, leaving the low part as flonum.  */
1064   a -= (TFtype)v;
1065   /* Convert that to fixed (but not to DWtype!) and add it in.
1066      Sometimes A comes out negative.  This is significant, since
1067      A has more bits than a long int does.  */
1068   if (a < 0)
1069     v -= (UWtype) (- a);
1070   else
1071     v += (UWtype) a;
1072   return v;
1073 }
1074 #endif
1075
1076 #if defined(L_fixtfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
1077 DWtype
1078 __fixtfdi (TFtype a)
1079 {
1080   if (a < 0)
1081     return - __fixunstfDI (-a);
1082   return __fixunstfDI (a);
1083 }
1084 #endif
1085
1086 #if defined(L_fixunsxfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96)
1087 #define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
1088 #define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
1089
1090 DWtype
1091 __fixunsxfDI (XFtype a)
1092 {
1093   XFtype b;
1094   UDWtype v;
1095
1096   if (a < 0)
1097     return 0;
1098
1099   /* Compute high word of result, as a flonum.  */
1100   b = (a / HIGH_WORD_COEFF);
1101   /* Convert that to fixed (but not to DWtype!),
1102      and shift it into the high word.  */
1103   v = (UWtype) b;
1104   v <<= WORD_SIZE;
1105   /* Remove high part from the XFtype, leaving the low part as flonum.  */
1106   a -= (XFtype)v;
1107   /* Convert that to fixed (but not to DWtype!) and add it in.
1108      Sometimes A comes out negative.  This is significant, since
1109      A has more bits than a long int does.  */
1110   if (a < 0)
1111     v -= (UWtype) (- a);
1112   else
1113     v += (UWtype) a;
1114   return v;
1115 }
1116 #endif
1117
1118 #if defined(L_fixxfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96)
1119 DWtype
1120 __fixxfdi (XFtype a)
1121 {
1122   if (a < 0)
1123     return - __fixunsxfDI (-a);
1124   return __fixunsxfDI (a);
1125 }
1126 #endif
1127
1128 #ifdef L_fixunsdfdi
1129 #define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
1130 #define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
1131
1132 DWtype
1133 __fixunsdfDI (DFtype a)
1134 {
1135   UWtype hi, lo;
1136
1137   /* Get high part of result.  The division here will just moves the radix
1138      point and will not cause any rounding.  Then the conversion to integral
1139      type chops result as desired.  */
1140   hi = a / HIGH_WORD_COEFF;
1141
1142   /* Get low part of result.  Convert `hi' to floating type and scale it back,
1143      then subtract this from the number being converted.  This leaves the low
1144      part.  Convert that to integral type.  */
1145   lo = (a - ((DFtype) hi) * HIGH_WORD_COEFF);
1146
1147   /* Assemble result from the two parts.  */
1148   return ((UDWtype) hi << WORD_SIZE) | lo;
1149 }
1150 #endif
1151
1152 #ifdef L_fixdfdi
1153 DWtype
1154 __fixdfdi (DFtype a)
1155 {
1156   if (a < 0)
1157     return - __fixunsdfDI (-a);
1158   return __fixunsdfDI (a);
1159 }
1160 #endif
1161
1162 #ifdef L_fixunssfdi
1163 #define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
1164 #define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
1165
1166 DWtype
1167 __fixunssfDI (SFtype original_a)
1168 {
1169   /* Convert the SFtype to a DFtype, because that is surely not going
1170      to lose any bits.  Some day someone else can write a faster version
1171      that avoids converting to DFtype, and verify it really works right.  */
1172   DFtype a = original_a;
1173   UWtype hi, lo;
1174
1175   /* Get high part of result.  The division here will just moves the radix
1176      point and will not cause any rounding.  Then the conversion to integral
1177      type chops result as desired.  */
1178   hi = a / HIGH_WORD_COEFF;
1179
1180   /* Get low part of result.  Convert `hi' to floating type and scale it back,
1181      then subtract this from the number being converted.  This leaves the low
1182      part.  Convert that to integral type.  */
1183   lo = (a - ((DFtype) hi) * HIGH_WORD_COEFF);
1184
1185   /* Assemble result from the two parts.  */
1186   return ((UDWtype) hi << WORD_SIZE) | lo;
1187 }
1188 #endif
1189
1190 #ifdef L_fixsfdi
1191 DWtype
1192 __fixsfdi (SFtype a)
1193 {
1194   if (a < 0)
1195     return - __fixunssfDI (-a);
1196   return __fixunssfDI (a);
1197 }
1198 #endif
1199
1200 #if defined(L_floatdixf) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96)
1201 #define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
1202 #define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
1203 #define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
1204
1205 XFtype
1206 __floatdixf (DWtype u)
1207 {
1208   XFtype d;
1209
1210   d = (Wtype) (u >> WORD_SIZE);
1211   d *= HIGH_HALFWORD_COEFF;
1212   d *= HIGH_HALFWORD_COEFF;
1213   d += (UWtype) (u & (HIGH_WORD_COEFF - 1));
1214
1215   return d;
1216 }
1217 #endif
1218
1219 #if defined(L_floatditf) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
1220 #define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
1221 #define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
1222 #define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
1223
1224 TFtype
1225 __floatditf (DWtype u)
1226 {
1227   TFtype d;
1228
1229   d = (Wtype) (u >> WORD_SIZE);
1230   d *= HIGH_HALFWORD_COEFF;
1231   d *= HIGH_HALFWORD_COEFF;
1232   d += (UWtype) (u & (HIGH_WORD_COEFF - 1));
1233
1234   return d;
1235 }
1236 #endif
1237
1238 #ifdef L_floatdidf
1239 #define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
1240 #define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
1241 #define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
1242
1243 DFtype
1244 __floatdidf (DWtype u)
1245 {
1246   DFtype d;
1247
1248   d = (Wtype) (u >> WORD_SIZE);
1249   d *= HIGH_HALFWORD_COEFF;
1250   d *= HIGH_HALFWORD_COEFF;
1251   d += (UWtype) (u & (HIGH_WORD_COEFF - 1));
1252
1253   return d;
1254 }
1255 #endif
1256
1257 #ifdef L_floatdisf
1258 #define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
1259 #define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
1260 #define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
1261
1262 #define DI_SIZE (sizeof (DWtype) * BITS_PER_UNIT)
1263 #define DF_SIZE DBL_MANT_DIG
1264 #define SF_SIZE FLT_MANT_DIG
1265
1266 SFtype
1267 __floatdisf (DWtype u)
1268 {
1269   /* Do the calculation in DFmode
1270      so that we don't lose any of the precision of the high word
1271      while multiplying it.  */
1272   DFtype f;
1273
1274   /* Protect against double-rounding error.
1275      Represent any low-order bits, that might be truncated in DFmode,
1276      by a bit that won't be lost.  The bit can go in anywhere below the
1277      rounding position of the SFmode.  A fixed mask and bit position
1278      handles all usual configurations.  It doesn't handle the case
1279      of 128-bit DImode, however.  */
1280   if (DF_SIZE < DI_SIZE
1281       && DF_SIZE > (DI_SIZE - DF_SIZE + SF_SIZE))
1282     {
1283 #define REP_BIT ((UDWtype) 1 << (DI_SIZE - DF_SIZE))
1284       if (! (- ((DWtype) 1 << DF_SIZE) < u
1285              && u < ((DWtype) 1 << DF_SIZE)))
1286         {
1287           if ((UDWtype) u & (REP_BIT - 1))
1288             {
1289               u &= ~ (REP_BIT - 1);
1290               u |= REP_BIT;
1291             }
1292         }
1293     }
1294   f = (Wtype) (u >> WORD_SIZE);
1295   f *= HIGH_HALFWORD_COEFF;
1296   f *= HIGH_HALFWORD_COEFF;
1297   f += (UWtype) (u & (HIGH_WORD_COEFF - 1));
1298
1299   return (SFtype) f;
1300 }
1301 #endif
1302
1303 #if defined(L_fixunsxfsi) && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
1304 /* Reenable the normal types, in case limits.h needs them.  */
1305 #undef char
1306 #undef short
1307 #undef int
1308 #undef long
1309 #undef unsigned
1310 #undef float
1311 #undef double
1312 #undef MIN
1313 #undef MAX
1314 #include <limits.h>
1315
1316 UWtype
1317 __fixunsxfSI (XFtype a)
1318 {
1319   if (a >= - (DFtype) Wtype_MIN)
1320     return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
1321   return (Wtype) a;
1322 }
1323 #endif
1324
1325 #ifdef L_fixunsdfsi
1326 /* Reenable the normal types, in case limits.h needs them.  */
1327 #undef char
1328 #undef short
1329 #undef int
1330 #undef long
1331 #undef unsigned
1332 #undef float
1333 #undef double
1334 #undef MIN
1335 #undef MAX
1336 #include <limits.h>
1337
1338 UWtype
1339 __fixunsdfSI (DFtype a)
1340 {
1341   if (a >= - (DFtype) Wtype_MIN)
1342     return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
1343   return (Wtype) a;
1344 }
1345 #endif
1346
1347 #ifdef L_fixunssfsi
1348 /* Reenable the normal types, in case limits.h needs them.  */
1349 #undef char
1350 #undef short
1351 #undef int
1352 #undef long
1353 #undef unsigned
1354 #undef float
1355 #undef double
1356 #undef MIN
1357 #undef MAX
1358 #include <limits.h>
1359
1360 UWtype
1361 __fixunssfSI (SFtype a)
1362 {
1363   if (a >= - (SFtype) Wtype_MIN)
1364     return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
1365   return (Wtype) a;
1366 }
1367 #endif
1368 \f
1369 /* From here on down, the routines use normal data types.  */
1370
1371 #define SItype bogus_type
1372 #define USItype bogus_type
1373 #define DItype bogus_type
1374 #define UDItype bogus_type
1375 #define SFtype bogus_type
1376 #define DFtype bogus_type
1377 #undef Wtype
1378 #undef UWtype
1379 #undef HWtype
1380 #undef UHWtype
1381 #undef DWtype
1382 #undef UDWtype
1383
1384 #undef char
1385 #undef short
1386 #undef int
1387 #undef long
1388 #undef unsigned
1389 #undef float
1390 #undef double
1391 \f
1392 #ifdef L__gcc_bcmp
1393
1394 /* Like bcmp except the sign is meaningful.
1395    Result is negative if S1 is less than S2,
1396    positive if S1 is greater, 0 if S1 and S2 are equal.  */
1397
1398 int
1399 __gcc_bcmp (const unsigned char *s1, const unsigned char *s2, size_t size)
1400 {
1401   while (size > 0)
1402     {
1403       unsigned char c1 = *s1++, c2 = *s2++;
1404       if (c1 != c2)
1405         return c1 - c2;
1406       size--;
1407     }
1408   return 0;
1409 }
1410
1411 #endif
1412 \f
1413 /* __eprintf used to be used by GCC's private version of <assert.h>.
1414    We no longer provide that header, but this routine remains in libgcc.a
1415    for binary backward compatibility.  Note that it is not included in
1416    the shared version of libgcc.  */
1417 #ifdef L_eprintf
1418 #ifndef inhibit_libc
1419
1420 #undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch.  */
1421 #include <stdio.h>
1422
1423 void
1424 __eprintf (const char *string, const char *expression,
1425            unsigned int line, const char *filename)
1426 {
1427   fprintf (stderr, string, expression, line, filename);
1428   fflush (stderr);
1429   abort ();
1430 }
1431
1432 #endif
1433 #endif
1434
1435 \f
1436 #ifdef L_clear_cache
1437 /* Clear part of an instruction cache.  */
1438
1439 void
1440 __clear_cache (char *beg __attribute__((__unused__)),
1441                char *end __attribute__((__unused__)))
1442 {
1443 #ifdef CLEAR_INSN_CACHE
1444   CLEAR_INSN_CACHE (beg, end);
1445 #endif /* CLEAR_INSN_CACHE */
1446 }
1447
1448 #endif /* L_clear_cache */
1449 \f
1450 #ifdef L_trampoline
1451
1452 /* Jump to a trampoline, loading the static chain address.  */
1453
1454 #if defined(WINNT) && ! defined(__CYGWIN__) && ! defined (_UWIN)
1455
1456 long
1457 getpagesize (void)
1458 {
1459 #ifdef _ALPHA_
1460   return 8192;
1461 #else
1462   return 4096;
1463 #endif
1464 }
1465
1466 #ifdef __i386__
1467 extern int VirtualProtect (char *, int, int, int *) __attribute__((stdcall));
1468 #endif
1469
1470 int
1471 mprotect (char *addr, int len, int prot)
1472 {
1473   int np, op;
1474
1475   if (prot == 7)
1476     np = 0x40;
1477   else if (prot == 5)
1478     np = 0x20;
1479   else if (prot == 4)
1480     np = 0x10;
1481   else if (prot == 3)
1482     np = 0x04;
1483   else if (prot == 1)
1484     np = 0x02;
1485   else if (prot == 0)
1486     np = 0x01;
1487
1488   if (VirtualProtect (addr, len, np, &op))
1489     return 0;
1490   else
1491     return -1;
1492 }
1493
1494 #endif /* WINNT && ! __CYGWIN__ && ! _UWIN */
1495
1496 #ifdef TRANSFER_FROM_TRAMPOLINE
1497 TRANSFER_FROM_TRAMPOLINE
1498 #endif
1499 #endif /* L_trampoline */
1500 \f
1501 #ifndef __CYGWIN__
1502 #ifdef L__main
1503
1504 #include "gbl-ctors.h"
1505 /* Some systems use __main in a way incompatible with its use in gcc, in these
1506    cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
1507    give the same symbol without quotes for an alternative entry point.  You
1508    must define both, or neither.  */
1509 #ifndef NAME__MAIN
1510 #define NAME__MAIN "__main"
1511 #define SYMBOL__MAIN __main
1512 #endif
1513
1514 #ifdef INIT_SECTION_ASM_OP
1515 #undef HAS_INIT_SECTION
1516 #define HAS_INIT_SECTION
1517 #endif
1518
1519 #if !defined (HAS_INIT_SECTION) || !defined (OBJECT_FORMAT_ELF)
1520
1521 /* Some ELF crosses use crtstuff.c to provide __CTOR_LIST__, but use this
1522    code to run constructors.  In that case, we need to handle EH here, too.  */
1523
1524 #ifdef EH_FRAME_SECTION_NAME
1525 #include "unwind-dw2-fde.h"
1526 extern unsigned char __EH_FRAME_BEGIN__[];
1527 #endif
1528
1529 /* Run all the global destructors on exit from the program.  */
1530
1531 void
1532 __do_global_dtors (void)
1533 {
1534 #ifdef DO_GLOBAL_DTORS_BODY
1535   DO_GLOBAL_DTORS_BODY;
1536 #else
1537   static func_ptr *p = __DTOR_LIST__ + 1;
1538   while (*p)
1539     {
1540       p++;
1541       (*(p-1)) ();
1542     }
1543 #endif
1544 #if defined (EH_FRAME_SECTION_NAME) && !defined (HAS_INIT_SECTION)
1545   {
1546     static int completed = 0;
1547     if (! completed)
1548       {
1549         completed = 1;
1550         __deregister_frame_info (__EH_FRAME_BEGIN__);
1551       }
1552   }
1553 #endif
1554 }
1555 #endif
1556
1557 #ifndef HAS_INIT_SECTION
1558 /* Run all the global constructors on entry to the program.  */
1559
1560 void
1561 __do_global_ctors (void)
1562 {
1563 #ifdef EH_FRAME_SECTION_NAME
1564   {
1565     static struct object object;
1566     __register_frame_info (__EH_FRAME_BEGIN__, &object);
1567   }
1568 #endif
1569   DO_GLOBAL_CTORS_BODY;
1570   atexit (__do_global_dtors);
1571 }
1572 #endif /* no HAS_INIT_SECTION */
1573
1574 #if !defined (HAS_INIT_SECTION) || defined (INVOKE__main)
1575 /* Subroutine called automatically by `main'.
1576    Compiling a global function named `main'
1577    produces an automatic call to this function at the beginning.
1578
1579    For many systems, this routine calls __do_global_ctors.
1580    For systems which support a .init section we use the .init section
1581    to run __do_global_ctors, so we need not do anything here.  */
1582
1583 void
1584 SYMBOL__MAIN ()
1585 {
1586   /* Support recursive calls to `main': run initializers just once.  */
1587   static int initialized;
1588   if (! initialized)
1589     {
1590       initialized = 1;
1591       __do_global_ctors ();
1592     }
1593 }
1594 #endif /* no HAS_INIT_SECTION or INVOKE__main */
1595
1596 #endif /* L__main */
1597 #endif /* __CYGWIN__ */
1598 \f
1599 #ifdef L_ctors
1600
1601 #include "gbl-ctors.h"
1602
1603 /* Provide default definitions for the lists of constructors and
1604    destructors, so that we don't get linker errors.  These symbols are
1605    intentionally bss symbols, so that gld and/or collect will provide
1606    the right values.  */
1607
1608 /* We declare the lists here with two elements each,
1609    so that they are valid empty lists if no other definition is loaded.
1610
1611    If we are using the old "set" extensions to have the gnu linker
1612    collect ctors and dtors, then we __CTOR_LIST__ and __DTOR_LIST__
1613    must be in the bss/common section.
1614
1615    Long term no port should use those extensions.  But many still do.  */
1616 #if !defined(INIT_SECTION_ASM_OP) && !defined(CTOR_LISTS_DEFINED_EXTERNALLY)
1617 #if defined (TARGET_ASM_CONSTRUCTOR) || defined (USE_COLLECT2)
1618 func_ptr __CTOR_LIST__[2] = {0, 0};
1619 func_ptr __DTOR_LIST__[2] = {0, 0};
1620 #else
1621 func_ptr __CTOR_LIST__[2];
1622 func_ptr __DTOR_LIST__[2];
1623 #endif
1624 #endif /* no INIT_SECTION_ASM_OP and not CTOR_LISTS_DEFINED_EXTERNALLY */
1625 #endif /* L_ctors */
1626