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