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