home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / libgcc2.c < prev    next >
C/C++ Source or Header  |  1993-06-17  |  28KB  |  1,357 lines

  1. /* More subroutines needed by GCC output code on some machines.  */
  2. /* Compile this one with gcc.  */
  3. /* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* As a special exception, if you link this library with files
  22.    compiled with GCC to produce an executable, this does not cause
  23.    the resulting executable to be covered by the GNU General Public License.
  24.    This exception does not however invalidate any other reasons why
  25.    the executable file might be covered by the GNU General Public License.  */
  26.  
  27. #ifndef atarist
  28.  
  29. /* It is incorrect to include config.h here, because this file is being
  30.    compiled for the target, and hence definitions concerning only the host
  31.    do not apply.  */
  32.  
  33. #include "tconfig.h"
  34. #include "machmode.h"
  35. #ifndef L_trampoline
  36. #include "gstddef.h"
  37. #endif
  38.  
  39. #else
  40.  
  41. /* For the atari, include the relevant parts of config/m68k.h directly. */
  42.  
  43. #ifndef __mc68000__
  44. #define __mc68000__ 1
  45. #ifdef __M68020__
  46. #define __mc68020__ 1
  47. #endif
  48. #endif
  49.  
  50. #if __GNUC__ < 2
  51. #error This file is for GCC version 2 only.
  52. #endif
  53.  
  54. #ifndef L_trampoline
  55. #include <stddef.h>
  56. #endif
  57.  
  58. /* Define this if most significant byte of a word is the lowest numbered.  */
  59. /* That is true on the 68000.  */
  60. #define BYTES_BIG_ENDIAN 1
  61.  
  62. /* Define this if most significant word of a multiword number is the lowest
  63.    numbered.  */
  64. /* For 68000 we can decide arbitrarily
  65.    since there are no machine instructions for them.
  66.    So let's be consistent.  */
  67. #define WORDS_BIG_ENDIAN 1
  68.  
  69. /* number of bits in an addressable storage unit */
  70. #define BITS_PER_UNIT 8
  71.  
  72. /* for this file this is always true, never compile anything in here with
  73.    -mshort */
  74. #define BITS_PER_WORD 32
  75.  
  76. /* This is the library routine that is used
  77.    to transfer control from the trampoline
  78.    to the actual nested function.  */
  79.  
  80. /* A colon is used with no explicit operands
  81.    to cause the template string to be scanned for %-constructs.  */
  82. /* The function name __transfer_from_trampoline is not actually used.
  83.    The function definition just permits use of "asm with operands"
  84.    (though the operand list is empty).  */
  85. #define TRANSFER_FROM_TRAMPOLINE                \
  86. void                                \
  87. __transfer_from_trampoline ()                    \
  88. {                                \
  89.   register char *a0 asm ("%a0");                \
  90.   asm (".globl ___trampoline");                    \
  91.   asm ("___trampoline:");                    \
  92.   asm volatile ("move%.l %0,%@" : : "m" (a0[22]));        \
  93.   asm volatile ("move%.l %1,%0" : "=a" (a0) : "m" (a0[18]));    \
  94.   asm ("rts":);                            \
  95. }
  96.  
  97. #endif /* atarist */
  98.  
  99. /* In the first part of this file, we are interfacing to calls generated
  100.    by the compiler itself.  These calls pass values into these routines
  101.    which have very specific modes (rather than very specific types), and
  102.    these compiler-generated calls also expect any return values to have
  103.    very specific modes (rather than very specific types).  Thus, we need
  104.    to avoid using regular C language type names in this part of the file
  105.    because the sizes for those types can be configured to be anything.
  106.    Instead we use the following special type names.  */
  107.  
  108. typedef unsigned int UQItype    __attribute__ ((mode (QI)));
  109. typedef      int SItype    __attribute__ ((mode (SI)));
  110. typedef unsigned int USItype    __attribute__ ((mode (SI)));
  111. typedef         int DItype    __attribute__ ((mode (DI)));
  112. typedef unsigned int UDItype    __attribute__ ((mode (DI)));
  113. typedef     float SFtype    __attribute__ ((mode (SF)));
  114. typedef        float DFtype    __attribute__ ((mode (DF)));
  115. #if LONG_DOUBLE_TYPE_SIZE == 96
  116. typedef        float XFtype    __attribute__ ((mode (XF)));
  117. #endif
  118. #if LONG_DOUBLE_TYPE_SIZE == 128
  119. typedef        float TFtype    __attribute__ ((mode (TF)));
  120. #endif
  121.  
  122. #if BITS_PER_WORD==16
  123. typedef int word_type __attribute__ ((mode (HI)));
  124. #endif
  125. #if BITS_PER_WORD==32
  126. typedef int word_type __attribute__ ((mode (SI)));
  127. #endif
  128. #if BITS_PER_WORD==64
  129. typedef int word_type __attribute__ ((mode (DI)));
  130. #endif
  131.  
  132. /* Make sure that we don't accidentally use any normal C language built-in
  133.    type names in the first part of this file.  Instead we want to use *only*
  134.    the type names defined above.  The following macro definitions insure
  135.    that if we *do* accidentally use some normal C language built-in type name,
  136.    we will get a syntax error.  */
  137.  
  138. #define char bogus_type
  139. #define short bogus_type
  140. #define int bogus_type
  141. #define long bogus_type
  142. #define unsigned bogus_type
  143. #define float bogus_type
  144. #define double bogus_type
  145.  
  146. #define SI_TYPE_SIZE (sizeof (SItype) * BITS_PER_UNIT)
  147.  
  148. /* DIstructs are pairs of SItype values in the order determined by
  149.    WORDS_BIG_ENDIAN.  */
  150.  
  151. #if WORDS_BIG_ENDIAN
  152.   struct DIstruct {SItype high, low;};
  153. #else
  154.   struct DIstruct {SItype low, high;};
  155. #endif
  156.  
  157. /* We need this union to unpack/pack DImode values, since we don't have
  158.    any arithmetic yet.  Incoming DImode parameters are stored into the
  159.    `ll' field, and the unpacked result is read from the struct `s'.  */
  160.  
  161. typedef union
  162. {
  163.   struct DIstruct s;
  164.   DItype ll;
  165. } DIunion;
  166.  
  167. #if defined (L_udivmoddi4) || defined (L_muldi3) || defined (L_udiv_w_sdiv)
  168.  
  169. #include "longlong.h"
  170.  
  171. #endif /* udiv or mul */
  172.  
  173. extern DItype __fixunssfdi (SFtype a);
  174. extern DItype __fixunsdfdi (DFtype a);
  175.  
  176. #if defined (L_negdi2) || defined (L_divdi3) || defined (L_moddi3)
  177. #if defined (L_divdi3) || defined (L_moddi3)
  178. static inline
  179. #endif
  180. DItype
  181. __negdi2 (u)
  182.      DItype u;
  183. {
  184.   DIunion w;
  185.   DIunion uu;
  186.  
  187.   uu.ll = u;
  188.  
  189.   w.s.low = -uu.s.low;
  190.   w.s.high = -uu.s.high - ((USItype) w.s.low > 0);
  191.  
  192.   return w.ll;
  193. }
  194. #endif
  195.  
  196. #ifdef L_lshldi3
  197. DItype
  198. __lshldi3 (u, b)
  199.      DItype u;
  200.      SItype b;
  201. {
  202.   DIunion w;
  203.   SItype bm;
  204.   DIunion uu;
  205.  
  206.   if (b == 0)
  207.     return u;
  208.  
  209.   uu.ll = u;
  210.  
  211.   bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
  212.   if (bm <= 0)
  213.     {
  214.       w.s.low = 0;
  215.       w.s.high = (USItype)uu.s.low << -bm;
  216.     }
  217.   else
  218.     {
  219.       USItype carries = (USItype)uu.s.low >> bm;
  220.       w.s.low = (USItype)uu.s.low << b;
  221.       w.s.high = ((USItype)uu.s.high << b) | carries;
  222.     }
  223.  
  224.   return w.ll;
  225. }
  226. #endif
  227.  
  228. #ifdef L_lshrdi3
  229. DItype
  230. __lshrdi3 (u, b)
  231.      DItype u;
  232.      SItype b;
  233. {
  234.   DIunion w;
  235.   SItype bm;
  236.   DIunion uu;
  237.  
  238.   if (b == 0)
  239.     return u;
  240.  
  241.   uu.ll = u;
  242.  
  243.   bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
  244.   if (bm <= 0)
  245.     {
  246.       w.s.high = 0;
  247.       w.s.low = (USItype)uu.s.high >> -bm;
  248.     }
  249.   else
  250.     {
  251.       USItype carries = (USItype)uu.s.high << bm;
  252.       w.s.high = (USItype)uu.s.high >> b;
  253.       w.s.low = ((USItype)uu.s.low >> b) | carries;
  254.     }
  255.  
  256.   return w.ll;
  257. }
  258. #endif
  259.  
  260. #ifdef L_ashldi3
  261. DItype
  262. __ashldi3 (u, b)
  263.      DItype u;
  264.      SItype b;
  265. {
  266.   DIunion w;
  267.   SItype bm;
  268.   DIunion uu;
  269.  
  270.   if (b == 0)
  271.     return u;
  272.  
  273.   uu.ll = u;
  274.  
  275.   bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
  276.   if (bm <= 0)
  277.     {
  278.       w.s.low = 0;
  279.       w.s.high = (USItype)uu.s.low << -bm;
  280.     }
  281.   else
  282.     {
  283.       USItype carries = (USItype)uu.s.low >> bm;
  284.       w.s.low = (USItype)uu.s.low << b;
  285.       w.s.high = ((USItype)uu.s.high << b) | carries;
  286.     }
  287.  
  288.   return w.ll;
  289. }
  290. #endif
  291.  
  292. #ifdef L_ashrdi3
  293. DItype
  294. __ashrdi3 (u, b)
  295.      DItype u;
  296.      SItype b;
  297. {
  298.   DIunion w;
  299.   SItype bm;
  300.   DIunion uu;
  301.  
  302.   if (b == 0)
  303.     return u;
  304.  
  305.   uu.ll = u;
  306.  
  307.   bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
  308.   if (bm <= 0)
  309.     {
  310.       /* w.s.high = 1..1 or 0..0 */
  311.       w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1);
  312.       w.s.low = uu.s.high >> -bm;
  313.     }
  314.   else
  315.     {
  316.       USItype carries = (USItype)uu.s.high << bm;
  317.       w.s.high = uu.s.high >> b;
  318.       w.s.low = ((USItype)uu.s.low >> b) | carries;
  319.     }
  320.  
  321.   return w.ll;
  322. }
  323. #endif
  324.  
  325. #ifdef L_ffsdi2
  326. DItype
  327. __ffsdi2 (u)
  328.      DItype u;
  329. {
  330.   DIunion uu, w;
  331.   uu.ll = u;
  332.   w.s.high = 0;
  333.   w.s.low = ffs (uu.s.low);
  334.   if (w.s.low != 0)
  335.     return w.ll;
  336.   w.s.low = ffs (uu.s.high);
  337.   if (w.s.low != 0)
  338.     {
  339.       w.s.low += BITS_PER_UNIT * sizeof (SItype);
  340.       return w.ll;
  341.     }
  342.   return w.ll;
  343. }
  344. #endif
  345.  
  346. #ifdef L_muldi3
  347. DItype
  348. __muldi3 (u, v)
  349.      DItype u, v;
  350. {
  351.   DIunion w;
  352.   DIunion uu, vv;
  353.  
  354.   uu.ll = u,
  355.   vv.ll = v;
  356.  
  357.   w.ll = __umulsidi3 (uu.s.low, vv.s.low);
  358.   w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high
  359.            + (USItype) uu.s.high * (USItype) vv.s.low);
  360.  
  361.   return w.ll;
  362. }
  363. #endif
  364.  
  365. #ifdef L_udiv_w_sdiv
  366. USItype
  367. __udiv_w_sdiv (rp, a1, a0, d)
  368.      USItype *rp, a1, a0, d;
  369. {
  370.   USItype q, r;
  371.   USItype c0, c1, b1;
  372.  
  373.   if ((SItype) d >= 0)
  374.     {
  375.       if (a1 < d - a1 - (a0 >> (SI_TYPE_SIZE - 1)))
  376.     {
  377.       /* dividend, divisor, and quotient are nonnegative */
  378.       sdiv_qrnnd (q, r, a1, a0, d);
  379.     }
  380.       else
  381.     {
  382.       /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d */
  383.       sub_ddmmss (c1, c0, a1, a0, d >> 1, d << (SI_TYPE_SIZE - 1));
  384.       /* Divide (c1*2^32 + c0) by d */
  385.       sdiv_qrnnd (q, r, c1, c0, d);
  386.       /* Add 2^31 to quotient */
  387.       q += (USItype) 1 << (SI_TYPE_SIZE - 1);
  388.     }
  389.     }
  390.   else
  391.     {
  392.       b1 = d >> 1;            /* d/2, between 2^30 and 2^31 - 1 */
  393.       c1 = a1 >> 1;            /* A/2 */
  394.       c0 = (a1 << (SI_TYPE_SIZE - 1)) + (a0 >> 1);
  395.  
  396.       if (a1 < b1)            /* A < 2^32*b1, so A/2 < 2^31*b1 */
  397.     {
  398.       sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
  399.  
  400.       r = 2*r + (a0 & 1);        /* Remainder from A/(2*b1) */
  401.       if ((d & 1) != 0)
  402.         {
  403.           if (r >= q)
  404.         r = r - q;
  405.           else if (q - r <= d)
  406.         {
  407.           r = r - q + d;
  408.           q--;
  409.         }
  410.           else
  411.         {
  412.           r = r - q + 2*d;
  413.           q -= 2;
  414.         }
  415.         }
  416.     }
  417.       else if (c1 < b1)            /* So 2^31 <= (A/2)/b1 < 2^32 */
  418.     {
  419.       c1 = (b1 - 1) - c1;
  420.       c0 = ~c0;            /* logical NOT */
  421.  
  422.       sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
  423.  
  424.       q = ~q;            /* (A/2)/b1 */
  425.       r = (b1 - 1) - r;
  426.  
  427.       r = 2*r + (a0 & 1);        /* A/(2*b1) */
  428.  
  429.       if ((d & 1) != 0)
  430.         {
  431.           if (r >= q)
  432.         r = r - q;
  433.           else if (q - r <= d)
  434.         {
  435.           r = r - q + d;
  436.           q--;
  437.         }
  438.           else
  439.         {
  440.           r = r - q + 2*d;
  441.           q -= 2;
  442.         }
  443.         }
  444.     }
  445.       else                /* Implies c1 = b1 */
  446.     {                /* Hence a1 = d - 1 = 2*b1 - 1 */
  447.       if (a0 >= -d)
  448.         {
  449.           q = -1;
  450.           r = a0 + d;
  451.         }
  452.       else
  453.         {
  454.           q = -2;
  455.           r = a0 + 2*d;
  456.         }
  457.     }
  458.     }
  459.  
  460.   *rp = r;
  461.   return q;
  462. }
  463. #endif
  464.  
  465. #ifdef L_udivmoddi4
  466. static const UQItype __clz_tab[] =
  467. {
  468.   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,
  469.   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,
  470.   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,
  471.   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,
  472.   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,
  473.   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,
  474.   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,
  475.   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,
  476. };
  477.  
  478. UDItype
  479. __udivmoddi4 (n, d, rp)
  480.      UDItype n, d;
  481.      UDItype *rp;
  482. {
  483.   DIunion ww;
  484.   DIunion nn, dd;
  485.   DIunion rr;
  486.   USItype d0, d1, n0, n1, n2;
  487.   USItype q0, q1;
  488.   USItype b, bm;
  489.  
  490.   nn.ll = n;
  491.   dd.ll = d;
  492.  
  493.   d0 = dd.s.low;
  494.   d1 = dd.s.high;
  495.   n0 = nn.s.low;
  496.   n1 = nn.s.high;
  497.  
  498. #if !UDIV_NEEDS_NORMALIZATION
  499.   if (d1 == 0)
  500.     {
  501.       if (d0 > n1)
  502.     {
  503.       /* 0q = nn / 0D */
  504.  
  505.       udiv_qrnnd (q0, n0, n1, n0, d0);
  506.       q1 = 0;
  507.  
  508.       /* Remainder in n0.  */
  509.     }
  510.       else
  511.     {
  512.       /* qq = NN / 0d */
  513.  
  514.       if (d0 == 0)
  515.         d0 = 1 / d0;    /* Divide intentionally by zero.  */
  516.  
  517.       udiv_qrnnd (q1, n1, 0, n1, d0);
  518.       udiv_qrnnd (q0, n0, n1, n0, d0);
  519.  
  520.       /* Remainder in n0.  */
  521.     }
  522.  
  523.       if (rp != 0)
  524.     {
  525.       rr.s.low = n0;
  526.       rr.s.high = 0;
  527.       *rp = rr.ll;
  528.     }
  529.     }
  530.  
  531. #else /* UDIV_NEEDS_NORMALIZATION */
  532.  
  533.   if (d1 == 0)
  534.     {
  535.       if (d0 > n1)
  536.     {
  537.       /* 0q = nn / 0D */
  538.  
  539.       count_leading_zeros (bm, d0);
  540.  
  541.       if (bm != 0)
  542.         {
  543.           /* Normalize, i.e. make the most significant bit of the
  544.          denominator set.  */
  545.  
  546.           d0 = d0 << bm;
  547.           n1 = (n1 << bm) | (n0 >> (SI_TYPE_SIZE - bm));
  548.           n0 = n0 << bm;
  549.         }
  550.  
  551.       udiv_qrnnd (q0, n0, n1, n0, d0);
  552.       q1 = 0;
  553.  
  554.       /* Remainder in n0 >> bm.  */
  555.     }
  556.       else
  557.     {
  558.       /* qq = NN / 0d */
  559.  
  560.       if (d0 == 0)
  561.         d0 = 1 / d0;    /* Divide intentionally by zero.  */
  562.  
  563.       count_leading_zeros (bm, d0);
  564.  
  565.       if (bm == 0)
  566.         {
  567.           /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
  568.          conclude (the most significant bit of n1 is set) /\ (the
  569.          leading quotient digit q1 = 1).
  570.  
  571.          This special case is necessary, not an optimization.
  572.          (Shifts counts of SI_TYPE_SIZE are undefined.)  */
  573.  
  574.           n1 -= d0;
  575.           q1 = 1;
  576.         }
  577.       else
  578.         {
  579.           /* Normalize.  */
  580.  
  581.           b = SI_TYPE_SIZE - bm;
  582.  
  583.           d0 = d0 << bm;
  584.           n2 = n1 >> b;
  585.           n1 = (n1 << bm) | (n0 >> b);
  586.           n0 = n0 << bm;
  587.  
  588.           udiv_qrnnd (q1, n1, n2, n1, d0);
  589.         }
  590.  
  591.       /* n1 != d0... */
  592.  
  593.       udiv_qrnnd (q0, n0, n1, n0, d0);
  594.  
  595.       /* Remainder in n0 >> bm.  */
  596.     }
  597.  
  598.       if (rp != 0)
  599.     {
  600.       rr.s.low = n0 >> bm;
  601.       rr.s.high = 0;
  602.       *rp = rr.ll;
  603.     }
  604.     }
  605. #endif /* UDIV_NEEDS_NORMALIZATION */
  606.  
  607.   else
  608.     {
  609.       if (d1 > n1)
  610.     {
  611.       /* 00 = nn / DD */
  612.  
  613.       q0 = 0;
  614.       q1 = 0;
  615.  
  616.       /* Remainder in n1n0.  */
  617.       if (rp != 0)
  618.         {
  619.           rr.s.low = n0;
  620.           rr.s.high = n1;
  621.           *rp = rr.ll;
  622.         }
  623.     }
  624.       else
  625.     {
  626.       /* 0q = NN / dd */
  627.  
  628.       count_leading_zeros (bm, d1);
  629.       if (bm == 0)
  630.         {
  631.           /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
  632.          conclude (the most significant bit of n1 is set) /\ (the
  633.          quotient digit q0 = 0 or 1).
  634.  
  635.          This special case is necessary, not an optimization.  */
  636.  
  637.           /* The condition on the next line takes advantage of that
  638.          n1 >= d1 (true due to program flow).  */
  639.           if (n1 > d1 || n0 >= d0)
  640.         {
  641.           q0 = 1;
  642.           sub_ddmmss (n1, n0, n1, n0, d1, d0);
  643.         }
  644.           else
  645.         q0 = 0;
  646.  
  647.           q1 = 0;
  648.  
  649.           if (rp != 0)
  650.         {
  651.           rr.s.low = n0;
  652.           rr.s.high = n1;
  653.           *rp = rr.ll;
  654.         }
  655.         }
  656.       else
  657.         {
  658.           USItype m1, m0;
  659.           /* Normalize.  */
  660.  
  661.           b = SI_TYPE_SIZE - bm;
  662.  
  663.           d1 = (d1 << bm) | (d0 >> b);
  664.           d0 = d0 << bm;
  665.           n2 = n1 >> b;
  666.           n1 = (n1 << bm) | (n0 >> b);
  667.           n0 = n0 << bm;
  668.  
  669.           udiv_qrnnd (q0, n1, n2, n1, d1);
  670.           umul_ppmm (m1, m0, q0, d0);
  671.  
  672.           if (m1 > n1 || (m1 == n1 && m0 > n0))
  673.         {
  674.           q0--;
  675.           sub_ddmmss (m1, m0, m1, m0, d1, d0);
  676.         }
  677.  
  678.           q1 = 0;
  679.  
  680.           /* Remainder in (n1n0 - m1m0) >> bm.  */
  681.           if (rp != 0)
  682.         {
  683.           sub_ddmmss (n1, n0, n1, n0, m1, m0);
  684.           rr.s.low = (n1 << b) | (n0 >> bm);
  685.           rr.s.high = n1 >> bm;
  686.           *rp = rr.ll;
  687.         }
  688.         }
  689.     }
  690.     }
  691.  
  692.   ww.s.low = q0;
  693.   ww.s.high = q1;
  694.   return ww.ll;
  695. }
  696. #endif
  697.  
  698. #ifdef L_divdi3
  699. UDItype __udivmoddi4 ();
  700. DItype
  701. __divdi3 (u, v)
  702.      DItype u, v;
  703. {
  704.   SItype c = 0;
  705.   DIunion uu, vv;
  706.   DItype w;
  707.  
  708.   uu.ll = u;
  709.   vv.ll = v;
  710.  
  711.   if (uu.s.high < 0)
  712.     c = ~c,
  713.     uu.ll = __negdi2 (uu.ll);
  714.   if (vv.s.high < 0)
  715.     c = ~c,
  716.     vv.ll = __negdi2 (vv.ll);
  717.  
  718.   w = __udivmoddi4 (uu.ll, vv.ll, (UDItype *) 0);
  719.   if (c)
  720.     w = __negdi2 (w);
  721.  
  722.   return w;
  723. }
  724. #endif
  725.  
  726. #ifdef L_moddi3
  727. UDItype __udivmoddi4 ();
  728. DItype
  729. __moddi3 (u, v)
  730.      DItype u, v;
  731. {
  732.   SItype c = 0;
  733.   DIunion uu, vv;
  734.   DItype w;
  735.  
  736.   uu.ll = u;
  737.   vv.ll = v;
  738.  
  739.   if (uu.s.high < 0)
  740.     c = ~c,
  741.     uu.ll = __negdi2 (uu.ll);
  742.   if (vv.s.high < 0)
  743.     vv.ll = __negdi2 (vv.ll);
  744.  
  745.   (void) __udivmoddi4 (uu.ll, vv.ll, &w);
  746.   if (c)
  747.     w = __negdi2 (w);
  748.  
  749.   return w;
  750. }
  751. #endif
  752.  
  753. #ifdef L_umoddi3
  754. UDItype __udivmoddi4 ();
  755. UDItype
  756. __umoddi3 (u, v)
  757.      UDItype u, v;
  758. {
  759.   DItype w;
  760.  
  761.   (void) __udivmoddi4 (u, v, &w);
  762.  
  763.   return w;
  764. }
  765. #endif
  766.  
  767. #ifdef L_udivdi3
  768. UDItype __udivmoddi4 ();
  769. UDItype
  770. __udivdi3 (n, d)
  771.      UDItype n, d;
  772. {
  773.   return __udivmoddi4 (n, d, (UDItype *) 0);
  774. }
  775. #endif
  776.  
  777. #ifdef L_cmpdi2
  778. word_type
  779. __cmpdi2 (a, b)
  780.      DItype a, b;
  781. {
  782.   DIunion au, bu;
  783.  
  784.   au.ll = a, bu.ll = b;
  785.  
  786.   if (au.s.high < bu.s.high)
  787.     return 0;
  788.   else if (au.s.high > bu.s.high)
  789.     return 2;
  790.   if ((USItype) au.s.low < (USItype) bu.s.low)
  791.     return 0;
  792.   else if ((USItype) au.s.low > (USItype) bu.s.low)
  793.     return 2;
  794.   return 1;
  795. }
  796. #endif
  797.  
  798. #ifdef L_ucmpdi2
  799. word_type
  800. __ucmpdi2 (a, b)
  801.      DItype a, b;
  802. {
  803.   DIunion au, bu;
  804.  
  805.   au.ll = a, bu.ll = b;
  806.  
  807.   if ((USItype) au.s.high < (USItype) bu.s.high)
  808.     return 0;
  809.   else if ((USItype) au.s.high > (USItype) bu.s.high)
  810.     return 2;
  811.   if ((USItype) au.s.low < (USItype) bu.s.low)
  812.     return 0;
  813.   else if ((USItype) au.s.low > (USItype) bu.s.low)
  814.     return 2;
  815.   return 1;
  816. }
  817. #endif
  818.  
  819. #if defined(L_fixunstfdi) && (LONG_DOUBLE_TYPE_SIZE == 128)
  820. #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
  821. #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)
  822.  
  823. DItype
  824. __fixunstfdi (a)
  825.      TFtype a;
  826. {
  827.   TFtype b;
  828.   UDItype v;
  829.  
  830.   if (a < 0)
  831.     return 0;
  832.  
  833.   /* Compute high word of result, as a flonum.  */
  834.   b = (a / HIGH_WORD_COEFF);
  835.   /* Convert that to fixed (but not to DItype!),
  836.      and shift it into the high word.  */
  837.   v = (USItype) b;
  838.   v <<= WORD_SIZE;
  839.   /* Remove high part from the TFtype, leaving the low part as flonum.  */
  840.   a -= (TFtype)v;
  841.   /* Convert that to fixed (but not to DItype!) and add it in.
  842.      Sometimes A comes out negative.  This is significant, since
  843.      A has more bits than a long int does.  */
  844.   if (a < 0)
  845.     v -= (USItype) (- a);
  846.   else
  847.     v += (USItype) a;
  848.   return v;
  849. }
  850. #endif
  851.  
  852. #if defined(L_fixtfdi) && (LONG_DOUBLE_TYPE_SIZE == 128)
  853. DItype
  854. __fixtfdi (a)
  855.      TFtype a;
  856. {
  857.   if (a < 0)
  858.     return - __fixunstfdi (-a);
  859.   return __fixunstfdi (a);
  860. }
  861. #endif
  862.  
  863. #if defined(L_fixunsxfdi) && (LONG_DOUBLE_TYPE_SIZE == 96)
  864. #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
  865. #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)
  866.  
  867. DItype
  868. __fixunsxfdi (a)
  869.      XFtype a;
  870. {
  871.   XFtype b;
  872.   UDItype v;
  873.  
  874.   if (a < 0)
  875.     return 0;
  876.  
  877.   /* Compute high word of result, as a flonum.  */
  878.   b = (a / HIGH_WORD_COEFF);
  879.   /* Convert that to fixed (but not to DItype!),
  880.      and shift it into the high word.  */
  881.   v = (USItype) b;
  882.   v <<= WORD_SIZE;
  883.   /* Remove high part from the XFtype, leaving the low part as flonum.  */
  884.   a -= (XFtype)v;
  885.   /* Convert that to fixed (but not to DItype!) and add it in.
  886.      Sometimes A comes out negative.  This is significant, since
  887.      A has more bits than a long int does.  */
  888.   if (a < 0)
  889.     v -= (USItype) (- a);
  890.   else
  891.     v += (USItype) a;
  892.   return v;
  893. }
  894. #endif
  895.  
  896. #if defined(L_fixxfdi) && (LONG_DOUBLE_TYPE_SIZE == 96)
  897. DItype
  898. __fixxfdi (a)
  899.      XFtype a;
  900. {
  901.   if (a < 0)
  902.     return - __fixunsxfdi (-a);
  903.   return __fixunsxfdi (a);
  904. }
  905. #endif
  906.  
  907. #ifdef L_fixunsdfdi
  908. #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
  909. #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)
  910.  
  911. DItype
  912. __fixunsdfdi (a)
  913.      DFtype a;
  914. {
  915.   DFtype b;
  916.   UDItype v;
  917.  
  918.   if (a < 0)
  919.     return 0;
  920.  
  921.   /* Compute high word of result, as a flonum.  */
  922.   b = (a / HIGH_WORD_COEFF);
  923.   /* Convert that to fixed (but not to DItype!),
  924.      and shift it into the high word.  */
  925.   v = (USItype) b;
  926.   v <<= WORD_SIZE;
  927.   /* Remove high part from the DFtype, leaving the low part as flonum.  */
  928.   a -= (DFtype)v;
  929.   /* Convert that to fixed (but not to DItype!) and add it in.
  930.      Sometimes A comes out negative.  This is significant, since
  931.      A has more bits than a long int does.  */
  932.   if (a < 0)
  933.     v -= (USItype) (- a);
  934.   else
  935.     v += (USItype) a;
  936.   return v;
  937. }
  938. #endif
  939.  
  940. #ifdef L_fixdfdi
  941. DItype
  942. __fixdfdi (a)
  943.      DFtype a;
  944. {
  945.   if (a < 0)
  946.     return - __fixunsdfdi (-a);
  947.   return __fixunsdfdi (a);
  948. }
  949. #endif
  950.  
  951. #ifdef L_fixunssfdi
  952. #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
  953. #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)
  954.  
  955. DItype
  956. __fixunssfdi (SFtype original_a)
  957. {
  958.   /* Convert the SFtype to a DFtype, because that is surely not going
  959.      to lose any bits.  Some day someone else can write a faster version
  960.      that avoids converting to DFtype, and verify it really works right.  */
  961.   DFtype a = original_a;
  962.   DFtype b;
  963.   UDItype v;
  964.  
  965.   if (a < 0)
  966.     return 0;
  967.  
  968.   /* Compute high word of result, as a flonum.  */
  969.   b = (a / HIGH_WORD_COEFF);
  970.   /* Convert that to fixed (but not to DItype!),
  971.      and shift it into the high word.  */
  972.   v = (USItype) b;
  973.   v <<= WORD_SIZE;
  974.   /* Remove high part from the DFtype, leaving the low part as flonum.  */
  975.   a -= (DFtype)v;
  976.   /* Convert that to fixed (but not to DItype!) and add it in.
  977.      Sometimes A comes out negative.  This is significant, since
  978.      A has more bits than a long int does.  */
  979.   if (a < 0)
  980.     v -= (USItype) (- a);
  981.   else
  982.     v += (USItype) a;
  983.   return v;
  984. }
  985. #endif
  986.  
  987. #ifdef L_fixsfdi
  988. DItype
  989. __fixsfdi (SFtype a)
  990. {
  991.   if (a < 0)
  992.     return - __fixunssfdi (-a);
  993.   return __fixunssfdi (a);
  994. }
  995. #endif
  996.  
  997. #if defined(L_floatdixf) && (LONG_DOUBLE_TYPE_SIZE == 96)
  998. #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
  999. #define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2))
  1000. #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)
  1001.  
  1002. XFtype
  1003. __floatdixf (u)
  1004.      DItype u;
  1005. {
  1006.   XFtype d;
  1007.   SItype negate = 0;
  1008.  
  1009.   if (u < 0)
  1010.     u = -u, negate = 1;
  1011.  
  1012.   d = (USItype) (u >> WORD_SIZE);
  1013.   d *= HIGH_HALFWORD_COEFF;
  1014.   d *= HIGH_HALFWORD_COEFF;
  1015.   d += (USItype) (u & (HIGH_WORD_COEFF - 1));
  1016.  
  1017.   return (negate ? -d : d);
  1018. }
  1019. #endif
  1020.  
  1021. #if defined(L_floatditf) && (LONG_DOUBLE_TYPE_SIZE == 128)
  1022. #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
  1023. #define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2))
  1024. #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)
  1025.  
  1026. TFtype
  1027. __floatditf (u)
  1028.      DItype u;
  1029. {
  1030.   TFtype d;
  1031.   SItype negate = 0;
  1032.  
  1033.   if (u < 0)
  1034.     u = -u, negate = 1;
  1035.  
  1036.   d = (USItype) (u >> WORD_SIZE);
  1037.   d *= HIGH_HALFWORD_COEFF;
  1038.   d *= HIGH_HALFWORD_COEFF;
  1039.   d += (USItype) (u & (HIGH_WORD_COEFF - 1));
  1040.  
  1041.   return (negate ? -d : d);
  1042. }
  1043. #endif
  1044.  
  1045. #ifdef L_floatdidf
  1046. #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
  1047. #define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2))
  1048. #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)
  1049.  
  1050. DFtype
  1051. __floatdidf (u)
  1052.      DItype u;
  1053. {
  1054.   DFtype d;
  1055.   SItype negate = 0;
  1056.  
  1057.   if (u < 0)
  1058.     u = -u, negate = 1;
  1059.  
  1060.   d = (USItype) (u >> WORD_SIZE);
  1061.   d *= HIGH_HALFWORD_COEFF;
  1062.   d *= HIGH_HALFWORD_COEFF;
  1063.   d += (USItype) (u & (HIGH_WORD_COEFF - 1));
  1064.  
  1065.   return (negate ? -d : d);
  1066. }
  1067. #endif
  1068.  
  1069. #ifdef L_floatdisf
  1070. #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
  1071. #define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2))
  1072. #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)
  1073.  
  1074. SFtype
  1075. __floatdisf (u)
  1076.      DItype u;
  1077. {
  1078.   /* Do the calculation in DFmode
  1079.      so that we don't lose any of the precision of the high word
  1080.      while multiplying it.  */
  1081.   DFtype f;
  1082.   SItype negate = 0;
  1083.  
  1084.   if (u < 0)
  1085.     u = -u, negate = 1;
  1086.  
  1087.   f = (USItype) (u >> WORD_SIZE);
  1088.   f *= HIGH_HALFWORD_COEFF;
  1089.   f *= HIGH_HALFWORD_COEFF;
  1090.   f += (USItype) (u & (HIGH_WORD_COEFF - 1));
  1091.  
  1092.   return (SFtype) (negate ? -f : f);
  1093. }
  1094. #endif
  1095.  
  1096. #if defined(L_fixunsxfsi) && LONG_DOUBLE_TYPE_SIZE == 96
  1097. #include "glimits.h"
  1098.  
  1099. USItype
  1100. __fixunsxfsi (a)
  1101.      XFtype a;
  1102. {
  1103.   if (a >= - (DFtype) LONG_MIN)
  1104.     return (SItype) (a + LONG_MIN) - LONG_MIN;
  1105.   return (SItype) a;
  1106. }
  1107. #endif
  1108.  
  1109. #ifdef L_fixunsdfsi
  1110. #include <limits.h>
  1111.  
  1112. USItype
  1113. __fixunsdfsi (a)
  1114.      DFtype a;
  1115. {
  1116.   if (a >= - (DFtype) LONG_MIN)
  1117.     return (SItype) (a + LONG_MIN) - LONG_MIN;
  1118.   return (SItype) a;
  1119. }
  1120. #endif
  1121.  
  1122. #ifdef L_fixunssfsi
  1123. #include <limits.h>
  1124.  
  1125. USItype
  1126. __fixunssfsi (SFtype a)
  1127. {
  1128.   if (a >= - (SFtype) LONG_MIN)
  1129.     return (SItype) (a + LONG_MIN) - LONG_MIN;
  1130.   return (SItype) a;
  1131. }
  1132. #endif
  1133.  
  1134. /* From here on down, the routines use normal data types.  */
  1135.  
  1136. #define SItype bogus_type
  1137. #define USItype bogus_type
  1138. #define DItype bogus_type
  1139. #define UDItype bogus_type
  1140. #define SFtype bogus_type
  1141. #define DFtype bogus_type
  1142.  
  1143. #undef char
  1144. #undef short
  1145. #undef int
  1146. #undef long
  1147. #undef unsigned
  1148. #undef float
  1149. #undef double
  1150.  
  1151. /* frills for C++ */
  1152.  
  1153. #ifdef L_builtin_new
  1154. #include <memory.h>
  1155.  
  1156. typedef void (*vfp)(void);
  1157.  
  1158. extern vfp __new_handler;
  1159.  
  1160. void *
  1161. __builtin_new (size_t sz)
  1162. {
  1163.   void *p;
  1164.  
  1165.   /* malloc (0) is unpredictable; avoid it.  */
  1166.   if (sz == 0)
  1167.     sz = 1;
  1168.   p = (void *) malloc (sz);
  1169.   if (p == 0)
  1170.     (*__new_handler) ();
  1171.   return p;
  1172. }
  1173. #endif
  1174.  
  1175. #ifdef L_caps_New
  1176.  
  1177.   /* Avoid forcing the library's meaning of `write' on the user program
  1178.      by using the "internal" name (for use within the library)  */
  1179. #define write(fd, buf, n)    _write((fd), (buf), (n))
  1180.  
  1181. typedef void (*vfp)(void);
  1182.  
  1183. extern void *__builtin_new (size_t);
  1184. static void default_new_handler (void);
  1185.  
  1186. vfp __new_handler = default_new_handler;
  1187.  
  1188. void *
  1189. __builtin_vec_new (p, maxindex, size, ctor)
  1190.      void *p;
  1191.      size_t maxindex;
  1192.      size_t size;
  1193.      void (*ctor)(void *);
  1194. {
  1195.   size_t i;
  1196.   size_t nelts = maxindex + 1;
  1197.   void *rval;
  1198.  
  1199.   if (p == 0)
  1200.     p = __builtin_new (nelts * size);
  1201.  
  1202.   rval = p;
  1203.  
  1204.   for (i = 0; i < nelts; i++)
  1205.     {
  1206.       (*ctor) (p);
  1207.       p += size;
  1208.     }
  1209.  
  1210.   return rval;
  1211. }
  1212.  
  1213. vfp
  1214. __set_new_handler (handler)
  1215.      vfp handler;
  1216. {
  1217.   vfp prev_handler;
  1218.  
  1219.   prev_handler = __new_handler;
  1220.   if (handler == 0) handler = default_new_handler;
  1221.   __new_handler = handler;
  1222.   return prev_handler;
  1223. }
  1224.  
  1225. vfp
  1226. set_new_handler (handler)
  1227.      vfp handler;
  1228. {
  1229.   return __set_new_handler (handler);
  1230. }
  1231.  
  1232. #define MESSAGE "Virtual memory exceeded in `new'\n"
  1233.  
  1234. static void
  1235. default_new_handler ()
  1236. {
  1237.   /* don't use fprintf (stderr, ...) because it may need to call malloc.  */
  1238.   /* This should really print the name of the program, but that is hard to
  1239.      do.  We need a standard, clean way to get at the name.  */
  1240.   write (2, MESSAGE, sizeof (MESSAGE));
  1241.   /* don't call exit () because that may call global destructors which
  1242.      may cause a loop.  */
  1243.   _exit (-1);
  1244. }
  1245. #endif
  1246.  
  1247. #ifdef L_builtin_del
  1248. typedef void (*vfp)(void);
  1249.  
  1250. void
  1251. __builtin_delete (void *ptr)
  1252. {
  1253.   if (ptr)
  1254.     free (ptr);
  1255. }
  1256.  
  1257. void
  1258. __builtin_vec_delete (ptr, maxindex, size, dtor, auto_delete_vec, auto_delete)
  1259.      void *ptr;
  1260.      size_t maxindex;
  1261.      size_t size;
  1262.      void (*dtor)(void *, int);
  1263.      int auto_delete;
  1264. {
  1265.   size_t i;
  1266.   size_t nelts = maxindex + 1;
  1267.   void *p = ptr;
  1268.  
  1269.   ptr += nelts * size;
  1270.  
  1271.   for (i = 0; i < nelts; i++)
  1272.     {
  1273.       ptr -= size;
  1274.       (*dtor) (ptr, auto_delete);
  1275.     }
  1276.  
  1277.   if (auto_delete_vec)
  1278.     __builtin_delete (p);
  1279. }
  1280.  
  1281. #endif
  1282.  
  1283. #ifdef L_trampoline
  1284.  
  1285. /* Jump to a trampoline, loading the static chain address.  */
  1286.  
  1287. #ifdef TRANSFER_FROM_TRAMPOLINE 
  1288. TRANSFER_FROM_TRAMPOLINE 
  1289. #endif
  1290. #endif /* L_trampoline */
  1291.  
  1292. #ifdef L__main
  1293.  
  1294. #include "gbl-ctors.h"
  1295.  
  1296. /* Run all the global destructors on exit from the program.  */
  1297.  
  1298. void
  1299. __do_global_dtors ()
  1300. {
  1301.   unsigned nptrs = (unsigned long) __DTOR_LIST__[0];
  1302.   unsigned i;
  1303.  
  1304.   /* Some systems place the number of pointers
  1305.      in the first word of the table.
  1306.      On other systems, that word is -1.
  1307.      In all cases, the table is null-terminated.  */
  1308.  
  1309.   /* If the length is not recorded, count up to the null.  */
  1310.   if (nptrs == -1)
  1311.     for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);
  1312.  
  1313.   /* GNU LD format.  */
  1314.   for (i = nptrs; i >= 1; i--)
  1315.     __DTOR_LIST__[i] ();
  1316. }
  1317.  
  1318. /* Run all the global constructors on entry to the program.  */
  1319.  
  1320. void
  1321. __do_global_ctors ()
  1322. {
  1323.   DO_GLOBAL_CTORS_BODY;
  1324. }
  1325.  
  1326. /* Subroutine called automatically by `main'.
  1327.    Compiling a global function named `main'
  1328.    produces an automatic call to this function at the beginning.
  1329.  
  1330.    For many systems, this routine calls __do_global_ctors.
  1331.    For systems which support a .init section we use the .init section
  1332.    to run __do_global_ctors, so we need not do anything here.  */
  1333.  
  1334. void
  1335. __main ()
  1336. {
  1337.   /* Support recursive calls to `main': run initializers just once.  */
  1338.   static int initialized = 0;
  1339.   if (! initialized)
  1340.     {
  1341.       initialized = 1;
  1342.       __do_global_ctors ();
  1343.     }
  1344. }
  1345.  
  1346. #endif /* L__main */
  1347.  
  1348. #ifdef L_ctor_list
  1349. #include "gbl-ctors.h"
  1350. const func_ptr __CTOR_LIST__[2] = {0, 0};
  1351. #endif /* L_ctor_list */
  1352.  
  1353. #ifdef L_dtor_list
  1354. #include "gbl-ctors.h"
  1355. const func_ptr __DTOR_LIST__[2] = {0, 0};
  1356. #endif /* L_ctor_list */
  1357.