OSDN Git Service

* config/darwin-c.c (darwin_pragma_options): Use BAD instead.
[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, 2004, 2005  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, 51 Franklin Street, Fifth Floor, Boston, MA
30 02110-1301, USA.  */
31
32 #include "tconfig.h"
33 #include "tsystem.h"
34 #include "coretypes.h"
35 #include "tm.h"
36
37 #ifdef HAVE_GAS_HIDDEN
38 #define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
39 #else
40 #define ATTRIBUTE_HIDDEN
41 #endif
42
43 #ifndef MIN_UNITS_PER_WORD
44 #define MIN_UNITS_PER_WORD UNITS_PER_WORD
45 #endif
46
47 #ifndef LIBGCC2_UNITS_PER_WORD
48 # if MIN_UNITS_PER_WORD > 4
49 #  define LIBGCC2_UNITS_PER_WORD 8
50 # elif (MIN_UNITS_PER_WORD > 2 \
51         || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32))
52 #  define LIBGCC2_UNITS_PER_WORD 4
53 # else
54 #  define LIBGCC2_UNITS_PER_WORD MIN_UNITS_PER_WORD
55 # endif
56 #endif
57
58 #if LIBGCC2_UNITS_PER_WORD <= MIN_UNITS_PER_WORD
59
60 #include "libgcc2.h"
61 \f
62 #ifdef DECLARE_LIBRARY_RENAMES
63   DECLARE_LIBRARY_RENAMES
64 #endif
65
66 #if defined (L_negdi2)
67 DWtype
68 __negdi2 (DWtype u)
69 {
70   const DWunion uu = {.ll = u};
71   const DWunion w = { {.low = -uu.s.low,
72                        .high = -uu.s.high - ((UWtype) -uu.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   const Wtype w = a + b;
83
84   if (b >= 0 ? w < a : w > a)
85     abort ();
86
87   return w;
88 }
89 #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
90 SItype
91 __addvsi3 (SItype a, SItype b)
92 {
93   const SItype w = a + b;
94
95   if (b >= 0 ? w < a : w > a)
96     abort ();
97
98   return w;
99 }
100 #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
101 #endif
102 \f
103 #ifdef L_addvdi3
104 DWtype
105 __addvDI3 (DWtype a, DWtype b)
106 {
107   const DWtype w = a + b;
108
109   if (b >= 0 ? w < a : w > a)
110     abort ();
111
112   return w;
113 }
114 #endif
115 \f
116 #ifdef L_subvsi3
117 Wtype
118 __subvSI3 (Wtype a, Wtype b)
119 {
120   const Wtype w = a - b;
121
122   if (b >= 0 ? w > a : w < a)
123     abort ();
124
125   return w;
126 }
127 #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
128 SItype
129 __subvsi3 (SItype a, SItype b)
130 {
131   const SItype w = a - b;
132
133   if (b >= 0 ? w > a : w < a)
134     abort ();
135
136   return w;
137 }
138 #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
139 #endif
140 \f
141 #ifdef L_subvdi3
142 DWtype
143 __subvDI3 (DWtype a, DWtype b)
144 {
145   const DWtype w = a - b;
146
147   if (b >= 0 ? w > a : w < a)
148     abort ();
149
150   return w;
151 }
152 #endif
153 \f
154 #ifdef L_mulvsi3
155 Wtype
156 __mulvSI3 (Wtype a, Wtype b)
157 {
158   const DWtype w = (DWtype) a * (DWtype) b;
159
160   if ((Wtype) (w >> W_TYPE_SIZE) != (Wtype) w >> (W_TYPE_SIZE - 1))
161     abort ();
162
163   return w;
164 }
165 #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
166 #undef WORD_SIZE
167 #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
168 SItype
169 __mulvsi3 (SItype a, SItype b)
170 {
171   const DItype w = (DItype) a * (DItype) b;
172
173   if ((SItype) (w >> WORD_SIZE) != (SItype) w >> (WORD_SIZE-1))
174     abort ();
175
176   return w;
177 }
178 #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
179 #endif
180 \f
181 #ifdef L_negvsi2
182 Wtype
183 __negvSI2 (Wtype a)
184 {
185   const Wtype w = -a;
186
187   if (a >= 0 ? w > 0 : w < 0)
188     abort ();
189
190    return w;
191 }
192 #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
193 SItype
194 __negvsi2 (SItype a)
195 {
196   const SItype w = -a;
197
198   if (a >= 0 ? w > 0 : w < 0)
199     abort ();
200
201    return w;
202 }
203 #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
204 #endif
205 \f
206 #ifdef L_negvdi2
207 DWtype
208 __negvDI2 (DWtype a)
209 {
210   const DWtype w = -a;
211
212   if (a >= 0 ? w > 0 : w < 0)
213     abort ();
214
215   return w;
216 }
217 #endif
218 \f
219 #ifdef L_absvsi2
220 Wtype
221 __absvSI2 (Wtype a)
222 {
223   Wtype w = a;
224
225   if (a < 0)
226 #ifdef L_negvsi2
227     w = __negvSI2 (a);
228 #else
229     w = -a;
230
231   if (w < 0)
232     abort ();
233 #endif
234
235    return w;
236 }
237 #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC
238 SItype
239 __absvsi2 (SItype a)
240 {
241   SItype w = a;
242
243   if (a < 0)
244 #ifdef L_negvsi2
245     w = __negvsi2 (a);
246 #else
247     w = -a;
248
249   if (w < 0)
250     abort ();
251 #endif
252
253    return w;
254 }
255 #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */
256 #endif
257 \f
258 #ifdef L_absvdi2
259 DWtype
260 __absvDI2 (DWtype a)
261 {
262   DWtype w = a;
263
264   if (a < 0)
265 #ifdef L_negvdi2
266     w = __negvDI2 (a);
267 #else
268     w = -a;
269
270   if (w < 0)
271     abort ();
272 #endif
273
274   return w;
275 }
276 #endif
277 \f
278 #ifdef L_mulvdi3
279 DWtype
280 __mulvDI3 (DWtype u, DWtype v)
281 {
282   /* The unchecked multiplication needs 3 Wtype x Wtype multiplications,
283      but the checked multiplication needs only two.  */
284   const DWunion uu = {.ll = u};
285   const DWunion vv = {.ll = v};
286
287   if (__builtin_expect (uu.s.high == uu.s.low >> (W_TYPE_SIZE - 1), 1))
288     {
289       /* u fits in a single Wtype.  */
290       if (__builtin_expect (vv.s.high == vv.s.low >> (W_TYPE_SIZE - 1), 1))
291         {
292           /* v fits in a single Wtype as well.  */
293           /* A single multiplication.  No overflow risk.  */
294           return (DWtype) uu.s.low * (DWtype) vv.s.low;
295         }
296       else
297         {
298           /* Two multiplications.  */
299           DWunion w0 = {.ll = (UDWtype) (UWtype) uu.s.low
300                         * (UDWtype) (UWtype) vv.s.low};
301           DWunion w1 = {.ll = (UDWtype) (UWtype) uu.s.low
302                         * (UDWtype) (UWtype) vv.s.high};
303
304           if (vv.s.high < 0)
305             w1.s.high -= uu.s.low;
306           if (uu.s.low < 0)
307             w1.ll -= vv.ll;
308           w1.ll += (UWtype) w0.s.high;
309           if (__builtin_expect (w1.s.high == w1.s.low >> (W_TYPE_SIZE - 1), 1))
310             {
311               w0.s.high = w1.s.low;
312               return w0.ll;
313             }
314         }
315     }
316   else
317     {
318       if (__builtin_expect (vv.s.high == vv.s.low >> (W_TYPE_SIZE - 1), 1))
319         {
320           /* v fits into a single Wtype.  */
321           /* Two multiplications.  */
322           DWunion w0 = {.ll = (UDWtype) (UWtype) uu.s.low
323                         * (UDWtype) (UWtype) vv.s.low};
324           DWunion w1 = {.ll = (UDWtype) (UWtype) uu.s.high
325                         * (UDWtype) (UWtype) vv.s.low};
326
327           if (uu.s.high < 0)
328             w1.s.high -= vv.s.low;
329           if (vv.s.low < 0)
330             w1.ll -= uu.ll;
331           w1.ll += (UWtype) w0.s.high;
332           if (__builtin_expect (w1.s.high == w1.s.low >> (W_TYPE_SIZE - 1), 1))
333             {
334               w0.s.high = w1.s.low;
335               return w0.ll;
336             }
337         }
338       else
339         {
340           /* A few sign checks and a single multiplication.  */
341           if (uu.s.high >= 0)
342             {
343               if (vv.s.high >= 0)
344                 {
345                   if (uu.s.high == 0 && vv.s.high == 0)
346                     {
347                       const DWtype w = (UDWtype) (UWtype) uu.s.low
348                         * (UDWtype) (UWtype) vv.s.low;
349                       if (__builtin_expect (w >= 0, 1))
350                         return w;
351                     }
352                 }
353               else
354                 {
355                   if (uu.s.high == 0 && vv.s.high == (Wtype) -1)
356                     {
357                       DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
358                                     * (UDWtype) (UWtype) vv.s.low};
359
360                       ww.s.high -= uu.s.low;
361                       if (__builtin_expect (ww.s.high < 0, 1))
362                         return ww.ll;
363                     }
364                 }
365             }
366           else
367             {
368               if (vv.s.high >= 0)
369                 {
370                   if (uu.s.high == (Wtype) -1 && vv.s.high == 0)
371                     {
372                       DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
373                                     * (UDWtype) (UWtype) vv.s.low};
374
375                       ww.s.high -= vv.s.low;
376                       if (__builtin_expect (ww.s.high < 0, 1))
377                         return ww.ll;
378                     }
379                 }
380               else
381                 {
382                   if (uu.s.high == (Wtype) -1 && vv.s.high == (Wtype) - 1)
383                     {
384                       DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
385                                     * (UDWtype) (UWtype) vv.s.low};
386
387                       ww.s.high -= uu.s.low;
388                       ww.s.high -= vv.s.low;
389                       if (__builtin_expect (ww.s.high >= 0, 1))
390                         return ww.ll;
391                     }
392                 }
393             }
394         }
395     }
396
397   /* Overflow.  */
398   abort ();
399 }
400 #endif
401 \f
402
403 /* Unless shift functions are defined with full ANSI prototypes,
404    parameter b will be promoted to int if word_type is smaller than an int.  */
405 #ifdef L_lshrdi3
406 DWtype
407 __lshrdi3 (DWtype u, word_type b)
408 {
409   if (b == 0)
410     return u;
411
412   const DWunion uu = {.ll = u};
413   const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
414   DWunion w;
415
416   if (bm <= 0)
417     {
418       w.s.high = 0;
419       w.s.low = (UWtype) uu.s.high >> -bm;
420     }
421   else
422     {
423       const UWtype carries = (UWtype) uu.s.high << bm;
424
425       w.s.high = (UWtype) uu.s.high >> b;
426       w.s.low = ((UWtype) uu.s.low >> b) | carries;
427     }
428
429   return w.ll;
430 }
431 #endif
432
433 #ifdef L_ashldi3
434 DWtype
435 __ashldi3 (DWtype u, word_type b)
436 {
437   if (b == 0)
438     return u;
439
440   const DWunion uu = {.ll = u};
441   const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
442   DWunion w;
443
444   if (bm <= 0)
445     {
446       w.s.low = 0;
447       w.s.high = (UWtype) uu.s.low << -bm;
448     }
449   else
450     {
451       const UWtype carries = (UWtype) uu.s.low >> bm;
452
453       w.s.low = (UWtype) uu.s.low << b;
454       w.s.high = ((UWtype) uu.s.high << b) | carries;
455     }
456
457   return w.ll;
458 }
459 #endif
460
461 #ifdef L_ashrdi3
462 DWtype
463 __ashrdi3 (DWtype u, word_type b)
464 {
465   if (b == 0)
466     return u;
467
468   const DWunion uu = {.ll = u};
469   const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
470   DWunion w;
471
472   if (bm <= 0)
473     {
474       /* w.s.high = 1..1 or 0..0 */
475       w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
476       w.s.low = uu.s.high >> -bm;
477     }
478   else
479     {
480       const UWtype carries = (UWtype) uu.s.high << bm;
481
482       w.s.high = uu.s.high >> b;
483       w.s.low = ((UWtype) uu.s.low >> b) | carries;
484     }
485
486   return w.ll;
487 }
488 #endif
489 \f
490 #ifdef L_ffssi2
491 #undef int
492 int
493 __ffsSI2 (UWtype u)
494 {
495   UWtype count;
496
497   if (u == 0)
498     return 0;
499
500   count_trailing_zeros (count, u);
501   return count + 1;
502 }
503 #endif
504 \f
505 #ifdef L_ffsdi2
506 #undef int
507 int
508 __ffsDI2 (DWtype u)
509 {
510   const DWunion uu = {.ll = u};
511   UWtype word, count, add;
512
513   if (uu.s.low != 0)
514     word = uu.s.low, add = 0;
515   else if (uu.s.high != 0)
516     word = uu.s.high, add = BITS_PER_UNIT * sizeof (Wtype);
517   else
518     return 0;
519
520   count_trailing_zeros (count, word);
521   return count + add + 1;
522 }
523 #endif
524 \f
525 #ifdef L_muldi3
526 DWtype
527 __muldi3 (DWtype u, DWtype v)
528 {
529   const DWunion uu = {.ll = u};
530   const DWunion vv = {.ll = v};
531   DWunion w = {.ll = __umulsidi3 (uu.s.low, vv.s.low)};
532
533   w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high
534                + (UWtype) uu.s.high * (UWtype) vv.s.low);
535
536   return w.ll;
537 }
538 #endif
539 \f
540 #if (defined (L_udivdi3) || defined (L_divdi3) || \
541      defined (L_umoddi3) || defined (L_moddi3))
542 #if defined (sdiv_qrnnd)
543 #define L_udiv_w_sdiv
544 #endif
545 #endif
546
547 #ifdef L_udiv_w_sdiv
548 #if defined (sdiv_qrnnd)
549 #if (defined (L_udivdi3) || defined (L_divdi3) || \
550      defined (L_umoddi3) || defined (L_moddi3))
551 static inline __attribute__ ((__always_inline__))
552 #endif
553 UWtype
554 __udiv_w_sdiv (UWtype *rp, UWtype a1, UWtype a0, UWtype d)
555 {
556   UWtype q, r;
557   UWtype c0, c1, b1;
558
559   if ((Wtype) d >= 0)
560     {
561       if (a1 < d - a1 - (a0 >> (W_TYPE_SIZE - 1)))
562         {
563           /* Dividend, divisor, and quotient are nonnegative.  */
564           sdiv_qrnnd (q, r, a1, a0, d);
565         }
566       else
567         {
568           /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d.  */
569           sub_ddmmss (c1, c0, a1, a0, d >> 1, d << (W_TYPE_SIZE - 1));
570           /* Divide (c1*2^32 + c0) by d.  */
571           sdiv_qrnnd (q, r, c1, c0, d);
572           /* Add 2^31 to quotient.  */
573           q += (UWtype) 1 << (W_TYPE_SIZE - 1);
574         }
575     }
576   else
577     {
578       b1 = d >> 1;                      /* d/2, between 2^30 and 2^31 - 1 */
579       c1 = a1 >> 1;                     /* A/2 */
580       c0 = (a1 << (W_TYPE_SIZE - 1)) + (a0 >> 1);
581
582       if (a1 < b1)                      /* A < 2^32*b1, so A/2 < 2^31*b1 */
583         {
584           sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
585
586           r = 2*r + (a0 & 1);           /* Remainder from A/(2*b1) */
587           if ((d & 1) != 0)
588             {
589               if (r >= q)
590                 r = r - q;
591               else if (q - r <= d)
592                 {
593                   r = r - q + d;
594                   q--;
595                 }
596               else
597                 {
598                   r = r - q + 2*d;
599                   q -= 2;
600                 }
601             }
602         }
603       else if (c1 < b1)                 /* So 2^31 <= (A/2)/b1 < 2^32 */
604         {
605           c1 = (b1 - 1) - c1;
606           c0 = ~c0;                     /* logical NOT */
607
608           sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
609
610           q = ~q;                       /* (A/2)/b1 */
611           r = (b1 - 1) - r;
612
613           r = 2*r + (a0 & 1);           /* A/(2*b1) */
614
615           if ((d & 1) != 0)
616             {
617               if (r >= q)
618                 r = r - q;
619               else if (q - r <= d)
620                 {
621                   r = r - q + d;
622                   q--;
623                 }
624               else
625                 {
626                   r = r - q + 2*d;
627                   q -= 2;
628                 }
629             }
630         }
631       else                              /* Implies c1 = b1 */
632         {                               /* Hence a1 = d - 1 = 2*b1 - 1 */
633           if (a0 >= -d)
634             {
635               q = -1;
636               r = a0 + d;
637             }
638           else
639             {
640               q = -2;
641               r = a0 + 2*d;
642             }
643         }
644     }
645
646   *rp = r;
647   return q;
648 }
649 #else
650 /* If sdiv_qrnnd doesn't exist, define dummy __udiv_w_sdiv.  */
651 UWtype
652 __udiv_w_sdiv (UWtype *rp __attribute__ ((__unused__)),
653                UWtype a1 __attribute__ ((__unused__)),
654                UWtype a0 __attribute__ ((__unused__)),
655                UWtype d __attribute__ ((__unused__)))
656 {
657   return 0;
658 }
659 #endif
660 #endif
661 \f
662 #if (defined (L_udivdi3) || defined (L_divdi3) || \
663      defined (L_umoddi3) || defined (L_moddi3))
664 #define L_udivmoddi4
665 #endif
666
667 #ifdef L_clz
668 const UQItype __clz_tab[256] =
669 {
670   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,
671   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,
672   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,
673   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,
674   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,
675   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,
676   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,
677   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
678 };
679 #endif
680 \f
681 #ifdef L_clzsi2
682 #undef int
683 int
684 __clzSI2 (UWtype x)
685 {
686   Wtype ret;
687
688   count_leading_zeros (ret, x);
689
690   return ret;
691 }
692 #endif
693 \f
694 #ifdef L_clzdi2
695 #undef int
696 int
697 __clzDI2 (UDWtype x)
698 {
699   const DWunion uu = {.ll = x};
700   UWtype word;
701   Wtype ret, add;
702
703   if (uu.s.high)
704     word = uu.s.high, add = 0;
705   else
706     word = uu.s.low, add = W_TYPE_SIZE;
707
708   count_leading_zeros (ret, word);
709   return ret + add;
710 }
711 #endif
712 \f
713 #ifdef L_ctzsi2
714 #undef int
715 int
716 __ctzSI2 (UWtype x)
717 {
718   Wtype ret;
719
720   count_trailing_zeros (ret, x);
721
722   return ret;
723 }
724 #endif
725 \f
726 #ifdef L_ctzdi2
727 #undef int
728 int
729 __ctzDI2 (UDWtype x)
730 {
731   const DWunion uu = {.ll = x};
732   UWtype word;
733   Wtype ret, add;
734
735   if (uu.s.low)
736     word = uu.s.low, add = 0;
737   else
738     word = uu.s.high, add = W_TYPE_SIZE;
739
740   count_trailing_zeros (ret, word);
741   return ret + add;
742 }
743 #endif
744
745 #ifdef L_popcount_tab
746 const UQItype __popcount_tab[256] =
747 {
748     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,
749     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,
750     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,
751     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,
752     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,
753     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,
754     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,
755     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
756 };
757 #endif
758 \f
759 #ifdef L_popcountsi2
760 #undef int
761 int
762 __popcountSI2 (UWtype x)
763 {
764   int i, ret = 0;
765
766   for (i = 0; i < W_TYPE_SIZE; i += 8)
767     ret += __popcount_tab[(x >> i) & 0xff];
768
769   return ret;
770 }
771 #endif
772 \f
773 #ifdef L_popcountdi2
774 #undef int
775 int
776 __popcountDI2 (UDWtype x)
777 {
778   int i, ret = 0;
779
780   for (i = 0; i < 2*W_TYPE_SIZE; i += 8)
781     ret += __popcount_tab[(x >> i) & 0xff];
782
783   return ret;
784 }
785 #endif
786 \f
787 #ifdef L_paritysi2
788 #undef int
789 int
790 __paritySI2 (UWtype x)
791 {
792 #if W_TYPE_SIZE > 64
793 # error "fill out the table"
794 #endif
795 #if W_TYPE_SIZE > 32
796   x ^= x >> 32;
797 #endif
798 #if W_TYPE_SIZE > 16
799   x ^= x >> 16;
800 #endif
801   x ^= x >> 8;
802   x ^= x >> 4;
803   x &= 0xf;
804   return (0x6996 >> x) & 1;
805 }
806 #endif
807 \f
808 #ifdef L_paritydi2
809 #undef int
810 int
811 __parityDI2 (UDWtype x)
812 {
813   const DWunion uu = {.ll = x};
814   UWtype nx = uu.s.low ^ uu.s.high;
815
816 #if W_TYPE_SIZE > 64
817 # error "fill out the table"
818 #endif
819 #if W_TYPE_SIZE > 32
820   nx ^= nx >> 32;
821 #endif
822 #if W_TYPE_SIZE > 16
823   nx ^= nx >> 16;
824 #endif
825   nx ^= nx >> 8;
826   nx ^= nx >> 4;
827   nx &= 0xf;
828   return (0x6996 >> nx) & 1;
829 }
830 #endif
831
832 #ifdef L_udivmoddi4
833
834 #if (defined (L_udivdi3) || defined (L_divdi3) || \
835      defined (L_umoddi3) || defined (L_moddi3))
836 static inline __attribute__ ((__always_inline__))
837 #endif
838 UDWtype
839 __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
840 {
841   const DWunion nn = {.ll = n};
842   const DWunion dd = {.ll = d};
843   DWunion rr;
844   UWtype d0, d1, n0, n1, n2;
845   UWtype q0, q1;
846   UWtype b, bm;
847
848   d0 = dd.s.low;
849   d1 = dd.s.high;
850   n0 = nn.s.low;
851   n1 = nn.s.high;
852
853 #if !UDIV_NEEDS_NORMALIZATION
854   if (d1 == 0)
855     {
856       if (d0 > n1)
857         {
858           /* 0q = nn / 0D */
859
860           udiv_qrnnd (q0, n0, n1, n0, d0);
861           q1 = 0;
862
863           /* Remainder in n0.  */
864         }
865       else
866         {
867           /* qq = NN / 0d */
868
869           if (d0 == 0)
870             d0 = 1 / d0;        /* Divide intentionally by zero.  */
871
872           udiv_qrnnd (q1, n1, 0, n1, d0);
873           udiv_qrnnd (q0, n0, n1, n0, d0);
874
875           /* Remainder in n0.  */
876         }
877
878       if (rp != 0)
879         {
880           rr.s.low = n0;
881           rr.s.high = 0;
882           *rp = rr.ll;
883         }
884     }
885
886 #else /* UDIV_NEEDS_NORMALIZATION */
887
888   if (d1 == 0)
889     {
890       if (d0 > n1)
891         {
892           /* 0q = nn / 0D */
893
894           count_leading_zeros (bm, d0);
895
896           if (bm != 0)
897             {
898               /* Normalize, i.e. make the most significant bit of the
899                  denominator set.  */
900
901               d0 = d0 << bm;
902               n1 = (n1 << bm) | (n0 >> (W_TYPE_SIZE - bm));
903               n0 = n0 << bm;
904             }
905
906           udiv_qrnnd (q0, n0, n1, n0, d0);
907           q1 = 0;
908
909           /* Remainder in n0 >> bm.  */
910         }
911       else
912         {
913           /* qq = NN / 0d */
914
915           if (d0 == 0)
916             d0 = 1 / d0;        /* Divide intentionally by zero.  */
917
918           count_leading_zeros (bm, d0);
919
920           if (bm == 0)
921             {
922               /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
923                  conclude (the most significant bit of n1 is set) /\ (the
924                  leading quotient digit q1 = 1).
925
926                  This special case is necessary, not an optimization.
927                  (Shifts counts of W_TYPE_SIZE are undefined.)  */
928
929               n1 -= d0;
930               q1 = 1;
931             }
932           else
933             {
934               /* Normalize.  */
935
936               b = W_TYPE_SIZE - bm;
937
938               d0 = d0 << bm;
939               n2 = n1 >> b;
940               n1 = (n1 << bm) | (n0 >> b);
941               n0 = n0 << bm;
942
943               udiv_qrnnd (q1, n1, n2, n1, d0);
944             }
945
946           /* n1 != d0...  */
947
948           udiv_qrnnd (q0, n0, n1, n0, d0);
949
950           /* Remainder in n0 >> bm.  */
951         }
952
953       if (rp != 0)
954         {
955           rr.s.low = n0 >> bm;
956           rr.s.high = 0;
957           *rp = rr.ll;
958         }
959     }
960 #endif /* UDIV_NEEDS_NORMALIZATION */
961
962   else
963     {
964       if (d1 > n1)
965         {
966           /* 00 = nn / DD */
967
968           q0 = 0;
969           q1 = 0;
970
971           /* Remainder in n1n0.  */
972           if (rp != 0)
973             {
974               rr.s.low = n0;
975               rr.s.high = n1;
976               *rp = rr.ll;
977             }
978         }
979       else
980         {
981           /* 0q = NN / dd */
982
983           count_leading_zeros (bm, d1);
984           if (bm == 0)
985             {
986               /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
987                  conclude (the most significant bit of n1 is set) /\ (the
988                  quotient digit q0 = 0 or 1).
989
990                  This special case is necessary, not an optimization.  */
991
992               /* The condition on the next line takes advantage of that
993                  n1 >= d1 (true due to program flow).  */
994               if (n1 > d1 || n0 >= d0)
995                 {
996                   q0 = 1;
997                   sub_ddmmss (n1, n0, n1, n0, d1, d0);
998                 }
999               else
1000                 q0 = 0;
1001
1002               q1 = 0;
1003
1004               if (rp != 0)
1005                 {
1006                   rr.s.low = n0;
1007                   rr.s.high = n1;
1008                   *rp = rr.ll;
1009                 }
1010             }
1011           else
1012             {
1013               UWtype m1, m0;
1014               /* Normalize.  */
1015
1016               b = W_TYPE_SIZE - bm;
1017
1018               d1 = (d1 << bm) | (d0 >> b);
1019               d0 = d0 << bm;
1020               n2 = n1 >> b;
1021               n1 = (n1 << bm) | (n0 >> b);
1022               n0 = n0 << bm;
1023
1024               udiv_qrnnd (q0, n1, n2, n1, d1);
1025               umul_ppmm (m1, m0, q0, d0);
1026
1027               if (m1 > n1 || (m1 == n1 && m0 > n0))
1028                 {
1029                   q0--;
1030                   sub_ddmmss (m1, m0, m1, m0, d1, d0);
1031                 }
1032
1033               q1 = 0;
1034
1035               /* Remainder in (n1n0 - m1m0) >> bm.  */
1036               if (rp != 0)
1037                 {
1038                   sub_ddmmss (n1, n0, n1, n0, m1, m0);
1039                   rr.s.low = (n1 << b) | (n0 >> bm);
1040                   rr.s.high = n1 >> bm;
1041                   *rp = rr.ll;
1042                 }
1043             }
1044         }
1045     }
1046
1047   const DWunion ww = {{.low = q0, .high = q1}};
1048   return ww.ll;
1049 }
1050 #endif
1051
1052 #ifdef L_divdi3
1053 DWtype
1054 __divdi3 (DWtype u, DWtype v)
1055 {
1056   word_type c = 0;
1057   DWunion uu = {.ll = u};
1058   DWunion vv = {.ll = v};
1059   DWtype w;
1060
1061   if (uu.s.high < 0)
1062     c = ~c,
1063     uu.ll = -uu.ll;
1064   if (vv.s.high < 0)
1065     c = ~c,
1066     vv.ll = -vv.ll;
1067
1068   w = __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) 0);
1069   if (c)
1070     w = -w;
1071
1072   return w;
1073 }
1074 #endif
1075
1076 #ifdef L_moddi3
1077 DWtype
1078 __moddi3 (DWtype u, DWtype v)
1079 {
1080   word_type c = 0;
1081   DWunion uu = {.ll = u};
1082   DWunion vv = {.ll = v};
1083   DWtype w;
1084
1085   if (uu.s.high < 0)
1086     c = ~c,
1087     uu.ll = -uu.ll;
1088   if (vv.s.high < 0)
1089     vv.ll = -vv.ll;
1090
1091   (void) __udivmoddi4 (uu.ll, vv.ll, (UDWtype*)&w);
1092   if (c)
1093     w = -w;
1094
1095   return w;
1096 }
1097 #endif
1098
1099 #ifdef L_umoddi3
1100 UDWtype
1101 __umoddi3 (UDWtype u, UDWtype v)
1102 {
1103   UDWtype w;
1104
1105   (void) __udivmoddi4 (u, v, &w);
1106
1107   return w;
1108 }
1109 #endif
1110
1111 #ifdef L_udivdi3
1112 UDWtype
1113 __udivdi3 (UDWtype n, UDWtype d)
1114 {
1115   return __udivmoddi4 (n, d, (UDWtype *) 0);
1116 }
1117 #endif
1118 \f
1119 #ifdef L_cmpdi2
1120 word_type
1121 __cmpdi2 (DWtype a, DWtype b)
1122 {
1123   const DWunion au = {.ll = a};
1124   const DWunion bu = {.ll = b};
1125
1126   if (au.s.high < bu.s.high)
1127     return 0;
1128   else if (au.s.high > bu.s.high)
1129     return 2;
1130   if ((UWtype) au.s.low < (UWtype) bu.s.low)
1131     return 0;
1132   else if ((UWtype) au.s.low > (UWtype) bu.s.low)
1133     return 2;
1134   return 1;
1135 }
1136 #endif
1137
1138 #ifdef L_ucmpdi2
1139 word_type
1140 __ucmpdi2 (DWtype a, DWtype b)
1141 {
1142   const DWunion au = {.ll = a};
1143   const DWunion bu = {.ll = b};
1144
1145   if ((UWtype) au.s.high < (UWtype) bu.s.high)
1146     return 0;
1147   else if ((UWtype) au.s.high > (UWtype) bu.s.high)
1148     return 2;
1149   if ((UWtype) au.s.low < (UWtype) bu.s.low)
1150     return 0;
1151   else if ((UWtype) au.s.low > (UWtype) bu.s.low)
1152     return 2;
1153   return 1;
1154 }
1155 #endif
1156 \f
1157 #if defined(L_fixunstfdi) && LIBGCC2_HAS_TF_MODE
1158 DWtype
1159 __fixunstfDI (TFtype a)
1160 {
1161   if (a < 0)
1162     return 0;
1163
1164   /* Compute high word of result, as a flonum.  */
1165   const TFtype b = (a / Wtype_MAXp1_F);
1166   /* Convert that to fixed (but not to DWtype!),
1167      and shift it into the high word.  */
1168   UDWtype v = (UWtype) b;
1169   v <<= W_TYPE_SIZE;
1170   /* Remove high part from the TFtype, leaving the low part as flonum.  */
1171   a -= (TFtype)v;
1172   /* Convert that to fixed (but not to DWtype!) and add it in.
1173      Sometimes A comes out negative.  This is significant, since
1174      A has more bits than a long int does.  */
1175   if (a < 0)
1176     v -= (UWtype) (- a);
1177   else
1178     v += (UWtype) a;
1179   return v;
1180 }
1181 #endif
1182
1183 #if defined(L_fixtfdi) && LIBGCC2_HAS_TF_MODE
1184 DWtype
1185 __fixtfdi (TFtype a)
1186 {
1187   if (a < 0)
1188     return - __fixunstfDI (-a);
1189   return __fixunstfDI (a);
1190 }
1191 #endif
1192
1193 #if defined(L_fixunsxfdi) && LIBGCC2_HAS_XF_MODE
1194 DWtype
1195 __fixunsxfDI (XFtype a)
1196 {
1197   if (a < 0)
1198     return 0;
1199
1200   /* Compute high word of result, as a flonum.  */
1201   const XFtype b = (a / Wtype_MAXp1_F);
1202   /* Convert that to fixed (but not to DWtype!),
1203      and shift it into the high word.  */
1204   UDWtype v = (UWtype) b;
1205   v <<= W_TYPE_SIZE;
1206   /* Remove high part from the XFtype, leaving the low part as flonum.  */
1207   a -= (XFtype)v;
1208   /* Convert that to fixed (but not to DWtype!) and add it in.
1209      Sometimes A comes out negative.  This is significant, since
1210      A has more bits than a long int does.  */
1211   if (a < 0)
1212     v -= (UWtype) (- a);
1213   else
1214     v += (UWtype) a;
1215   return v;
1216 }
1217 #endif
1218
1219 #if defined(L_fixxfdi) && LIBGCC2_HAS_XF_MODE
1220 DWtype
1221 __fixxfdi (XFtype a)
1222 {
1223   if (a < 0)
1224     return - __fixunsxfDI (-a);
1225   return __fixunsxfDI (a);
1226 }
1227 #endif
1228
1229 #if defined(L_fixunsdfdi) && LIBGCC2_HAS_DF_MODE
1230 DWtype
1231 __fixunsdfDI (DFtype a)
1232 {
1233   /* Get high part of result.  The division here will just moves the radix
1234      point and will not cause any rounding.  Then the conversion to integral
1235      type chops result as desired.  */
1236   const UWtype hi = a / Wtype_MAXp1_F;
1237
1238   /* Get low part of result.  Convert `hi' to floating type and scale it back,
1239      then subtract this from the number being converted.  This leaves the low
1240      part.  Convert that to integral type.  */
1241   const UWtype lo = a - (DFtype) hi * Wtype_MAXp1_F;
1242
1243   /* Assemble result from the two parts.  */
1244   return ((UDWtype) hi << W_TYPE_SIZE) | lo;
1245 }
1246 #endif
1247
1248 #if defined(L_fixdfdi) && LIBGCC2_HAS_DF_MODE
1249 DWtype
1250 __fixdfdi (DFtype a)
1251 {
1252   if (a < 0)
1253     return - __fixunsdfDI (-a);
1254   return __fixunsdfDI (a);
1255 }
1256 #endif
1257
1258 #if defined(L_fixunssfdi) && LIBGCC2_HAS_SF_MODE
1259 DWtype
1260 __fixunssfDI (SFtype a)
1261 {
1262 #if LIBGCC2_HAS_DF_MODE
1263   /* Convert the SFtype to a DFtype, because that is surely not going
1264      to lose any bits.  Some day someone else can write a faster version
1265      that avoids converting to DFtype, and verify it really works right.  */
1266   const DFtype dfa = a;
1267
1268   /* Get high part of result.  The division here will just moves the radix
1269      point and will not cause any rounding.  Then the conversion to integral
1270      type chops result as desired.  */
1271   const UWtype hi = dfa / Wtype_MAXp1_F;
1272
1273   /* Get low part of result.  Convert `hi' to floating type and scale it back,
1274      then subtract this from the number being converted.  This leaves the low
1275      part.  Convert that to integral type.  */
1276   const UWtype lo = dfa - (DFtype) hi * Wtype_MAXp1_F;
1277
1278   /* Assemble result from the two parts.  */
1279   return ((UDWtype) hi << W_TYPE_SIZE) | lo;
1280 #elif FLT_MANT_DIG < W_TYPE_SIZE
1281   if (a < 1)
1282     return 0;
1283   if (a < Wtype_MAXp1_F)
1284     return (UWtype)a;
1285   if (a < Wtype_MAXp1_F * Wtype_MAXp1_F)
1286     {
1287       /* Since we know that there are fewer significant bits in the SFmode
1288          quantity than in a word, we know that we can convert out all the
1289          significant bits in one step, and thus avoid losing bits.  */
1290
1291       /* ??? This following loop essentially performs frexpf.  If we could
1292          use the real libm function, or poke at the actual bits of the fp
1293          format, it would be significantly faster.  */
1294
1295       UWtype shift = 0, counter;
1296       SFtype msb;
1297
1298       a /= Wtype_MAXp1_F;
1299       for (counter = W_TYPE_SIZE / 2; counter != 0; counter >>= 1)
1300         {
1301           SFtype counterf = (UWtype)1 << counter;
1302           if (a >= counterf)
1303             {
1304               shift |= counter;
1305               a /= counterf;
1306             }
1307         }
1308
1309       /* Rescale into the range of one word, extract the bits of that
1310          one word, and shift the result into position.  */
1311       a *= Wtype_MAXp1_F;
1312       counter = a;
1313       return (DWtype)counter << shift;
1314     }
1315   return -1;
1316 #else
1317 # error
1318 #endif
1319 }
1320 #endif
1321
1322 #if defined(L_fixsfdi) && LIBGCC2_HAS_SF_MODE
1323 DWtype
1324 __fixsfdi (SFtype a)
1325 {
1326   if (a < 0)
1327     return - __fixunssfDI (-a);
1328   return __fixunssfDI (a);
1329 }
1330 #endif
1331
1332 #if defined(L_floatdixf) && LIBGCC2_HAS_XF_MODE
1333 XFtype
1334 __floatdixf (DWtype u)
1335 {
1336 #if W_TYPE_SIZE > XF_SIZE
1337 # error
1338 #endif
1339   XFtype d = (Wtype) (u >> W_TYPE_SIZE);
1340   d *= Wtype_MAXp1_F;
1341   d += (UWtype)u;
1342   return d;
1343 }
1344 #endif
1345
1346 #if defined(L_floatundixf) && LIBGCC2_HAS_XF_MODE
1347 XFtype
1348 __floatundixf (UDWtype u)
1349 {
1350 #if W_TYPE_SIZE > XF_SIZE
1351 # error
1352 #endif
1353   XFtype d = (UWtype) (u >> W_TYPE_SIZE);
1354   d *= Wtype_MAXp1_F;
1355   d += (UWtype)u;
1356   return d;
1357 }
1358 #endif
1359
1360 #if defined(L_floatditf) && LIBGCC2_HAS_TF_MODE
1361 TFtype
1362 __floatditf (DWtype u)
1363 {
1364 #if W_TYPE_SIZE > TF_SIZE
1365 # error
1366 #endif
1367   TFtype d = (Wtype) (u >> W_TYPE_SIZE);
1368   d *= Wtype_MAXp1_F;
1369   d += (UWtype)u;
1370   return d;
1371 }
1372 #endif
1373
1374 #if defined(L_floatunditf) && LIBGCC2_HAS_TF_MODE
1375 TFtype
1376 __floatunditf (UDWtype u)
1377 {
1378 #if W_TYPE_SIZE > TF_SIZE
1379 # error
1380 #endif
1381   TFtype d = (UWtype) (u >> W_TYPE_SIZE);
1382   d *= Wtype_MAXp1_F;
1383   d += (UWtype)u;
1384   return d;
1385 }
1386 #endif
1387
1388 #if (defined(L_floatdisf) && LIBGCC2_HAS_SF_MODE)       \
1389      || (defined(L_floatdidf) && LIBGCC2_HAS_DF_MODE)
1390 #define DI_SIZE (W_TYPE_SIZE * 2)
1391 #define F_MODE_OK(SIZE) \
1392   (SIZE < DI_SIZE                                                       \
1393    && SIZE > (DI_SIZE - SIZE + FSSIZE)                                  \
1394    /* Don't use IBM Extended Double TFmode for TI->SF calculations.     \
1395       The conversion from long double to float suffers from double      \
1396       rounding, because we convert via double.  In any case, the        \
1397       fallback code is faster.  */                                      \
1398    && !IS_IBM_EXTENDED (SIZE))
1399 #if defined(L_floatdisf)
1400 #define FUNC __floatdisf
1401 #define FSTYPE SFtype
1402 #define FSSIZE SF_SIZE
1403 #else
1404 #define FUNC __floatdidf
1405 #define FSTYPE DFtype
1406 #define FSSIZE DF_SIZE
1407 #endif
1408
1409 FSTYPE
1410 FUNC (DWtype u)
1411 {
1412 #if FSSIZE >= W_TYPE_SIZE
1413   /* When the word size is small, we never get any rounding error.  */
1414   FSTYPE f = (Wtype) (u >> W_TYPE_SIZE);
1415   f *= Wtype_MAXp1_F;
1416   f += (UWtype)u;
1417   return f;
1418 #elif (LIBGCC2_HAS_DF_MODE && F_MODE_OK (DF_SIZE))      \
1419      || (LIBGCC2_HAS_XF_MODE && F_MODE_OK (XF_SIZE))    \
1420      || (LIBGCC2_HAS_TF_MODE && F_MODE_OK (TF_SIZE))
1421
1422 #if (LIBGCC2_HAS_DF_MODE && F_MODE_OK (DF_SIZE))
1423 # define FSIZE DF_SIZE
1424 # define FTYPE DFtype
1425 #elif (LIBGCC2_HAS_XF_MODE && F_MODE_OK (XF_SIZE))
1426 # define FSIZE XF_SIZE
1427 # define FTYPE XFtype
1428 #elif (LIBGCC2_HAS_TF_MODE && F_MODE_OK (TF_SIZE))
1429 # define FSIZE TF_SIZE
1430 # define FTYPE TFtype
1431 #else
1432 # error
1433 #endif
1434
1435 #define REP_BIT ((UDWtype) 1 << (DI_SIZE - FSIZE))
1436
1437   /* Protect against double-rounding error.
1438      Represent any low-order bits, that might be truncated by a bit that
1439      won't be lost.  The bit can go in anywhere below the rounding position
1440      of the FSTYPE.  A fixed mask and bit position handles all usual
1441      configurations.  */
1442   if (! (- ((DWtype) 1 << FSIZE) < u
1443          && u < ((DWtype) 1 << FSIZE)))
1444     {
1445       if ((UDWtype) u & (REP_BIT - 1))
1446         {
1447           u &= ~ (REP_BIT - 1);
1448           u |= REP_BIT;
1449         }
1450     }
1451
1452   /* Do the calculation in a wider type so that we don't lose any of
1453      the precision of the high word while multiplying it.  */
1454   FTYPE f = (Wtype) (u >> W_TYPE_SIZE);
1455   f *= Wtype_MAXp1_F;
1456   f += (UWtype)u;
1457   return (FSTYPE) f;
1458 #else
1459 #if FSSIZE >= W_TYPE_SIZE - 2
1460 # error
1461 #endif
1462   /* Finally, the word size is larger than the number of bits in the
1463      required FSTYPE, and we've got no suitable wider type.  The only
1464      way to avoid double rounding is to special case the
1465      extraction.  */
1466
1467   /* If there are no high bits set, fall back to one conversion.  */
1468   if ((Wtype)u == u)
1469     return (FSTYPE)(Wtype)u;
1470
1471   /* Otherwise, find the power of two.  */
1472   Wtype hi = u >> W_TYPE_SIZE;
1473   if (hi < 0)
1474     hi = -hi;
1475
1476   UWtype count, shift;
1477   count_leading_zeros (count, hi);
1478
1479   /* No leading bits means u == minimum.  */
1480   if (count == 0)
1481     return -(Wtype_MAXp1_F * (Wtype_MAXp1_F / 2));
1482
1483   shift = 1 + W_TYPE_SIZE - count;
1484
1485   /* Shift down the most significant bits.  */
1486   hi = u >> shift;
1487
1488   /* If we lost any nonzero bits, set the lsb to ensure correct rounding.  */
1489   if (u & (((DWtype)1 << shift) - 1))
1490     hi |= 1;
1491
1492   /* Convert the one word of data, and rescale.  */
1493   FSTYPE f = hi;
1494   f *= (UDWtype)1 << shift;
1495   return f;
1496 #endif
1497 }
1498 #endif
1499
1500 #if (defined(L_floatundisf) && LIBGCC2_HAS_SF_MODE)     \
1501      || (defined(L_floatundidf) && LIBGCC2_HAS_DF_MODE)
1502 #define DI_SIZE (W_TYPE_SIZE * 2)
1503 #define F_MODE_OK(SIZE) \
1504   (SIZE < DI_SIZE                                                       \
1505    && SIZE > (DI_SIZE - SIZE + FSSIZE)                                  \
1506    /* Don't use IBM Extended Double TFmode for TI->SF calculations.     \
1507       The conversion from long double to float suffers from double      \
1508       rounding, because we convert via double.  In any case, the        \
1509       fallback code is faster.  */                                      \
1510    && !IS_IBM_EXTENDED (SIZE))
1511 #if defined(L_floatundisf)
1512 #define FUNC __floatundisf
1513 #define FSTYPE SFtype
1514 #define FSSIZE SF_SIZE
1515 #else
1516 #define FUNC __floatundidf
1517 #define FSTYPE DFtype
1518 #define FSSIZE DF_SIZE
1519 #endif
1520
1521 FSTYPE
1522 FUNC (UDWtype u)
1523 {
1524 #if FSSIZE >= W_TYPE_SIZE
1525   /* When the word size is small, we never get any rounding error.  */
1526   FSTYPE f = (UWtype) (u >> W_TYPE_SIZE);
1527   f *= Wtype_MAXp1_F;
1528   f += (UWtype)u;
1529   return f;
1530 #elif (LIBGCC2_HAS_DF_MODE && F_MODE_OK (DF_SIZE))      \
1531      || (LIBGCC2_HAS_XF_MODE && F_MODE_OK (XF_SIZE))    \
1532      || (LIBGCC2_HAS_TF_MODE && F_MODE_OK (TF_SIZE))
1533
1534 #if (LIBGCC2_HAS_DF_MODE && F_MODE_OK (DF_SIZE))
1535 # define FSIZE DF_SIZE
1536 # define FTYPE DFtype
1537 #elif (LIBGCC2_HAS_XF_MODE && F_MODE_OK (XF_SIZE))
1538 # define FSIZE XF_SIZE
1539 # define FTYPE XFtype
1540 #elif (LIBGCC2_HAS_TF_MODE && F_MODE_OK (TF_SIZE))
1541 # define FSIZE TF_SIZE
1542 # define FTYPE TFtype
1543 #else
1544 # error
1545 #endif
1546
1547 #define REP_BIT ((UDWtype) 1 << (DI_SIZE - FSIZE))
1548
1549   /* Protect against double-rounding error.
1550      Represent any low-order bits, that might be truncated by a bit that
1551      won't be lost.  The bit can go in anywhere below the rounding position
1552      of the FSTYPE.  A fixed mask and bit position handles all usual
1553      configurations.  */
1554   if (u >= ((UDWtype) 1 << FSIZE))
1555     {
1556       if ((UDWtype) u & (REP_BIT - 1))
1557         {
1558           u &= ~ (REP_BIT - 1);
1559           u |= REP_BIT;
1560         }
1561     }
1562
1563   /* Do the calculation in a wider type so that we don't lose any of
1564      the precision of the high word while multiplying it.  */
1565   FTYPE f = (UWtype) (u >> W_TYPE_SIZE);
1566   f *= Wtype_MAXp1_F;
1567   f += (UWtype)u;
1568   return (FSTYPE) f;
1569 #else
1570 #if FSSIZE == W_TYPE_SIZE - 1
1571 # error
1572 #endif
1573   /* Finally, the word size is larger than the number of bits in the
1574      required FSTYPE, and we've got no suitable wider type.  The only
1575      way to avoid double rounding is to special case the
1576      extraction.  */
1577
1578   /* If there are no high bits set, fall back to one conversion.  */
1579   if ((UWtype)u == u)
1580     return (FSTYPE)(UWtype)u;
1581
1582   /* Otherwise, find the power of two.  */
1583   UWtype hi = u >> W_TYPE_SIZE;
1584
1585   UWtype count, shift;
1586   count_leading_zeros (count, hi);
1587
1588   shift = W_TYPE_SIZE - count;
1589
1590   /* Shift down the most significant bits.  */
1591   hi = u >> shift;
1592
1593   /* If we lost any nonzero bits, set the lsb to ensure correct rounding.  */
1594   if (u & (((UDWtype)1 << shift) - 1))
1595     hi |= 1;
1596
1597   /* Convert the one word of data, and rescale.  */
1598   FSTYPE f = hi;
1599   f *= (UDWtype)1 << shift;
1600   return f;
1601 #endif
1602 }
1603 #endif
1604
1605 #if defined(L_fixunsxfsi) && LIBGCC2_HAS_XF_MODE
1606 /* Reenable the normal types, in case limits.h needs them.  */
1607 #undef char
1608 #undef short
1609 #undef int
1610 #undef long
1611 #undef unsigned
1612 #undef float
1613 #undef double
1614 #undef MIN
1615 #undef MAX
1616 #include <limits.h>
1617
1618 UWtype
1619 __fixunsxfSI (XFtype a)
1620 {
1621   if (a >= - (DFtype) Wtype_MIN)
1622     return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
1623   return (Wtype) a;
1624 }
1625 #endif
1626
1627 #if defined(L_fixunsdfsi) && LIBGCC2_HAS_DF_MODE
1628 /* Reenable the normal types, in case limits.h needs them.  */
1629 #undef char
1630 #undef short
1631 #undef int
1632 #undef long
1633 #undef unsigned
1634 #undef float
1635 #undef double
1636 #undef MIN
1637 #undef MAX
1638 #include <limits.h>
1639
1640 UWtype
1641 __fixunsdfSI (DFtype a)
1642 {
1643   if (a >= - (DFtype) Wtype_MIN)
1644     return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
1645   return (Wtype) a;
1646 }
1647 #endif
1648
1649 #if defined(L_fixunssfsi) && LIBGCC2_HAS_SF_MODE
1650 /* Reenable the normal types, in case limits.h needs them.  */
1651 #undef char
1652 #undef short
1653 #undef int
1654 #undef long
1655 #undef unsigned
1656 #undef float
1657 #undef double
1658 #undef MIN
1659 #undef MAX
1660 #include <limits.h>
1661
1662 UWtype
1663 __fixunssfSI (SFtype a)
1664 {
1665   if (a >= - (SFtype) Wtype_MIN)
1666     return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
1667   return (Wtype) a;
1668 }
1669 #endif
1670 \f
1671 /* Integer power helper used from __builtin_powi for non-constant
1672    exponents.  */
1673
1674 #if (defined(L_powisf2) && LIBGCC2_HAS_SF_MODE) \
1675     || (defined(L_powidf2) && LIBGCC2_HAS_DF_MODE) \
1676     || (defined(L_powixf2) && LIBGCC2_HAS_XF_MODE) \
1677     || (defined(L_powitf2) && LIBGCC2_HAS_TF_MODE)
1678 # if defined(L_powisf2)
1679 #  define TYPE SFtype
1680 #  define NAME __powisf2
1681 # elif defined(L_powidf2)
1682 #  define TYPE DFtype
1683 #  define NAME __powidf2
1684 # elif defined(L_powixf2)
1685 #  define TYPE XFtype
1686 #  define NAME __powixf2
1687 # elif defined(L_powitf2)
1688 #  define TYPE TFtype
1689 #  define NAME __powitf2
1690 # endif
1691
1692 #undef int
1693 #undef unsigned
1694 TYPE
1695 NAME (TYPE x, int m)
1696 {
1697   unsigned int n = m < 0 ? -m : m;
1698   TYPE y = n % 2 ? x : 1;
1699   while (n >>= 1)
1700     {
1701       x = x * x;
1702       if (n % 2)
1703         y = y * x;
1704     }
1705   return m < 0 ? 1/y : y;
1706 }
1707
1708 #endif
1709 \f
1710 #if ((defined(L_mulsc3) || defined(L_divsc3)) && LIBGCC2_HAS_SF_MODE) \
1711     || ((defined(L_muldc3) || defined(L_divdc3)) && LIBGCC2_HAS_DF_MODE) \
1712     || ((defined(L_mulxc3) || defined(L_divxc3)) && LIBGCC2_HAS_XF_MODE) \
1713     || ((defined(L_multc3) || defined(L_divtc3)) && LIBGCC2_HAS_TF_MODE)
1714
1715 #undef float
1716 #undef double
1717 #undef long
1718
1719 #if defined(L_mulsc3) || defined(L_divsc3)
1720 # define MTYPE  SFtype
1721 # define CTYPE  SCtype
1722 # define MODE   sc
1723 # define CEXT   f
1724 # define NOTRUNC __FLT_EVAL_METHOD__ == 0
1725 #elif defined(L_muldc3) || defined(L_divdc3)
1726 # define MTYPE  DFtype
1727 # define CTYPE  DCtype
1728 # define MODE   dc
1729 # if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 64
1730 #  define CEXT  l
1731 #  define NOTRUNC 1
1732 # else
1733 #  define CEXT
1734 #  define NOTRUNC __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 1
1735 # endif
1736 #elif defined(L_mulxc3) || defined(L_divxc3)
1737 # define MTYPE  XFtype
1738 # define CTYPE  XCtype
1739 # define MODE   xc
1740 # define CEXT   l
1741 # define NOTRUNC 1
1742 #elif defined(L_multc3) || defined(L_divtc3)
1743 # define MTYPE  TFtype
1744 # define CTYPE  TCtype
1745 # define MODE   tc
1746 # define CEXT   l
1747 # define NOTRUNC 1
1748 #else
1749 # error
1750 #endif
1751
1752 #define CONCAT3(A,B,C)  _CONCAT3(A,B,C)
1753 #define _CONCAT3(A,B,C) A##B##C
1754
1755 #define CONCAT2(A,B)    _CONCAT2(A,B)
1756 #define _CONCAT2(A,B)   A##B
1757
1758 /* All of these would be present in a full C99 implementation of <math.h>
1759    and <complex.h>.  Our problem is that only a few systems have such full
1760    implementations.  Further, libgcc_s.so isn't currently linked against
1761    libm.so, and even for systems that do provide full C99, the extra overhead
1762    of all programs using libgcc having to link against libm.  So avoid it.  */
1763
1764 #define isnan(x)        __builtin_expect ((x) != (x), 0)
1765 #define isfinite(x)     __builtin_expect (!isnan((x) - (x)), 1)
1766 #define isinf(x)        __builtin_expect (!isnan(x) & !isfinite(x), 0)
1767
1768 #define INFINITY        CONCAT2(__builtin_inf, CEXT) ()
1769 #define I               1i
1770
1771 /* Helpers to make the following code slightly less gross.  */
1772 #define COPYSIGN        CONCAT2(__builtin_copysign, CEXT)
1773 #define FABS            CONCAT2(__builtin_fabs, CEXT)
1774
1775 /* Verify that MTYPE matches up with CEXT.  */
1776 extern void *compile_type_assert[sizeof(INFINITY) == sizeof(MTYPE) ? 1 : -1];
1777
1778 /* Ensure that we've lost any extra precision.  */
1779 #if NOTRUNC
1780 # define TRUNC(x)
1781 #else
1782 # define TRUNC(x)       __asm__ ("" : "=m"(x) : "m"(x))
1783 #endif
1784
1785 #if defined(L_mulsc3) || defined(L_muldc3) \
1786     || defined(L_mulxc3) || defined(L_multc3)
1787
1788 CTYPE
1789 CONCAT3(__mul,MODE,3) (MTYPE a, MTYPE b, MTYPE c, MTYPE d)
1790 {
1791   MTYPE ac, bd, ad, bc, x, y;
1792
1793   ac = a * c;
1794   bd = b * d;
1795   ad = a * d;
1796   bc = b * c;
1797
1798   TRUNC (ac);
1799   TRUNC (bd);
1800   TRUNC (ad);
1801   TRUNC (bc);
1802
1803   x = ac - bd;
1804   y = ad + bc;
1805
1806   if (isnan (x) && isnan (y))
1807     {
1808       /* Recover infinities that computed as NaN + iNaN.  */
1809       _Bool recalc = 0;
1810       if (isinf (a) || isinf (b))
1811         {
1812           /* z is infinite.  "Box" the infinity and change NaNs in
1813              the other factor to 0.  */
1814           a = COPYSIGN (isinf (a) ? 1 : 0, a);
1815           b = COPYSIGN (isinf (b) ? 1 : 0, b);
1816           if (isnan (c)) c = COPYSIGN (0, c);
1817           if (isnan (d)) d = COPYSIGN (0, d);
1818           recalc = 1;
1819         }
1820      if (isinf (c) || isinf (d))
1821         {
1822           /* w is infinite.  "Box" the infinity and change NaNs in
1823              the other factor to 0.  */
1824           c = COPYSIGN (isinf (c) ? 1 : 0, c);
1825           d = COPYSIGN (isinf (d) ? 1 : 0, d);
1826           if (isnan (a)) a = COPYSIGN (0, a);
1827           if (isnan (b)) b = COPYSIGN (0, b);
1828           recalc = 1;
1829         }
1830      if (!recalc
1831           && (isinf (ac) || isinf (bd)
1832               || isinf (ad) || isinf (bc)))
1833         {
1834           /* Recover infinities from overflow by changing NaNs to 0.  */
1835           if (isnan (a)) a = COPYSIGN (0, a);
1836           if (isnan (b)) b = COPYSIGN (0, b);
1837           if (isnan (c)) c = COPYSIGN (0, c);
1838           if (isnan (d)) d = COPYSIGN (0, d);
1839           recalc = 1;
1840         }
1841       if (recalc)
1842         {
1843           x = INFINITY * (a * c - b * d);
1844           y = INFINITY * (a * d + b * c);
1845         }
1846     }
1847
1848   return x + I * y;
1849 }
1850 #endif /* complex multiply */
1851
1852 #if defined(L_divsc3) || defined(L_divdc3) \
1853     || defined(L_divxc3) || defined(L_divtc3)
1854
1855 CTYPE
1856 CONCAT3(__div,MODE,3) (MTYPE a, MTYPE b, MTYPE c, MTYPE d)
1857 {
1858   MTYPE denom, ratio, x, y;
1859
1860   /* ??? We can get better behavior from logarithmic scaling instead of 
1861      the division.  But that would mean starting to link libgcc against
1862      libm.  We could implement something akin to ldexp/frexp as gcc builtins
1863      fairly easily...  */
1864   if (FABS (c) < FABS (d))
1865     {
1866       ratio = c / d;
1867       denom = (c * ratio) + d;
1868       x = ((a * ratio) + b) / denom;
1869       y = ((b * ratio) - a) / denom;
1870     }
1871   else
1872     {
1873       ratio = d / c;
1874       denom = (d * ratio) + c;
1875       x = ((b * ratio) + a) / denom;
1876       y = (b - (a * ratio)) / denom;
1877     }
1878
1879   /* Recover infinities and zeros that computed as NaN+iNaN; the only cases
1880      are nonzero/zero, infinite/finite, and finite/infinite.  */
1881   if (isnan (x) && isnan (y))
1882     {
1883       if (denom == 0.0 && (!isnan (a) || !isnan (b)))
1884         {
1885           x = COPYSIGN (INFINITY, c) * a;
1886           y = COPYSIGN (INFINITY, c) * b;
1887         }
1888       else if ((isinf (a) || isinf (b)) && isfinite (c) && isfinite (d))
1889         {
1890           a = COPYSIGN (isinf (a) ? 1 : 0, a);
1891           b = COPYSIGN (isinf (b) ? 1 : 0, b);
1892           x = INFINITY * (a * c + b * d);
1893           y = INFINITY * (b * c - a * d);
1894         }
1895       else if ((isinf (c) || isinf (d)) && isfinite (a) && isfinite (b))
1896         {
1897           c = COPYSIGN (isinf (c) ? 1 : 0, c);
1898           d = COPYSIGN (isinf (d) ? 1 : 0, d);
1899           x = 0.0 * (a * c + b * d);
1900           y = 0.0 * (b * c - a * d);
1901         }
1902     }
1903
1904   return x + I * y;
1905 }
1906 #endif /* complex divide */
1907
1908 #endif /* all complex float routines */
1909 \f
1910 /* From here on down, the routines use normal data types.  */
1911
1912 #define SItype bogus_type
1913 #define USItype bogus_type
1914 #define DItype bogus_type
1915 #define UDItype bogus_type
1916 #define SFtype bogus_type
1917 #define DFtype bogus_type
1918 #undef Wtype
1919 #undef UWtype
1920 #undef HWtype
1921 #undef UHWtype
1922 #undef DWtype
1923 #undef UDWtype
1924
1925 #undef char
1926 #undef short
1927 #undef int
1928 #undef long
1929 #undef unsigned
1930 #undef float
1931 #undef double
1932 \f
1933 #ifdef L__gcc_bcmp
1934
1935 /* Like bcmp except the sign is meaningful.
1936    Result is negative if S1 is less than S2,
1937    positive if S1 is greater, 0 if S1 and S2 are equal.  */
1938
1939 int
1940 __gcc_bcmp (const unsigned char *s1, const unsigned char *s2, size_t size)
1941 {
1942   while (size > 0)
1943     {
1944       const unsigned char c1 = *s1++, c2 = *s2++;
1945       if (c1 != c2)
1946         return c1 - c2;
1947       size--;
1948     }
1949   return 0;
1950 }
1951
1952 #endif
1953 \f
1954 /* __eprintf used to be used by GCC's private version of <assert.h>.
1955    We no longer provide that header, but this routine remains in libgcc.a
1956    for binary backward compatibility.  Note that it is not included in
1957    the shared version of libgcc.  */
1958 #ifdef L_eprintf
1959 #ifndef inhibit_libc
1960
1961 #undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch.  */
1962 #include <stdio.h>
1963
1964 void
1965 __eprintf (const char *string, const char *expression,
1966            unsigned int line, const char *filename)
1967 {
1968   fprintf (stderr, string, expression, line, filename);
1969   fflush (stderr);
1970   abort ();
1971 }
1972
1973 #endif
1974 #endif
1975
1976 \f
1977 #ifdef L_clear_cache
1978 /* Clear part of an instruction cache.  */
1979
1980 void
1981 __clear_cache (char *beg __attribute__((__unused__)),
1982                char *end __attribute__((__unused__)))
1983 {
1984 #ifdef CLEAR_INSN_CACHE
1985   CLEAR_INSN_CACHE (beg, end);
1986 #endif /* CLEAR_INSN_CACHE */
1987 }
1988
1989 #endif /* L_clear_cache */
1990 \f
1991 #ifdef L_enable_execute_stack
1992 /* Attempt to turn on execute permission for the stack.  */
1993
1994 #ifdef ENABLE_EXECUTE_STACK
1995   ENABLE_EXECUTE_STACK
1996 #else
1997 void
1998 __enable_execute_stack (void *addr __attribute__((__unused__)))
1999 {}
2000 #endif /* ENABLE_EXECUTE_STACK */
2001
2002 #endif /* L_enable_execute_stack */
2003 \f
2004 #ifdef L_trampoline
2005
2006 /* Jump to a trampoline, loading the static chain address.  */
2007
2008 #if defined(WINNT) && ! defined(__CYGWIN__) && ! defined (_UWIN)
2009
2010 int
2011 getpagesize (void)
2012 {
2013 #ifdef _ALPHA_
2014   return 8192;
2015 #else
2016   return 4096;
2017 #endif
2018 }
2019
2020 #ifdef __i386__
2021 extern int VirtualProtect (char *, int, int, int *) __attribute__((stdcall));
2022 #endif
2023
2024 int
2025 mprotect (char *addr, int len, int prot)
2026 {
2027   int np, op;
2028
2029   if (prot == 7)
2030     np = 0x40;
2031   else if (prot == 5)
2032     np = 0x20;
2033   else if (prot == 4)
2034     np = 0x10;
2035   else if (prot == 3)
2036     np = 0x04;
2037   else if (prot == 1)
2038     np = 0x02;
2039   else if (prot == 0)
2040     np = 0x01;
2041
2042   if (VirtualProtect (addr, len, np, &op))
2043     return 0;
2044   else
2045     return -1;
2046 }
2047
2048 #endif /* WINNT && ! __CYGWIN__ && ! _UWIN */
2049
2050 #ifdef TRANSFER_FROM_TRAMPOLINE
2051 TRANSFER_FROM_TRAMPOLINE
2052 #endif
2053 #endif /* L_trampoline */
2054 \f
2055 #ifndef __CYGWIN__
2056 #ifdef L__main
2057
2058 #include "gbl-ctors.h"
2059
2060 /* Some systems use __main in a way incompatible with its use in gcc, in these
2061    cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
2062    give the same symbol without quotes for an alternative entry point.  You
2063    must define both, or neither.  */
2064 #ifndef NAME__MAIN
2065 #define NAME__MAIN "__main"
2066 #define SYMBOL__MAIN __main
2067 #endif
2068
2069 #if defined (INIT_SECTION_ASM_OP) || defined (INIT_ARRAY_SECTION_ASM_OP)
2070 #undef HAS_INIT_SECTION
2071 #define HAS_INIT_SECTION
2072 #endif
2073
2074 #if !defined (HAS_INIT_SECTION) || !defined (OBJECT_FORMAT_ELF)
2075
2076 /* Some ELF crosses use crtstuff.c to provide __CTOR_LIST__, but use this
2077    code to run constructors.  In that case, we need to handle EH here, too.  */
2078
2079 #ifdef EH_FRAME_SECTION_NAME
2080 #include "unwind-dw2-fde.h"
2081 extern unsigned char __EH_FRAME_BEGIN__[];
2082 #endif
2083
2084 /* Run all the global destructors on exit from the program.  */
2085
2086 void
2087 __do_global_dtors (void)
2088 {
2089 #ifdef DO_GLOBAL_DTORS_BODY
2090   DO_GLOBAL_DTORS_BODY;
2091 #else
2092   static func_ptr *p = __DTOR_LIST__ + 1;
2093   while (*p)
2094     {
2095       p++;
2096       (*(p-1)) ();
2097     }
2098 #endif
2099 #if defined (EH_FRAME_SECTION_NAME) && !defined (HAS_INIT_SECTION)
2100   {
2101     static int completed = 0;
2102     if (! completed)
2103       {
2104         completed = 1;
2105         __deregister_frame_info (__EH_FRAME_BEGIN__);
2106       }
2107   }
2108 #endif
2109 }
2110 #endif
2111
2112 #ifndef HAS_INIT_SECTION
2113 /* Run all the global constructors on entry to the program.  */
2114
2115 void
2116 __do_global_ctors (void)
2117 {
2118 #ifdef EH_FRAME_SECTION_NAME
2119   {
2120     static struct object object;
2121     __register_frame_info (__EH_FRAME_BEGIN__, &object);
2122   }
2123 #endif
2124   DO_GLOBAL_CTORS_BODY;
2125   atexit (__do_global_dtors);
2126 }
2127 #endif /* no HAS_INIT_SECTION */
2128
2129 #if !defined (HAS_INIT_SECTION) || defined (INVOKE__main)
2130 /* Subroutine called automatically by `main'.
2131    Compiling a global function named `main'
2132    produces an automatic call to this function at the beginning.
2133
2134    For many systems, this routine calls __do_global_ctors.
2135    For systems which support a .init section we use the .init section
2136    to run __do_global_ctors, so we need not do anything here.  */
2137
2138 extern void SYMBOL__MAIN (void);
2139 void
2140 SYMBOL__MAIN (void)
2141 {
2142   /* Support recursive calls to `main': run initializers just once.  */
2143   static int initialized;
2144   if (! initialized)
2145     {
2146       initialized = 1;
2147       __do_global_ctors ();
2148     }
2149 }
2150 #endif /* no HAS_INIT_SECTION or INVOKE__main */
2151
2152 #endif /* L__main */
2153 #endif /* __CYGWIN__ */
2154 \f
2155 #ifdef L_ctors
2156
2157 #include "gbl-ctors.h"
2158
2159 /* Provide default definitions for the lists of constructors and
2160    destructors, so that we don't get linker errors.  These symbols are
2161    intentionally bss symbols, so that gld and/or collect will provide
2162    the right values.  */
2163
2164 /* We declare the lists here with two elements each,
2165    so that they are valid empty lists if no other definition is loaded.
2166
2167    If we are using the old "set" extensions to have the gnu linker
2168    collect ctors and dtors, then we __CTOR_LIST__ and __DTOR_LIST__
2169    must be in the bss/common section.
2170
2171    Long term no port should use those extensions.  But many still do.  */
2172 #if !defined(INIT_SECTION_ASM_OP) && !defined(CTOR_LISTS_DEFINED_EXTERNALLY)
2173 #if defined (TARGET_ASM_CONSTRUCTOR) || defined (USE_COLLECT2)
2174 func_ptr __CTOR_LIST__[2] = {0, 0};
2175 func_ptr __DTOR_LIST__[2] = {0, 0};
2176 #else
2177 func_ptr __CTOR_LIST__[2];
2178 func_ptr __DTOR_LIST__[2];
2179 #endif
2180 #endif /* no INIT_SECTION_ASM_OP and not CTOR_LISTS_DEFINED_EXTERNALLY */
2181 #endif /* L_ctors */
2182 #endif /* LIBGCC2_UNITS_PER_WORD <= MIN_UNITS_PER_WORD */