home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / gnulib2.c < prev    next >
C/C++ Source or Header  |  1992-12-12  |  31KB  |  1,669 lines

  1. /* WARNING: compile this in 32 bit int mode even for short library */
  2. #include <string.h>
  3. #include <memory.h>
  4. #ifndef _COMPILER_H
  5. #include <compiler.h>
  6. #endif
  7.  
  8. #ifdef __DEF_ALL__    /* this def'ed when making on the ST */
  9.  
  10. #define L_adddi3
  11. #define L_subdi3
  12. #define L_muldi3
  13. #define L_divdi3
  14. #define L_moddi3
  15. #define L_udivdi3
  16. #define L_umoddi3
  17. #define L_negdi2
  18. #define L_anddi3
  19. #define L_iordi3
  20. #define L_xordi3
  21. #define L_lshrdi3
  22. #define L_lshldi3
  23. #define L_ashldi3
  24. #define L_ashrdi3
  25. #define L_one_cmpldi2
  26. #define L_bdiv
  27. #define L_cmpdi2
  28. #define L_ucmpdi2
  29. #define L_fixunsdfdi
  30. #define L_fixdfdi
  31. #define L_floatdidf
  32.  
  33. /* gcc-2.0 stuff */
  34. #if 0    /* NOTE: these are now covered, and should not be generated here */
  35. #define L_lshrsi3
  36. #define L_lshlsi3
  37. #define L_ashrsi3
  38. #define L_ashlsi3
  39. #define L_eqdf2
  40. #define L_nedf2
  41. #define L_gtdf2
  42. #define L_gedf2
  43. #define L_ltdf2
  44. #define L_ledf2
  45. #define L_fixsfsi
  46. #define L_floatsisf
  47. #define L_eqsf2
  48. #define L_nesf2
  49. #define L_gtsf2
  50. #define L_gesf2
  51. #define L_ltsf2
  52. #define L_lesf2
  53. #endif
  54. #define L_fxussfsi
  55. #define L_gccbcmp
  56.  
  57. #endif /* __DEF_ALL__ */
  58.  
  59. /* More subroutines needed by GCC output code on some machines.  */
  60. /* Compile this one with gcc.  */
  61.  
  62. #if 0
  63. #include "config.h"    /* dont drag this in, just define relevant
  64.                stuff from xm/tm-atari.h & xm/tm-m68k.h here */
  65. #else
  66.  
  67. /* #defines that need visibility everywhere.  */
  68. #define FALSE 0
  69. #define TRUE 1
  70.  
  71. /* This describes the machine the compiler is hosted on.  */
  72. #define HOST_BITS_PER_CHAR 8
  73. #define HOST_BITS_PER_SHORT 16
  74. #define HOST_BITS_PER_INT 32
  75. #define HOST_BITS_PER_LONG 32
  76.  
  77. /* Define this if most significant bit is lowest numbered
  78.    in instructions that operate on numbered bit-fields.
  79.    This is true for 68020 insns such as bfins and bfexts.
  80.    We make it true always by avoiding using the single-bit insns
  81.    except in special cases with constant bit numbers.  */
  82. #define BITS_BIG_ENDIAN
  83.  
  84. /* Define this if most significant byte of a word is the lowest numbered.  */
  85. /* That is true on the 68000.  */
  86. #define BYTES_BIG_ENDIAN
  87.  
  88. /* Define this if most significant word of a multiword number is numbered.  */
  89. /* For 68000 we can decide arbitrarily
  90.    since there are no machine instructions for them.  */
  91. /* #define WORDS_BIG_ENDIAN */
  92.  
  93. /* number of bits in an addressible storage unit */
  94. #define BITS_PER_UNIT 8
  95.  
  96. /* Width in bits of a "word", which is the contents of a machine register.
  97.    Note that this is not necessarily the width of data type `int';
  98.    if using 16-bit ints on a 68000, this would still be 32.
  99.    But on a machine with 16-bit registers, this would be 16.  */
  100. #define BITS_PER_WORD 32
  101.  
  102. /* Width of a word, in units (bytes).  */
  103. #define UNITS_PER_WORD 4
  104.  
  105. /* Width in bits of a pointer.
  106.    See also the macro `Pmode' defined below.  */
  107. #define POINTER_SIZE 32
  108.  
  109. /* Allocation boundary (in *bits*) for storing pointers in memory.  */
  110. #define POINTER_BOUNDARY 16
  111.  
  112. /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
  113. #define PARM_BOUNDARY (TARGET_SHORT ? 16 : 32)
  114.  
  115. /* Boundary (in *bits*) on which stack pointer should be aligned.  */
  116. #define STACK_BOUNDARY 16
  117.  
  118. /* Allocation boundary (in *bits*) for the code of a function.  */
  119. #define FUNCTION_BOUNDARY 16
  120.  
  121. /* Alignment of field after `int : 0' in a structure.  */
  122. #define EMPTY_FIELD_BOUNDARY 16
  123.  
  124. /* No data type wants to be aligned rounder than this.  */
  125. #define BIGGEST_ALIGNMENT 16
  126.  
  127. /* Define this if move instructions will actually fail to work
  128.    when given unaligned data.  */
  129. #define STRICT_ALIGNMENT
  130.  
  131. /* Define number of bits in most basic integer type.
  132.    (If undefined, default is BITS_PER_WORD).  */
  133. #ifdef __MSHORT__
  134. #define INT_TYPE_SIZE 16
  135. #else
  136. #define INT_TYPE_SIZE 32
  137. #endif
  138.  
  139. #endif
  140.  
  141. #ifndef minix
  142. #include <stddef.h>
  143. #else
  144.      typedef unsigned long size_t;
  145. #include "lib.h"
  146. #endif
  147.  
  148. #ifndef SItype
  149. #define SItype long int
  150. #endif
  151.  
  152. /* long long ints are pairs of long ints in the order determined by
  153.    WORDS_BIG_ENDIAN.  */
  154.  
  155. #ifdef WORDS_BIG_ENDIAN
  156.   struct longlong {long high, low;};
  157. #else
  158.   struct longlong {long low, high;};
  159. #endif
  160.  
  161. /* We need this union to unpack/pack longlongs, since we don't have
  162.    any arithmetic yet.  Incoming long long parameters are stored
  163.    into the `ll' field, and the unpacked result is read from the struct
  164.    longlong.  */
  165.  
  166. typedef union
  167. {
  168.   struct longlong s;
  169.   long long ll;
  170.   SItype i[2];
  171.   unsigned SItype ui[2];
  172. } long_long;
  173.  
  174. /* Internally, long long ints are strings of unsigned shorts in the
  175.    order determined by BYTES_BIG_ENDIAN.  */
  176.  
  177. #define B 0x10000
  178. #define low16 (B - 1)
  179.  
  180. #ifdef BYTES_BIG_ENDIAN
  181.  
  182. /* Note that HIGH and LOW do not describe the order
  183.    of words in a long long.  They describe the order of words
  184.    in vectors ordered according to the byte order.  */
  185.  
  186. #define HIGH 0
  187. #define LOW 1
  188.  
  189. #define big_end(n)    0 
  190. #define little_end(n)    ((n) - 1)
  191. #define next_msd(i)    ((i) - 1)
  192. #define next_lsd(i)    ((i) + 1)
  193. #define is_not_msd(i,n)    ((i) >= 0)
  194. #define is_not_lsd(i,n)    ((i) < (n))
  195.  
  196. #else
  197.  
  198. #define LOW 0
  199. #define HIGH 1
  200.  
  201. #define big_end(n)    ((n) - 1)
  202. #define little_end(n)    0 
  203. #define next_msd(i)    ((i) + 1)
  204. #define next_lsd(i)    ((i) - 1)
  205. #define is_not_msd(i,n)    ((i) < (n))
  206. #define is_not_lsd(i,n)    ((i) >= 0)
  207.  
  208. #endif
  209.  
  210. /* These algorithms are all straight out of Knuth, vol. 2, sec. 4.3.1. */
  211.  
  212. __EXTERN long long __adddi3 __PROTO((long long u, long long v));
  213. __EXTERN long long __anddi3 __PROTO((long long u, long long v));
  214. __EXTERN long long __iordi3 __PROTO((long long u, long long v));
  215. __EXTERN long long __xordi3 __PROTO((long long u, long long v));
  216. __EXTERN long long __one_cmpldi2 __PROTO((long long u));
  217. __EXTERN long long __lshldi3 __PROTO((long long u, long int b1));
  218. __EXTERN long long __lshrdi3 __PROTO((long long u, long int b1));
  219. __EXTERN long long __ashldi3 __PROTO((long long u, long int b1));
  220. __EXTERN long long __ashrdi3 __PROTO((long long u, long int b1));
  221. __EXTERN long long __subdi3 __PROTO((long long u, long long v));
  222. __EXTERN long long __muldi3 __PROTO((long long u, long long v));
  223. __EXTERN long long __divdi3 __PROTO((long long u, long long v));
  224. __EXTERN long long __moddi3 __PROTO((long long u, long long v));
  225. __EXTERN long long __udivdi3 __PROTO((long long u, long long v));
  226. __EXTERN long long __umoddi3 __PROTO((long long u, long long v));
  227. __EXTERN long long __negdi2 __PROTO((long long u));
  228. __EXTERN void __bdiv __PROTO((unsigned short *a, unsigned short *b, unsigned short *q, unsigned short *r, size_t m, size_t n));
  229. __EXTERN SItype __cmpdi2 __PROTO((long long a, long long b));
  230. __EXTERN SItype __ucmpdi2 __PROTO((long long a, long long b));
  231. __EXTERN long long __fixunsdfdi __PROTO((double a));
  232. __EXTERN long long __fixdfdi __PROTO((double a));
  233. __EXTERN double __floatdidf __PROTO((long long u));
  234. __EXTERN int __builtin_saveregs __PROTO((void));
  235. __EXTERN unsigned SItype __fixunssfsi __PROTO((float a));
  236.  
  237. #ifdef L_adddi3
  238. static int badd __PROTO((unsigned short *a, unsigned short *b, unsigned short *c, size_t n));
  239.  
  240. long long 
  241. __adddi3 (u, v)
  242.      long long u, v;
  243. {
  244.   long a[2], b[2], c[2];
  245.   long_long w;
  246.   long_long uu, vv;
  247.  
  248.   uu.ll = u;
  249.   vv.ll = v;
  250.  
  251.   a[HIGH] = uu.s.high;
  252.   a[LOW] = uu.s.low;
  253.   b[HIGH] = vv.s.high;
  254.   b[LOW] = vv.s.low;
  255.  
  256.   badd ((unsigned short *)a, (unsigned short *)b, (unsigned short *)c, sizeof c);
  257.  
  258.   w.s.high = c[HIGH];
  259.   w.s.low = c[LOW];
  260.   return w.ll;
  261. }
  262.  
  263. static int 
  264. badd (a, b, c, n)
  265.      unsigned short *a, *b, *c;
  266.      size_t n;
  267. {
  268.   unsigned long acc;
  269.   int i;
  270.  
  271.   n /= sizeof *c;
  272.  
  273.   acc = 0;
  274.   for (i = little_end (n); is_not_msd (i, n); i = next_msd (i))
  275.     {
  276.       /* Widen before adding to avoid loss of high bits.  */
  277.       acc += (unsigned long) a[i] + b[i];
  278.       c[i] = acc & low16;
  279.       acc = acc >> 16;
  280.     }
  281.   return acc;
  282. }
  283. #endif
  284.  
  285. #ifdef L_anddi3
  286. long long 
  287. __anddi3 (u, v)
  288.      long long u, v;
  289. {
  290.   long_long w;
  291.   long_long uu, vv;
  292.  
  293.   uu.ll = u;
  294.   vv.ll = v;
  295.  
  296.   w.s.high = uu.s.high & vv.s.high;
  297.   w.s.low = uu.s.low & vv.s.low;
  298.  
  299.   return w.ll;
  300. }
  301. #endif
  302.  
  303. #ifdef L_iordi3
  304. long long 
  305. __iordi3 (u, v)
  306.      long long u, v;
  307. {
  308.   long_long w;
  309.   long_long uu, vv;
  310.  
  311.   uu.ll = u;
  312.   vv.ll = v;
  313.  
  314.   w.s.high = uu.s.high | vv.s.high;
  315.   w.s.low = uu.s.low | vv.s.low;
  316.  
  317.   return w.ll;
  318. }
  319. #endif
  320.  
  321. #ifdef L_xordi3
  322. long long 
  323. __xordi3 (u, v)
  324.      long long u, v;
  325. {
  326.   long_long w;
  327.   long_long uu, vv;
  328.  
  329.   uu.ll = u;
  330.   vv.ll = v;
  331.  
  332.   w.s.high = uu.s.high ^ vv.s.high;
  333.   w.s.low = uu.s.low ^ vv.s.low;
  334.  
  335.   return w.ll;
  336. }
  337. #endif
  338.  
  339. #ifdef L_one_cmpldi2
  340. long long
  341. __one_cmpldi2 (u)
  342.      long long u;
  343. {
  344.   long_long w;
  345.   long_long uu;
  346.  
  347.   uu.ll = u;
  348.  
  349.   w.s.high = ~uu.s.high;
  350.   w.s.low = ~uu.s.low;
  351.  
  352.   return w.ll;
  353. }
  354. #endif
  355.  
  356. #ifdef L_lshldi3
  357. long long
  358. __lshldi3 (u, b1)
  359.      long long u;
  360.      long int b1;
  361. {
  362.   long_long w;
  363.   unsigned long carries;
  364.   int bm;
  365.   long_long uu;
  366.   int b = b1;
  367.   
  368.   if (b == 0)
  369.     return u;
  370.  
  371.   uu.ll = u;
  372.  
  373.   bm = (sizeof (int) * BITS_PER_UNIT) - b;
  374.   if (bm <= 0)
  375.     {
  376.       w.s.low = 0;
  377.       w.s.high = (unsigned long)uu.s.low << -bm;
  378.     }
  379.   else
  380.     {
  381.       carries = (unsigned long)uu.s.low >> bm;
  382.       w.s.low = (unsigned long)uu.s.low << b;
  383.       w.s.high = ((unsigned long)uu.s.high << b) | carries;
  384.     }
  385.  
  386.   return w.ll;
  387. }
  388. #endif
  389.  
  390. #ifdef L_lshrdi3
  391. long long
  392. __lshrdi3 (u, b1)
  393.      long long u;
  394.      long int b1;
  395. {
  396.   long_long w;
  397.   unsigned long carries;
  398.   int bm;
  399.   long_long uu;
  400.   int b = b1;
  401.   
  402.   if (b == 0)
  403.     return u;
  404.  
  405.   uu.ll = u;
  406.  
  407.   bm = (sizeof (int) * BITS_PER_UNIT) - b;
  408.   if (bm <= 0)
  409.     {
  410.       w.s.high = 0;
  411.       w.s.low = (unsigned long)uu.s.high >> -bm;
  412.     }
  413.   else
  414.     {
  415.       carries = (unsigned long)uu.s.high << bm;
  416.       w.s.high = (unsigned long)uu.s.high >> b;
  417.       w.s.low = ((unsigned long)uu.s.low >> b) | carries;
  418.     }
  419.  
  420.   return w.ll;
  421. }
  422. #endif
  423.  
  424. #ifdef L_ashldi3
  425. long long
  426. __ashldi3 (u, b1)
  427.      long long u;
  428.      long int b1;
  429. {
  430.   long_long w;
  431.   unsigned long carries;
  432.   int bm;
  433.   long_long uu;
  434.   int b = b1;
  435.   
  436.   if (b == 0)
  437.     return u;
  438.  
  439.   uu.ll = u;
  440.  
  441.   bm = (sizeof (int) * BITS_PER_UNIT) - b;
  442.   if (bm <= 0)
  443.     {
  444.       w.s.low = 0;
  445.       w.s.high = (unsigned long)uu.s.low << -bm;
  446.     }
  447.   else
  448.     {
  449.       carries = (unsigned long)uu.s.low >> bm;
  450.       w.s.low = (unsigned long)uu.s.low << b;
  451.       w.s.high = ((unsigned long)uu.s.high << b) | carries;
  452.     }
  453.  
  454.   return w.ll;
  455. }
  456. #endif
  457.  
  458. #ifdef L_ashrdi3
  459. long long
  460. __ashrdi3 (u, b1)
  461.      long long u;
  462.      long int b1;
  463. {
  464.   long_long w;
  465.   unsigned long carries;
  466.   int bm;
  467.   long_long uu;
  468.   int b = b1;
  469.   
  470.   if (b == 0)
  471.     return u;
  472.  
  473.   uu.ll = u;
  474.  
  475.   bm = (sizeof (int) * BITS_PER_UNIT) - b;
  476.   if (bm <= 0)
  477.     {
  478.       w.s.high = uu.s.high >> 31; /* just to make w.s.high 1..1 or 0..0 */
  479.       w.s.low = uu.s.high >> -bm;
  480.     }
  481.   else
  482.     {
  483.       carries = (unsigned long)uu.s.high << bm;
  484.       w.s.high = uu.s.high >> b;
  485.       w.s.low = ((unsigned long)uu.s.low >> b) | carries;
  486.     }
  487.  
  488.   return w.ll;
  489. }
  490. #endif
  491.  
  492. #ifdef L_subdi3
  493.  
  494. static int bsub __PROTO((unsigned short *a, unsigned short *b, unsigned short *c, size_t n));
  495.  
  496. long long 
  497. __subdi3 (u, v)
  498.      long long u, v;
  499. {
  500.   long a[2], b[2], c[2];
  501.   long_long w;
  502.   long_long uu, vv;
  503.  
  504.   uu.ll = u;
  505.   vv.ll = v;
  506.  
  507.   a[HIGH] = uu.s.high;
  508.   a[LOW] = uu.s.low;
  509.   b[HIGH] = vv.s.high;
  510.   b[LOW] = vv.s.low;
  511.  
  512.   bsub ((unsigned short *)a, (unsigned short *)b, (unsigned short *)c, sizeof c);
  513.  
  514.   w.s.high = c[HIGH];
  515.   w.s.low = c[LOW];
  516.   return w.ll;
  517. }
  518.  
  519. static int 
  520. bsub (a, b, c, n)
  521.      unsigned short *a, *b, *c;
  522.      size_t n;
  523. {
  524.   signed long acc;
  525.   int i;
  526.  
  527.   n /= sizeof *c;
  528.  
  529.   acc = 0;
  530.   for (i = little_end (n); is_not_msd (i, n); i = next_msd (i))
  531.     {
  532.       /* Widen before subtracting to avoid loss of high bits.  */
  533.       acc += (long) a[i] - b[i];
  534.       c[i] = acc & low16;
  535.       acc = acc >> 16;
  536.     }
  537.   return acc;
  538. }
  539. #endif
  540.  
  541. #ifdef L_muldi3
  542.  
  543. static void bmul __PROTO((unsigned short *a, unsigned short *b, unsigned short *c, size_t m, size_t n));
  544.  
  545. long long 
  546. __muldi3 (u, v)
  547.      long long u, v;
  548. {
  549.   long a[2], b[2], c[2][2];
  550.   long_long w;
  551.   long_long uu, vv;
  552.  
  553.   uu.ll = u;
  554.   vv.ll = v;
  555.  
  556.   a[HIGH] = uu.s.high;
  557.   a[LOW] = uu.s.low;
  558.   b[HIGH] = vv.s.high;
  559.   b[LOW] = vv.s.low;
  560.  
  561.   bmul ((unsigned short *)a, (unsigned short *)b, (unsigned short *)c, sizeof a, sizeof b);
  562.  
  563.   w.s.high = c[LOW][HIGH];
  564.   w.s.low = c[LOW][LOW];
  565.   return w.ll;
  566. }
  567.  
  568. static void 
  569. bmul (a, b, c, m, n)
  570.     unsigned short *a, *b, *c;
  571.     size_t m, n;
  572. {
  573.   int i, j;
  574.   unsigned long acc;
  575.  
  576.   (void)bzero (c, m + n);
  577.  
  578.   m /= sizeof *a;
  579.   n /= sizeof *b;
  580.  
  581.   for (j = little_end (n); is_not_msd (j, n); j = next_msd (j))
  582.     {
  583.       unsigned short *c1 = c + j + little_end (2);
  584.       acc = 0;
  585.       for (i = little_end (m); is_not_msd (i, m); i = next_msd (i))
  586.     {
  587.       /* Widen before arithmetic to avoid loss of high bits.  */
  588.       acc += (unsigned long) a[i] * b[j] + c1[i];
  589.       c1[i] = acc & low16;
  590.       acc = acc >> 16;
  591.     }
  592.       c1[i] = acc;
  593.     }
  594. }
  595. #endif
  596.  
  597. #ifdef L_divdi3
  598. long long
  599. __divdi3 (u, v)
  600.      long long u, v;
  601. {
  602.   if (u < 0)
  603.     if (v < 0)
  604.       return (unsigned long long) -u / (unsigned long long) -v;
  605.     else
  606.       return - ((unsigned long long) -u / (unsigned long long) v);
  607.   else
  608.     if (v < 0)
  609.       return - ((unsigned long long) u / (unsigned long long) -v);
  610.     else
  611.       return (unsigned long long) u / (unsigned long long) v;
  612. }
  613. #endif
  614.  
  615. #ifdef L_moddi3
  616. long long
  617. __moddi3 (u, v)
  618.      long long u, v;
  619. {
  620.   if (u < 0)
  621.     if (v < 0)
  622.       return - ((unsigned long long) -u % (unsigned long long) -v);
  623.     else
  624.       return - ((unsigned long long) -u % (unsigned long long) v);
  625.   else
  626.     if (v < 0)
  627.       return (unsigned long long) u % (unsigned long long) -v;
  628.     else
  629.       return (unsigned long long) u % (unsigned long long) v;
  630. }
  631. #endif
  632.  
  633. #ifdef L_udivdi3
  634. long long 
  635. __udivdi3 (u, v)
  636.      long long u, v;
  637. {
  638.   unsigned long a[2][2], b[2], q[2], r[2];
  639.   long_long w;
  640.   long_long uu, vv;
  641.  
  642.   uu.ll = u;
  643.   vv.ll = v;
  644.  
  645.   a[HIGH][HIGH] = 0;
  646.   a[HIGH][LOW] = 0;
  647.   a[LOW][HIGH] = uu.s.high;
  648.   a[LOW][LOW] = uu.s.low;
  649.   b[HIGH] = vv.s.high;
  650.   b[LOW] = vv.s.low;
  651.  
  652.   __bdiv ((unsigned short *)a, (unsigned short *)b, (unsigned short *)q,
  653.       (unsigned short *)r, sizeof a, sizeof b);
  654.  
  655.   w.s.high = q[HIGH];
  656.   w.s.low = q[LOW];
  657.   return w.ll;
  658. }
  659. #endif
  660.  
  661. #ifdef L_umoddi3
  662. long long 
  663. __umoddi3 (u, v)
  664.      long long u, v;
  665. {
  666.   unsigned long a[2][2], b[2], q[2], r[2];
  667.   long_long w;
  668.   long_long uu, vv;
  669.  
  670.   uu.ll = u;
  671.   vv.ll = v;
  672.  
  673.   a[HIGH][HIGH] = 0;
  674.   a[HIGH][LOW] = 0;
  675.   a[LOW][HIGH] = uu.s.high;
  676.   a[LOW][LOW] = uu.s.low;
  677.   b[HIGH] = vv.s.high;
  678.   b[LOW] = vv.s.low;
  679.  
  680.   __bdiv ((unsigned short *)a, (unsigned short *)b, (unsigned short *)q,
  681.       (unsigned short *)r, sizeof a, sizeof b);
  682.  
  683.   w.s.high = r[HIGH];
  684.   w.s.low = r[LOW];
  685.   return w.ll;
  686. }
  687. #endif
  688.  
  689. #ifdef L_negdi2
  690.  
  691. static int bneg __PROTO((unsigned short *a, unsigned short *b, size_t n));
  692.  
  693. long long 
  694. __negdi2 (u)
  695.      long long u;
  696. {
  697.   unsigned long a[2], b[2];
  698.   long_long w;
  699.   long_long uu;
  700.  
  701.   uu.ll = u;
  702.  
  703.   a[HIGH] = uu.s.high;
  704.   a[LOW] = uu.s.low;
  705.  
  706.   bneg ((unsigned short *)a, (unsigned short *)b, sizeof b);
  707.  
  708.   w.s.high = b[HIGH];
  709.   w.s.low = b[LOW];
  710.   return w.ll;
  711. }
  712.  
  713. static int
  714. bneg (a, b, n)
  715.      unsigned short *a, *b;
  716.      size_t n;
  717. {
  718.   signed long acc;
  719.   int i;
  720.  
  721.   n /= sizeof (short);
  722.  
  723.   acc = 0;
  724.   for (i = little_end (n); is_not_msd (i, n); i = next_msd (i))
  725.     {
  726.       acc -= a[i];
  727.       b[i] = acc & low16;
  728.       acc = acc >> 16;
  729.     }
  730.   return acc;
  731. }
  732. #endif
  733.  
  734. /* Divide a by b, producing quotient q and remainder r.
  735.  
  736.        sizeof a is m
  737.        sizeof b is n
  738.        sizeof q is m - n
  739.        sizeof r is n
  740.  
  741.    The quotient must fit in m - n bytes, i.e., the most significant
  742.    n digits of a must be less than b, and m must be greater than n.  */
  743.  
  744. /* The name of this used to be __div_internal,
  745.    but that is too long for SYSV.  */
  746.  
  747. #ifdef L_bdiv
  748. static int bshift __PROTO((unsigned short *u, int k, unsigned short *w, unsigned int carry_in, int n));
  749.  
  750. void 
  751. __bdiv (a, b, q, r, m, n)
  752.      unsigned short *a, *b, *q, *r;
  753.      size_t m, n;
  754. {
  755.   void abort(void);
  756.   unsigned long qhat, rhat;
  757.   unsigned long acc;
  758.   unsigned short *u = (unsigned short *) alloca (m);
  759.   unsigned short *v = (unsigned short *) alloca (n);
  760.   unsigned short *u0, *u1, *u2;
  761.   unsigned short *v0;
  762.   int d, qn;
  763.   int i, j;
  764.  
  765.   m /= sizeof *a;
  766.   n /= sizeof *b;
  767.   qn = m - n;
  768.  
  769.   /* Remove leading zero digits from divisor, and the same number of
  770.      digits (which must be zero) from dividend.  */
  771.  
  772.   while (b[big_end (n)] == 0)
  773.     {
  774.       r[big_end (n)] = 0;
  775.  
  776.       a += little_end (2);
  777.       b += little_end (2);
  778.       r += little_end (2);
  779.       m--;
  780.       n--;
  781.  
  782.       /* Check for zero divisor.  */
  783.       if (n == 0)
  784.     abort ();
  785.     }
  786.       
  787.   /* If divisor is a single digit, do short division.  */
  788.  
  789.   if (n == 1)
  790.     {
  791.       acc = a[big_end (m)];
  792.       a += little_end (2);
  793.       for (j = big_end (qn); is_not_lsd (j, qn); j = next_lsd (j))
  794.     {
  795.       acc = (acc << 16) | a[j];
  796.       q[j] = acc / *b;
  797.       acc = acc % *b;
  798.     }
  799.       *r = acc;
  800.       return;
  801.     }
  802.  
  803.   /* No such luck, must do long division. Shift divisor and dividend
  804.      left until the high bit of the divisor is 1.  */
  805.  
  806.   for (d = 0; d < 16; d++)
  807.     if (b[big_end (n)] & (1 << (16 - 1 - d)))
  808.       break;
  809.  
  810.   bshift (a, d, u, 0, m);
  811.   bshift (b, d, v, 0, n);
  812.  
  813.   /* Get pointers to the high dividend and divisor digits.  */
  814.  
  815.   u0 = u + big_end (m) - big_end (qn);
  816.   u1 = next_lsd (u0);
  817.   u2 = next_lsd (u1);
  818.   u += little_end (2);
  819.  
  820.   v0 = v + big_end (n);
  821.  
  822.   /* Main loop: find a quotient digit, multiply it by the divisor,
  823.      and subtract that from the dividend, shifted over the right amount. */
  824.  
  825.   for (j = big_end (qn); is_not_lsd (j, qn); j = next_lsd (j))
  826.     {
  827.       /* Quotient digit initial guess: high 2 dividend digits over high
  828.      divisor digit.  */
  829.  
  830.       if (u0[j] == *v0)
  831.     {
  832.       qhat = B - 1;
  833.       rhat = (unsigned long) *v0 + u1[j];
  834.     }
  835.       else
  836.     {
  837.       unsigned long numerator = ((unsigned long) u0[j] << 16) | u1[j];
  838.       qhat = numerator / *v0;
  839.       rhat = numerator % *v0;
  840.     }
  841.  
  842.       /* Now get the quotient right for high 3 dividend digits over
  843.      high 2 divisor digits.  */
  844.  
  845.       while (rhat < B && qhat * *next_lsd (v0) > ((rhat << 16) | u2[j]))
  846.     {
  847.       qhat -= 1;
  848.       rhat += *v0;
  849.     }
  850.         
  851.       /* Multiply quotient by divisor, subtract from dividend.  */
  852.  
  853.       acc = 0;
  854.       for (i = little_end (n); is_not_msd (i, n); i = next_msd (i))
  855.     {
  856.       acc += (unsigned long) (u + j)[i] - v[i] * qhat;
  857.       (u + j)[i] = acc & low16;
  858.       if (acc < B)
  859.         acc = 0;
  860.       else
  861.         acc = (acc >> 16) | -B;
  862.     }
  863.  
  864.       q[j] = qhat;
  865.  
  866.       /* Quotient may have been too high by 1.  If dividend went negative,
  867.      decrement the quotient by 1 and add the divisor back.  */
  868.  
  869.       if ((signed long) (acc + u0[j]) < 0)
  870.     {
  871.       q[j] -= 1;
  872.       acc = 0;
  873.       for (i = little_end (n); is_not_msd (i, n); i = next_msd (i))
  874.         {
  875.           acc += (unsigned long) (u + j)[i] + v[i];
  876.           (u + j)[i] = acc & low16;
  877.           acc = acc >> 16;
  878.         }
  879.     }
  880.     }
  881.  
  882.   /* Now the remainder is what's left of the dividend, shifted right
  883.      by the amount of the normalizing left shift at the top.  */
  884.  
  885.   r[big_end (n)] = bshift (u + 1 + little_end (j - 1),
  886.                16 - d,
  887.                r + little_end (2),
  888.                u[little_end (m - 1)] >> d,
  889.                n - 1);
  890. }
  891.  
  892. /* Left shift U by K giving W; fill the introduced low-order bits with
  893.    CARRY_IN.  Length of U and W is N.  Return carry out.  K must be
  894.    in 0 .. 16.  */
  895.  
  896. static int
  897. bshift (u, k, w, carry_in, n)
  898.      unsigned short *u, *w;
  899.      unsigned int carry_in;
  900.      int k, n;
  901. {
  902.   unsigned long acc;
  903.   int i;
  904.  
  905.   if (k == 0)
  906.     {
  907.       bcopy (u, w, n * sizeof *u);
  908.       return 0;
  909.     }
  910.  
  911.   acc = carry_in;
  912.   for (i = little_end (n); is_not_msd (i, n); i = next_msd (i))
  913.     {
  914.       acc |= (unsigned long) u[i] << k;
  915.       w[i] = acc & low16;
  916.       acc = acc >> 16;
  917.     }
  918.   return acc;
  919. }
  920. #endif
  921.  
  922. #ifdef L_cmpdi2
  923. SItype
  924. __cmpdi2 (a, b)
  925.      long long a, b;
  926. {
  927.   long_long au, bu;
  928.  
  929.   au.ll = a, bu.ll = b;
  930.  
  931.   if (au.s.high < bu.s.high)
  932.     return 0;
  933.   else if (au.s.high > bu.s.high)
  934.     return 2;
  935.   if ((unsigned) au.s.low < (unsigned) bu.s.low)
  936.     return 0;
  937.   else if ((unsigned) au.s.low > (unsigned) bu.s.low)
  938.     return 2;
  939.   return 1;
  940. }
  941. #endif
  942.  
  943. #ifdef L_ucmpdi2
  944. SItype
  945. __ucmpdi2 (a, b)
  946.      long long a, b;
  947. {
  948.   long_long au, bu;
  949.  
  950.   au.ll = a, bu.ll = b;
  951.  
  952.   if ((unsigned) au.s.high < (unsigned) bu.s.high)
  953.     return 0;
  954.   else if ((unsigned) au.s.high > (unsigned) bu.s.high)
  955.     return 2;
  956.   if ((unsigned) au.s.low < (unsigned) bu.s.low)
  957.     return 0;
  958.   else if ((unsigned) au.s.low > (unsigned) bu.s.low)
  959.     return 2;
  960.   return 1;
  961. }
  962. #endif
  963.  
  964. #ifdef L_fixunsdfdi
  965. #define HIGH_WORD_COEFF (((long long) 1) << BITS_PER_WORD)
  966.  
  967. long long
  968. __fixunsdfdi (a)
  969.      double a;
  970. {
  971.   double b;
  972.   unsigned long long v;
  973.  
  974.   if (a < 0)
  975.     return 0;
  976.  
  977.   /* Compute high word of result, as a flonum.  */
  978.   b = (a / HIGH_WORD_COEFF);
  979.   /* Convert that to fixed (but not to long long!),
  980.      and shift it into the high word.  */
  981.   v = (unsigned long int) b;
  982.   v <<= BITS_PER_WORD;
  983.   /* Remove high part from the double, leaving the low part as flonum.  */
  984.   a -= (double)v;
  985.   /* Convert that to fixed (but not to long long!) and add it in.
  986.      Sometimes A comes out negative.  This is significant, since
  987.      A has more bits than a long int does.  */
  988.   if (a < 0)
  989.     v -= (unsigned long int) (- a);
  990.   else
  991.     v += (unsigned long int) a;
  992.   return v;
  993. }
  994. #endif
  995.  
  996. #ifdef L_fixdfdi
  997. long long
  998. __fixdfdi (a)
  999.      double a;
  1000. {
  1001.   long long __fixunsdfdi (double a);
  1002.  
  1003.   if (a < 0)
  1004.     return - __fixunsdfdi (-a);
  1005.   return __fixunsdfdi (a);
  1006. }
  1007. #endif
  1008.  
  1009. #ifdef L_floatdidf
  1010. #define HIGH_HALFWORD_COEFF (((long long) 1) << (BITS_PER_WORD / 2))
  1011. #define HIGH_WORD_COEFF (((long long) 1) << BITS_PER_WORD)
  1012.  
  1013. double
  1014. __floatdidf (u)
  1015.      long long u;
  1016. {
  1017.   double d;
  1018.   int negate = 0;
  1019.  
  1020.   if (u < 0)  /* was : if (d < 0)     */
  1021.     u = -u, negate = 1;
  1022.  
  1023.   d = (unsigned int) (u >> BITS_PER_WORD);
  1024.   d *= HIGH_HALFWORD_COEFF;
  1025.   d *= HIGH_HALFWORD_COEFF;
  1026.   d += (unsigned int) (u & (HIGH_WORD_COEFF - 1));
  1027.  
  1028.   return (negate ? -d : d);
  1029. }
  1030. #endif
  1031.  
  1032. #ifdef L_varargs
  1033. #ifdef sparc
  1034.     asm (".global ___builtin_saveregs");
  1035.     asm ("___builtin_saveregs:");
  1036.     asm ("st %i0,[%fp+68]");
  1037.     asm ("st %i1,[%fp+72]");
  1038.     asm ("st %i2,[%fp+76]");
  1039.     asm ("st %i3,[%fp+80]");
  1040.     asm ("st %i4,[%fp+84]");
  1041.     asm ("retl");
  1042.     asm ("st %i5,[%fp+88]");
  1043. #else /* not sparc */
  1044. #if defined(MIPSEL) | defined(R3000) | defined(R2000) | defined(mips)
  1045.  
  1046.   asm ("    .ent __builtin_saveregs");
  1047.   asm ("    .globl __builtin_saveregs");
  1048.   asm ("__builtin_saveregs:");
  1049.   asm ("    sw    $4,0($30)");
  1050.   asm ("    sw    $5,4($30)");
  1051.   asm ("    sw    $6,8($30)");
  1052.   asm ("    sw    $7,12($30)");
  1053.   asm ("    j    $31");
  1054.   asm ("    .end __builtin_saveregs");
  1055. #else /* not mips */
  1056. __builtin_saveregs ()
  1057. {
  1058.   abort ();
  1059. }
  1060. #endif /* not mips */
  1061. #endif /* not sparc */
  1062. #endif
  1063.  
  1064. /* stuff for gcc-2.0, note that you cannot compile the corresponding
  1065.    C code from libgcc1.c for these functions with gcc-2.0!
  1066.    This stuff should eventually be hand optimized as we have done
  1067.    with the other stuff,
  1068.  */
  1069.  
  1070. #if 0    /* these were the decls used to compile the asm below */
  1071.  
  1072. #ifndef SItype
  1073. #define SItype long int
  1074. #endif
  1075.  
  1076. #ifndef FLOAT_VALUE_TYPE  
  1077. #define FLOAT_VALUE_TYPE long int
  1078. #endif
  1079.  
  1080. #ifndef INTIFY
  1081. #define INTIFY(FLOATVAL)  (intify.f = (FLOATVAL), intify.i)
  1082. #endif
  1083.  
  1084. #ifndef FLOATIFY
  1085. #define FLOATIFY(INTVAL)  ((INTVAL).f)
  1086. #endif
  1087.  
  1088. #ifndef FLOAT_ARG_TYPE
  1089. #define FLOAT_ARG_TYPE union flt_or_int
  1090. #endif
  1091.  
  1092. union flt_or_value { FLOAT_VALUE_TYPE i; float f; };
  1093.  
  1094. union flt_or_int { long int i; float f; };
  1095. #endif
  1096.  
  1097. #if 0        /* NOTE: all these come from elsewhere now */
  1098. #ifdef L_lshrsi3
  1099. #if 0
  1100. SItype
  1101. __lshrsi3 (a, b)
  1102.      unsigned SItype a, b;
  1103. {
  1104.   return a >> b;
  1105. }
  1106. #endif
  1107.  
  1108. asm("    .text
  1109.     .even
  1110. .globl ___lshrsi3
  1111. ___lshrsi3:
  1112.     movel sp@(4),d0
  1113.     movel sp@(8),d1
  1114.     lsrl d1,d0
  1115.     rts
  1116. ");
  1117. #endif
  1118.  
  1119. #ifdef L_lshlsi3
  1120. #if 0
  1121. SItype
  1122. __lshlsi3 (a, b)
  1123.      unsigned SItype a, b;
  1124. {
  1125.   return a << b;
  1126. }
  1127. #endif
  1128.  
  1129. asm("   .text
  1130.     .even
  1131. .globl ___lshlsi3
  1132. ___lshlsi3:
  1133.     movel sp@(4),d0
  1134.     movel sp@(8),d1
  1135.     lsll d1,d0
  1136.     rts
  1137. ");
  1138. #endif
  1139.  
  1140. #ifdef L_ashrsi3
  1141. #if 0
  1142. SItype
  1143. __ashrsi3 (a, b)
  1144.      SItype a, b;
  1145. {
  1146.   return a >> b;
  1147. }
  1148. #endif
  1149.  
  1150. asm("   .text
  1151.     .even
  1152. .globl ___ashrsi3
  1153. ___ashrsi3:
  1154.     movel sp@(4),d0
  1155.     movel sp@(8),d1
  1156.     asrl d1,d0
  1157.     rts
  1158. ");
  1159. #endif
  1160.  
  1161. #ifdef L_ashlsi3
  1162. #if 0
  1163. SItype
  1164. __ashlsi3 (a, b)
  1165.      SItype a, b;
  1166. {
  1167.   return a << b;
  1168. }
  1169. #endif
  1170.  
  1171. asm("    .text
  1172.     .even
  1173. .globl ___ashlsi3
  1174. ___ashlsi3:
  1175.     movel sp@(4),d0
  1176.     movel sp@(8),d1
  1177.     asll d1,d0
  1178.     rts
  1179. ");
  1180. #endif
  1181.  
  1182. #ifdef L_eqdf2
  1183. #if 0
  1184. SItype
  1185. __eqdf2 (a, b)
  1186.      double a, b;
  1187. {
  1188.   /* Value == 0 iff a == b.  */
  1189.   return !(a == b);
  1190. }
  1191. #endif
  1192.  
  1193. asm("    .text
  1194.     .even
  1195. .globl ___eqdf2
  1196. ___eqdf2:
  1197.     moveml #0x3000,sp@-
  1198.     movel sp@(12),d1
  1199.     movel sp@(16),d2
  1200.     movel sp@(24),sp@-
  1201.     movel sp@(24),sp@-
  1202.     movel d2,sp@-
  1203.     movel d1,sp@-
  1204.     jbsr ___cmpdf2
  1205.     addw #16,sp
  1206.     tstl d0
  1207.     sne d0
  1208.     moveq #1,d3
  1209.     andl d3,d0
  1210.     moveml sp@+,#0xc
  1211.     rts
  1212. ");
  1213. #endif
  1214.  
  1215. #ifdef L_nedf2
  1216. #if 0
  1217. SItype
  1218. __nedf2 (a, b)
  1219.      double a, b;
  1220. {
  1221.   /* Value != 0 iff a != b.  */
  1222.   return a != b;
  1223. }
  1224. #endif
  1225.  
  1226. asm("    .text
  1227.     .even
  1228. .globl ___nedf2
  1229. ___nedf2:
  1230.     moveml #0x3000,sp@-
  1231.     movel sp@(12),d1
  1232.     movel sp@(16),d2
  1233.     movel sp@(24),sp@-
  1234.     movel sp@(24),sp@-
  1235.     movel d2,sp@-
  1236.     movel d1,sp@-
  1237.     jbsr ___cmpdf2
  1238.     addw #16,sp
  1239.     tstl d0
  1240.     sne d0
  1241.     moveq #1,d3
  1242.     andl d3,d0
  1243.     moveml sp@+,#0xc
  1244.     rts
  1245. ");
  1246. #endif
  1247.  
  1248. #ifdef L_gtdf2
  1249. #if 0
  1250. SItype
  1251. __gtdf2 (a, b)
  1252.      double a, b;
  1253. {
  1254.   /* Value > 0 iff a > b.  */
  1255.   return a > b;
  1256. }
  1257. #endif
  1258.  
  1259. asm("    .text
  1260.     .even
  1261. .globl ___gtdf2
  1262. ___gtdf2:
  1263.     moveml #0x3000,sp@-
  1264.     movel sp@(12),d1
  1265.     movel sp@(16),d2
  1266.     movel sp@(24),sp@-
  1267.     movel sp@(24),sp@-
  1268.     movel d2,sp@-
  1269.     movel d1,sp@-
  1270.     jbsr ___cmpdf2
  1271.     addw #16,sp
  1272.     tstl d0
  1273.     sgt d0
  1274.     moveq #1,d3
  1275.     andl d3,d0
  1276.     moveml sp@+,#0xc
  1277.     rts
  1278. ");
  1279. #endif
  1280.  
  1281. #ifdef L_gedf2
  1282. #if 0
  1283. SItype
  1284. __gedf2 (a, b)
  1285.      double a, b;
  1286. {
  1287.   /* Value >= 0 iff a >= b.  */
  1288.   return (a >= b) - 1;
  1289. }
  1290. #endif
  1291.  
  1292. asm("    .text
  1293.     .even
  1294. .globl ___gedf2
  1295. ___gedf2:
  1296.     moveml #0x3000,sp@-
  1297.     movel sp@(12),d1
  1298.     movel sp@(16),d2
  1299.     movel sp@(24),sp@-
  1300.     movel sp@(24),sp@-
  1301.     movel d2,sp@-
  1302.     movel d1,sp@-
  1303.     jbsr ___cmpdf2
  1304.     addw #16,sp
  1305.     tstl d0
  1306.     sge d0
  1307.     moveq #1,d3
  1308.     andl d3,d0
  1309.     subql #1,d0
  1310.     moveml sp@+,#0xc
  1311.     rts
  1312. ");
  1313. #endif
  1314.  
  1315. #ifdef L_ltdf2
  1316. #if 0
  1317. SItype
  1318. __ltdf2 (a, b)
  1319.      double a, b;
  1320. {
  1321.   /* Value < 0 iff a < b.  */
  1322.   return -(a < b);
  1323. }
  1324. #endif
  1325.  
  1326. asm("    .text
  1327.     .even
  1328. .globl ___ltdf2
  1329. ___ltdf2:
  1330.     moveml #0x3000,sp@-
  1331.     movel sp@(12),d1
  1332.     movel sp@(16),d2
  1333.     movel sp@(24),sp@-
  1334.     movel sp@(24),sp@-
  1335.     movel d2,sp@-
  1336.     movel d1,sp@-
  1337.     jbsr ___cmpdf2
  1338.     addw #16,sp
  1339.     tstl d0
  1340.     slt d0
  1341.     moveq #1,d3
  1342.     andl d3,d0
  1343.     negl d0
  1344.     moveml sp@+,#0xc
  1345.     rts
  1346. ");
  1347. #endif
  1348.  
  1349. #ifdef L_ledf2
  1350. #if 0
  1351. SItype
  1352. __ledf2 (a, b)
  1353.      double a, b;
  1354. {
  1355.   /* Value <= 0 iff a <= b.  */
  1356.   return 1 - (a <= b);
  1357. }
  1358. #endif
  1359.  
  1360. asm("    .text
  1361.     .even
  1362. .globl ___ledf2
  1363. ___ledf2:
  1364.     movel d2,sp@-
  1365.     movel sp@(8),d0
  1366.     movel sp@(12),d1
  1367.     moveq #1,d2
  1368.     movel sp@(20),sp@-
  1369.     movel sp@(20),sp@-
  1370.     movel d1,sp@-
  1371.     movel d0,sp@-
  1372.     jbsr ___cmpdf2
  1373.     addw #16,sp
  1374.     tstl d0
  1375.     jgt L11
  1376.     moveq #0,d2
  1377. L11:
  1378.     movel d2,d0
  1379.     movel sp@+,d2
  1380.     rts
  1381. ");
  1382. #endif
  1383.  
  1384. #ifdef L_fixsfsi
  1385. #if 0
  1386. SItype
  1387. __fixsfsi (a)
  1388.      FLOAT_ARG_TYPE a;
  1389. {
  1390.   union flt_or_value intify;
  1391. #define perform_fixsfsi(a) return (SItype) a
  1392.   perform_fixsfsi (FLOATIFY (a));
  1393. }
  1394. #endif
  1395.  
  1396. asm("    .text
  1397.     .even
  1398. .globl ___fixsfsi
  1399. ___fixsfsi:
  1400.     movel sp@(4),sp@-
  1401.     jbsr ___extendsfdf2
  1402.     addqw #4,sp
  1403.     movel d1,sp@-
  1404.     movel d0,sp@-
  1405.     jbsr ___fixdfsi
  1406.     addqw #8,sp
  1407.     rts
  1408. ");
  1409. #endif
  1410.  
  1411. #ifdef L_floatsisf
  1412. #if 0
  1413. FLOAT_VALUE_TYPE
  1414. __floatsisf (a)
  1415.      SItype a;
  1416. {
  1417.   union flt_or_value intify;
  1418. #define perform_floatsisf(a)  return INTIFY ((float) a)
  1419.   perform_floatsisf (a);
  1420. }
  1421. #endif
  1422.  
  1423. asm("    .text
  1424.     .even
  1425. .globl ___floatsisf
  1426. ___floatsisf:
  1427.     movel sp@(4),sp@-
  1428.     jbsr ___floatsidf
  1429.     addqw #4,sp
  1430.     movel d1,sp@-
  1431.     movel d0,sp@-
  1432.     jbsr ___truncdfsf2
  1433.     addqw #8,sp
  1434.     rts
  1435. ");
  1436. #endif
  1437.  
  1438. #ifdef L_eqsf2
  1439. #if 0
  1440. SItype
  1441. __eqsf2 (a, b)
  1442.      FLOAT_ARG_TYPE a, b;
  1443. {
  1444.   union flt_or_int intify;
  1445.   /* Value == 0 iff a == b.  */
  1446. #define perform_eqsf2(a, b) return !(a == b)
  1447.   perform_eqsf2 (FLOATIFY (a), FLOATIFY (b));
  1448. }
  1449. #endif
  1450.  
  1451. asm("    .text
  1452.     .even
  1453. .globl ___eqsf2
  1454. ___eqsf2:
  1455.     movel d2,sp@-
  1456.     movel sp@(8),d1
  1457.     movel sp@(12),sp@-
  1458.     movel d1,sp@-
  1459.     jbsr ___cmpsf2
  1460.     addqw #8,sp
  1461.     tstl d0
  1462.     sne d0
  1463.     moveq #1,d2
  1464.     andl d2,d0
  1465.     movel sp@+,d2
  1466.     rts
  1467. ");
  1468. #endif
  1469.  
  1470. #ifdef L_nesf2
  1471. #if 0
  1472. SItype
  1473. __nesf2 (a, b)
  1474.      FLOAT_ARG_TYPE a, b;
  1475. {
  1476.   union flt_or_int intify;
  1477.   /* Value != 0 iff a != b.  */
  1478. #define perform_nesf2(a, b) return a != b
  1479.   perform_nesf2 (FLOATIFY (a), FLOATIFY (b));
  1480. }
  1481. #endif
  1482.  
  1483. asm("    .text
  1484.     .even
  1485. .globl ___nesf2
  1486. ___nesf2:
  1487.     movel d2,sp@-
  1488.     movel sp@(8),d1
  1489.     movel sp@(12),sp@-
  1490.     movel d1,sp@-
  1491.     jbsr ___cmpsf2
  1492.     addqw #8,sp
  1493.     tstl d0
  1494.     sne d0
  1495.     moveq #1,d2
  1496.     andl d2,d0
  1497.     movel sp@+,d2
  1498.     rts
  1499. ");
  1500. #endif
  1501.  
  1502. #ifdef L_gtsf2
  1503. #if 0
  1504. SItype
  1505. __gtsf2 (a, b)
  1506.      FLOAT_ARG_TYPE a, b;
  1507. {
  1508.   union flt_or_int intify;
  1509.   /* Value > 0 iff a > b.  */
  1510. #define perform_gtsf2(a, b) return a > b
  1511.   perform_gtsf2 (FLOATIFY (a), FLOATIFY (b));
  1512. }
  1513. #endif
  1514.  
  1515. asm("    .text
  1516.     .even
  1517. .globl ___gtsf2
  1518. ___gtsf2:
  1519.     movel d2,sp@-
  1520.     movel sp@(8),d1
  1521.     movel sp@(12),sp@-
  1522.     movel d1,sp@-
  1523.     jbsr ___cmpsf2
  1524.     addqw #8,sp
  1525.     tstl d0
  1526.     sgt d0
  1527.     moveq #1,d2
  1528.     andl d2,d0
  1529.     movel sp@+,d2
  1530.     rts
  1531. ");
  1532. #endif
  1533.  
  1534. #ifdef L_gesf2
  1535. #if 0
  1536. SItype
  1537. __gesf2 (a, b)
  1538.      FLOAT_ARG_TYPE a, b;
  1539. {
  1540.   union flt_or_int intify;
  1541.   /* Value >= 0 iff a >= b.  */
  1542. #define perform_gesf2(a, b) return (a >= b) - 1
  1543.   perform_gesf2 (FLOATIFY (a), FLOATIFY (b));
  1544. }
  1545. #endif
  1546.  
  1547. asm("    .text
  1548.     .even
  1549. .globl ___gesf2
  1550. ___gesf2:
  1551.     movel d2,sp@-
  1552.     movel sp@(8),d1
  1553.     movel sp@(12),sp@-
  1554.     movel d1,sp@-
  1555.     jbsr ___cmpsf2
  1556.     addqw #8,sp
  1557.     tstl d0
  1558.     sge d0
  1559.     moveq #1,d2
  1560.     andl d2,d0
  1561.     subql #1,d0
  1562.     movel sp@+,d2
  1563.     rts
  1564. ");
  1565. #endif
  1566.  
  1567. #ifdef L_ltsf2
  1568. #if 0
  1569. SItype
  1570. __ltsf2 (a, b)
  1571.      FLOAT_ARG_TYPE a, b;
  1572. {
  1573.   union flt_or_int intify;
  1574.   /* Value < 0 iff a < b.  */
  1575. #define perform_ltsf2(a, b) return -(a < b)
  1576.   perform_ltsf2 (FLOATIFY (a), FLOATIFY (b));
  1577. }
  1578. #endif
  1579.  
  1580. asm("    .text
  1581.     .even
  1582. .globl ___ltsf2
  1583. ___ltsf2:
  1584.     movel d2,sp@-
  1585.     movel sp@(8),d1
  1586.     movel sp@(12),sp@-
  1587.     movel d1,sp@-
  1588.     jbsr ___cmpsf2
  1589.     addqw #8,sp
  1590.     tstl d0
  1591.     slt d0
  1592.     moveq #1,d2
  1593.     andl d2,d0
  1594.     negl d0
  1595.     movel sp@+,d2
  1596.     rts
  1597. ");
  1598. #endif
  1599.  
  1600. #ifdef L_lesf2
  1601. #if 0
  1602. SItype
  1603. __lesf2 (a, b)
  1604.      FLOAT_ARG_TYPE a, b;
  1605. {
  1606.   union flt_or_int intify;
  1607.   /* Value <= 0 iff a <= b.  */
  1608. #define perform_lesf2(a, b) return 1 - (a <= b); /* note bug fix from libgcc1.c */
  1609.   perform_lesf2 (FLOATIFY (a), FLOATIFY (b));
  1610. }
  1611. #endif
  1612.  
  1613. asm("    .text
  1614.     .even
  1615. .globl ___lesf2
  1616. ___lesf2:
  1617.     movel d2,sp@-
  1618.     movel sp@(8),d0
  1619.     moveq #1,d2
  1620.     movel sp@(12),sp@-
  1621.     movel d0,sp@-
  1622.     jbsr ___cmpsf2
  1623.     addqw #8,sp
  1624.     tstl d0
  1625.     jgt L20
  1626.     moveq #0,d2
  1627. L20:
  1628.     movel d2,d0
  1629.     movel sp@+,d2
  1630.     rts
  1631. ");
  1632. #endif
  1633. #endif    /* # if 0 to ensure that the above functions are not compiled */
  1634.  
  1635.  
  1636. #ifdef L_fxussfsi
  1637. #include <limits.h>
  1638. unsigned SItype
  1639. __fixunssfsi (float a)
  1640. {
  1641.   if (a >= ((float) LONG_MAX)+1)
  1642.     return (SItype) (a + LONG_MIN) - LONG_MIN;
  1643.   return (SItype) a;
  1644. }
  1645. #endif
  1646.  
  1647. #ifdef L_gccbcmp
  1648.  
  1649. /* Like bcmp except the sign is meaningful.
  1650.    Reult is negative if S1 is less than S2,
  1651.    positive if S1 is greater, 0 if S1 and S2 are equal.  */
  1652.  
  1653. int
  1654. __gcc_bcmp (s1, s2, size)
  1655.      unsigned char *s1, *s2;
  1656.      size_t size;
  1657. {
  1658.   while (size > 0)
  1659.     {
  1660.       unsigned char c1 = *s1++, c2 = *s2++;
  1661.       if (c1 != c2)
  1662.     return c1 - c2;
  1663.       size--;
  1664.     }
  1665.   return 0;
  1666. }
  1667.  
  1668. #endif
  1669.