home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / gnulib / rcs / libgcc2.c,v < prev    next >
Encoding:
Text File  |  1992-07-04  |  29.8 KB  |  1,407 lines

  1. head    1.1;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ * @;
  7.  
  8.  
  9. 1.1
  10. date    92.06.08.19.47.59;    author mwild;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @initial checkin
  17. @
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/* More subroutines needed by GCC output code on some machines.  */
  26. /* Compile this one with gcc.  */
  27. /* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
  28.  
  29. This file is part of GNU CC.
  30.  
  31. GNU CC is free software; you can redistribute it and/or modify
  32. it under the terms of the GNU General Public License as published by
  33. the Free Software Foundation; either version 2, or (at your option)
  34. any later version.
  35.  
  36. GNU CC is distributed in the hope that it will be useful,
  37. but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  39. GNU General Public License for more details.
  40.  
  41. You should have received a copy of the GNU General Public License
  42. along with GNU CC; see the file COPYING.  If not, write to
  43. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  44.  
  45. /* As a special exception, if you link this library with files
  46.    compiled with GCC to produce an executable, this does not cause
  47.    the resulting executable to be covered by the GNU General Public License.
  48.    This exception does not however invalidate any other reasons why
  49.    the executable file might be covered by the GNU General Public License.  */
  50.  
  51. /* It is incorrect to include config.h here, because this file is being
  52.    compiled for the target, and hence definitions concerning only the host
  53.    do not apply.  */
  54.  
  55. #if 0
  56. #include "tm.h"
  57. #include "gstddef.h"
  58. #else
  59. #include "types.h"
  60. #include <stddef.h>
  61. #endif
  62.  
  63. /* Don't use `fancy_abort' here even if config.h says to use it.  */
  64. #ifdef abort
  65. #undef abort
  66. #endif
  67.  
  68. /* Need to undef this because LONG_TYPE_SIZE may rely upon GCC's
  69.    internal `target_flags' variable.  */
  70. #undef LONG_TYPE_SIZE
  71.  
  72. #define LONG_TYPE_SIZE (sizeof (long) * BITS_PER_UNIT)
  73.  
  74. #ifndef SItype
  75. #define SItype long int
  76. #endif
  77.  
  78. /* long long ints are pairs of long ints in the order determined by
  79.    WORDS_BIG_ENDIAN.  */
  80.  
  81. #if WORDS_BIG_ENDIAN
  82.   struct longlong {long high, low;};
  83. #else
  84.   struct longlong {long low, high;};
  85. #endif
  86.  
  87. /* We need this union to unpack/pack longlongs, since we don't have
  88.    any arithmetic yet.  Incoming long long parameters are stored
  89.    into the `ll' field, and the unpacked result is read from the struct
  90.    longlong.  */
  91.  
  92. typedef union
  93. {
  94.   struct longlong s;
  95.   long long ll;
  96. } long_long;
  97.  
  98. #if defined (L_udivmoddi4) || defined (L_muldi3)
  99.  
  100. #include "longlong.h"
  101.  
  102. #endif /* udiv or mul */
  103.  
  104. extern long long __fixunssfdi (float a);
  105. extern long long __fixunsdfdi (double a);
  106.  
  107. #if defined (L_negdi2) || defined (L_divdi3) || defined (L_moddi3)
  108. #if defined (L_divdi3) || defined (L_moddi3)
  109. static inline
  110. #endif
  111. long long
  112. __negdi2 (u)
  113.      long long u;
  114. {
  115.   long_long w;
  116.   long_long uu;
  117.  
  118.   uu.ll = u;
  119.  
  120.   w.s.low = -uu.s.low;
  121.   w.s.high = -uu.s.high - ((unsigned long) w.s.low > 0);
  122.  
  123.   return w.ll;
  124. }
  125. #endif
  126.  
  127. #ifdef L_lshldi3
  128. long long
  129. __lshldi3 (u, b)
  130.      long long u;
  131.      int b;
  132. {
  133.   long_long w;
  134.   long bm;
  135.   long_long uu;
  136.  
  137.   if (b == 0)
  138.     return u;
  139.  
  140.   uu.ll = u;
  141.  
  142.   bm = (sizeof (long) * BITS_PER_UNIT) - b;
  143.   if (bm <= 0)
  144.     {
  145.       w.s.low = 0;
  146.       w.s.high = (unsigned long)uu.s.low << -bm;
  147.     }
  148.   else
  149.     {
  150.       unsigned long carries = (unsigned long)uu.s.low >> bm;
  151.       w.s.low = (unsigned long)uu.s.low << b;
  152.       w.s.high = ((unsigned long)uu.s.high << b) | carries;
  153.     }
  154.  
  155.   return w.ll;
  156. }
  157. #endif
  158.  
  159. #ifdef L_lshrdi3
  160. long long
  161. __lshrdi3 (u, b)
  162.      long long u;
  163.      int b;
  164. {
  165.   long_long w;
  166.   long bm;
  167.   long_long uu;
  168.  
  169.   if (b == 0)
  170.     return u;
  171.  
  172.   uu.ll = u;
  173.  
  174.   bm = (sizeof (long) * BITS_PER_UNIT) - b;
  175.   if (bm <= 0)
  176.     {
  177.       w.s.high = 0;
  178.       w.s.low = (unsigned long)uu.s.high >> -bm;
  179.     }
  180.   else
  181.     {
  182.       unsigned long carries = (unsigned long)uu.s.high << bm;
  183.       w.s.high = (unsigned long)uu.s.high >> b;
  184.       w.s.low = ((unsigned long)uu.s.low >> b) | carries;
  185.     }
  186.  
  187.   return w.ll;
  188. }
  189. #endif
  190.  
  191. #ifdef L_ashldi3
  192. long long
  193. __ashldi3 (u, b)
  194.      long long u;
  195.      int b;
  196. {
  197.   long_long w;
  198.   long bm;
  199.   long_long uu;
  200.  
  201.   if (b == 0)
  202.     return u;
  203.  
  204.   uu.ll = u;
  205.  
  206.   bm = (sizeof (long) * BITS_PER_UNIT) - b;
  207.   if (bm <= 0)
  208.     {
  209.       w.s.low = 0;
  210.       w.s.high = (unsigned long)uu.s.low << -bm;
  211.     }
  212.   else
  213.     {
  214.       unsigned long carries = (unsigned long)uu.s.low >> bm;
  215.       w.s.low = (unsigned long)uu.s.low << b;
  216.       w.s.high = ((unsigned long)uu.s.high << b) | carries;
  217.     }
  218.  
  219.   return w.ll;
  220. }
  221. #endif
  222.  
  223. #ifdef L_ashrdi3
  224. long long
  225. __ashrdi3 (u, b)
  226.      long long u;
  227.      int b;
  228. {
  229.   long_long w;
  230.   long bm;
  231.   long_long uu;
  232.  
  233.   if (b == 0)
  234.     return u;
  235.  
  236.   uu.ll = u;
  237.  
  238.   bm = (sizeof (long) * BITS_PER_UNIT) - b;
  239.   if (bm <= 0)
  240.     {
  241.       /* w.s.high = 1..1 or 0..0 */
  242.       w.s.high = uu.s.high >> (sizeof (long) * BITS_PER_UNIT - 1);
  243.       w.s.low = uu.s.high >> -bm;
  244.     }
  245.   else
  246.     {
  247.       unsigned long carries = (unsigned long)uu.s.high << bm;
  248.       w.s.high = uu.s.high >> b;
  249.       w.s.low = ((unsigned long)uu.s.low >> b) | carries;
  250.     }
  251.  
  252.   return w.ll;
  253. }
  254. #endif
  255.  
  256. #ifdef L_muldi3
  257. long long
  258. __muldi3 (u, v)
  259.      long long u, v;
  260. {
  261.   long_long w;
  262.   long_long uu, vv;
  263.  
  264.   uu.ll = u,
  265.   vv.ll = v;
  266.  
  267.   w.ll = __umulsidi3 (uu.s.low, vv.s.low);
  268.   w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high
  269.            + (unsigned long) uu.s.high * (unsigned long) vv.s.low);
  270.  
  271.   return w.ll;
  272. }
  273. #endif
  274.  
  275. #ifdef L_udivmoddi4
  276. static const unsigned char __clz_tab[] =
  277. {
  278.   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,
  279.   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,
  280.   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,
  281.   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,
  282.   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,
  283.   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,
  284.   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,
  285.   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,
  286. };
  287.  
  288. unsigned long long
  289. __udivmoddi4 (n, d, rp)
  290.      unsigned long long n, d;
  291.      unsigned long long int *rp;
  292. {
  293.   long_long ww;
  294.   long_long nn, dd;
  295.   long_long rr;
  296.   unsigned long d0, d1, n0, n1, n2;
  297.   unsigned long q0, q1;
  298.   unsigned b, bm;
  299.  
  300.   nn.ll = n;
  301.   dd.ll = d;
  302.  
  303.   d0 = dd.s.low;
  304.   d1 = dd.s.high;
  305.   n0 = nn.s.low;
  306.   n1 = nn.s.high;
  307.  
  308. #if !UDIV_NEEDS_NORMALIZATION
  309.   if (d1 == 0)
  310.     {
  311.       if (d0 > n1)
  312.     {
  313.       /* 0q = nn / 0D */
  314.  
  315.       udiv_qrnnd (q0, n0, n1, n0, d0);
  316.       q1 = 0;
  317.  
  318.       /* Remainder in n0.  */
  319.     }
  320.       else
  321.     {
  322.       /* qq = NN / 0d */
  323.  
  324.       if (d0 == 0)
  325.         d0 = 1 / d0;    /* Divide intentionally by zero.  */
  326.  
  327.       udiv_qrnnd (q1, n1, 0, n1, d0);
  328.       udiv_qrnnd (q0, n0, n1, n0, d0);
  329.  
  330.       /* Remainder in n0.  */
  331.     }
  332.  
  333.       if (rp != 0)
  334.     {
  335.       rr.s.low = n0;
  336.       rr.s.high = 0;
  337.       *rp = rr.ll;
  338.     }
  339.     }
  340.  
  341. #else /* UDIV_NEEDS_NORMALIZATION */
  342.  
  343.   if (d1 == 0)
  344.     {
  345.       if (d0 > n1)
  346.     {
  347.       /* 0q = nn / 0D */
  348.  
  349.       count_leading_zeros (bm, d0);
  350.  
  351.       if (bm != 0)
  352.         {
  353.           /* Normalize, i.e. make the most significant bit of the
  354.          denominator set.  */
  355.  
  356.           d0 = d0 << bm;
  357.           n1 = (n1 << bm) | (n0 >> (LONG_TYPE_SIZE - bm));
  358.           n0 = n0 << bm;
  359.         }
  360.  
  361.       udiv_qrnnd (q0, n0, n1, n0, d0);
  362.       q1 = 0;
  363.  
  364.       /* Remainder in n0 >> bm.  */
  365.     }
  366.       else
  367.     {
  368.       /* qq = NN / 0d */
  369.  
  370.       if (d0 == 0)
  371.         d0 = 1 / d0;    /* Divide intentionally by zero.  */
  372.  
  373.       count_leading_zeros (bm, d0);
  374.  
  375.       if (bm == 0)
  376.         {
  377.           /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
  378.          conclude (the most significant bit of n1 is set) /\ (the
  379.          leading quotient digit q1 = 1).
  380.  
  381.          This special case is necessary, not an optimization.
  382.          (Shifts counts of LONG_TYPE_SIZE are undefined.)  */
  383.  
  384.           n1 -= d0;
  385.           q1 = 1;
  386.         }
  387.       else
  388.         {
  389.           /* Normalize.  */
  390.  
  391.           b = LONG_TYPE_SIZE - bm;
  392.  
  393.           d0 = d0 << bm;
  394.           n2 = n1 >> b;
  395.           n1 = (n1 << bm) | (n0 >> b);
  396.           n0 = n0 << bm;
  397.  
  398.           udiv_qrnnd (q1, n1, n2, n1, d0);
  399.         }
  400.  
  401.       /* n1 != d0... */
  402.  
  403.       udiv_qrnnd (q0, n0, n1, n0, d0);
  404.  
  405.       /* Remainder in n0 >> bm.  */
  406.     }
  407.  
  408.       if (rp != 0)
  409.     {
  410.       rr.s.low = n0 >> bm;
  411.       rr.s.high = 0;
  412.       *rp = rr.ll;
  413.     }
  414.     }
  415. #endif /* UDIV_NEEDS_NORMALIZATION */
  416.  
  417.   else
  418.     {
  419.       if (d1 > n1)
  420.     {
  421.       /* 00 = nn / DD */
  422.  
  423.       q0 = 0;
  424.       q1 = 0;
  425.  
  426.       /* Remainder in n1n0.  */
  427.       if (rp != 0)
  428.         {
  429.           rr.s.low = n0;
  430.           rr.s.high = n1;
  431.           *rp = rr.ll;
  432.         }
  433.     }
  434.       else
  435.     {
  436.       /* 0q = NN / dd */
  437.  
  438.       count_leading_zeros (bm, d1);
  439.       if (bm == 0)
  440.         {
  441.           /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
  442.          conclude (the most significant bit of n1 is set) /\ (the
  443.          quotient digit q0 = 0 or 1).
  444.  
  445.          This special case is necessary, not an optimization.  */
  446.  
  447.           /* The condition on the next line takes advantage of that
  448.          n1 >= d1 (true due to program flow).  */
  449.           if (n1 > d1 || n0 >= d0)
  450.         {
  451.           q0 = 1;
  452.           sub_ddmmss (n1, n0, n1, n0, d1, d0);
  453.         }
  454.           else
  455.         q0 = 0;
  456.  
  457.           q1 = 0;
  458.  
  459.           if (rp != 0)
  460.         {
  461.           rr.s.low = n0;
  462.           rr.s.high = n1;
  463.           *rp = rr.ll;
  464.         }
  465.         }
  466.       else
  467.         {
  468.           unsigned long m1, m0;
  469.           /* Normalize.  */
  470.  
  471.           b = LONG_TYPE_SIZE - bm;
  472.  
  473.           d1 = (d1 << bm) | (d0 >> b);
  474.           d0 = d0 << bm;
  475.           n2 = n1 >> b;
  476.           n1 = (n1 << bm) | (n0 >> b);
  477.           n0 = n0 << bm;
  478.  
  479.           udiv_qrnnd (q0, n1, n2, n1, d1);
  480.           umul_ppmm (m1, m0, q0, d0);
  481.  
  482.           if (m1 > n1 || (m1 == n1 && m0 > n0))
  483.         {
  484.           q0--;
  485.           sub_ddmmss (m1, m0, m1, m0, d1, d0);
  486.         }
  487.  
  488.           q1 = 0;
  489.  
  490.           /* Remainder in (n1n0 - m1m0) >> bm.  */
  491.           if (rp != 0)
  492.         {
  493.           sub_ddmmss (n1, n0, n1, n0, m1, m0);
  494.           rr.s.low = (n1 << b) | (n0 >> bm);
  495.           rr.s.high = n1 >> bm;
  496.           *rp = rr.ll;
  497.         }
  498.         }
  499.     }
  500.     }
  501.  
  502.   ww.s.low = q0;
  503.   ww.s.high = q1;
  504.   return ww.ll;
  505. }
  506. #endif
  507.  
  508. #ifdef L_divdi3
  509. unsigned long long __udivmoddi4 ();
  510. long long
  511. __divdi3 (u, v)
  512.      long long u, v;
  513. {
  514.   int c = 0;
  515.   long_long uu, vv;
  516.   long long w;
  517.  
  518.   uu.ll = u;
  519.   vv.ll = v;
  520.  
  521.   if (uu.s.high < 0)
  522.     c = ~c,
  523.     uu.ll = __negdi2 (uu.ll);
  524.   if (vv.s.high < 0)
  525.     c = ~c,
  526.     vv.ll = __negdi2 (vv.ll);
  527.  
  528.   w = __udivmoddi4 (uu.ll, vv.ll, (unsigned long long *) 0);
  529.   if (c)
  530.     w = __negdi2 (w);
  531.  
  532.   return w;
  533. }
  534. #endif
  535.  
  536. #ifdef L_moddi3
  537. unsigned long long __udivmoddi4 ();
  538. long long
  539. __moddi3 (u, v)
  540.      long long u, v;
  541. {
  542.   int c = 0;
  543.   long_long uu, vv;
  544.   long long w;
  545.  
  546.   uu.ll = u;
  547.   vv.ll = v;
  548.  
  549.   if (uu.s.high < 0)
  550.     c = ~c,
  551.     uu.ll = __negdi2 (uu.ll);
  552.   if (vv.s.high < 0)
  553.     vv.ll = __negdi2 (vv.ll);
  554.  
  555.   (void) __udivmoddi4 (uu.ll, vv.ll, &w);
  556.   if (c)
  557.     w = __negdi2 (w);
  558.  
  559.   return w;
  560. }
  561. #endif
  562.  
  563. #ifdef L_umoddi3
  564. unsigned long long __udivmoddi4 ();
  565. unsigned long long
  566. __umoddi3 (u, v)
  567.      unsigned long long u, v;
  568. {
  569.   long long w;
  570.  
  571.   (void) __udivmoddi4 (u, v, &w);
  572.  
  573.   return w;
  574. }
  575. #endif
  576.  
  577. #ifdef L_udivdi3
  578. unsigned long long __udivmoddi4 ();
  579. unsigned long long
  580. __udivdi3 (n, d)
  581.      unsigned long long n, d;
  582. {
  583.   return __udivmoddi4 (n, d, (unsigned long long *) 0);
  584. }
  585. #endif
  586.  
  587. #ifdef L_cmpdi2
  588. SItype
  589. __cmpdi2 (a, b)
  590.      long long a, b;
  591. {
  592.   long_long au, bu;
  593.  
  594.   au.ll = a, bu.ll = b;
  595.  
  596.   if (au.s.high < bu.s.high)
  597.     return 0;
  598.   else if (au.s.high > bu.s.high)
  599.     return 2;
  600.   if ((unsigned long) au.s.low < (unsigned long) bu.s.low)
  601.     return 0;
  602.   else if ((unsigned long) au.s.low > (unsigned long) bu.s.low)
  603.     return 2;
  604.   return 1;
  605. }
  606. #endif
  607.  
  608. #ifdef L_ucmpdi2
  609. SItype
  610. __ucmpdi2 (a, b)
  611.      long long a, b;
  612. {
  613.   long_long au, bu;
  614.  
  615.   au.ll = a, bu.ll = b;
  616.  
  617.   if ((unsigned long) au.s.high < (unsigned long) bu.s.high)
  618.     return 0;
  619.   else if ((unsigned long) au.s.high > (unsigned long) bu.s.high)
  620.     return 2;
  621.   if ((unsigned long) au.s.low < (unsigned long) bu.s.low)
  622.     return 0;
  623.   else if ((unsigned long) au.s.low > (unsigned long) bu.s.low)
  624.     return 2;
  625.   return 1;
  626. }
  627. #endif
  628.  
  629. #ifdef L_fixunsdfdi
  630. #define WORD_SIZE (sizeof (long) * BITS_PER_UNIT)
  631. #define HIGH_WORD_COEFF (((long long) 1) << WORD_SIZE)
  632.  
  633. long long
  634. __fixunsdfdi (a)
  635.      double a;
  636. {
  637.   double b;
  638.   unsigned long long v;
  639.  
  640.   if (a < 0)
  641.     return 0;
  642.  
  643.   /* Compute high word of result, as a flonum.  */
  644.   b = (a / HIGH_WORD_COEFF);
  645.   /* Convert that to fixed (but not to long long!),
  646.      and shift it into the high word.  */
  647.   v = (unsigned long int) b;
  648.   v <<= WORD_SIZE;
  649.   /* Remove high part from the double, leaving the low part as flonum.  */
  650.   a -= (double)v;
  651.   /* Convert that to fixed (but not to long long!) and add it in.
  652.      Sometimes A comes out negative.  This is significant, since
  653.      A has more bits than a long int does.  */
  654.   if (a < 0)
  655.     v -= (unsigned long int) (- a);
  656.   else
  657.     v += (unsigned long int) a;
  658.   return v;
  659. }
  660. #endif
  661.  
  662. #ifdef L_fixdfdi
  663. long long
  664. __fixdfdi (a)
  665.      double a;
  666. {
  667.   if (a < 0)
  668.     return - __fixunsdfdi (-a);
  669.   return __fixunsdfdi (a);
  670. }
  671. #endif
  672.  
  673. #ifdef L_fixunssfdi
  674. #define WORD_SIZE (sizeof (long) * BITS_PER_UNIT)
  675. #define HIGH_WORD_COEFF (((long long) 1) << WORD_SIZE)
  676.  
  677. long long
  678. __fixunssfdi (float original_a)
  679. {
  680.   /* Convert the float to a double, because that is surely not going
  681.      to lose any bits.  Some day someone else can write a faster version
  682.      that avoids converting to double, and verify it really works right.  */
  683.   double a = original_a;
  684.   double b;
  685.   unsigned long long v;
  686.  
  687.   if (a < 0)
  688.     return 0;
  689.  
  690.   /* Compute high word of result, as a flonum.  */
  691.   b = (a / HIGH_WORD_COEFF);
  692.   /* Convert that to fixed (but not to long long!),
  693.      and shift it into the high word.  */
  694.   v = (unsigned long int) b;
  695.   v <<= WORD_SIZE;
  696.   /* Remove high part from the double, leaving the low part as flonum.  */
  697.   a -= (double)v;
  698.   /* Convert that to fixed (but not to long long!) and add it in.
  699.      Sometimes A comes out negative.  This is significant, since
  700.      A has more bits than a long int does.  */
  701.   if (a < 0)
  702.     v -= (unsigned long int) (- a);
  703.   else
  704.     v += (unsigned long int) a;
  705.   return v;
  706. }
  707. #endif
  708.  
  709. #ifdef L_fixsfdi
  710. long long
  711. __fixsfdi (float a)
  712. {
  713.   if (a < 0)
  714.     return - __fixunssfdi (-a);
  715.   return __fixunssfdi (a);
  716. }
  717. #endif
  718.  
  719. #ifdef L_floatdidf
  720. #define WORD_SIZE (sizeof (long) * BITS_PER_UNIT)
  721. #define HIGH_HALFWORD_COEFF (((long long) 1) << (WORD_SIZE / 2))
  722. #define HIGH_WORD_COEFF (((long long) 1) << WORD_SIZE)
  723.  
  724. double
  725. __floatdidf (u)
  726.      long long u;
  727. {
  728.   double d;
  729.   int negate = 0;
  730.  
  731.   if (u < 0)
  732.     u = -u, negate = 1;
  733.  
  734.   d = (unsigned int) (u >> WORD_SIZE);
  735.   d *= HIGH_HALFWORD_COEFF;
  736.   d *= HIGH_HALFWORD_COEFF;
  737.   d += (unsigned int) (u & (HIGH_WORD_COEFF - 1));
  738.  
  739.   return (negate ? -d : d);
  740. }
  741. #endif
  742.  
  743. #ifdef L_floatdisf
  744. #define WORD_SIZE (sizeof (long) * BITS_PER_UNIT)
  745. #define HIGH_HALFWORD_COEFF (((long long) 1) << (WORD_SIZE / 2))
  746. #define HIGH_WORD_COEFF (((long long) 1) << WORD_SIZE)
  747.  
  748. float
  749. __floatdisf (u)
  750.      long long u;
  751. {
  752.   float f;
  753.   int negate = 0;
  754.  
  755.   if (u < 0)
  756.     u = -u, negate = 1;
  757.  
  758.   f = (unsigned int) (u >> WORD_SIZE);
  759.   f *= HIGH_HALFWORD_COEFF;
  760.   f *= HIGH_HALFWORD_COEFF;
  761.   f += (unsigned int) (u & (HIGH_WORD_COEFF - 1));
  762.  
  763.   return (negate ? -f : f);
  764. }
  765. #endif
  766.  
  767. #ifdef L_fixunsdfsi
  768. #include "limits.h"
  769.  
  770. unsigned SItype
  771. __fixunsdfsi (a)
  772.      double a;
  773. {
  774.   if (a >= - (double) LONG_MIN)
  775.     return (SItype) (a + LONG_MIN) - LONG_MIN;
  776.   return (SItype) a;
  777. }
  778. #endif
  779.  
  780. #ifdef L_fixunssfsi
  781. #include "limits.h"
  782.  
  783. unsigned SItype
  784. __fixunssfsi (float a)
  785. {
  786.   if (a >= - (float) LONG_MIN)
  787.     return (SItype) (a + LONG_MIN) - LONG_MIN;
  788.   return (SItype) a;
  789. }
  790. #endif
  791.  
  792. #ifdef L_varargs
  793. #ifdef __i860__
  794. #ifdef SVR4
  795.     asm ("    .text");
  796.     asm ("    .align    4");
  797.  
  798.     asm (".globl    __builtin_saveregs");
  799. asm ("__builtin_saveregs:");
  800.     asm ("    andnot    0x0f,%sp,%sp");    /* round down to 16-byte boundary */
  801.     asm ("    adds    -96,%sp,%sp");  /* allocate stack space for reg save
  802.                        area and also for a new va_list
  803.                        structure */
  804.     /* Save all argument registers in the arg reg save area.  The
  805.        arg reg save area must have the following layout (according
  806.        to the svr4 ABI):
  807.  
  808.         struct {
  809.           union  {
  810.             float freg[8];
  811.             double dreg[4];
  812.           } float_regs;
  813.           long    ireg[12];
  814.         };
  815.     */
  816.  
  817.     asm ("    fst.q    %f8,  0(%sp)"); /* save floating regs (f8-f15)  */
  818.     asm ("    fst.q    %f12,16(%sp)"); 
  819.  
  820.     asm ("    st.l    %r16,32(%sp)"); /* save integer regs (r16-r27) */
  821.     asm ("    st.l    %r17,36(%sp)"); 
  822.     asm ("    st.l    %r18,40(%sp)");
  823.     asm ("    st.l    %r19,44(%sp)");
  824.     asm ("    st.l    %r20,48(%sp)");
  825.     asm ("    st.l    %r21,52(%sp)");
  826.     asm ("    st.l    %r22,56(%sp)");
  827.     asm ("    st.l    %r23,60(%sp)");
  828.     asm ("    st.l    %r24,64(%sp)");
  829.     asm ("    st.l    %r25,68(%sp)");
  830.     asm ("    st.l    %r26,72(%sp)");
  831.     asm ("    st.l    %r27,76(%sp)");
  832.  
  833.     asm ("    adds    80,%sp,%r16");  /* compute the address of the new
  834.                        va_list structure.  Put in into
  835.                        r16 so that it will be returned
  836.                        to the caller.  */
  837.  
  838.     /* Initialize all fields of the new va_list structure.  This
  839.        structure looks like:
  840.  
  841.         typedef struct {
  842.             unsigned long    ireg_used;
  843.             unsigned long    freg_used;
  844.             long        *reg_base;
  845.             long        *mem_ptr;
  846.         } va_list;
  847.     */
  848.  
  849.     asm ("    st.l    %r0, 0(%r16)"); /* nfixed */
  850.     asm ("    st.l    %r0, 4(%r16)"); /* nfloating */
  851.     asm ("  st.l    %sp, 8(%r16)"); /* __va_ctl points to __va_struct.  */
  852.     asm ("    bri    %r1");        /* delayed return */
  853.     asm ("    st.l    %r28,12(%r16)"); /* pointer to overflow args */
  854.  
  855. #else /* not SVR4 */
  856.     asm ("    .text");
  857.     asm ("    .align    4");
  858.  
  859.     asm (".globl    ___builtin_saveregs");
  860.     asm ("___builtin_saveregs:");
  861.     asm ("    mov    sp,r30");
  862.     asm ("    andnot    0x0f,sp,sp");
  863.     asm ("    adds    -96,sp,sp");  /* allocate sufficient space on the stack */
  864.  
  865. /* Fill in the __va_struct.  */
  866.     asm ("    st.l    r16, 0(sp)"); /* save integer regs (r16-r27) */
  867.     asm ("    st.l    r17, 4(sp)"); /* int    fixed[12] */
  868.     asm ("    st.l    r18, 8(sp)");
  869.     asm ("    st.l    r19,12(sp)");
  870.     asm ("    st.l    r20,16(sp)");
  871.     asm ("    st.l    r21,20(sp)");
  872.     asm ("    st.l    r22,24(sp)");
  873.     asm ("    st.l    r23,28(sp)");
  874.     asm ("    st.l    r24,32(sp)");
  875.     asm ("    st.l    r25,36(sp)");
  876.     asm ("    st.l    r26,40(sp)");
  877.     asm ("    st.l    r27,44(sp)");
  878.  
  879.     asm ("    fst.q    f8, 48(sp)"); /* save floating regs (f8-f15) */
  880.     asm ("    fst.q    f12,64(sp)"); /* int floating[8] */
  881.  
  882. /* Fill in the __va_ctl.  */
  883.     asm ("  st.l    sp, 80(sp)"); /* __va_ctl points to __va_struct.  */
  884.     asm ("    st.l    r28,84(sp)"); /* pointer to more args */
  885.     asm ("    st.l    r0, 88(sp)"); /* nfixed */
  886.     asm ("    st.l    r0, 92(sp)"); /* nfloating */
  887.  
  888.     asm ("    adds    80,sp,r16");  /* return address of the __va_ctl.  */
  889.     asm ("    bri    r1");
  890.     asm ("    mov    r30,sp");
  891.                 /* recover stack and pass address to start 
  892.                    of data.  */
  893. #endif /* not SVR4 */
  894. #else /* not __i860__ */
  895. #ifdef __sparc__
  896.     asm (".global ___builtin_saveregs");
  897.     asm ("___builtin_saveregs:");
  898.     asm ("st %i0,[%fp+68]");
  899.     asm ("st %i1,[%fp+72]");
  900.     asm ("st %i2,[%fp+76]");
  901.     asm ("st %i3,[%fp+80]");
  902.     asm ("st %i4,[%fp+84]");
  903.     asm ("retl");
  904.     asm ("st %i5,[%fp+88]");
  905. #else /* not __sparc__ */
  906. #if defined(__MIPSEL__) | defined(__R3000__) | defined(__R2000__) | defined(__mips__)
  907.  
  908.   asm ("    .text");
  909.   asm ("    .ent __builtin_saveregs");
  910.   asm ("    .globl __builtin_saveregs");
  911.   asm ("__builtin_saveregs:");
  912.   asm ("    sw    $4,0($30)");
  913.   asm ("    sw    $5,4($30)");
  914.   asm ("    sw    $6,8($30)");
  915.   asm ("    sw    $7,12($30)");
  916.   asm ("    j    $31");
  917.   asm ("    .end __builtin_saveregs");
  918. #else /* not __mips__, etc. */
  919. __builtin_saveregs ()
  920. {
  921.   abort ();
  922. }
  923. #endif /* not __mips__ */
  924. #endif /* not __sparc__ */
  925. #endif /* not __i860__ */
  926. #endif
  927.  
  928. #ifdef L_eprintf
  929. #undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch.  */
  930. #include <stdio.h>
  931. /* This is used by the `assert' macro.  */
  932. void
  933. __eprintf (string, expression, line, filename)
  934.      char *string;
  935.      char *expression;
  936.      int line;
  937.      char *filename;
  938. {
  939.   fprintf (stderr, string, expression, line, filename);
  940.   fflush (stderr);
  941.   abort ();
  942. }
  943. #endif
  944.  
  945. #ifdef L_bb
  946. /* Avoid warning from ranlib about empty object file.  */
  947. void
  948. __bb_avoid_warning ()
  949. {}
  950.  
  951. #if defined (__sun__) && defined (__mc68000__)
  952. struct bb
  953. {
  954.   int initialized;
  955.   char *filename;
  956.   int *counts;
  957.   int ncounts;
  958.   int zero_word;
  959.   int *addresses;
  960. };
  961.  
  962. extern int ___tcov_init;
  963.  
  964. __bb_init_func (blocks)
  965.     struct bb *blocks;
  966. {
  967.   if (! ___tcov_init)
  968.     ___tcov_init_func ();
  969.  
  970.   ___bb_link (blocks->filename, blocks->counts, blocks->ncounts);
  971. }
  972.  
  973. #endif
  974. #endif
  975.  
  976. /* frills for C++ */
  977.  
  978. #ifdef L_builtin_new
  979. typedef void (*vfp)(void);
  980.  
  981. extern vfp __new_handler;
  982.  
  983. void *
  984. __builtin_new (sz)
  985.      long sz;
  986. {
  987.   void *p;
  988.  
  989.   p = (void *) malloc (sz);
  990.   if (p == 0)
  991.     (*__new_handler) ();
  992.   return p;
  993. }
  994. #endif
  995.  
  996. #ifdef L_builtin_New
  997. typedef void (*vfp)(void);
  998.  
  999. static void default_new_handler ();
  1000.  
  1001. vfp __new_handler = default_new_handler;
  1002.  
  1003. void *
  1004. __builtin_vec_new (p, maxindex, size, ctor)
  1005.      void *p;
  1006.      int maxindex, size;
  1007.      void (*ctor)(void *);
  1008. {
  1009.   int i, nelts = maxindex + 1;
  1010.   void *rval;
  1011.  
  1012.   if (p == 0)
  1013.     p = (void *)__builtin_new (nelts * size);
  1014.  
  1015.   rval = p;
  1016.  
  1017.   for (i = 0; i < nelts; i++)
  1018.     {
  1019.       (*ctor) (p);
  1020.       p += size;
  1021.     }
  1022.  
  1023.   return rval;
  1024. }
  1025.  
  1026. vfp
  1027. __set_new_handler (handler)
  1028.      vfp handler;
  1029. {
  1030.   vfp prev_handler;
  1031.  
  1032.   prev_handler = __new_handler;
  1033.   if (handler == 0) handler = default_new_handler;
  1034.   __new_handler = handler;
  1035.   return prev_handler;
  1036. }
  1037.  
  1038. vfp
  1039. set_new_handler (handler)
  1040.      vfp handler;
  1041. {
  1042.   return __set_new_handler (handler);
  1043. }
  1044.  
  1045. static void
  1046. default_new_handler ()
  1047. {
  1048.   /* don't use fprintf (stderr, ...) because it may need to call malloc.  */
  1049.   /* This should really print the name of the program, but that is hard to
  1050.      do.  We need a standard, clean way to get at the name.  */
  1051.   write (2, "Virtual memory exceeded in `new'\n", 33);
  1052.   /* don't call exit () because that may call global destructors which
  1053.      may cause a loop.  */
  1054.   _exit (-1);
  1055. }
  1056. #endif
  1057.  
  1058. #ifdef L_builtin_del
  1059. typedef void (*vfp)(void);
  1060.  
  1061. void
  1062. __builtin_delete (ptr)
  1063.      void *ptr;
  1064. {
  1065.   if (ptr)
  1066.     free (ptr);
  1067. }
  1068.  
  1069. void
  1070. __builtin_vec_delete (ptr, maxindex, size, dtor, auto_delete_vec, auto_delete)
  1071.      void *ptr;
  1072.      int maxindex, size;
  1073.      void (*dtor)();
  1074.      int auto_delete;
  1075. {
  1076.   int i, nelts = maxindex + 1;
  1077.   void *p = ptr;
  1078.  
  1079.   ptr += nelts * size;
  1080.  
  1081.   for (i = 0; i < nelts; i++)
  1082.     {
  1083.       ptr -= size;
  1084.       (*dtor) (ptr, auto_delete);
  1085.     }
  1086.  
  1087.   if (auto_delete_vec)
  1088.     __builtin_delete (p);
  1089. }
  1090.  
  1091. #endif
  1092.  
  1093. #ifdef L_shtab
  1094. unsigned int __shtab[] = {
  1095.     0x00000001, 0x00000002, 0x00000004, 0x00000008,
  1096.     0x00000010, 0x00000020, 0x00000040, 0x00000080,
  1097.     0x00000100, 0x00000200, 0x00000400, 0x00000800,
  1098.     0x00001000, 0x00002000, 0x00004000, 0x00008000,
  1099.     0x00010000, 0x00020000, 0x00040000, 0x00080000,
  1100.     0x00100000, 0x00200000, 0x00400000, 0x00800000,
  1101.     0x01000000, 0x02000000, 0x04000000, 0x08000000,
  1102.     0x10000000, 0x20000000, 0x40000000, 0x80000000
  1103.   };
  1104. #endif
  1105.  
  1106. #ifdef L_clear_cache
  1107. /* Clear part of an instruction cache.  */
  1108.  
  1109. #define INSN_CACHE_PLANE_SIZE (INSN_CACHE_SIZE / INSN_CACHE_DEPTH)
  1110.  
  1111. void
  1112. __clear_cache (beg, end)
  1113.      char *beg, *end;
  1114. {
  1115. #ifdef INSN_CACHE_SIZE
  1116.   static char array[INSN_CACHE_SIZE + INSN_CACHE_PLANE_SIZE + INSN_CACHE_LINE_WIDTH];
  1117.   static int initialized = 0;
  1118.   int offset;
  1119.   unsigned int start_addr, end_addr;
  1120.   typedef (*function_ptr) ();
  1121.  
  1122. #if (INSN_CACHE_SIZE / INSN_CACHE_LINE_WIDTH) < 16
  1123.   /* It's cheaper to clear the whole cache.
  1124.      Put in a series of jump instructions so that calling the beginning
  1125.      of the cache will clear the whole thing.  */
  1126.  
  1127.   if (! initialized)
  1128.     {
  1129.       int ptr = (((int) array + INSN_CACHE_LINE_WIDTH - 1)
  1130.          & -INSN_CACHE_LINE_WIDTH);
  1131.       int end_ptr = ptr + INSN_CACHE_SIZE;
  1132.  
  1133.       while (ptr < end_ptr)
  1134.     {
  1135.       *(INSTRUCTION_TYPE *)ptr
  1136.         = JUMP_AHEAD_INSTRUCTION + INSN_CACHE_LINE_WIDTH;
  1137.       ptr += INSN_CACHE_LINE_WIDTH;
  1138.     }
  1139.       *(INSTRUCTION_TYPE *)(ptr - INSN_CACHE_LINE_WIDTH) = RETURN_INSTRUCTION;
  1140.  
  1141.       initialized = 1;
  1142.     }
  1143.  
  1144.   /* Call the beginning of the sequence.  */
  1145.   (((function_ptr) (((int) array + INSN_CACHE_LINE_WIDTH - 1)
  1146.             & -INSN_CACHE_LINE_WIDTH))
  1147.    ());
  1148.  
  1149. #else /* Cache is large.  */
  1150.  
  1151.   if (! initialized)
  1152.     {
  1153.       int ptr = (((int) array + INSN_CACHE_LINE_WIDTH - 1)
  1154.          & -INSN_CACHE_LINE_WIDTH);
  1155.  
  1156.       while (ptr < (int) array + sizeof array)
  1157.     {
  1158.       *(INSTRUCTION_TYPE *)ptr = RETURN_INSTRUCTION;
  1159.       ptr += INSN_CACHE_LINE_WIDTH;
  1160.     }
  1161.  
  1162.       initialized = 1;
  1163.     }
  1164.  
  1165.   /* Find the location in array that occupies the same cache line as BEG.  */
  1166.  
  1167.   offset = ((int) beg & -INSN_CACHE_LINE_WIDTH) & (INSN_CACHE_PLANE_SIZE - 1);
  1168.   start_addr = (((int) (array + INSN_CACHE_PLANE_SIZE - 1)
  1169.          & -INSN_CACHE_PLANE_SIZE)
  1170.         + offset);
  1171.  
  1172.   /* Compute the cache alignment of the place to stop clearing.  */
  1173. #if 0  /* This is not needed for gcc's purposes.  */
  1174.   /* If the block to clear is bigger than a cache plane,
  1175.      we clear the entire cache, and OFFSET is already correct.  */ 
  1176.   if (end < beg + INSN_CACHE_PLANE_SIZE)
  1177. #endif
  1178.     offset = (((int) (end + INSN_CACHE_LINE_WIDTH - 1)
  1179.            & -INSN_CACHE_LINE_WIDTH)
  1180.           & (INSN_CACHE_PLANE_SIZE - 1));
  1181.  
  1182. #if INSN_CACHE_DEPTH > 1
  1183.   end_addr = (start_addr & -INSN_CACHE_PLANE_SIZE) + offset;
  1184.   if (end_addr <= start_addr)
  1185.     end_addr += INSN_CACHE_PLANE_SIZE;
  1186.  
  1187.   for (plane = 0; plane < INSN_CACHE_DEPTH; plane++)
  1188.     {
  1189.       int addr = start_addr + plane * INSN_CACHE_PLANE_SIZE;
  1190.       int stop = end_addr + plane * INSN_CACHE_PLANE_SIZE;
  1191.  
  1192.       while (addr != stop)
  1193.     {
  1194.       /* Call the return instruction at ADDR.  */
  1195.       ((function_ptr) addr) ();
  1196.  
  1197.       addr += INSN_CACHE_LINE_WIDTH;
  1198.     }
  1199.     }
  1200. #else /* just one plane */
  1201.   do
  1202.     {
  1203.       /* Call the return instruction at START_ADDR.  */
  1204.       ((function_ptr) start_addr) ();
  1205.  
  1206.       start_addr += INSN_CACHE_LINE_WIDTH;
  1207.     }
  1208.   while ((start_addr % INSN_CACHE_SIZE) != offset);
  1209. #endif /* just one plane */
  1210. #endif /* Cache is large */
  1211. #endif /* Cache exists */
  1212. }
  1213.  
  1214. #endif /* L_clear_cache */
  1215.  
  1216. #ifdef L_trampoline
  1217.  
  1218. /* Jump to a trampoline, loading the static chain address.  */
  1219.  
  1220. #ifdef TRANSFER_FROM_TRAMPOLINE 
  1221. TRANSFER_FROM_TRAMPOLINE 
  1222. #endif
  1223.  
  1224. #ifdef __convex__
  1225.  
  1226. /* Make stack executable so we can call trampolines on stack.
  1227.    This is called from INITIALIZE_TRAMPOLINE in convex.h.  */
  1228.  
  1229. #include <sys/mman.h>
  1230. #include <sys/vmparam.h>
  1231. #include <machine/machparam.h>
  1232.  
  1233. void
  1234. __enable_execute_stack ()
  1235. {
  1236.   int fp;
  1237.   static unsigned lowest = USRSTACK;
  1238.   unsigned current = (unsigned) &fp & -NBPG;
  1239.  
  1240.   if (lowest > current)
  1241.     {
  1242.       unsigned len = lowest - current;
  1243.       mremap (current, &len, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
  1244.       lowest = current;
  1245.     }
  1246.  
  1247.   /* Clear instruction cache in case an old trampoline is in it. */
  1248.   asm ("pich");
  1249. }
  1250. #endif /* __convex__ */
  1251. #endif /* L_trampoline */
  1252.  
  1253. #ifdef L__main
  1254.  
  1255. #include "gbl-ctors.h"
  1256.  
  1257. /* Run all the global destructors on exit from the program.  */
  1258.  
  1259. void
  1260. __do_global_dtors ()
  1261. {
  1262. #ifdef DO_GLOBAL_DTORS_BODY
  1263.   DO_GLOBAL_DTORS_BODY;
  1264. #else
  1265.   int nptrs = *(int *)__DTOR_LIST__;
  1266.   int i;
  1267.  
  1268.   /* Some systems place the number of pointers
  1269.      in the first word of the table.
  1270.      On other systems, that word is -1.
  1271.      In all cases, the table is null-terminated.  */
  1272.  
  1273.   /* If the length is not recorded, count up to the null.  */
  1274.   if (nptrs == -1)
  1275.     for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);
  1276.  
  1277.   /* GNU LD format.  */
  1278.   for (i = nptrs; i >= 1; i--)
  1279.     __DTOR_LIST__[i] ();
  1280. #endif
  1281. }
  1282.  
  1283. #ifndef INIT_SECTION_ASM_OP
  1284. /* Run all the global constructors on entry to the program.  */
  1285.  
  1286. #ifndef ON_EXIT
  1287. #define ON_EXIT(a, b)
  1288. #else
  1289. /* Make sure the exit routine is pulled in to define the globals as
  1290.    bss symbols, just in case the linker does not automatically pull
  1291.    bss definitions from the library.  */
  1292.  
  1293. extern int _exit_dummy_decl;
  1294. int *_exit_dummy_ref = &_exit_dummy_decl;
  1295. #endif /* ON_EXIT */
  1296.  
  1297. void
  1298. __do_global_ctors ()
  1299. {
  1300.   DO_GLOBAL_CTORS_BODY;
  1301.   ON_EXIT (__do_global_dtors, 0);
  1302. }
  1303.  
  1304. /* Subroutine called automatically by `main'.
  1305.    Compiling a global function named `main'
  1306.    produces an automatic call to this function at the beginning.
  1307.  
  1308.    For many systems, this routine calls __do_global_ctors.
  1309.    For systems which support a .init section we use the .init section
  1310.    to run __do_global_ctors, so we need not do anything here.  */
  1311.  
  1312. void
  1313. __main ()
  1314. {
  1315.   /* Support recursive calls to `main': run initializers just once.  */
  1316.   static initialized = 0;
  1317.   if (! initialized)
  1318.     {
  1319.       initialized = 1;
  1320.       __do_global_ctors ();
  1321.     }
  1322. }
  1323. #endif /* no INIT_SECTION_ASM_OP */
  1324.  
  1325. #endif /* L__main */
  1326.  
  1327. #ifdef L_exit
  1328.  
  1329. #include "gbl-ctors.h"
  1330.  
  1331. /* Provide default definitions for the lists of constructors and
  1332.    destructors, so that we don't get linker errors.  These symbols are
  1333.    intentionally bss symbols, so that gld and/or collect will provide
  1334.    the right values.  */
  1335.  
  1336. /* We declare the lists here with two elements each,
  1337.    so that they are valid empty lists if no other definition is loaded.  */
  1338. #ifndef INIT_SECTION_ASM_OP
  1339. func_ptr __CTOR_LIST__[2];
  1340. func_ptr __DTOR_LIST__[2];
  1341. #endif /* INIT_SECTION_ASM_OP */
  1342.  
  1343. #ifndef ON_EXIT
  1344.  
  1345. /* If we have no known way of registering our own __do_global_dtors
  1346.    routine so that it will be invoked at program exit time, then we
  1347.    have to define our own exit routine which will get this to happen.  */
  1348.  
  1349. extern void __do_global_dtors ();
  1350. extern void _cleanup ();
  1351. extern void _exit ();
  1352.  
  1353. void 
  1354. exit (status)
  1355.      int status;
  1356. {
  1357.   __do_global_dtors ();
  1358. #ifdef EXIT_BODY
  1359.   EXIT_BODY;
  1360. #else
  1361.   _cleanup ();
  1362. #endif
  1363.   _exit (status);
  1364. }
  1365.  
  1366. #else
  1367. int _exit_dummy_decl = 0;    /* prevent compiler & linker warnings */
  1368. #endif
  1369.  
  1370. #endif /* L_exit */
  1371.  
  1372. /* In a.out systems, we need to have these dummy constructor and destructor
  1373.    lists in the library.
  1374.  
  1375.    When using `collect', the first link will resolve __CTOR_LIST__
  1376.    and __DTOR_LIST__ to these symbols.  We will then run "nm" on the
  1377.    result, build the correct __CTOR_LIST__ and __DTOR_LIST__, and relink.
  1378.    Since we don't do the second link if no constructors existed, these
  1379.    dummies must be fully functional empty lists.
  1380.  
  1381.    When using `gnu ld', these symbols will be used if there are no
  1382.    constructors.  If there are constructors, the N_SETV symbol defined
  1383.    by the linker from the N_SETT's in input files will define __CTOR_LIST__
  1384.    and __DTOR_LIST__ rather than its being allocated as common storage
  1385.    by the definitions below.
  1386.  
  1387.    When using a linker that supports constructor and destructor segments,
  1388.    these definitions will not be used, since crtbegin.o and crtend.o
  1389.    (from crtstuff.c) will have already defined __CTOR_LIST__ and
  1390.     __DTOR_LIST__.  The crt*.o files are passed directly to the linker
  1391.    on its command line, by gcc.  */
  1392.  
  1393. /* The list needs two elements:  one is ignored (the old count); the
  1394.    second is the terminating zero.  Since both values are zero, this
  1395.    declaration is not initialized, and it becomes `common'.  */
  1396.  
  1397. #ifdef L_ctor_list
  1398. #include "gbl-ctors.h"
  1399. func_ptr __CTOR_LIST__[2];
  1400. #endif
  1401.  
  1402. #ifdef L_dtor_list
  1403. #include "gbl-ctors.h"
  1404. func_ptr __DTOR_LIST__[2];
  1405. #endif
  1406. @
  1407.