]> git.wh0rd.org Git - patches.git/blob - nios2-5.1.patch
more random patches. who knows.
[patches.git] / nios2-5.1.patch
1 the niosii-gnutools-src-5.1.tgz release from altera is missing a lot of
2 core gcc files, this patch adds them back in
3
4 --- ./gcc/gcc/config/nios2/crti.asm
5 +++ ./gcc/gcc/config/nios2/crti.asm
6 @@ -0,0 +1,88 @@
7 +/*
8 +  Copyright (C) 2003 
9 + by Jonah Graham (jgraham@altera.com)
10 +
11 +This file is free software; you can redistribute it and/or modify it
12 +under the terms of the GNU General Public License as published by the
13 +Free Software Foundation; either version 2, or (at your option) any
14 +later version.
15 +
16 +In addition to the permissions in the GNU General Public License, the
17 +Free Software Foundation gives you unlimited permission to link the
18 +compiled version of this file with other programs, and to distribute
19 +those programs without any restriction coming from the use of this
20 +file.  (The General Public License restrictions do apply in other
21 +respects; for example, they cover modification of the file, and
22 +distribution when not linked into another program.)
23 +
24 +This file is distributed in the hope that it will be useful, but
25 +WITHOUT ANY WARRANTY; without even the implied warranty of
26 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27 +General Public License for more details.
28 +
29 +You should have received a copy of the GNU General Public License
30 +along with this program; see the file COPYING.  If not, write to
31 +the Free Software Foundation, 59 Temple Place - Suite 330,
32 +Boston, MA 02111-1307, USA.
33 +
34 +   As a special exception, if you link this library with files
35 +   compiled with GCC to produce an executable, this does not cause
36 +   the resulting executable to be covered by the GNU General Public License.
37 +   This exception does not however invalidate any other reasons why
38 +   the executable file might be covered by the GNU General Public License.
39 +
40 +
41 +This file just make a stack frame for the contents of the .fini and
42 +.init sections.  Users may put any desired instructions in those
43 +sections.
44 +
45 +
46 +While technically any code can be put in the init and fini sections
47 +most stuff will not work other than stuff which obeys the call frame
48 +and ABI. All the call-preserved registers are saved, the call clobbered
49 +registers should have been saved by the code calling init and fini.
50 +
51 +See crtstuff.c for an example of code that inserts itself in the 
52 +init and fini sections. 
53 +
54 +See crt0.s for the code that calls init and fini.
55 +*/
56 +
57 +       .file   "crti.asm"
58 +
59 +       .section        ".init"
60 +       .align 2
61 +       .global _init
62 +_init:
63 +       addi    sp, sp, -48
64 +       stw     ra, 44(sp)
65 +       stw     r23, 40(sp)
66 +       stw     r22, 36(sp)
67 +       stw     r21, 32(sp)
68 +       stw     r20, 28(sp)
69 +       stw     r19, 24(sp)
70 +       stw     r18, 20(sp)
71 +       stw     r17, 16(sp)
72 +       stw     r16, 12(sp)
73 +       stw     fp, 8(sp)
74 +       mov     fp, sp
75 +       
76 +       
77 +       .section        ".fini"
78 +       .align  2
79 +       .global _fini
80 +_fini:
81 +       addi    sp, sp, -48
82 +       stw     ra, 44(sp)
83 +       stw     r23, 40(sp)
84 +       stw     r22, 36(sp)
85 +       stw     r21, 32(sp)
86 +       stw     r20, 28(sp)
87 +       stw     r19, 24(sp)
88 +       stw     r18, 20(sp)
89 +       stw     r17, 16(sp)
90 +       stw     r16, 12(sp)
91 +       stw     fp, 8(sp)
92 +       mov     fp, sp
93 +       
94 +
95 --- ./gcc/gcc/config/nios2/crtn.asm
96 +++ ./gcc/gcc/config/nios2/crtn.asm
97 @@ -0,0 +1,70 @@
98 +/*
99 +  Copyright (C) 2003 
100 + by Jonah Graham (jgraham@altera.com)
101 +
102 +This file is free software; you can redistribute it and/or modify it
103 +under the terms of the GNU General Public License as published by the
104 +Free Software Foundation; either version 2, or (at your option) any
105 +later version.
106 +
107 +In addition to the permissions in the GNU General Public License, the
108 +Free Software Foundation gives you unlimited permission to link the
109 +compiled version of this file with other programs, and to distribute
110 +those programs without any restriction coming from the use of this
111 +file.  (The General Public License restrictions do apply in other
112 +respects; for example, they cover modification of the file, and
113 +distribution when not linked into another program.)
114 +
115 +This file is distributed in the hope that it will be useful, but
116 +WITHOUT ANY WARRANTY; without even the implied warranty of
117 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
118 +General Public License for more details.
119 +
120 +You should have received a copy of the GNU General Public License
121 +along with this program; see the file COPYING.  If not, write to
122 +the Free Software Foundation, 59 Temple Place - Suite 330,
123 +Boston, MA 02111-1307, USA.
124 +
125 +   As a special exception, if you link this library with files
126 +   compiled with GCC to produce an executable, this does not cause
127 +   the resulting executable to be covered by the GNU General Public License.
128 +   This exception does not however invalidate any other reasons why
129 +   the executable file might be covered by the GNU General Public License.
130 +
131 +
132 +This file just makes sure that the .fini and .init sections do in
133 +fact return.  Users may put any desired instructions in those sections.
134 +This file is the last thing linked into any executable.
135 +*/     
136 +       .file   "crtn.asm"
137 +
138 +
139 +
140 +       .section        ".init"
141 +       ldw     ra, 44(sp)
142 +       ldw     r23, 40(sp)
143 +       ldw     r22, 36(sp)
144 +       ldw     r21, 32(sp)
145 +       ldw     r20, 28(sp)
146 +       ldw     r19, 24(sp)
147 +       ldw     r18, 20(sp)
148 +       ldw     r17, 16(sp)
149 +       ldw     r16, 12(sp)
150 +       ldw     fp, 8(sp)
151 +       addi    sp, sp, -48
152 +       ret
153 +       
154 +       .section        ".fini"
155 +       ldw     ra, 44(sp)
156 +       ldw     r23, 40(sp)
157 +       ldw     r22, 36(sp)
158 +       ldw     r21, 32(sp)
159 +       ldw     r20, 28(sp)
160 +       ldw     r19, 24(sp)
161 +       ldw     r18, 20(sp)
162 +       ldw     r17, 16(sp)
163 +       ldw     r16, 12(sp)
164 +       ldw     fp, 8(sp)
165 +       addi    sp, sp, -48
166 +       ret
167 +       
168 --- ./gcc/gcc/config/nios2/lib2-divmod-hi.c
169 +++ ./gcc/gcc/config/nios2/lib2-divmod-hi.c
170 @@ -0,0 +1,123 @@
171 +
172 +/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
173 +   supposedly valid even though this is a "target" file.  */
174 +#include "auto-host.h"
175 +
176 +
177 +#include "tconfig.h"
178 +#include "tsystem.h"
179 +#include "coretypes.h"
180 +#include "tm.h"
181 +
182 +
183 +/* Don't use `fancy_abort' here even if config.h says to use it.  */
184 +#ifdef abort
185 +#undef abort
186 +#endif
187 +
188 +
189 +#ifdef HAVE_GAS_HIDDEN
190 +#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
191 +#else
192 +#define ATTRIBUTE_HIDDEN
193 +#endif
194 +
195 +#include "libgcc2.h"
196 +
197 +extern HItype __modhi3 (HItype, HItype);
198 +extern HItype __divhi3 (HItype, HItype);
199 +extern HItype __umodhi3 (HItype, HItype);
200 +extern HItype __udivhi3 (HItype, HItype);
201 +
202 +static UHItype udivmodhi4(UHItype, UHItype, word_type);
203 +
204 +static UHItype
205 +udivmodhi4(UHItype num, UHItype den, word_type modwanted)
206 +{
207 +  UHItype bit = 1;
208 +  UHItype res = 0;
209 +
210 +  while (den < num && bit && !(den & (1L<<15)))
211 +    {
212 +      den <<=1;
213 +      bit <<=1;
214 +    }
215 +  while (bit)
216 +    {
217 +      if (num >= den)
218 +       {
219 +         num -= den;
220 +         res |= bit;
221 +       }
222 +      bit >>=1;
223 +      den >>=1;
224 +    }
225 +  if (modwanted) return num;
226 +  return res;
227 +}
228 +
229 +
230 +HItype
231 +__divhi3 (HItype a, HItype b)
232 +{
233 +  word_type neg = 0;
234 +  HItype res;
235 +
236 +  if (a < 0)
237 +    {
238 +      a = -a;
239 +      neg = !neg;
240 +    }
241 +
242 +  if (b < 0)
243 +    {
244 +      b = -b;
245 +      neg = !neg;
246 +    }
247 +
248 +  res = udivmodhi4 (a, b, 0);
249 +
250 +  if (neg)
251 +    res = -res;
252 +
253 +  return res;
254 +}
255 +
256 +
257 +HItype
258 +__modhi3 (HItype a, HItype b)
259 +{
260 +  word_type neg = 0;
261 +  HItype res;
262 +
263 +  if (a < 0)
264 +    {
265 +      a = -a;
266 +      neg = 1;
267 +    }
268 +
269 +  if (b < 0)
270 +    b = -b;
271 +
272 +  res = udivmodhi4 (a, b, 1);
273 +
274 +  if (neg)
275 +    res = -res;
276 +
277 +  return res;
278 +}
279 +
280 +
281 +HItype
282 +__udivhi3 (HItype a, HItype b)
283 +{
284 +  return udivmodhi4 (a, b, 0);
285 +}
286 +
287 +
288 +HItype
289 +__umodhi3 (HItype a, HItype b)
290 +{
291 +  return udivmodhi4 (a, b, 1);
292 +}
293 +
294 --- ./gcc/gcc/config/nios2/lib2-divmod.c
295 +++ ./gcc/gcc/config/nios2/lib2-divmod.c
296 @@ -0,0 +1,126 @@
297 +
298 +/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
299 +   supposedly valid even though this is a "target" file.  */
300 +#include "auto-host.h"
301 +
302 +
303 +#include "tconfig.h"
304 +#include "tsystem.h"
305 +#include "coretypes.h"
306 +#include "tm.h"
307 +
308 +
309 +/* Don't use `fancy_abort' here even if config.h says to use it.  */
310 +#ifdef abort
311 +#undef abort
312 +#endif
313 +
314 +
315 +#ifdef HAVE_GAS_HIDDEN
316 +#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
317 +#else
318 +#define ATTRIBUTE_HIDDEN
319 +#endif
320 +
321 +#include "libgcc2.h"
322 +
323 +extern SItype __modsi3 (SItype, SItype);
324 +extern SItype __divsi3 (SItype, SItype);
325 +extern SItype __umodsi3 (SItype, SItype);
326 +extern SItype __udivsi3 (SItype, SItype);
327 +
328 +static USItype udivmodsi4(USItype, USItype, word_type);
329 +
330 +/* 16-bit SI divide and modulo as used in NIOS */
331 +
332 +
333 +static USItype
334 +udivmodsi4(USItype num, USItype den, word_type modwanted)
335 +{
336 +  USItype bit = 1;
337 +  USItype res = 0;
338 +
339 +  while (den < num && bit && !(den & (1L<<31)))
340 +    {
341 +      den <<=1;
342 +      bit <<=1;
343 +    }
344 +  while (bit)
345 +    {
346 +      if (num >= den)
347 +       {
348 +         num -= den;
349 +         res |= bit;
350 +       }
351 +      bit >>=1;
352 +      den >>=1;
353 +    }
354 +  if (modwanted) return num;
355 +  return res;
356 +}
357 +
358 +
359 +SItype
360 +__divsi3 (SItype a, SItype b)
361 +{
362 +  word_type neg = 0;
363 +  SItype res;
364 +
365 +  if (a < 0)
366 +    {
367 +      a = -a;
368 +      neg = !neg;
369 +    }
370 +
371 +  if (b < 0)
372 +    {
373 +      b = -b;
374 +      neg = !neg;
375 +    }
376 +
377 +  res = udivmodsi4 (a, b, 0);
378 +
379 +  if (neg)
380 +    res = -res;
381 +
382 +  return res;
383 +}
384 +
385 +
386 +SItype
387 +__modsi3 (SItype a, SItype b)
388 +{
389 +  word_type neg = 0;
390 +  SItype res;
391 +
392 +  if (a < 0)
393 +    {
394 +      a = -a;
395 +      neg = 1;
396 +    }
397 +
398 +  if (b < 0)
399 +    b = -b;
400 +
401 +  res = udivmodsi4 (a, b, 1);
402 +
403 +  if (neg)
404 +    res = -res;
405 +
406 +  return res;
407 +}
408 +
409 +
410 +SItype
411 +__udivsi3 (SItype a, SItype b)
412 +{
413 +  return udivmodsi4 (a, b, 0);
414 +}
415 +
416 +
417 +SItype
418 +__umodsi3 (SItype a, SItype b)
419 +{
420 +  return udivmodsi4 (a, b, 1);
421 +}
422 +
423 --- ./gcc/gcc/config/nios2/lib2-divtable.c
424 +++ ./gcc/gcc/config/nios2/lib2-divtable.c
425 @@ -0,0 +1,46 @@
426 +
427 +/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
428 +   supposedly valid even though this is a "target" file.  */
429 +#include "auto-host.h"
430 +
431 +
432 +#include "tconfig.h"
433 +#include "tsystem.h"
434 +#include "coretypes.h"
435 +#include "tm.h"
436 +
437 +
438 +/* Don't use `fancy_abort' here even if config.h says to use it.  */
439 +#ifdef abort
440 +#undef abort
441 +#endif
442 +
443 +
444 +#ifdef HAVE_GAS_HIDDEN
445 +#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
446 +#else
447 +#define ATTRIBUTE_HIDDEN
448 +#endif
449 +
450 +#include "libgcc2.h"
451 +
452 +UQItype __divsi3_table[] =
453 +{
454 +  0, 0/1, 0/2, 0/3, 0/4, 0/5, 0/6, 0/7, 0/8, 0/9, 0/10, 0/11, 0/12, 0/13, 0/14, 0/15,
455 +  0, 1/1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15,
456 +  0, 2/1, 2/2, 2/3, 2/4, 2/5, 2/6, 2/7, 2/8, 2/9, 2/10, 2/11, 2/12, 2/13, 2/14, 2/15,
457 +  0, 3/1, 3/2, 3/3, 3/4, 3/5, 3/6, 3/7, 3/8, 3/9, 3/10, 3/11, 3/12, 3/13, 3/14, 3/15,
458 +  0, 4/1, 4/2, 4/3, 4/4, 4/5, 4/6, 4/7, 4/8, 4/9, 4/10, 4/11, 4/12, 4/13, 4/14, 4/15,
459 +  0, 5/1, 5/2, 5/3, 5/4, 5/5, 5/6, 5/7, 5/8, 5/9, 5/10, 5/11, 5/12, 5/13, 5/14, 5/15,
460 +  0, 6/1, 6/2, 6/3, 6/4, 6/5, 6/6, 6/7, 6/8, 6/9, 6/10, 6/11, 6/12, 6/13, 6/14, 6/15,
461 +  0, 7/1, 7/2, 7/3, 7/4, 7/5, 7/6, 7/7, 7/8, 7/9, 7/10, 7/11, 7/12, 7/13, 7/14, 7/15,
462 +  0, 8/1, 8/2, 8/3, 8/4, 8/5, 8/6, 8/7, 8/8, 8/9, 8/10, 8/11, 8/12, 8/13, 8/14, 8/15,
463 +  0, 9/1, 9/2, 9/3, 9/4, 9/5, 9/6, 9/7, 9/8, 9/9, 9/10, 9/11, 9/12, 9/13, 9/14, 9/15,
464 +  0, 10/1, 10/2, 10/3, 10/4, 10/5, 10/6, 10/7, 10/8, 10/9, 10/10, 10/11, 10/12, 10/13, 10/14, 10/15,
465 +  0, 11/1, 11/2, 11/3, 11/4, 11/5, 11/6, 11/7, 11/8, 11/9, 11/10, 11/11, 11/12, 11/13, 11/14, 11/15,
466 +  0, 12/1, 12/2, 12/3, 12/4, 12/5, 12/6, 12/7, 12/8, 12/9, 12/10, 12/11, 12/12, 12/13, 12/14, 12/15,
467 +  0, 13/1, 13/2, 13/3, 13/4, 13/5, 13/6, 13/7, 13/8, 13/9, 13/10, 13/11, 13/12, 13/13, 13/14, 13/15,
468 +  0, 14/1, 14/2, 14/3, 14/4, 14/5, 14/6, 14/7, 14/8, 14/9, 14/10, 14/11, 14/12, 14/13, 14/14, 14/15,
469 +  0, 15/1, 15/2, 15/3, 15/4, 15/5, 15/6, 15/7, 15/8, 15/9, 15/10, 15/11, 15/12, 15/13, 15/14, 15/15,
470 +};
471 +
472 --- ./gcc/gcc/config/nios2/lib2-mul.c
473 +++ ./gcc/gcc/config/nios2/lib2-mul.c
474 @@ -0,0 +1,103 @@
475 +/* while we are debugging (ie compile outside of gcc build) 
476 +   disable gcc specific headers */
477 +#ifndef DEBUG_MULSI3
478 +
479 +
480 +/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
481 +   supposedly valid even though this is a "target" file.  */
482 +#include "auto-host.h"
483 +
484 +
485 +#include "tconfig.h"
486 +#include "tsystem.h"
487 +#include "coretypes.h"
488 +#include "tm.h"
489 +
490 +
491 +/* Don't use `fancy_abort' here even if config.h says to use it.  */
492 +#ifdef abort
493 +#undef abort
494 +#endif
495 +
496 +
497 +#ifdef HAVE_GAS_HIDDEN
498 +#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
499 +#else
500 +#define ATTRIBUTE_HIDDEN
501 +#endif
502 +
503 +#include "libgcc2.h"
504 +
505 +#else
506 +#define SItype int
507 +#define USItype unsigned int
508 +#endif
509 +
510 +
511 +extern SItype __mulsi3 (SItype, SItype);
512 +
513 +SItype
514 +__mulsi3 (SItype a, SItype b)
515 +{
516 +  SItype res = 0;
517 +  USItype cnt = a;
518 +  
519 +  while (cnt)
520 +    {
521 +      if (cnt & 1)
522 +        {
523 +         res += b;       
524 +       }
525 +      b <<= 1;
526 +      cnt >>= 1;
527 +    }
528 +    
529 +  return res;
530 +}
531 +/*
532 +TODO: Choose best alternative implementation.
533 +
534 +SItype
535 +__divsi3 (SItype a, SItype b)
536 +{
537 +  SItype res = 0;
538 +  USItype cnt = 0;
539 +  
540 +  while (cnt < 32)
541 +    {
542 +      if (a & (1L << cnt))
543 +        {
544 +         res += b;       
545 +       }
546 +      b <<= 1;
547 +      cnt++;
548 +    }
549 +    
550 +  return res;
551 +}
552 +*/
553 +
554 +
555 +#ifdef DEBUG_MULSI3
556 +
557 +int
558 +main ()
559 +{
560 +  int i, j;
561 +  int error = 0;
562 +  
563 +  for (i = -1000; i < 1000; i++)
564 +    for (j = -1000; j < 1000; j++)
565 +      {
566 +       int expect = i * j;
567 +       int actual = A__divsi3 (i, j);
568 +       if (expect != actual)
569 +         {
570 +           printf ("error: %d * %d = %d not %d\n", i, j, expect, actual);
571 +           error = 1;
572 +         }
573 +      }
574 +
575 +  return error;
576 +}
577 +#endif
578 --- ./gcc/gcc/config/nios2/nios2-dp-bit.c
579 +++ ./gcc/gcc/config/nios2/nios2-dp-bit.c
580 @@ -0,0 +1,1652 @@
581 +
582 +/* This is a software floating point library which can be used
583 +   for targets without hardware floating point. 
584 +   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004
585 +   Free Software Foundation, Inc.
586 +
587 +This file is free software; you can redistribute it and/or modify it
588 +under the terms of the GNU General Public License as published by the
589 +Free Software Foundation; either version 2, or (at your option) any
590 +later version.
591 +
592 +In addition to the permissions in the GNU General Public License, the
593 +Free Software Foundation gives you unlimited permission to link the
594 +compiled version of this file with other programs, and to distribute
595 +those programs without any restriction coming from the use of this
596 +file.  (The General Public License restrictions do apply in other
597 +respects; for example, they cover modification of the file, and
598 +distribution when not linked into another program.)
599 +
600 +This file is distributed in the hope that it will be useful, but
601 +WITHOUT ANY WARRANTY; without even the implied warranty of
602 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
603 +General Public License for more details.
604 +
605 +You should have received a copy of the GNU General Public License
606 +along with this program; see the file COPYING.  If not, write to
607 +the Free Software Foundation, 59 Temple Place - Suite 330,
608 +Boston, MA 02111-1307, USA.  */
609 +
610 +/* As a special exception, if you link this library with other files,
611 +   some of which are compiled with GCC, to produce an executable,
612 +   this library does not by itself cause the resulting executable
613 +   to be covered by the GNU General Public License.
614 +   This exception does not however invalidate any other reasons why
615 +   the executable file might be covered by the GNU General Public License.  */
616 +
617 +/* This implements IEEE 754 format arithmetic, but does not provide a
618 +   mechanism for setting the rounding mode, or for generating or handling
619 +   exceptions.
620 +
621 +   The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
622 +   Wilson, all of Cygnus Support.  */
623 +
624 +/* The intended way to use this file is to make two copies, add `#define FLOAT'
625 +   to one copy, then compile both copies and add them to libgcc.a.  */
626 +
627 +#include "tconfig.h"
628 +#include "coretypes.h"
629 +#include "tm.h"
630 +#include "config/fp-bit.h"
631 +
632 +/* The following macros can be defined to change the behavior of this file:
633 +   FLOAT: Implement a `float', aka SFmode, fp library.  If this is not
634 +     defined, then this file implements a `double', aka DFmode, fp library.
635 +   FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.
636 +     don't include float->double conversion which requires the double library.
637 +     This is useful only for machines which can't support doubles, e.g. some
638 +     8-bit processors.
639 +   CMPtype: Specify the type that floating point compares should return.
640 +     This defaults to SItype, aka int.
641 +   US_SOFTWARE_GOFAST: This makes all entry points use the same names as the
642 +     US Software goFast library.
643 +   _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding
644 +     two integers to the FLO_union_type.
645 +   NO_DENORMALS: Disable handling of denormals.
646 +   NO_NANS: Disable nan and infinity handling
647 +   SMALL_MACHINE: Useful when operations on QIs and HIs are faster
648 +     than on an SI */
649 +
650 +/* We don't currently support extended floats (long doubles) on machines
651 +   without hardware to deal with them.
652 +
653 +   These stubs are just to keep the linker from complaining about unresolved
654 +   references which can be pulled in from libio & libstdc++, even if the
655 +   user isn't using long doubles.  However, they may generate an unresolved
656 +   external to abort if abort is not used by the function, and the stubs
657 +   are referenced from within libc, since libgcc goes before and after the
658 +   system library.  */
659 +
660 +#ifdef DECLARE_LIBRARY_RENAMES
661 +  DECLARE_LIBRARY_RENAMES
662 +#endif
663 +
664 +#ifdef EXTENDED_FLOAT_STUBS
665 +extern void abort (void);
666 +void __extendsfxf2 (void) { abort(); }
667 +void __extenddfxf2 (void) { abort(); }
668 +void __truncxfdf2 (void) { abort(); }
669 +void __truncxfsf2 (void) { abort(); }
670 +void __fixxfsi (void) { abort(); }
671 +void __floatsixf (void) { abort(); }
672 +void __addxf3 (void) { abort(); }
673 +void __subxf3 (void) { abort(); }
674 +void __mulxf3 (void) { abort(); }
675 +void __divxf3 (void) { abort(); }
676 +void __negxf2 (void) { abort(); }
677 +void __eqxf2 (void) { abort(); }
678 +void __nexf2 (void) { abort(); }
679 +void __gtxf2 (void) { abort(); }
680 +void __gexf2 (void) { abort(); }
681 +void __lexf2 (void) { abort(); }
682 +void __ltxf2 (void) { abort(); }
683 +
684 +void __extendsftf2 (void) { abort(); }
685 +void __extenddftf2 (void) { abort(); }
686 +void __trunctfdf2 (void) { abort(); }
687 +void __trunctfsf2 (void) { abort(); }
688 +void __fixtfsi (void) { abort(); }
689 +void __floatsitf (void) { abort(); }
690 +void __addtf3 (void) { abort(); }
691 +void __subtf3 (void) { abort(); }
692 +void __multf3 (void) { abort(); }
693 +void __divtf3 (void) { abort(); }
694 +void __negtf2 (void) { abort(); }
695 +void __eqtf2 (void) { abort(); }
696 +void __netf2 (void) { abort(); }
697 +void __gttf2 (void) { abort(); }
698 +void __getf2 (void) { abort(); }
699 +void __letf2 (void) { abort(); }
700 +void __lttf2 (void) { abort(); }
701 +#else  /* !EXTENDED_FLOAT_STUBS, rest of file */
702 +
703 +/* IEEE "special" number predicates */
704 +
705 +#ifdef NO_NANS
706 +
707 +#define nan() 0
708 +#define isnan(x) 0
709 +#define isinf(x) 0
710 +#else
711 +
712 +#if   defined L_thenan_sf
713 +const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
714 +#elif defined L_thenan_df
715 +const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };
716 +#elif defined L_thenan_tf
717 +const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
718 +#elif defined TFLOAT
719 +extern const fp_number_type __thenan_tf;
720 +#elif defined FLOAT
721 +extern const fp_number_type __thenan_sf;
722 +#else
723 +extern const fp_number_type __thenan_df;
724 +#endif
725 +
726 +INLINE
727 +static fp_number_type *
728 +nan (void)
729 +{
730 +  /* Discard the const qualifier...  */
731 +#ifdef TFLOAT
732 +  return (fp_number_type *) (& __thenan_tf);
733 +#elif defined FLOAT  
734 +  return (fp_number_type *) (& __thenan_sf);
735 +#else
736 +  return (fp_number_type *) (& __thenan_df);
737 +#endif
738 +}
739 +
740 +INLINE
741 +static int
742 +isnan ( fp_number_type *  x)
743 +{
744 +  return x->class == CLASS_SNAN || x->class == CLASS_QNAN;
745 +}
746 +
747 +INLINE
748 +static int
749 +isinf ( fp_number_type *  x)
750 +{
751 +  return x->class == CLASS_INFINITY;
752 +}
753 +
754 +#endif /* NO_NANS */
755 +
756 +INLINE
757 +static int
758 +iszero ( fp_number_type *  x)
759 +{
760 +  return x->class == CLASS_ZERO;
761 +}
762 +
763 +INLINE 
764 +static void
765 +flip_sign ( fp_number_type *  x)
766 +{
767 +  x->sign = !x->sign;
768 +}
769 +
770 +extern FLO_type pack_d ( fp_number_type * );
771 +
772 +#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
773 +FLO_type
774 +pack_d ( fp_number_type *  src)
775 +{
776 +  FLO_union_type dst;
777 +  fractype fraction = src->fraction.ll;        /* wasn't unsigned before? */
778 +  int sign = src->sign;
779 +  int exp = 0;
780 +
781 +  if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))
782 +    {
783 +      /* We can't represent these values accurately.  By using the
784 +        largest possible magnitude, we guarantee that the conversion
785 +        of infinity is at least as big as any finite number.  */
786 +      exp = EXPMAX;
787 +      fraction = ((fractype) 1 << FRACBITS) - 1;
788 +    }
789 +  else if (isnan (src))
790 +    {
791 +      exp = EXPMAX;
792 +      if (src->class == CLASS_QNAN || 1)
793 +       {
794 +#ifdef QUIET_NAN_NEGATED
795 +         fraction |= QUIET_NAN - 1;
796 +#else
797 +         fraction |= QUIET_NAN;
798 +#endif
799 +       }
800 +    }
801 +  else if (isinf (src))
802 +    {
803 +      exp = EXPMAX;
804 +      fraction = 0;
805 +    }
806 +  else if (iszero (src))
807 +    {
808 +      exp = 0;
809 +      fraction = 0;
810 +    }
811 +  else if (fraction == 0)
812 +    {
813 +      exp = 0;
814 +    }
815 +  else
816 +    {
817 +      if (src->normal_exp < NORMAL_EXPMIN)
818 +       {
819 +#ifdef NO_DENORMALS
820 +         /* Go straight to a zero representation if denormals are not
821 +            supported.  The denormal handling would be harmless but
822 +            isn't unnecessary.  */
823 +         exp = 0;
824 +         fraction = 0;
825 +#else /* NO_DENORMALS */
826 +         /* This number's exponent is too low to fit into the bits
827 +            available in the number, so we'll store 0 in the exponent and
828 +            shift the fraction to the right to make up for it.  */
829 +
830 +         int shift = NORMAL_EXPMIN - src->normal_exp;
831 +
832 +         exp = 0;
833 +
834 +         if (shift > FRAC_NBITS - NGARDS)
835 +           {
836 +             /* No point shifting, since it's more that 64 out.  */
837 +             fraction = 0;
838 +           }
839 +         else
840 +           {
841 +             int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;
842 +             fraction = (fraction >> shift) | lowbit;
843 +           }
844 +         if ((fraction & GARDMASK) == GARDMSB)
845 +           {
846 +             if ((fraction & (1 << NGARDS)))
847 +               fraction += GARDROUND + 1;
848 +           }
849 +         else
850 +           {
851 +             /* Add to the guards to round up.  */
852 +             fraction += GARDROUND;
853 +           }
854 +         /* Perhaps the rounding means we now need to change the
855 +             exponent, because the fraction is no longer denormal.  */
856 +         if (fraction >= IMPLICIT_1)
857 +           {
858 +             exp += 1;
859 +           }
860 +         fraction >>= NGARDS;
861 +#endif /* NO_DENORMALS */
862 +       }
863 +      else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
864 +              && src->normal_exp > EXPBIAS)
865 +       {
866 +         exp = EXPMAX;
867 +         fraction = 0;
868 +       }
869 +      else
870 +       {
871 +         exp = src->normal_exp + EXPBIAS;
872 +         if (!ROUND_TOWARDS_ZERO)
873 +           {
874 +             /* IF the gard bits are the all zero, but the first, then we're
875 +                half way between two numbers, choose the one which makes the
876 +                lsb of the answer 0.  */
877 +             if ((fraction & GARDMASK) == GARDMSB)
878 +               {
879 +                 if (fraction & (1 << NGARDS))
880 +                   fraction += GARDROUND + 1;
881 +               }
882 +             else
883 +               {
884 +                 /* Add a one to the guards to round up */
885 +                 fraction += GARDROUND;
886 +               }
887 +             if (fraction >= IMPLICIT_2)
888 +               {
889 +                 fraction >>= 1;
890 +                 exp += 1;
891 +               }
892 +           }
893 +         fraction >>= NGARDS;
894 +
895 +         if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)
896 +           {
897 +             /* Saturate on overflow.  */
898 +             exp = EXPMAX;
899 +             fraction = ((fractype) 1 << FRACBITS) - 1;
900 +           }
901 +       }
902 +    }
903 +
904 +  /* We previously used bitfields to store the number, but this doesn't
905 +     handle little/big endian systems conveniently, so use shifts and
906 +     masks */
907 +#ifdef FLOAT_BIT_ORDER_MISMATCH
908 +  dst.bits.fraction = fraction;
909 +  dst.bits.exp = exp;
910 +  dst.bits.sign = sign;
911 +#else
912 +# if defined TFLOAT && defined HALFFRACBITS
913 + {
914 +   halffractype high, low, unity;
915 +   int lowsign, lowexp;
916 +
917 +   unity = (halffractype) 1 << HALFFRACBITS;
918 +
919 +   /* Set HIGH to the high double's significand, masking out the implicit 1.
920 +      Set LOW to the low double's full significand.  */
921 +   high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);
922 +   low = fraction & (unity * 2 - 1);
923 +
924 +   /* Get the initial sign and exponent of the low double.  */
925 +   lowexp = exp - HALFFRACBITS - 1;
926 +   lowsign = sign;
927 +
928 +   /* HIGH should be rounded like a normal double, making |LOW| <=
929 +      0.5 ULP of HIGH.  Assume round-to-nearest.  */
930 +   if (exp < EXPMAX)
931 +     if (low > unity || (low == unity && (high & 1) == 1))
932 +       {
933 +        /* Round HIGH up and adjust LOW to match.  */
934 +        high++;
935 +        if (high == unity)
936 +          {
937 +            /* May make it infinite, but that's OK.  */
938 +            high = 0;
939 +            exp++;
940 +          }
941 +        low = unity * 2 - low;
942 +        lowsign ^= 1;
943 +       }
944 +
945 +   high |= (halffractype) exp << HALFFRACBITS;
946 +   high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);
947 +
948 +   if (exp == EXPMAX || exp == 0 || low == 0)
949 +     low = 0;
950 +   else
951 +     {
952 +       while (lowexp > 0 && low < unity)
953 +        {
954 +          low <<= 1;
955 +          lowexp--;
956 +        }
957 +
958 +       if (lowexp <= 0)
959 +        {
960 +          halffractype roundmsb, round;
961 +          int shift;
962 +
963 +          shift = 1 - lowexp;
964 +          roundmsb = (1 << (shift - 1));
965 +          round = low & ((roundmsb << 1) - 1);
966 +
967 +          low >>= shift;
968 +          lowexp = 0;
969 +
970 +          if (round > roundmsb || (round == roundmsb && (low & 1) == 1))
971 +            {
972 +              low++;
973 +              if (low == unity)
974 +                /* LOW rounds up to the smallest normal number.  */
975 +                lowexp++;
976 +            }
977 +        }
978 +
979 +       low &= unity - 1;
980 +       low |= (halffractype) lowexp << HALFFRACBITS;
981 +       low |= (halffractype) lowsign << (HALFFRACBITS + EXPBITS);
982 +     }
983 +   dst.value_raw = ((fractype) high << HALFSHIFT) | low;
984 + }
985 +# else
986 +  dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
987 +  dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
988 +  dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
989 +# endif
990 +#endif
991 +
992 +#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
993 +#ifdef TFLOAT
994 +  {
995 +    qrtrfractype tmp1 = dst.words[0];
996 +    qrtrfractype tmp2 = dst.words[1];
997 +    dst.words[0] = dst.words[3];
998 +    dst.words[1] = dst.words[2];
999 +    dst.words[2] = tmp2;
1000 +    dst.words[3] = tmp1;
1001 +  }
1002 +#else
1003 +  {
1004 +    halffractype tmp = dst.words[0];
1005 +    dst.words[0] = dst.words[1];
1006 +    dst.words[1] = tmp;
1007 +  }
1008 +#endif
1009 +#endif
1010 +
1011 +  return dst.value;
1012 +}
1013 +#endif
1014 +
1015 +#if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
1016 +void
1017 +unpack_d (FLO_union_type * src, fp_number_type * dst)
1018 +{
1019 +  /* We previously used bitfields to store the number, but this doesn't
1020 +     handle little/big endian systems conveniently, so use shifts and
1021 +     masks */
1022 +  fractype fraction;
1023 +  int exp;
1024 +  int sign;
1025 +
1026 +#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
1027 +  FLO_union_type swapped;
1028 +
1029 +#ifdef TFLOAT
1030 +  swapped.words[0] = src->words[3];
1031 +  swapped.words[1] = src->words[2];
1032 +  swapped.words[2] = src->words[1];
1033 +  swapped.words[3] = src->words[0];
1034 +#else
1035 +  swapped.words[0] = src->words[1];
1036 +  swapped.words[1] = src->words[0];
1037 +#endif
1038 +  src = &swapped;
1039 +#endif
1040 +  
1041 +#ifdef FLOAT_BIT_ORDER_MISMATCH
1042 +  fraction = src->bits.fraction;
1043 +  exp = src->bits.exp;
1044 +  sign = src->bits.sign;
1045 +#else
1046 +# if defined TFLOAT && defined HALFFRACBITS
1047 + {
1048 +   halffractype high, low;
1049 +   
1050 +   high = src->value_raw >> HALFSHIFT;
1051 +   low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1);
1052 +
1053 +   fraction = high & ((((fractype)1) << HALFFRACBITS) - 1);
1054 +   fraction <<= FRACBITS - HALFFRACBITS;
1055 +   exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
1056 +   sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1;
1057 +
1058 +   if (exp != EXPMAX && exp != 0 && low != 0)
1059 +     {
1060 +       int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
1061 +       int lowsign = ((int)(low >> (((HALFFRACBITS + EXPBITS))))) & 1;
1062 +       int shift;
1063 +       fractype xlow;
1064 +
1065 +       xlow = low & ((((fractype)1) << HALFFRACBITS) - 1);
1066 +       if (lowexp)
1067 +        xlow |= (((halffractype)1) << HALFFRACBITS);
1068 +       else
1069 +        lowexp = 1;
1070 +       shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp);
1071 +       if (shift > 0)
1072 +        xlow <<= shift;
1073 +       else if (shift < 0)
1074 +        xlow >>= -shift;
1075 +       if (sign == lowsign)
1076 +        fraction += xlow;
1077 +       else if (fraction >= xlow)
1078 +        fraction -= xlow;
1079 +       else
1080 +        {
1081 +          /* The high part is a power of two but the full number is lower.
1082 +             This code will leave the implicit 1 in FRACTION, but we'd
1083 +             have added that below anyway.  */
1084 +          fraction = (((fractype) 1 << FRACBITS) - xlow) << 1;
1085 +          exp--;
1086 +        }
1087 +     }
1088 + }
1089 +# else
1090 +  fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
1091 +  exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
1092 +  sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
1093 +# endif
1094 +#endif
1095 +
1096 +  dst->sign = sign;
1097 +  if (exp == 0)
1098 +    {
1099 +      /* Hmm.  Looks like 0 */
1100 +      if (fraction == 0
1101 +#ifdef NO_DENORMALS
1102 +         || 1
1103 +#endif
1104 +         )
1105 +       {
1106 +         /* tastes like zero */
1107 +         dst->class = CLASS_ZERO;
1108 +       }
1109 +      else
1110 +       {
1111 +         /* Zero exponent with nonzero fraction - it's denormalized,
1112 +            so there isn't a leading implicit one - we'll shift it so
1113 +            it gets one.  */
1114 +         dst->normal_exp = exp - EXPBIAS + 1;
1115 +         fraction <<= NGARDS;
1116 +
1117 +         dst->class = CLASS_NUMBER;
1118 +#if 1
1119 +         while (fraction < IMPLICIT_1)
1120 +           {
1121 +             fraction <<= 1;
1122 +             dst->normal_exp--;
1123 +           }
1124 +#endif
1125 +         dst->fraction.ll = fraction;
1126 +       }
1127 +    }
1128 +  else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp == EXPMAX)
1129 +    {
1130 +      /* Huge exponent*/
1131 +      if (fraction == 0)
1132 +       {
1133 +         /* Attached to a zero fraction - means infinity */
1134 +         dst->class = CLASS_INFINITY;
1135 +       }
1136 +      else
1137 +       {
1138 +         /* Nonzero fraction, means nan */
1139 +#ifdef QUIET_NAN_NEGATED
1140 +         if ((fraction & QUIET_NAN) == 0)
1141 +#else
1142 +         if (fraction & QUIET_NAN)
1143 +#endif
1144 +           {
1145 +             dst->class = CLASS_QNAN;
1146 +           }
1147 +         else
1148 +           {
1149 +             dst->class = CLASS_SNAN;
1150 +           }
1151 +         /* Keep the fraction part as the nan number */
1152 +         dst->fraction.ll = fraction;
1153 +       }
1154 +    }
1155 +  else
1156 +    {
1157 +      /* Nothing strange about this number */
1158 +      dst->normal_exp = exp - EXPBIAS;
1159 +      dst->class = CLASS_NUMBER;
1160 +      dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
1161 +    }
1162 +}
1163 +#endif /* L_unpack_df || L_unpack_sf */
1164 +
1165 +#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
1166 +static fp_number_type *
1167 +_fpadd_parts (fp_number_type * a,
1168 +             fp_number_type * b,
1169 +             fp_number_type * tmp)
1170 +{
1171 +  intfrac tfraction;
1172 +
1173 +  /* Put commonly used fields in local variables.  */
1174 +  int a_normal_exp;
1175 +  int b_normal_exp;
1176 +  fractype a_fraction;
1177 +  fractype b_fraction;
1178 +
1179 +  if (isnan (a))
1180 +    {
1181 +      return a;
1182 +    }
1183 +  if (isnan (b))
1184 +    {
1185 +      return b;
1186 +    }
1187 +  if (isinf (a))
1188 +    {
1189 +      /* Adding infinities with opposite signs yields a NaN.  */
1190 +      if (isinf (b) && a->sign != b->sign)
1191 +       return nan ();
1192 +      return a;
1193 +    }
1194 +  if (isinf (b))
1195 +    {
1196 +      return b;
1197 +    }
1198 +  if (iszero (b))
1199 +    {
1200 +      if (iszero (a))
1201 +       {
1202 +         *tmp = *a;
1203 +         tmp->sign = a->sign & b->sign;
1204 +         return tmp;
1205 +       }
1206 +      return a;
1207 +    }
1208 +  if (iszero (a))
1209 +    {
1210 +      return b;
1211 +    }
1212 +
1213 +  /* Got two numbers. shift the smaller and increment the exponent till
1214 +     they're the same */
1215 +  {
1216 +    int diff;
1217 +
1218 +    a_normal_exp = a->normal_exp;
1219 +    b_normal_exp = b->normal_exp;
1220 +    a_fraction = a->fraction.ll;
1221 +    b_fraction = b->fraction.ll;
1222 +
1223 +    diff = a_normal_exp - b_normal_exp;
1224 +
1225 +    if (diff < 0)
1226 +      diff = -diff;
1227 +    if (diff < FRAC_NBITS)
1228 +      {
1229 +       /* ??? This does shifts one bit at a time.  Optimize.  */
1230 +       while (a_normal_exp > b_normal_exp)
1231 +         {
1232 +           b_normal_exp++;
1233 +           LSHIFT (b_fraction);
1234 +         }
1235 +       while (b_normal_exp > a_normal_exp)
1236 +         {
1237 +           a_normal_exp++;
1238 +           LSHIFT (a_fraction);
1239 +         }
1240 +      }
1241 +    else
1242 +      {
1243 +       /* Somethings's up.. choose the biggest */
1244 +       if (a_normal_exp > b_normal_exp)
1245 +         {
1246 +           b_normal_exp = a_normal_exp;
1247 +           b_fraction = 0;
1248 +         }
1249 +       else
1250 +         {
1251 +           a_normal_exp = b_normal_exp;
1252 +           a_fraction = 0;
1253 +         }
1254 +      }
1255 +  }
1256 +
1257 +  if (a->sign != b->sign)
1258 +    {
1259 +      if (a->sign)
1260 +       {
1261 +         tfraction = -a_fraction + b_fraction;
1262 +       }
1263 +      else
1264 +       {
1265 +         tfraction = a_fraction - b_fraction;
1266 +       }
1267 +      if (tfraction >= 0)
1268 +       {
1269 +         tmp->sign = 0;
1270 +         tmp->normal_exp = a_normal_exp;
1271 +         tmp->fraction.ll = tfraction;
1272 +       }
1273 +      else
1274 +       {
1275 +         tmp->sign = 1;
1276 +         tmp->normal_exp = a_normal_exp;
1277 +         tmp->fraction.ll = -tfraction;
1278 +       }
1279 +      /* and renormalize it */
1280 +
1281 +      while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
1282 +       {
1283 +         tmp->fraction.ll <<= 1;
1284 +         tmp->normal_exp--;
1285 +       }
1286 +    }
1287 +  else
1288 +    {
1289 +      tmp->sign = a->sign;
1290 +      tmp->normal_exp = a_normal_exp;
1291 +      tmp->fraction.ll = a_fraction + b_fraction;
1292 +    }
1293 +  tmp->class = CLASS_NUMBER;
1294 +  /* Now the fraction is added, we have to shift down to renormalize the
1295 +     number */
1296 +
1297 +  if (tmp->fraction.ll >= IMPLICIT_2)
1298 +    {
1299 +      LSHIFT (tmp->fraction.ll);
1300 +      tmp->normal_exp++;
1301 +    }
1302 +  return tmp;
1303 +
1304 +}
1305 +
1306 +FLO_type
1307 +add (FLO_type arg_a, FLO_type arg_b)
1308 +{
1309 +  fp_number_type a;
1310 +  fp_number_type b;
1311 +  fp_number_type tmp;
1312 +  fp_number_type *res;
1313 +  FLO_union_type au, bu;
1314 +
1315 +  au.value = arg_a;
1316 +  bu.value = arg_b;
1317 +
1318 +  unpack_d (&au, &a);
1319 +  unpack_d (&bu, &b);
1320 +
1321 +  res = _fpadd_parts (&a, &b, &tmp);
1322 +
1323 +  return pack_d (res);
1324 +}
1325 +
1326 +FLO_type
1327 +sub (FLO_type arg_a, FLO_type arg_b)
1328 +{
1329 +  fp_number_type a;
1330 +  fp_number_type b;
1331 +  fp_number_type tmp;
1332 +  fp_number_type *res;
1333 +  FLO_union_type au, bu;
1334 +
1335 +  au.value = arg_a;
1336 +  bu.value = arg_b;
1337 +
1338 +  unpack_d (&au, &a);
1339 +  unpack_d (&bu, &b);
1340 +
1341 +  b.sign ^= 1;
1342 +
1343 +  res = _fpadd_parts (&a, &b, &tmp);
1344 +
1345 +  return pack_d (res);
1346 +}
1347 +#endif /* L_addsub_sf || L_addsub_df */
1348 +
1349 +#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
1350 +static inline __attribute__ ((__always_inline__)) fp_number_type *
1351 +_fpmul_parts ( fp_number_type *  a,
1352 +              fp_number_type *  b,
1353 +              fp_number_type * tmp)
1354 +{
1355 +  fractype low = 0;
1356 +  fractype high = 0;
1357 +
1358 +  if (isnan (a))
1359 +    {
1360 +      a->sign = a->sign != b->sign;
1361 +      return a;
1362 +    }
1363 +  if (isnan (b))
1364 +    {
1365 +      b->sign = a->sign != b->sign;
1366 +      return b;
1367 +    }
1368 +  if (isinf (a))
1369 +    {
1370 +      if (iszero (b))
1371 +       return nan ();
1372 +      a->sign = a->sign != b->sign;
1373 +      return a;
1374 +    }
1375 +  if (isinf (b))
1376 +    {
1377 +      if (iszero (a))
1378 +       {
1379 +         return nan ();
1380 +       }
1381 +      b->sign = a->sign != b->sign;
1382 +      return b;
1383 +    }
1384 +  if (iszero (a))
1385 +    {
1386 +      a->sign = a->sign != b->sign;
1387 +      return a;
1388 +    }
1389 +  if (iszero (b))
1390 +    {
1391 +      b->sign = a->sign != b->sign;
1392 +      return b;
1393 +    }
1394 +
1395 +  /* Calculate the mantissa by multiplying both numbers to get a
1396 +     twice-as-wide number.  */
1397 +  {
1398 +#if defined(NO_DI_MODE) || defined(TFLOAT)
1399 +    {
1400 +      fractype x = a->fraction.ll;
1401 +      fractype ylow = b->fraction.ll;
1402 +      fractype yhigh = 0;
1403 +      int bit;
1404 +
1405 +      /* ??? This does multiplies one bit at a time.  Optimize.  */
1406 +      for (bit = 0; bit < FRAC_NBITS; bit++)
1407 +       {
1408 +         int carry;
1409 +
1410 +         if (x & 1)
1411 +           {
1412 +             carry = (low += ylow) < ylow;
1413 +             high += yhigh + carry;
1414 +           }
1415 +         yhigh <<= 1;
1416 +         if (ylow & FRACHIGH)
1417 +           {
1418 +             yhigh |= 1;
1419 +           }
1420 +         ylow <<= 1;
1421 +         x >>= 1;
1422 +       }
1423 +    }
1424 +#elif defined(FLOAT) 
1425 +    /* Multiplying two USIs to get a UDI, we're safe.  */
1426 +    {
1427 +      UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
1428 +      
1429 +      high = answer >> BITS_PER_SI;
1430 +      low = answer;
1431 +    }
1432 +#else
1433 +    /* fractype is DImode, but we need the result to be twice as wide.
1434 +       Assuming a widening multiply from DImode to TImode is not
1435 +       available, build one by hand.  */
1436 +    {
1437 +      USItype nl = a->fraction.ll;
1438 +      USItype nh = a->fraction.ll >> BITS_PER_SI;
1439 +      USItype ml = b->fraction.ll;
1440 +      USItype mh = b->fraction.ll >> BITS_PER_SI;
1441 +      UDItype pp_ll = (UDItype) ml * nl;
1442 +      UDItype pp_hl = (UDItype) mh * nl;
1443 +      UDItype pp_lh = (UDItype) ml * nh;
1444 +      UDItype pp_hh = (UDItype) mh * nh;
1445 +      UDItype res2 = 0;
1446 +      UDItype res0 = 0;
1447 +      UDItype ps_hh__ = pp_hl + pp_lh;
1448 +      if (ps_hh__ < pp_hl)
1449 +       res2 += (UDItype)1 << BITS_PER_SI;
1450 +      pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
1451 +      res0 = pp_ll + pp_hl;
1452 +      if (res0 < pp_ll)
1453 +       res2++;
1454 +      res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
1455 +      high = res2;
1456 +      low = res0;
1457 +    }
1458 +#endif
1459 +  }
1460 +
1461 +  tmp->normal_exp = a->normal_exp + b->normal_exp
1462 +    + FRAC_NBITS - (FRACBITS + NGARDS);
1463 +  tmp->sign = a->sign != b->sign;
1464 +  while (high >= IMPLICIT_2)
1465 +    {
1466 +      tmp->normal_exp++;
1467 +      if (high & 1)
1468 +       {
1469 +         low >>= 1;
1470 +         low |= FRACHIGH;
1471 +       }
1472 +      high >>= 1;
1473 +    }
1474 +  while (high < IMPLICIT_1)
1475 +    {
1476 +      tmp->normal_exp--;
1477 +
1478 +      high <<= 1;
1479 +      if (low & FRACHIGH)
1480 +       high |= 1;
1481 +      low <<= 1;
1482 +    }
1483 +  /* rounding is tricky. if we only round if it won't make us round later.  */
1484 +#if 0
1485 +  if (low & FRACHIGH2)
1486 +    {
1487 +      if (((high & GARDMASK) != GARDMSB)
1488 +         && (((high + 1) & GARDMASK) == GARDMSB))
1489 +       {
1490 +         /* don't round, it gets done again later.  */
1491 +       }
1492 +      else
1493 +       {
1494 +         high++;
1495 +       }
1496 +    }
1497 +#endif
1498 +  if (!ROUND_TOWARDS_ZERO && (high & GARDMASK) == GARDMSB)
1499 +    {
1500 +      if (high & (1 << NGARDS))
1501 +       {
1502 +         /* half way, so round to even */
1503 +         high += GARDROUND + 1;
1504 +       }
1505 +      else if (low)
1506 +       {
1507 +         /* but we really weren't half way */
1508 +         high += GARDROUND + 1;
1509 +       }
1510 +    }
1511 +  tmp->fraction.ll = high;
1512 +  tmp->class = CLASS_NUMBER;
1513 +  return tmp;
1514 +}
1515 +
1516 +FLO_type
1517 +multiply (FLO_type arg_a, FLO_type arg_b)
1518 +{
1519 +  fp_number_type a;
1520 +  fp_number_type b;
1521 +  fp_number_type tmp;
1522 +  fp_number_type *res;
1523 +  FLO_union_type au, bu;
1524 +
1525 +  au.value = arg_a;
1526 +  bu.value = arg_b;
1527 +
1528 +  unpack_d (&au, &a);
1529 +  unpack_d (&bu, &b);
1530 +
1531 +  res = _fpmul_parts (&a, &b, &tmp);
1532 +
1533 +  return pack_d (res);
1534 +}
1535 +#endif /* L_mul_sf || L_mul_df */
1536 +
1537 +#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
1538 +static inline __attribute__ ((__always_inline__)) fp_number_type *
1539 +_fpdiv_parts (fp_number_type * a,
1540 +             fp_number_type * b)
1541 +{
1542 +  fractype bit;
1543 +  fractype numerator;
1544 +  fractype denominator;
1545 +  fractype quotient;
1546 +
1547 +  if (isnan (a))
1548 +    {
1549 +      return a;
1550 +    }
1551 +  if (isnan (b))
1552 +    {
1553 +      return b;
1554 +    }
1555 +
1556 +  a->sign = a->sign ^ b->sign;
1557 +
1558 +  if (isinf (a) || iszero (a))
1559 +    {
1560 +      if (a->class == b->class)
1561 +       return nan ();
1562 +      return a;
1563 +    }
1564 +
1565 +  if (isinf (b))
1566 +    {
1567 +      a->fraction.ll = 0;
1568 +      a->normal_exp = 0;
1569 +      return a;
1570 +    }
1571 +  if (iszero (b))
1572 +    {
1573 +      a->class = CLASS_INFINITY;
1574 +      return a;
1575 +    }
1576 +
1577 +  /* Calculate the mantissa by multiplying both 64bit numbers to get a
1578 +     128 bit number */
1579 +  {
1580 +    /* quotient =
1581 +       ( numerator / denominator) * 2^(numerator exponent -  denominator exponent)
1582 +     */
1583 +
1584 +    a->normal_exp = a->normal_exp - b->normal_exp;
1585 +    numerator = a->fraction.ll;
1586 +    denominator = b->fraction.ll;
1587 +
1588 +    if (numerator < denominator)
1589 +      {
1590 +       /* Fraction will be less than 1.0 */
1591 +       numerator *= 2;
1592 +       a->normal_exp--;
1593 +      }
1594 +    bit = IMPLICIT_1;
1595 +    quotient = 0;
1596 +    /* ??? Does divide one bit at a time.  Optimize.  */
1597 +    while (bit)
1598 +      {
1599 +       if (numerator >= denominator)
1600 +         {
1601 +           quotient |= bit;
1602 +           numerator -= denominator;
1603 +         }
1604 +       bit >>= 1;
1605 +       numerator *= 2;
1606 +      }
1607 +
1608 +    if (!ROUND_TOWARDS_ZERO && (quotient & GARDMASK) == GARDMSB)
1609 +      {
1610 +       if (quotient & (1 << NGARDS))
1611 +         {
1612 +           /* half way, so round to even */
1613 +           quotient += GARDROUND + 1;
1614 +         }
1615 +       else if (numerator)
1616 +         {
1617 +           /* but we really weren't half way, more bits exist */
1618 +           quotient += GARDROUND + 1;
1619 +         }
1620 +      }
1621 +
1622 +    a->fraction.ll = quotient;
1623 +    return (a);
1624 +  }
1625 +}
1626 +
1627 +FLO_type
1628 +divide (FLO_type arg_a, FLO_type arg_b)
1629 +{
1630 +  fp_number_type a;
1631 +  fp_number_type b;
1632 +  fp_number_type *res;
1633 +  FLO_union_type au, bu;
1634 +
1635 +  au.value = arg_a;
1636 +  bu.value = arg_b;
1637 +
1638 +  unpack_d (&au, &a);
1639 +  unpack_d (&bu, &b);
1640 +
1641 +  res = _fpdiv_parts (&a, &b);
1642 +
1643 +  return pack_d (res);
1644 +}
1645 +#endif /* L_div_sf || L_div_df */
1646 +
1647 +#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
1648 +    || defined(L_fpcmp_parts_tf)
1649 +/* according to the demo, fpcmp returns a comparison with 0... thus
1650 +   a<b -> -1
1651 +   a==b -> 0
1652 +   a>b -> +1
1653 + */
1654 +
1655 +int
1656 +__fpcmp_parts (fp_number_type * a, fp_number_type * b)
1657 +{
1658 +#if 0
1659 +  /* either nan -> unordered. Must be checked outside of this routine.  */
1660 +  if (isnan (a) && isnan (b))
1661 +    {
1662 +      return 1;                        /* still unordered! */
1663 +    }
1664 +#endif
1665 +
1666 +  if (isnan (a) || isnan (b))
1667 +    {
1668 +      return 1;                        /* how to indicate unordered compare? */
1669 +    }
1670 +  if (isinf (a) && isinf (b))
1671 +    {
1672 +      /* +inf > -inf, but +inf != +inf */
1673 +      /* b    \a| +inf(0)| -inf(1)
1674 +       ______\+--------+--------
1675 +       +inf(0)| a==b(0)| a<b(-1)
1676 +       -------+--------+--------
1677 +       -inf(1)| a>b(1) | a==b(0)
1678 +       -------+--------+--------
1679 +       So since unordered must be nonzero, just line up the columns...
1680 +       */
1681 +      return b->sign - a->sign;
1682 +    }
1683 +  /* but not both...  */
1684 +  if (isinf (a))
1685 +    {
1686 +      return a->sign ? -1 : 1;
1687 +    }
1688 +  if (isinf (b))
1689 +    {
1690 +      return b->sign ? 1 : -1;
1691 +    }
1692 +  if (iszero (a) && iszero (b))
1693 +    {
1694 +      return 0;
1695 +    }
1696 +  if (iszero (a))
1697 +    {
1698 +      return b->sign ? 1 : -1;
1699 +    }
1700 +  if (iszero (b))
1701 +    {
1702 +      return a->sign ? -1 : 1;
1703 +    }
1704 +  /* now both are "normal".  */
1705 +  if (a->sign != b->sign)
1706 +    {
1707 +      /* opposite signs */
1708 +      return a->sign ? -1 : 1;
1709 +    }
1710 +  /* same sign; exponents? */
1711 +  if (a->normal_exp > b->normal_exp)
1712 +    {
1713 +      return a->sign ? -1 : 1;
1714 +    }
1715 +  if (a->normal_exp < b->normal_exp)
1716 +    {
1717 +      return a->sign ? 1 : -1;
1718 +    }
1719 +  /* same exponents; check size.  */
1720 +  if (a->fraction.ll > b->fraction.ll)
1721 +    {
1722 +      return a->sign ? -1 : 1;
1723 +    }
1724 +  if (a->fraction.ll < b->fraction.ll)
1725 +    {
1726 +      return a->sign ? 1 : -1;
1727 +    }
1728 +  /* after all that, they're equal.  */
1729 +  return 0;
1730 +}
1731 +#endif
1732 +
1733 +#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
1734 +CMPtype
1735 +compare (FLO_type arg_a, FLO_type arg_b)
1736 +{
1737 +  fp_number_type a;
1738 +  fp_number_type b;
1739 +  FLO_union_type au, bu;
1740 +
1741 +  au.value = arg_a;
1742 +  bu.value = arg_b;
1743 +
1744 +  unpack_d (&au, &a);
1745 +  unpack_d (&bu, &b);
1746 +
1747 +  return __fpcmp_parts (&a, &b);
1748 +}
1749 +#endif /* L_compare_sf || L_compare_df */
1750 +
1751 +#ifndef US_SOFTWARE_GOFAST
1752 +
1753 +/* These should be optimized for their specific tasks someday.  */
1754 +
1755 +#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
1756 +CMPtype
1757 +_eq_f2 (FLO_type arg_a, FLO_type arg_b)
1758 +{
1759 +  fp_number_type a;
1760 +  fp_number_type b;
1761 +  FLO_union_type au, bu;
1762 +
1763 +  au.value = arg_a;
1764 +  bu.value = arg_b;
1765 +
1766 +  unpack_d (&au, &a);
1767 +  unpack_d (&bu, &b);
1768 +
1769 +  if (isnan (&a) || isnan (&b))
1770 +    return 1;                  /* false, truth == 0 */
1771 +
1772 +  return __fpcmp_parts (&a, &b) ;
1773 +}
1774 +#endif /* L_eq_sf || L_eq_df */
1775 +
1776 +#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
1777 +CMPtype
1778 +_ne_f2 (FLO_type arg_a, FLO_type arg_b)
1779 +{
1780 +  fp_number_type a;
1781 +  fp_number_type b;
1782 +  FLO_union_type au, bu;
1783 +
1784 +  au.value = arg_a;
1785 +  bu.value = arg_b;
1786 +
1787 +  unpack_d (&au, &a);
1788 +  unpack_d (&bu, &b);
1789 +
1790 +  if (isnan (&a) || isnan (&b))
1791 +    return 1;                  /* true, truth != 0 */
1792 +
1793 +  return  __fpcmp_parts (&a, &b) ;
1794 +}
1795 +#endif /* L_ne_sf || L_ne_df */
1796 +
1797 +#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
1798 +CMPtype
1799 +_gt_f2 (FLO_type arg_a, FLO_type arg_b)
1800 +{
1801 +  fp_number_type a;
1802 +  fp_number_type b;
1803 +  FLO_union_type au, bu;
1804 +
1805 +  au.value = arg_a;
1806 +  bu.value = arg_b;
1807 +
1808 +  unpack_d (&au, &a);
1809 +  unpack_d (&bu, &b);
1810 +
1811 +  if (isnan (&a) || isnan (&b))
1812 +    return -1;                 /* false, truth > 0 */
1813 +
1814 +  return __fpcmp_parts (&a, &b);
1815 +}
1816 +#endif /* L_gt_sf || L_gt_df */
1817 +
1818 +#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
1819 +CMPtype
1820 +_ge_f2 (FLO_type arg_a, FLO_type arg_b)
1821 +{
1822 +  fp_number_type a;
1823 +  fp_number_type b;
1824 +  FLO_union_type au, bu;
1825 +
1826 +  au.value = arg_a;
1827 +  bu.value = arg_b;
1828 +
1829 +  unpack_d (&au, &a);
1830 +  unpack_d (&bu, &b);
1831 +
1832 +  if (isnan (&a) || isnan (&b))
1833 +    return -1;                 /* false, truth >= 0 */
1834 +  return __fpcmp_parts (&a, &b) ;
1835 +}
1836 +#endif /* L_ge_sf || L_ge_df */
1837 +
1838 +#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
1839 +CMPtype
1840 +_lt_f2 (FLO_type arg_a, FLO_type arg_b)
1841 +{
1842 +  fp_number_type a;
1843 +  fp_number_type b;
1844 +  FLO_union_type au, bu;
1845 +
1846 +  au.value = arg_a;
1847 +  bu.value = arg_b;
1848 +
1849 +  unpack_d (&au, &a);
1850 +  unpack_d (&bu, &b);
1851 +
1852 +  if (isnan (&a) || isnan (&b))
1853 +    return 1;                  /* false, truth < 0 */
1854 +
1855 +  return __fpcmp_parts (&a, &b);
1856 +}
1857 +#endif /* L_lt_sf || L_lt_df */
1858 +
1859 +#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
1860 +CMPtype
1861 +_le_f2 (FLO_type arg_a, FLO_type arg_b)
1862 +{
1863 +  fp_number_type a;
1864 +  fp_number_type b;
1865 +  FLO_union_type au, bu;
1866 +
1867 +  au.value = arg_a;
1868 +  bu.value = arg_b;
1869 +
1870 +  unpack_d (&au, &a);
1871 +  unpack_d (&bu, &b);
1872 +
1873 +  if (isnan (&a) || isnan (&b))
1874 +    return 1;                  /* false, truth <= 0 */
1875 +
1876 +  return __fpcmp_parts (&a, &b) ;
1877 +}
1878 +#endif /* L_le_sf || L_le_df */
1879 +
1880 +#endif /* ! US_SOFTWARE_GOFAST */
1881 +
1882 +#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
1883 +CMPtype
1884 +_unord_f2 (FLO_type arg_a, FLO_type arg_b)
1885 +{
1886 +  fp_number_type a;
1887 +  fp_number_type b;
1888 +  FLO_union_type au, bu;
1889 +
1890 +  au.value = arg_a;
1891 +  bu.value = arg_b;
1892 +
1893 +  unpack_d (&au, &a);
1894 +  unpack_d (&bu, &b);
1895 +
1896 +  return (isnan (&a) || isnan (&b));
1897 +}
1898 +#endif /* L_unord_sf || L_unord_df */
1899 +
1900 +#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
1901 +FLO_type
1902 +si_to_float (SItype arg_a)
1903 +{
1904 +  fp_number_type in;
1905 +
1906 +  in.class = CLASS_NUMBER;
1907 +  in.sign = arg_a < 0;
1908 +  if (!arg_a)
1909 +    {
1910 +      in.class = CLASS_ZERO;
1911 +    }
1912 +  else
1913 +    {
1914 +      in.normal_exp = FRACBITS + NGARDS;
1915 +      if (in.sign) 
1916 +       {
1917 +         /* Special case for minint, since there is no +ve integer
1918 +            representation for it */
1919 +         if (arg_a == (- MAX_SI_INT - 1))
1920 +           {
1921 +             return (FLO_type)(- MAX_SI_INT - 1);
1922 +           }
1923 +         in.fraction.ll = (-arg_a);
1924 +       }
1925 +      else
1926 +       in.fraction.ll = arg_a;
1927 +
1928 +      while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
1929 +       {
1930 +         in.fraction.ll <<= 1;
1931 +         in.normal_exp -= 1;
1932 +       }
1933 +    }
1934 +  return pack_d (&in);
1935 +}
1936 +#endif /* L_si_to_sf || L_si_to_df */
1937 +
1938 +#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
1939 +FLO_type
1940 +usi_to_float (USItype arg_a)
1941 +{
1942 +  fp_number_type in;
1943 +
1944 +  in.sign = 0;
1945 +  if (!arg_a)
1946 +    {
1947 +      in.class = CLASS_ZERO;
1948 +    }
1949 +  else
1950 +    {
1951 +      in.class = CLASS_NUMBER;
1952 +      in.normal_exp = FRACBITS + NGARDS;
1953 +      in.fraction.ll = arg_a;
1954 +
1955 +      while (in.fraction.ll > ((fractype)1 << (FRACBITS + NGARDS)))
1956 +        {
1957 +          in.fraction.ll >>= 1;
1958 +          in.normal_exp += 1;
1959 +        }
1960 +      while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
1961 +       {
1962 +         in.fraction.ll <<= 1;
1963 +         in.normal_exp -= 1;
1964 +       }
1965 +    }
1966 +  return pack_d (&in);
1967 +}
1968 +#endif
1969 +
1970 +#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
1971 +SItype
1972 +float_to_si (FLO_type arg_a)
1973 +{
1974 +  fp_number_type a;
1975 +  SItype tmp;
1976 +  FLO_union_type au;
1977 +
1978 +  au.value = arg_a;
1979 +  unpack_d (&au, &a);
1980 +
1981 +  if (iszero (&a))
1982 +    return 0;
1983 +  if (isnan (&a))
1984 +    return 0;
1985 +  /* get reasonable MAX_SI_INT...  */
1986 +  if (isinf (&a))
1987 +    return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
1988 +  /* it is a number, but a small one */
1989 +  if (a.normal_exp < 0)
1990 +    return 0;
1991 +  if (a.normal_exp > BITS_PER_SI - 2)
1992 +    return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
1993 +  tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
1994 +  return a.sign ? (-tmp) : (tmp);
1995 +}
1996 +#endif /* L_sf_to_si || L_df_to_si */
1997 +
1998 +#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
1999 +#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
2000 +/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
2001 +   we also define them for GOFAST because the ones in libgcc2.c have the
2002 +   wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
2003 +   out of libgcc2.c.  We can't define these here if not GOFAST because then
2004 +   there'd be duplicate copies.  */
2005 +
2006 +USItype
2007 +float_to_usi (FLO_type arg_a)
2008 +{
2009 +  fp_number_type a;
2010 +  FLO_union_type au;
2011 +
2012 +  au.value = arg_a;
2013 +  unpack_d (&au, &a);
2014 +
2015 +  if (iszero (&a))
2016 +    return 0;
2017 +  if (isnan (&a))
2018 +    return 0;
2019 +  /* it is a negative number */
2020 +  if (a.sign)
2021 +    return 0;
2022 +  /* get reasonable MAX_USI_INT...  */
2023 +  if (isinf (&a))
2024 +    return MAX_USI_INT;
2025 +  /* it is a number, but a small one */
2026 +  if (a.normal_exp < 0)
2027 +    return 0;
2028 +  if (a.normal_exp > BITS_PER_SI - 1)
2029 +    return MAX_USI_INT;
2030 +  else if (a.normal_exp > (FRACBITS + NGARDS))
2031 +    return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
2032 +  else
2033 +    return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
2034 +}
2035 +#endif /* US_SOFTWARE_GOFAST */
2036 +#endif /* L_sf_to_usi || L_df_to_usi */
2037 +
2038 +#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
2039 +FLO_type
2040 +negate (FLO_type arg_a)
2041 +{
2042 +  fp_number_type a;
2043 +  FLO_union_type au;
2044 +
2045 +  au.value = arg_a;
2046 +  unpack_d (&au, &a);
2047 +
2048 +  flip_sign (&a);
2049 +  return pack_d (&a);
2050 +}
2051 +#endif /* L_negate_sf || L_negate_df */
2052 +
2053 +#ifdef FLOAT
2054 +
2055 +#if defined(L_make_sf)
2056 +SFtype
2057 +__make_fp(fp_class_type class,
2058 +            unsigned int sign,
2059 +            int exp, 
2060 +            USItype frac)
2061 +{
2062 +  fp_number_type in;
2063 +
2064 +  in.class = class;
2065 +  in.sign = sign;
2066 +  in.normal_exp = exp;
2067 +  in.fraction.ll = frac;
2068 +  return pack_d (&in);
2069 +}
2070 +#endif /* L_make_sf */
2071 +
2072 +#ifndef FLOAT_ONLY
2073 +
2074 +/* This enables one to build an fp library that supports float but not double.
2075 +   Otherwise, we would get an undefined reference to __make_dp.
2076 +   This is needed for some 8-bit ports that can't handle well values that
2077 +   are 8-bytes in size, so we just don't support double for them at all.  */
2078 +
2079 +#if defined(L_sf_to_df)
2080 +DFtype
2081 +sf_to_df (SFtype arg_a)
2082 +{
2083 +  fp_number_type in;
2084 +  FLO_union_type au;
2085 +
2086 +  au.value = arg_a;
2087 +  unpack_d (&au, &in);
2088 +
2089 +  return __make_dp (in.class, in.sign, in.normal_exp,
2090 +                   ((UDItype) in.fraction.ll) << F_D_BITOFF);
2091 +}
2092 +#endif /* L_sf_to_df */
2093 +
2094 +#if defined(L_sf_to_tf) && defined(TMODES)
2095 +TFtype
2096 +sf_to_tf (SFtype arg_a)
2097 +{
2098 +  fp_number_type in;
2099 +  FLO_union_type au;
2100 +
2101 +  au.value = arg_a;
2102 +  unpack_d (&au, &in);
2103 +
2104 +  return __make_tp (in.class, in.sign, in.normal_exp,
2105 +                   ((UTItype) in.fraction.ll) << F_T_BITOFF);
2106 +}
2107 +#endif /* L_sf_to_df */
2108 +
2109 +#endif /* ! FLOAT_ONLY */
2110 +#endif /* FLOAT */
2111 +
2112 +#ifndef FLOAT
2113 +
2114 +extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
2115 +
2116 +#if defined(L_make_df)
2117 +DFtype
2118 +__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
2119 +{
2120 +  fp_number_type in;
2121 +
2122 +  in.class = class;
2123 +  in.sign = sign;
2124 +  in.normal_exp = exp;
2125 +  in.fraction.ll = frac;
2126 +  return pack_d (&in);
2127 +}
2128 +#endif /* L_make_df */
2129 +
2130 +#if defined(L_df_to_sf)
2131 +SFtype
2132 +df_to_sf (DFtype arg_a)
2133 +{
2134 +  fp_number_type in;
2135 +  USItype sffrac;
2136 +  FLO_union_type au;
2137 +
2138 +  au.value = arg_a;
2139 +  unpack_d (&au, &in);
2140 +
2141 +  sffrac = in.fraction.ll >> F_D_BITOFF;
2142 +
2143 +  /* We set the lowest guard bit in SFFRAC if we discarded any non
2144 +     zero bits.  */
2145 +  if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
2146 +    sffrac |= 1;
2147 +
2148 +  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
2149 +}
2150 +#endif /* L_df_to_sf */
2151 +
2152 +#if defined(L_df_to_tf) && defined(TMODES) \
2153 +    && !defined(FLOAT) && !defined(TFLOAT)
2154 +TFtype
2155 +df_to_tf (DFtype arg_a)
2156 +{
2157 +  fp_number_type in;
2158 +  FLO_union_type au;
2159 +
2160 +  au.value = arg_a;
2161 +  unpack_d (&au, &in);
2162 +
2163 +  return __make_tp (in.class, in.sign, in.normal_exp,
2164 +                   ((UTItype) in.fraction.ll) << D_T_BITOFF);
2165 +}
2166 +#endif /* L_sf_to_df */
2167 +
2168 +#ifdef TFLOAT
2169 +#if defined(L_make_tf)
2170 +TFtype
2171 +__make_tp(fp_class_type class,
2172 +            unsigned int sign,
2173 +            int exp, 
2174 +            UTItype frac)
2175 +{
2176 +  fp_number_type in;
2177 +
2178 +  in.class = class;
2179 +  in.sign = sign;
2180 +  in.normal_exp = exp;
2181 +  in.fraction.ll = frac;
2182 +  return pack_d (&in);
2183 +}
2184 +#endif /* L_make_tf */
2185 +
2186 +#if defined(L_tf_to_df)
2187 +DFtype
2188 +tf_to_df (TFtype arg_a)
2189 +{
2190 +  fp_number_type in;
2191 +  UDItype sffrac;
2192 +  FLO_union_type au;
2193 +
2194 +  au.value = arg_a;
2195 +  unpack_d (&au, &in);
2196 +
2197 +  sffrac = in.fraction.ll >> D_T_BITOFF;
2198 +
2199 +  /* We set the lowest guard bit in SFFRAC if we discarded any non
2200 +     zero bits.  */
2201 +  if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)
2202 +    sffrac |= 1;
2203 +
2204 +  return __make_dp (in.class, in.sign, in.normal_exp, sffrac);
2205 +}
2206 +#endif /* L_tf_to_df */
2207 +
2208 +#if defined(L_tf_to_sf)
2209 +SFtype
2210 +tf_to_sf (TFtype arg_a)
2211 +{
2212 +  fp_number_type in;
2213 +  USItype sffrac;
2214 +  FLO_union_type au;
2215 +
2216 +  au.value = arg_a;
2217 +  unpack_d (&au, &in);
2218 +
2219 +  sffrac = in.fraction.ll >> F_T_BITOFF;
2220 +
2221 +  /* We set the lowest guard bit in SFFRAC if we discarded any non
2222 +     zero bits.  */
2223 +  if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)
2224 +    sffrac |= 1;
2225 +
2226 +  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
2227 +}
2228 +#endif /* L_tf_to_sf */
2229 +#endif /* TFLOAT */
2230 +
2231 +#endif /* ! FLOAT */
2232 +#endif /* !EXTENDED_FLOAT_STUBS */
2233 --- ./gcc/gcc/config/nios2/nios2-fp-bit.c
2234 +++ ./gcc/gcc/config/nios2/nios2-fp-bit.c
2235 @@ -0,0 +1,1652 @@
2236 +#define FLOAT
2237 +/* This is a software floating point library which can be used
2238 +   for targets without hardware floating point. 
2239 +   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004
2240 +   Free Software Foundation, Inc.
2241 +
2242 +This file is free software; you can redistribute it and/or modify it
2243 +under the terms of the GNU General Public License as published by the
2244 +Free Software Foundation; either version 2, or (at your option) any
2245 +later version.
2246 +
2247 +In addition to the permissions in the GNU General Public License, the
2248 +Free Software Foundation gives you unlimited permission to link the
2249 +compiled version of this file with other programs, and to distribute
2250 +those programs without any restriction coming from the use of this
2251 +file.  (The General Public License restrictions do apply in other
2252 +respects; for example, they cover modification of the file, and
2253 +distribution when not linked into another program.)
2254 +
2255 +This file is distributed in the hope that it will be useful, but
2256 +WITHOUT ANY WARRANTY; without even the implied warranty of
2257 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2258 +General Public License for more details.
2259 +
2260 +You should have received a copy of the GNU General Public License
2261 +along with this program; see the file COPYING.  If not, write to
2262 +the Free Software Foundation, 59 Temple Place - Suite 330,
2263 +Boston, MA 02111-1307, USA.  */
2264 +
2265 +/* As a special exception, if you link this library with other files,
2266 +   some of which are compiled with GCC, to produce an executable,
2267 +   this library does not by itself cause the resulting executable
2268 +   to be covered by the GNU General Public License.
2269 +   This exception does not however invalidate any other reasons why
2270 +   the executable file might be covered by the GNU General Public License.  */
2271 +
2272 +/* This implements IEEE 754 format arithmetic, but does not provide a
2273 +   mechanism for setting the rounding mode, or for generating or handling
2274 +   exceptions.
2275 +
2276 +   The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
2277 +   Wilson, all of Cygnus Support.  */
2278 +
2279 +/* The intended way to use this file is to make two copies, add `#define FLOAT'
2280 +   to one copy, then compile both copies and add them to libgcc.a.  */
2281 +
2282 +#include "tconfig.h"
2283 +#include "coretypes.h"
2284 +#include "tm.h"
2285 +#include "config/fp-bit.h"
2286 +
2287 +/* The following macros can be defined to change the behavior of this file:
2288 +   FLOAT: Implement a `float', aka SFmode, fp library.  If this is not
2289 +     defined, then this file implements a `double', aka DFmode, fp library.
2290 +   FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.
2291 +     don't include float->double conversion which requires the double library.
2292 +     This is useful only for machines which can't support doubles, e.g. some
2293 +     8-bit processors.
2294 +   CMPtype: Specify the type that floating point compares should return.
2295 +     This defaults to SItype, aka int.
2296 +   US_SOFTWARE_GOFAST: This makes all entry points use the same names as the
2297 +     US Software goFast library.
2298 +   _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding
2299 +     two integers to the FLO_union_type.
2300 +   NO_DENORMALS: Disable handling of denormals.
2301 +   NO_NANS: Disable nan and infinity handling
2302 +   SMALL_MACHINE: Useful when operations on QIs and HIs are faster
2303 +     than on an SI */
2304 +
2305 +/* We don't currently support extended floats (long doubles) on machines
2306 +   without hardware to deal with them.
2307 +
2308 +   These stubs are just to keep the linker from complaining about unresolved
2309 +   references which can be pulled in from libio & libstdc++, even if the
2310 +   user isn't using long doubles.  However, they may generate an unresolved
2311 +   external to abort if abort is not used by the function, and the stubs
2312 +   are referenced from within libc, since libgcc goes before and after the
2313 +   system library.  */
2314 +
2315 +#ifdef DECLARE_LIBRARY_RENAMES
2316 +  DECLARE_LIBRARY_RENAMES
2317 +#endif
2318 +
2319 +#ifdef EXTENDED_FLOAT_STUBS
2320 +extern void abort (void);
2321 +void __extendsfxf2 (void) { abort(); }
2322 +void __extenddfxf2 (void) { abort(); }
2323 +void __truncxfdf2 (void) { abort(); }
2324 +void __truncxfsf2 (void) { abort(); }
2325 +void __fixxfsi (void) { abort(); }
2326 +void __floatsixf (void) { abort(); }
2327 +void __addxf3 (void) { abort(); }
2328 +void __subxf3 (void) { abort(); }
2329 +void __mulxf3 (void) { abort(); }
2330 +void __divxf3 (void) { abort(); }
2331 +void __negxf2 (void) { abort(); }
2332 +void __eqxf2 (void) { abort(); }
2333 +void __nexf2 (void) { abort(); }
2334 +void __gtxf2 (void) { abort(); }
2335 +void __gexf2 (void) { abort(); }
2336 +void __lexf2 (void) { abort(); }
2337 +void __ltxf2 (void) { abort(); }
2338 +
2339 +void __extendsftf2 (void) { abort(); }
2340 +void __extenddftf2 (void) { abort(); }
2341 +void __trunctfdf2 (void) { abort(); }
2342 +void __trunctfsf2 (void) { abort(); }
2343 +void __fixtfsi (void) { abort(); }
2344 +void __floatsitf (void) { abort(); }
2345 +void __addtf3 (void) { abort(); }
2346 +void __subtf3 (void) { abort(); }
2347 +void __multf3 (void) { abort(); }
2348 +void __divtf3 (void) { abort(); }
2349 +void __negtf2 (void) { abort(); }
2350 +void __eqtf2 (void) { abort(); }
2351 +void __netf2 (void) { abort(); }
2352 +void __gttf2 (void) { abort(); }
2353 +void __getf2 (void) { abort(); }
2354 +void __letf2 (void) { abort(); }
2355 +void __lttf2 (void) { abort(); }
2356 +#else  /* !EXTENDED_FLOAT_STUBS, rest of file */
2357 +
2358 +/* IEEE "special" number predicates */
2359 +
2360 +#ifdef NO_NANS
2361 +
2362 +#define nan() 0
2363 +#define isnan(x) 0
2364 +#define isinf(x) 0
2365 +#else
2366 +
2367 +#if   defined L_thenan_sf
2368 +const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
2369 +#elif defined L_thenan_df
2370 +const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };
2371 +#elif defined L_thenan_tf
2372 +const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
2373 +#elif defined TFLOAT
2374 +extern const fp_number_type __thenan_tf;
2375 +#elif defined FLOAT
2376 +extern const fp_number_type __thenan_sf;
2377 +#else
2378 +extern const fp_number_type __thenan_df;
2379 +#endif
2380 +
2381 +INLINE
2382 +static fp_number_type *
2383 +nan (void)
2384 +{
2385 +  /* Discard the const qualifier...  */
2386 +#ifdef TFLOAT
2387 +  return (fp_number_type *) (& __thenan_tf);
2388 +#elif defined FLOAT  
2389 +  return (fp_number_type *) (& __thenan_sf);
2390 +#else
2391 +  return (fp_number_type *) (& __thenan_df);
2392 +#endif
2393 +}
2394 +
2395 +INLINE
2396 +static int
2397 +isnan ( fp_number_type *  x)
2398 +{
2399 +  return x->class == CLASS_SNAN || x->class == CLASS_QNAN;
2400 +}
2401 +
2402 +INLINE
2403 +static int
2404 +isinf ( fp_number_type *  x)
2405 +{
2406 +  return x->class == CLASS_INFINITY;
2407 +}
2408 +
2409 +#endif /* NO_NANS */
2410 +
2411 +INLINE
2412 +static int
2413 +iszero ( fp_number_type *  x)
2414 +{
2415 +  return x->class == CLASS_ZERO;
2416 +}
2417 +
2418 +INLINE 
2419 +static void
2420 +flip_sign ( fp_number_type *  x)
2421 +{
2422 +  x->sign = !x->sign;
2423 +}
2424 +
2425 +extern FLO_type pack_d ( fp_number_type * );
2426 +
2427 +#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
2428 +FLO_type
2429 +pack_d ( fp_number_type *  src)
2430 +{
2431 +  FLO_union_type dst;
2432 +  fractype fraction = src->fraction.ll;        /* wasn't unsigned before? */
2433 +  int sign = src->sign;
2434 +  int exp = 0;
2435 +
2436 +  if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))
2437 +    {
2438 +      /* We can't represent these values accurately.  By using the
2439 +        largest possible magnitude, we guarantee that the conversion
2440 +        of infinity is at least as big as any finite number.  */
2441 +      exp = EXPMAX;
2442 +      fraction = ((fractype) 1 << FRACBITS) - 1;
2443 +    }
2444 +  else if (isnan (src))
2445 +    {
2446 +      exp = EXPMAX;
2447 +      if (src->class == CLASS_QNAN || 1)
2448 +       {
2449 +#ifdef QUIET_NAN_NEGATED
2450 +         fraction |= QUIET_NAN - 1;
2451 +#else
2452 +         fraction |= QUIET_NAN;
2453 +#endif
2454 +       }
2455 +    }
2456 +  else if (isinf (src))
2457 +    {
2458 +      exp = EXPMAX;
2459 +      fraction = 0;
2460 +    }
2461 +  else if (iszero (src))
2462 +    {
2463 +      exp = 0;
2464 +      fraction = 0;
2465 +    }
2466 +  else if (fraction == 0)
2467 +    {
2468 +      exp = 0;
2469 +    }
2470 +  else
2471 +    {
2472 +      if (src->normal_exp < NORMAL_EXPMIN)
2473 +       {
2474 +#ifdef NO_DENORMALS
2475 +         /* Go straight to a zero representation if denormals are not
2476 +            supported.  The denormal handling would be harmless but
2477 +            isn't unnecessary.  */
2478 +         exp = 0;
2479 +         fraction = 0;
2480 +#else /* NO_DENORMALS */
2481 +         /* This number's exponent is too low to fit into the bits
2482 +            available in the number, so we'll store 0 in the exponent and
2483 +            shift the fraction to the right to make up for it.  */
2484 +
2485 +         int shift = NORMAL_EXPMIN - src->normal_exp;
2486 +
2487 +         exp = 0;
2488 +
2489 +         if (shift > FRAC_NBITS - NGARDS)
2490 +           {
2491 +             /* No point shifting, since it's more that 64 out.  */
2492 +             fraction = 0;
2493 +           }
2494 +         else
2495 +           {
2496 +             int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;
2497 +             fraction = (fraction >> shift) | lowbit;
2498 +           }
2499 +         if ((fraction & GARDMASK) == GARDMSB)
2500 +           {
2501 +             if ((fraction & (1 << NGARDS)))
2502 +               fraction += GARDROUND + 1;
2503 +           }
2504 +         else
2505 +           {
2506 +             /* Add to the guards to round up.  */
2507 +             fraction += GARDROUND;
2508 +           }
2509 +         /* Perhaps the rounding means we now need to change the
2510 +             exponent, because the fraction is no longer denormal.  */
2511 +         if (fraction >= IMPLICIT_1)
2512 +           {
2513 +             exp += 1;
2514 +           }
2515 +         fraction >>= NGARDS;
2516 +#endif /* NO_DENORMALS */
2517 +       }
2518 +      else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)
2519 +              && src->normal_exp > EXPBIAS)
2520 +       {
2521 +         exp = EXPMAX;
2522 +         fraction = 0;
2523 +       }
2524 +      else
2525 +       {
2526 +         exp = src->normal_exp + EXPBIAS;
2527 +         if (!ROUND_TOWARDS_ZERO)
2528 +           {
2529 +             /* IF the gard bits are the all zero, but the first, then we're
2530 +                half way between two numbers, choose the one which makes the
2531 +                lsb of the answer 0.  */
2532 +             if ((fraction & GARDMASK) == GARDMSB)
2533 +               {
2534 +                 if (fraction & (1 << NGARDS))
2535 +                   fraction += GARDROUND + 1;
2536 +               }
2537 +             else
2538 +               {
2539 +                 /* Add a one to the guards to round up */
2540 +                 fraction += GARDROUND;
2541 +               }
2542 +             if (fraction >= IMPLICIT_2)
2543 +               {
2544 +                 fraction >>= 1;
2545 +                 exp += 1;
2546 +               }
2547 +           }
2548 +         fraction >>= NGARDS;
2549 +
2550 +         if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)
2551 +           {
2552 +             /* Saturate on overflow.  */
2553 +             exp = EXPMAX;
2554 +             fraction = ((fractype) 1 << FRACBITS) - 1;
2555 +           }
2556 +       }
2557 +    }
2558 +
2559 +  /* We previously used bitfields to store the number, but this doesn't
2560 +     handle little/big endian systems conveniently, so use shifts and
2561 +     masks */
2562 +#ifdef FLOAT_BIT_ORDER_MISMATCH
2563 +  dst.bits.fraction = fraction;
2564 +  dst.bits.exp = exp;
2565 +  dst.bits.sign = sign;
2566 +#else
2567 +# if defined TFLOAT && defined HALFFRACBITS
2568 + {
2569 +   halffractype high, low, unity;
2570 +   int lowsign, lowexp;
2571 +
2572 +   unity = (halffractype) 1 << HALFFRACBITS;
2573 +
2574 +   /* Set HIGH to the high double's significand, masking out the implicit 1.
2575 +      Set LOW to the low double's full significand.  */
2576 +   high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);
2577 +   low = fraction & (unity * 2 - 1);
2578 +
2579 +   /* Get the initial sign and exponent of the low double.  */
2580 +   lowexp = exp - HALFFRACBITS - 1;
2581 +   lowsign = sign;
2582 +
2583 +   /* HIGH should be rounded like a normal double, making |LOW| <=
2584 +      0.5 ULP of HIGH.  Assume round-to-nearest.  */
2585 +   if (exp < EXPMAX)
2586 +     if (low > unity || (low == unity && (high & 1) == 1))
2587 +       {
2588 +        /* Round HIGH up and adjust LOW to match.  */
2589 +        high++;
2590 +        if (high == unity)
2591 +          {
2592 +            /* May make it infinite, but that's OK.  */
2593 +            high = 0;
2594 +            exp++;
2595 +          }
2596 +        low = unity * 2 - low;
2597 +        lowsign ^= 1;
2598 +       }
2599 +
2600 +   high |= (halffractype) exp << HALFFRACBITS;
2601 +   high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);
2602 +
2603 +   if (exp == EXPMAX || exp == 0 || low == 0)
2604 +     low = 0;
2605 +   else
2606 +     {
2607 +       while (lowexp > 0 && low < unity)
2608 +        {
2609 +          low <<= 1;
2610 +          lowexp--;
2611 +        }
2612 +
2613 +       if (lowexp <= 0)
2614 +        {
2615 +          halffractype roundmsb, round;
2616 +          int shift;
2617 +
2618 +          shift = 1 - lowexp;
2619 +          roundmsb = (1 << (shift - 1));
2620 +          round = low & ((roundmsb << 1) - 1);
2621 +
2622 +          low >>= shift;
2623 +          lowexp = 0;
2624 +
2625 +          if (round > roundmsb || (round == roundmsb && (low & 1) == 1))
2626 +            {
2627 +              low++;
2628 +              if (low == unity)
2629 +                /* LOW rounds up to the smallest normal number.  */
2630 +                lowexp++;
2631 +            }
2632 +        }
2633 +
2634 +       low &= unity - 1;
2635 +       low |= (halffractype) lowexp << HALFFRACBITS;
2636 +       low |= (halffractype) lowsign << (HALFFRACBITS + EXPBITS);
2637 +     }
2638 +   dst.value_raw = ((fractype) high << HALFSHIFT) | low;
2639 + }
2640 +# else
2641 +  dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
2642 +  dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
2643 +  dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
2644 +# endif
2645 +#endif
2646 +
2647 +#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
2648 +#ifdef TFLOAT
2649 +  {
2650 +    qrtrfractype tmp1 = dst.words[0];
2651 +    qrtrfractype tmp2 = dst.words[1];
2652 +    dst.words[0] = dst.words[3];
2653 +    dst.words[1] = dst.words[2];
2654 +    dst.words[2] = tmp2;
2655 +    dst.words[3] = tmp1;
2656 +  }
2657 +#else
2658 +  {
2659 +    halffractype tmp = dst.words[0];
2660 +    dst.words[0] = dst.words[1];
2661 +    dst.words[1] = tmp;
2662 +  }
2663 +#endif
2664 +#endif
2665 +
2666 +  return dst.value;
2667 +}
2668 +#endif
2669 +
2670 +#if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
2671 +void
2672 +unpack_d (FLO_union_type * src, fp_number_type * dst)
2673 +{
2674 +  /* We previously used bitfields to store the number, but this doesn't
2675 +     handle little/big endian systems conveniently, so use shifts and
2676 +     masks */
2677 +  fractype fraction;
2678 +  int exp;
2679 +  int sign;
2680 +
2681 +#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
2682 +  FLO_union_type swapped;
2683 +
2684 +#ifdef TFLOAT
2685 +  swapped.words[0] = src->words[3];
2686 +  swapped.words[1] = src->words[2];
2687 +  swapped.words[2] = src->words[1];
2688 +  swapped.words[3] = src->words[0];
2689 +#else
2690 +  swapped.words[0] = src->words[1];
2691 +  swapped.words[1] = src->words[0];
2692 +#endif
2693 +  src = &swapped;
2694 +#endif
2695 +  
2696 +#ifdef FLOAT_BIT_ORDER_MISMATCH
2697 +  fraction = src->bits.fraction;
2698 +  exp = src->bits.exp;
2699 +  sign = src->bits.sign;
2700 +#else
2701 +# if defined TFLOAT && defined HALFFRACBITS
2702 + {
2703 +   halffractype high, low;
2704 +   
2705 +   high = src->value_raw >> HALFSHIFT;
2706 +   low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1);
2707 +
2708 +   fraction = high & ((((fractype)1) << HALFFRACBITS) - 1);
2709 +   fraction <<= FRACBITS - HALFFRACBITS;
2710 +   exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
2711 +   sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1;
2712 +
2713 +   if (exp != EXPMAX && exp != 0 && low != 0)
2714 +     {
2715 +       int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1);
2716 +       int lowsign = ((int)(low >> (((HALFFRACBITS + EXPBITS))))) & 1;
2717 +       int shift;
2718 +       fractype xlow;
2719 +
2720 +       xlow = low & ((((fractype)1) << HALFFRACBITS) - 1);
2721 +       if (lowexp)
2722 +        xlow |= (((halffractype)1) << HALFFRACBITS);
2723 +       else
2724 +        lowexp = 1;
2725 +       shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp);
2726 +       if (shift > 0)
2727 +        xlow <<= shift;
2728 +       else if (shift < 0)
2729 +        xlow >>= -shift;
2730 +       if (sign == lowsign)
2731 +        fraction += xlow;
2732 +       else if (fraction >= xlow)
2733 +        fraction -= xlow;
2734 +       else
2735 +        {
2736 +          /* The high part is a power of two but the full number is lower.
2737 +             This code will leave the implicit 1 in FRACTION, but we'd
2738 +             have added that below anyway.  */
2739 +          fraction = (((fractype) 1 << FRACBITS) - xlow) << 1;
2740 +          exp--;
2741 +        }
2742 +     }
2743 + }
2744 +# else
2745 +  fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
2746 +  exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
2747 +  sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
2748 +# endif
2749 +#endif
2750 +
2751 +  dst->sign = sign;
2752 +  if (exp == 0)
2753 +    {
2754 +      /* Hmm.  Looks like 0 */
2755 +      if (fraction == 0
2756 +#ifdef NO_DENORMALS
2757 +         || 1
2758 +#endif
2759 +         )
2760 +       {
2761 +         /* tastes like zero */
2762 +         dst->class = CLASS_ZERO;
2763 +       }
2764 +      else
2765 +       {
2766 +         /* Zero exponent with nonzero fraction - it's denormalized,
2767 +            so there isn't a leading implicit one - we'll shift it so
2768 +            it gets one.  */
2769 +         dst->normal_exp = exp - EXPBIAS + 1;
2770 +         fraction <<= NGARDS;
2771 +
2772 +         dst->class = CLASS_NUMBER;
2773 +#if 1
2774 +         while (fraction < IMPLICIT_1)
2775 +           {
2776 +             fraction <<= 1;
2777 +             dst->normal_exp--;
2778 +           }
2779 +#endif
2780 +         dst->fraction.ll = fraction;
2781 +       }
2782 +    }
2783 +  else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp == EXPMAX)
2784 +    {
2785 +      /* Huge exponent*/
2786 +      if (fraction == 0)
2787 +       {
2788 +         /* Attached to a zero fraction - means infinity */
2789 +         dst->class = CLASS_INFINITY;
2790 +       }
2791 +      else
2792 +       {
2793 +         /* Nonzero fraction, means nan */
2794 +#ifdef QUIET_NAN_NEGATED
2795 +         if ((fraction & QUIET_NAN) == 0)
2796 +#else
2797 +         if (fraction & QUIET_NAN)
2798 +#endif
2799 +           {
2800 +             dst->class = CLASS_QNAN;
2801 +           }
2802 +         else
2803 +           {
2804 +             dst->class = CLASS_SNAN;
2805 +           }
2806 +         /* Keep the fraction part as the nan number */
2807 +         dst->fraction.ll = fraction;
2808 +       }
2809 +    }
2810 +  else
2811 +    {
2812 +      /* Nothing strange about this number */
2813 +      dst->normal_exp = exp - EXPBIAS;
2814 +      dst->class = CLASS_NUMBER;
2815 +      dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
2816 +    }
2817 +}
2818 +#endif /* L_unpack_df || L_unpack_sf */
2819 +
2820 +#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
2821 +static fp_number_type *
2822 +_fpadd_parts (fp_number_type * a,
2823 +             fp_number_type * b,
2824 +             fp_number_type * tmp)
2825 +{
2826 +  intfrac tfraction;
2827 +
2828 +  /* Put commonly used fields in local variables.  */
2829 +  int a_normal_exp;
2830 +  int b_normal_exp;
2831 +  fractype a_fraction;
2832 +  fractype b_fraction;
2833 +
2834 +  if (isnan (a))
2835 +    {
2836 +      return a;
2837 +    }
2838 +  if (isnan (b))
2839 +    {
2840 +      return b;
2841 +    }
2842 +  if (isinf (a))
2843 +    {
2844 +      /* Adding infinities with opposite signs yields a NaN.  */
2845 +      if (isinf (b) && a->sign != b->sign)
2846 +       return nan ();
2847 +      return a;
2848 +    }
2849 +  if (isinf (b))
2850 +    {
2851 +      return b;
2852 +    }
2853 +  if (iszero (b))
2854 +    {
2855 +      if (iszero (a))
2856 +       {
2857 +         *tmp = *a;
2858 +         tmp->sign = a->sign & b->sign;
2859 +         return tmp;
2860 +       }
2861 +      return a;
2862 +    }
2863 +  if (iszero (a))
2864 +    {
2865 +      return b;
2866 +    }
2867 +
2868 +  /* Got two numbers. shift the smaller and increment the exponent till
2869 +     they're the same */
2870 +  {
2871 +    int diff;
2872 +
2873 +    a_normal_exp = a->normal_exp;
2874 +    b_normal_exp = b->normal_exp;
2875 +    a_fraction = a->fraction.ll;
2876 +    b_fraction = b->fraction.ll;
2877 +
2878 +    diff = a_normal_exp - b_normal_exp;
2879 +
2880 +    if (diff < 0)
2881 +      diff = -diff;
2882 +    if (diff < FRAC_NBITS)
2883 +      {
2884 +       /* ??? This does shifts one bit at a time.  Optimize.  */
2885 +       while (a_normal_exp > b_normal_exp)
2886 +         {
2887 +           b_normal_exp++;
2888 +           LSHIFT (b_fraction);
2889 +         }
2890 +       while (b_normal_exp > a_normal_exp)
2891 +         {
2892 +           a_normal_exp++;
2893 +           LSHIFT (a_fraction);
2894 +         }
2895 +      }
2896 +    else
2897 +      {
2898 +       /* Somethings's up.. choose the biggest */
2899 +       if (a_normal_exp > b_normal_exp)
2900 +         {
2901 +           b_normal_exp = a_normal_exp;
2902 +           b_fraction = 0;
2903 +         }
2904 +       else
2905 +         {
2906 +           a_normal_exp = b_normal_exp;
2907 +           a_fraction = 0;
2908 +         }
2909 +      }
2910 +  }
2911 +
2912 +  if (a->sign != b->sign)
2913 +    {
2914 +      if (a->sign)
2915 +       {
2916 +         tfraction = -a_fraction + b_fraction;
2917 +       }
2918 +      else
2919 +       {
2920 +         tfraction = a_fraction - b_fraction;
2921 +       }
2922 +      if (tfraction >= 0)
2923 +       {
2924 +         tmp->sign = 0;
2925 +         tmp->normal_exp = a_normal_exp;
2926 +         tmp->fraction.ll = tfraction;
2927 +       }
2928 +      else
2929 +       {
2930 +         tmp->sign = 1;
2931 +         tmp->normal_exp = a_normal_exp;
2932 +         tmp->fraction.ll = -tfraction;
2933 +       }
2934 +      /* and renormalize it */
2935 +
2936 +      while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
2937 +       {
2938 +         tmp->fraction.ll <<= 1;
2939 +         tmp->normal_exp--;
2940 +       }
2941 +    }
2942 +  else
2943 +    {
2944 +      tmp->sign = a->sign;
2945 +      tmp->normal_exp = a_normal_exp;
2946 +      tmp->fraction.ll = a_fraction + b_fraction;
2947 +    }
2948 +  tmp->class = CLASS_NUMBER;
2949 +  /* Now the fraction is added, we have to shift down to renormalize the
2950 +     number */
2951 +
2952 +  if (tmp->fraction.ll >= IMPLICIT_2)
2953 +    {
2954 +      LSHIFT (tmp->fraction.ll);
2955 +      tmp->normal_exp++;
2956 +    }
2957 +  return tmp;
2958 +
2959 +}
2960 +
2961 +FLO_type
2962 +add (FLO_type arg_a, FLO_type arg_b)
2963 +{
2964 +  fp_number_type a;
2965 +  fp_number_type b;
2966 +  fp_number_type tmp;
2967 +  fp_number_type *res;
2968 +  FLO_union_type au, bu;
2969 +
2970 +  au.value = arg_a;
2971 +  bu.value = arg_b;
2972 +
2973 +  unpack_d (&au, &a);
2974 +  unpack_d (&bu, &b);
2975 +
2976 +  res = _fpadd_parts (&a, &b, &tmp);
2977 +
2978 +  return pack_d (res);
2979 +}
2980 +
2981 +FLO_type
2982 +sub (FLO_type arg_a, FLO_type arg_b)
2983 +{
2984 +  fp_number_type a;
2985 +  fp_number_type b;
2986 +  fp_number_type tmp;
2987 +  fp_number_type *res;
2988 +  FLO_union_type au, bu;
2989 +
2990 +  au.value = arg_a;
2991 +  bu.value = arg_b;
2992 +
2993 +  unpack_d (&au, &a);
2994 +  unpack_d (&bu, &b);
2995 +
2996 +  b.sign ^= 1;
2997 +
2998 +  res = _fpadd_parts (&a, &b, &tmp);
2999 +
3000 +  return pack_d (res);
3001 +}
3002 +#endif /* L_addsub_sf || L_addsub_df */
3003 +
3004 +#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
3005 +static inline __attribute__ ((__always_inline__)) fp_number_type *
3006 +_fpmul_parts ( fp_number_type *  a,
3007 +              fp_number_type *  b,
3008 +              fp_number_type * tmp)
3009 +{
3010 +  fractype low = 0;
3011 +  fractype high = 0;
3012 +
3013 +  if (isnan (a))
3014 +    {
3015 +      a->sign = a->sign != b->sign;
3016 +      return a;
3017 +    }
3018 +  if (isnan (b))
3019 +    {
3020 +      b->sign = a->sign != b->sign;
3021 +      return b;
3022 +    }
3023 +  if (isinf (a))
3024 +    {
3025 +      if (iszero (b))
3026 +       return nan ();
3027 +      a->sign = a->sign != b->sign;
3028 +      return a;
3029 +    }
3030 +  if (isinf (b))
3031 +    {
3032 +      if (iszero (a))
3033 +       {
3034 +         return nan ();
3035 +       }
3036 +      b->sign = a->sign != b->sign;
3037 +      return b;
3038 +    }
3039 +  if (iszero (a))
3040 +    {
3041 +      a->sign = a->sign != b->sign;
3042 +      return a;
3043 +    }
3044 +  if (iszero (b))
3045 +    {
3046 +      b->sign = a->sign != b->sign;
3047 +      return b;
3048 +    }
3049 +
3050 +  /* Calculate the mantissa by multiplying both numbers to get a
3051 +     twice-as-wide number.  */
3052 +  {
3053 +#if defined(NO_DI_MODE) || defined(TFLOAT)
3054 +    {
3055 +      fractype x = a->fraction.ll;
3056 +      fractype ylow = b->fraction.ll;
3057 +      fractype yhigh = 0;
3058 +      int bit;
3059 +
3060 +      /* ??? This does multiplies one bit at a time.  Optimize.  */
3061 +      for (bit = 0; bit < FRAC_NBITS; bit++)
3062 +       {
3063 +         int carry;
3064 +
3065 +         if (x & 1)
3066 +           {
3067 +             carry = (low += ylow) < ylow;
3068 +             high += yhigh + carry;
3069 +           }
3070 +         yhigh <<= 1;
3071 +         if (ylow & FRACHIGH)
3072 +           {
3073 +             yhigh |= 1;
3074 +           }
3075 +         ylow <<= 1;
3076 +         x >>= 1;
3077 +       }
3078 +    }
3079 +#elif defined(FLOAT) 
3080 +    /* Multiplying two USIs to get a UDI, we're safe.  */
3081 +    {
3082 +      UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
3083 +      
3084 +      high = answer >> BITS_PER_SI;
3085 +      low = answer;
3086 +    }
3087 +#else
3088 +    /* fractype is DImode, but we need the result to be twice as wide.
3089 +       Assuming a widening multiply from DImode to TImode is not
3090 +       available, build one by hand.  */
3091 +    {
3092 +      USItype nl = a->fraction.ll;
3093 +      USItype nh = a->fraction.ll >> BITS_PER_SI;
3094 +      USItype ml = b->fraction.ll;
3095 +      USItype mh = b->fraction.ll >> BITS_PER_SI;
3096 +      UDItype pp_ll = (UDItype) ml * nl;
3097 +      UDItype pp_hl = (UDItype) mh * nl;
3098 +      UDItype pp_lh = (UDItype) ml * nh;
3099 +      UDItype pp_hh = (UDItype) mh * nh;
3100 +      UDItype res2 = 0;
3101 +      UDItype res0 = 0;
3102 +      UDItype ps_hh__ = pp_hl + pp_lh;
3103 +      if (ps_hh__ < pp_hl)
3104 +       res2 += (UDItype)1 << BITS_PER_SI;
3105 +      pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
3106 +      res0 = pp_ll + pp_hl;
3107 +      if (res0 < pp_ll)
3108 +       res2++;
3109 +      res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
3110 +      high = res2;
3111 +      low = res0;
3112 +    }
3113 +#endif
3114 +  }
3115 +
3116 +  tmp->normal_exp = a->normal_exp + b->normal_exp
3117 +    + FRAC_NBITS - (FRACBITS + NGARDS);
3118 +  tmp->sign = a->sign != b->sign;
3119 +  while (high >= IMPLICIT_2)
3120 +    {
3121 +      tmp->normal_exp++;
3122 +      if (high & 1)
3123 +       {
3124 +         low >>= 1;
3125 +         low |= FRACHIGH;
3126 +       }
3127 +      high >>= 1;
3128 +    }
3129 +  while (high < IMPLICIT_1)
3130 +    {
3131 +      tmp->normal_exp--;
3132 +
3133 +      high <<= 1;
3134 +      if (low & FRACHIGH)
3135 +       high |= 1;
3136 +      low <<= 1;
3137 +    }
3138 +  /* rounding is tricky. if we only round if it won't make us round later.  */
3139 +#if 0
3140 +  if (low & FRACHIGH2)
3141 +    {
3142 +      if (((high & GARDMASK) != GARDMSB)
3143 +         && (((high + 1) & GARDMASK) == GARDMSB))
3144 +       {
3145 +         /* don't round, it gets done again later.  */
3146 +       }
3147 +      else
3148 +       {
3149 +         high++;
3150 +       }
3151 +    }
3152 +#endif
3153 +  if (!ROUND_TOWARDS_ZERO && (high & GARDMASK) == GARDMSB)
3154 +    {
3155 +      if (high & (1 << NGARDS))
3156 +       {
3157 +         /* half way, so round to even */
3158 +         high += GARDROUND + 1;
3159 +       }
3160 +      else if (low)
3161 +       {
3162 +         /* but we really weren't half way */
3163 +         high += GARDROUND + 1;
3164 +       }
3165 +    }
3166 +  tmp->fraction.ll = high;
3167 +  tmp->class = CLASS_NUMBER;
3168 +  return tmp;
3169 +}
3170 +
3171 +FLO_type
3172 +multiply (FLO_type arg_a, FLO_type arg_b)
3173 +{
3174 +  fp_number_type a;
3175 +  fp_number_type b;
3176 +  fp_number_type tmp;
3177 +  fp_number_type *res;
3178 +  FLO_union_type au, bu;
3179 +
3180 +  au.value = arg_a;
3181 +  bu.value = arg_b;
3182 +
3183 +  unpack_d (&au, &a);
3184 +  unpack_d (&bu, &b);
3185 +
3186 +  res = _fpmul_parts (&a, &b, &tmp);
3187 +
3188 +  return pack_d (res);
3189 +}
3190 +#endif /* L_mul_sf || L_mul_df */
3191 +
3192 +#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
3193 +static inline __attribute__ ((__always_inline__)) fp_number_type *
3194 +_fpdiv_parts (fp_number_type * a,
3195 +             fp_number_type * b)
3196 +{
3197 +  fractype bit;
3198 +  fractype numerator;
3199 +  fractype denominator;
3200 +  fractype quotient;
3201 +
3202 +  if (isnan (a))
3203 +    {
3204 +      return a;
3205 +    }
3206 +  if (isnan (b))
3207 +    {
3208 +      return b;
3209 +    }
3210 +
3211 +  a->sign = a->sign ^ b->sign;
3212 +
3213 +  if (isinf (a) || iszero (a))
3214 +    {
3215 +      if (a->class == b->class)
3216 +       return nan ();
3217 +      return a;
3218 +    }
3219 +
3220 +  if (isinf (b))
3221 +    {
3222 +      a->fraction.ll = 0;
3223 +      a->normal_exp = 0;
3224 +      return a;
3225 +    }
3226 +  if (iszero (b))
3227 +    {
3228 +      a->class = CLASS_INFINITY;
3229 +      return a;
3230 +    }
3231 +
3232 +  /* Calculate the mantissa by multiplying both 64bit numbers to get a
3233 +     128 bit number */
3234 +  {
3235 +    /* quotient =
3236 +       ( numerator / denominator) * 2^(numerator exponent -  denominator exponent)
3237 +     */
3238 +
3239 +    a->normal_exp = a->normal_exp - b->normal_exp;
3240 +    numerator = a->fraction.ll;
3241 +    denominator = b->fraction.ll;
3242 +
3243 +    if (numerator < denominator)
3244 +      {
3245 +       /* Fraction will be less than 1.0 */
3246 +       numerator *= 2;
3247 +       a->normal_exp--;
3248 +      }
3249 +    bit = IMPLICIT_1;
3250 +    quotient = 0;
3251 +    /* ??? Does divide one bit at a time.  Optimize.  */
3252 +    while (bit)
3253 +      {
3254 +       if (numerator >= denominator)
3255 +         {
3256 +           quotient |= bit;
3257 +           numerator -= denominator;
3258 +         }
3259 +       bit >>= 1;
3260 +       numerator *= 2;
3261 +      }
3262 +
3263 +    if (!ROUND_TOWARDS_ZERO && (quotient & GARDMASK) == GARDMSB)
3264 +      {
3265 +       if (quotient & (1 << NGARDS))
3266 +         {
3267 +           /* half way, so round to even */
3268 +           quotient += GARDROUND + 1;
3269 +         }
3270 +       else if (numerator)
3271 +         {
3272 +           /* but we really weren't half way, more bits exist */
3273 +           quotient += GARDROUND + 1;
3274 +         }
3275 +      }
3276 +
3277 +    a->fraction.ll = quotient;
3278 +    return (a);
3279 +  }
3280 +}
3281 +
3282 +FLO_type
3283 +divide (FLO_type arg_a, FLO_type arg_b)
3284 +{
3285 +  fp_number_type a;
3286 +  fp_number_type b;
3287 +  fp_number_type *res;
3288 +  FLO_union_type au, bu;
3289 +
3290 +  au.value = arg_a;
3291 +  bu.value = arg_b;
3292 +
3293 +  unpack_d (&au, &a);
3294 +  unpack_d (&bu, &b);
3295 +
3296 +  res = _fpdiv_parts (&a, &b);
3297 +
3298 +  return pack_d (res);
3299 +}
3300 +#endif /* L_div_sf || L_div_df */
3301 +
3302 +#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
3303 +    || defined(L_fpcmp_parts_tf)
3304 +/* according to the demo, fpcmp returns a comparison with 0... thus
3305 +   a<b -> -1
3306 +   a==b -> 0
3307 +   a>b -> +1
3308 + */
3309 +
3310 +int
3311 +__fpcmp_parts (fp_number_type * a, fp_number_type * b)
3312 +{
3313 +#if 0
3314 +  /* either nan -> unordered. Must be checked outside of this routine.  */
3315 +  if (isnan (a) && isnan (b))
3316 +    {
3317 +      return 1;                        /* still unordered! */
3318 +    }
3319 +#endif
3320 +
3321 +  if (isnan (a) || isnan (b))
3322 +    {
3323 +      return 1;                        /* how to indicate unordered compare? */
3324 +    }
3325 +  if (isinf (a) && isinf (b))
3326 +    {
3327 +      /* +inf > -inf, but +inf != +inf */
3328 +      /* b    \a| +inf(0)| -inf(1)
3329 +       ______\+--------+--------
3330 +       +inf(0)| a==b(0)| a<b(-1)
3331 +       -------+--------+--------
3332 +       -inf(1)| a>b(1) | a==b(0)
3333 +       -------+--------+--------
3334 +       So since unordered must be nonzero, just line up the columns...
3335 +       */
3336 +      return b->sign - a->sign;
3337 +    }
3338 +  /* but not both...  */
3339 +  if (isinf (a))
3340 +    {
3341 +      return a->sign ? -1 : 1;
3342 +    }
3343 +  if (isinf (b))
3344 +    {
3345 +      return b->sign ? 1 : -1;
3346 +    }
3347 +  if (iszero (a) && iszero (b))
3348 +    {
3349 +      return 0;
3350 +    }
3351 +  if (iszero (a))
3352 +    {
3353 +      return b->sign ? 1 : -1;
3354 +    }
3355 +  if (iszero (b))
3356 +    {
3357 +      return a->sign ? -1 : 1;
3358 +    }
3359 +  /* now both are "normal".  */
3360 +  if (a->sign != b->sign)
3361 +    {
3362 +      /* opposite signs */
3363 +      return a->sign ? -1 : 1;
3364 +    }
3365 +  /* same sign; exponents? */
3366 +  if (a->normal_exp > b->normal_exp)
3367 +    {
3368 +      return a->sign ? -1 : 1;
3369 +    }
3370 +  if (a->normal_exp < b->normal_exp)
3371 +    {
3372 +      return a->sign ? 1 : -1;
3373 +    }
3374 +  /* same exponents; check size.  */
3375 +  if (a->fraction.ll > b->fraction.ll)
3376 +    {
3377 +      return a->sign ? -1 : 1;
3378 +    }
3379 +  if (a->fraction.ll < b->fraction.ll)
3380 +    {
3381 +      return a->sign ? 1 : -1;
3382 +    }
3383 +  /* after all that, they're equal.  */
3384 +  return 0;
3385 +}
3386 +#endif
3387 +
3388 +#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
3389 +CMPtype
3390 +compare (FLO_type arg_a, FLO_type arg_b)
3391 +{
3392 +  fp_number_type a;
3393 +  fp_number_type b;
3394 +  FLO_union_type au, bu;
3395 +
3396 +  au.value = arg_a;
3397 +  bu.value = arg_b;
3398 +
3399 +  unpack_d (&au, &a);
3400 +  unpack_d (&bu, &b);
3401 +
3402 +  return __fpcmp_parts (&a, &b);
3403 +}
3404 +#endif /* L_compare_sf || L_compare_df */
3405 +
3406 +#ifndef US_SOFTWARE_GOFAST
3407 +
3408 +/* These should be optimized for their specific tasks someday.  */
3409 +
3410 +#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
3411 +CMPtype
3412 +_eq_f2 (FLO_type arg_a, FLO_type arg_b)
3413 +{
3414 +  fp_number_type a;
3415 +  fp_number_type b;
3416 +  FLO_union_type au, bu;
3417 +
3418 +  au.value = arg_a;
3419 +  bu.value = arg_b;
3420 +
3421 +  unpack_d (&au, &a);
3422 +  unpack_d (&bu, &b);
3423 +
3424 +  if (isnan (&a) || isnan (&b))
3425 +    return 1;                  /* false, truth == 0 */
3426 +
3427 +  return __fpcmp_parts (&a, &b) ;
3428 +}
3429 +#endif /* L_eq_sf || L_eq_df */
3430 +
3431 +#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
3432 +CMPtype
3433 +_ne_f2 (FLO_type arg_a, FLO_type arg_b)
3434 +{
3435 +  fp_number_type a;
3436 +  fp_number_type b;
3437 +  FLO_union_type au, bu;
3438 +
3439 +  au.value = arg_a;
3440 +  bu.value = arg_b;
3441 +
3442 +  unpack_d (&au, &a);
3443 +  unpack_d (&bu, &b);
3444 +
3445 +  if (isnan (&a) || isnan (&b))
3446 +    return 1;                  /* true, truth != 0 */
3447 +
3448 +  return  __fpcmp_parts (&a, &b) ;
3449 +}
3450 +#endif /* L_ne_sf || L_ne_df */
3451 +
3452 +#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
3453 +CMPtype
3454 +_gt_f2 (FLO_type arg_a, FLO_type arg_b)
3455 +{
3456 +  fp_number_type a;
3457 +  fp_number_type b;
3458 +  FLO_union_type au, bu;
3459 +
3460 +  au.value = arg_a;
3461 +  bu.value = arg_b;
3462 +
3463 +  unpack_d (&au, &a);
3464 +  unpack_d (&bu, &b);
3465 +
3466 +  if (isnan (&a) || isnan (&b))
3467 +    return -1;                 /* false, truth > 0 */
3468 +
3469 +  return __fpcmp_parts (&a, &b);
3470 +}
3471 +#endif /* L_gt_sf || L_gt_df */
3472 +
3473 +#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
3474 +CMPtype
3475 +_ge_f2 (FLO_type arg_a, FLO_type arg_b)
3476 +{
3477 +  fp_number_type a;
3478 +  fp_number_type b;
3479 +  FLO_union_type au, bu;
3480 +
3481 +  au.value = arg_a;
3482 +  bu.value = arg_b;
3483 +
3484 +  unpack_d (&au, &a);
3485 +  unpack_d (&bu, &b);
3486 +
3487 +  if (isnan (&a) || isnan (&b))
3488 +    return -1;                 /* false, truth >= 0 */
3489 +  return __fpcmp_parts (&a, &b) ;
3490 +}
3491 +#endif /* L_ge_sf || L_ge_df */
3492 +
3493 +#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
3494 +CMPtype
3495 +_lt_f2 (FLO_type arg_a, FLO_type arg_b)
3496 +{
3497 +  fp_number_type a;
3498 +  fp_number_type b;
3499 +  FLO_union_type au, bu;
3500 +
3501 +  au.value = arg_a;
3502 +  bu.value = arg_b;
3503 +
3504 +  unpack_d (&au, &a);
3505 +  unpack_d (&bu, &b);
3506 +
3507 +  if (isnan (&a) || isnan (&b))
3508 +    return 1;                  /* false, truth < 0 */
3509 +
3510 +  return __fpcmp_parts (&a, &b);
3511 +}
3512 +#endif /* L_lt_sf || L_lt_df */
3513 +
3514 +#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
3515 +CMPtype
3516 +_le_f2 (FLO_type arg_a, FLO_type arg_b)
3517 +{
3518 +  fp_number_type a;
3519 +  fp_number_type b;
3520 +  FLO_union_type au, bu;
3521 +
3522 +  au.value = arg_a;
3523 +  bu.value = arg_b;
3524 +
3525 +  unpack_d (&au, &a);
3526 +  unpack_d (&bu, &b);
3527 +
3528 +  if (isnan (&a) || isnan (&b))
3529 +    return 1;                  /* false, truth <= 0 */
3530 +
3531 +  return __fpcmp_parts (&a, &b) ;
3532 +}
3533 +#endif /* L_le_sf || L_le_df */
3534 +
3535 +#endif /* ! US_SOFTWARE_GOFAST */
3536 +
3537 +#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
3538 +CMPtype
3539 +_unord_f2 (FLO_type arg_a, FLO_type arg_b)
3540 +{
3541 +  fp_number_type a;
3542 +  fp_number_type b;
3543 +  FLO_union_type au, bu;
3544 +
3545 +  au.value = arg_a;
3546 +  bu.value = arg_b;
3547 +
3548 +  unpack_d (&au, &a);
3549 +  unpack_d (&bu, &b);
3550 +
3551 +  return (isnan (&a) || isnan (&b));
3552 +}
3553 +#endif /* L_unord_sf || L_unord_df */
3554 +
3555 +#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
3556 +FLO_type
3557 +si_to_float (SItype arg_a)
3558 +{
3559 +  fp_number_type in;
3560 +
3561 +  in.class = CLASS_NUMBER;
3562 +  in.sign = arg_a < 0;
3563 +  if (!arg_a)
3564 +    {
3565 +      in.class = CLASS_ZERO;
3566 +    }
3567 +  else
3568 +    {
3569 +      in.normal_exp = FRACBITS + NGARDS;
3570 +      if (in.sign) 
3571 +       {
3572 +         /* Special case for minint, since there is no +ve integer
3573 +            representation for it */
3574 +         if (arg_a == (- MAX_SI_INT - 1))
3575 +           {
3576 +             return (FLO_type)(- MAX_SI_INT - 1);
3577 +           }
3578 +         in.fraction.ll = (-arg_a);
3579 +       }
3580 +      else
3581 +       in.fraction.ll = arg_a;
3582 +
3583 +      while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
3584 +       {
3585 +         in.fraction.ll <<= 1;
3586 +         in.normal_exp -= 1;
3587 +       }
3588 +    }
3589 +  return pack_d (&in);
3590 +}
3591 +#endif /* L_si_to_sf || L_si_to_df */
3592 +
3593 +#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
3594 +FLO_type
3595 +usi_to_float (USItype arg_a)
3596 +{
3597 +  fp_number_type in;
3598 +
3599 +  in.sign = 0;
3600 +  if (!arg_a)
3601 +    {
3602 +      in.class = CLASS_ZERO;
3603 +    }
3604 +  else
3605 +    {
3606 +      in.class = CLASS_NUMBER;
3607 +      in.normal_exp = FRACBITS + NGARDS;
3608 +      in.fraction.ll = arg_a;
3609 +
3610 +      while (in.fraction.ll > ((fractype)1 << (FRACBITS + NGARDS)))
3611 +        {
3612 +          in.fraction.ll >>= 1;
3613 +          in.normal_exp += 1;
3614 +        }
3615 +      while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
3616 +       {
3617 +         in.fraction.ll <<= 1;
3618 +         in.normal_exp -= 1;
3619 +       }
3620 +    }
3621 +  return pack_d (&in);
3622 +}
3623 +#endif
3624 +
3625 +#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
3626 +SItype
3627 +float_to_si (FLO_type arg_a)
3628 +{
3629 +  fp_number_type a;
3630 +  SItype tmp;
3631 +  FLO_union_type au;
3632 +
3633 +  au.value = arg_a;
3634 +  unpack_d (&au, &a);
3635 +
3636 +  if (iszero (&a))
3637 +    return 0;
3638 +  if (isnan (&a))
3639 +    return 0;
3640 +  /* get reasonable MAX_SI_INT...  */
3641 +  if (isinf (&a))
3642 +    return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
3643 +  /* it is a number, but a small one */
3644 +  if (a.normal_exp < 0)
3645 +    return 0;
3646 +  if (a.normal_exp > BITS_PER_SI - 2)
3647 +    return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
3648 +  tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
3649 +  return a.sign ? (-tmp) : (tmp);
3650 +}
3651 +#endif /* L_sf_to_si || L_df_to_si */
3652 +
3653 +#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
3654 +#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
3655 +/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
3656 +   we also define them for GOFAST because the ones in libgcc2.c have the
3657 +   wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
3658 +   out of libgcc2.c.  We can't define these here if not GOFAST because then
3659 +   there'd be duplicate copies.  */
3660 +
3661 +USItype
3662 +float_to_usi (FLO_type arg_a)
3663 +{
3664 +  fp_number_type a;
3665 +  FLO_union_type au;
3666 +
3667 +  au.value = arg_a;
3668 +  unpack_d (&au, &a);
3669 +
3670 +  if (iszero (&a))
3671 +    return 0;
3672 +  if (isnan (&a))
3673 +    return 0;
3674 +  /* it is a negative number */
3675 +  if (a.sign)
3676 +    return 0;
3677 +  /* get reasonable MAX_USI_INT...  */
3678 +  if (isinf (&a))
3679 +    return MAX_USI_INT;
3680 +  /* it is a number, but a small one */
3681 +  if (a.normal_exp < 0)
3682 +    return 0;
3683 +  if (a.normal_exp > BITS_PER_SI - 1)
3684 +    return MAX_USI_INT;
3685 +  else if (a.normal_exp > (FRACBITS + NGARDS))
3686 +    return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
3687 +  else
3688 +    return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
3689 +}
3690 +#endif /* US_SOFTWARE_GOFAST */
3691 +#endif /* L_sf_to_usi || L_df_to_usi */
3692 +
3693 +#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
3694 +FLO_type
3695 +negate (FLO_type arg_a)
3696 +{
3697 +  fp_number_type a;
3698 +  FLO_union_type au;
3699 +
3700 +  au.value = arg_a;
3701 +  unpack_d (&au, &a);
3702 +
3703 +  flip_sign (&a);
3704 +  return pack_d (&a);
3705 +}
3706 +#endif /* L_negate_sf || L_negate_df */
3707 +
3708 +#ifdef FLOAT
3709 +
3710 +#if defined(L_make_sf)
3711 +SFtype
3712 +__make_fp(fp_class_type class,
3713 +            unsigned int sign,
3714 +            int exp, 
3715 +            USItype frac)
3716 +{
3717 +  fp_number_type in;
3718 +
3719 +  in.class = class;
3720 +  in.sign = sign;
3721 +  in.normal_exp = exp;
3722 +  in.fraction.ll = frac;
3723 +  return pack_d (&in);
3724 +}
3725 +#endif /* L_make_sf */
3726 +
3727 +#ifndef FLOAT_ONLY
3728 +
3729 +/* This enables one to build an fp library that supports float but not double.
3730 +   Otherwise, we would get an undefined reference to __make_dp.
3731 +   This is needed for some 8-bit ports that can't handle well values that
3732 +   are 8-bytes in size, so we just don't support double for them at all.  */
3733 +
3734 +#if defined(L_sf_to_df)
3735 +DFtype
3736 +sf_to_df (SFtype arg_a)
3737 +{
3738 +  fp_number_type in;
3739 +  FLO_union_type au;
3740 +
3741 +  au.value = arg_a;
3742 +  unpack_d (&au, &in);
3743 +
3744 +  return __make_dp (in.class, in.sign, in.normal_exp,
3745 +                   ((UDItype) in.fraction.ll) << F_D_BITOFF);
3746 +}
3747 +#endif /* L_sf_to_df */
3748 +
3749 +#if defined(L_sf_to_tf) && defined(TMODES)
3750 +TFtype
3751 +sf_to_tf (SFtype arg_a)
3752 +{
3753 +  fp_number_type in;
3754 +  FLO_union_type au;
3755 +
3756 +  au.value = arg_a;
3757 +  unpack_d (&au, &in);
3758 +
3759 +  return __make_tp (in.class, in.sign, in.normal_exp,
3760 +                   ((UTItype) in.fraction.ll) << F_T_BITOFF);
3761 +}
3762 +#endif /* L_sf_to_df */
3763 +
3764 +#endif /* ! FLOAT_ONLY */
3765 +#endif /* FLOAT */
3766 +
3767 +#ifndef FLOAT
3768 +
3769 +extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
3770 +
3771 +#if defined(L_make_df)
3772 +DFtype
3773 +__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
3774 +{
3775 +  fp_number_type in;
3776 +
3777 +  in.class = class;
3778 +  in.sign = sign;
3779 +  in.normal_exp = exp;
3780 +  in.fraction.ll = frac;
3781 +  return pack_d (&in);
3782 +}
3783 +#endif /* L_make_df */
3784 +
3785 +#if defined(L_df_to_sf)
3786 +SFtype
3787 +df_to_sf (DFtype arg_a)
3788 +{
3789 +  fp_number_type in;
3790 +  USItype sffrac;
3791 +  FLO_union_type au;
3792 +
3793 +  au.value = arg_a;
3794 +  unpack_d (&au, &in);
3795 +
3796 +  sffrac = in.fraction.ll >> F_D_BITOFF;
3797 +
3798 +  /* We set the lowest guard bit in SFFRAC if we discarded any non
3799 +     zero bits.  */
3800 +  if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
3801 +    sffrac |= 1;
3802 +
3803 +  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
3804 +}
3805 +#endif /* L_df_to_sf */
3806 +
3807 +#if defined(L_df_to_tf) && defined(TMODES) \
3808 +    && !defined(FLOAT) && !defined(TFLOAT)
3809 +TFtype
3810 +df_to_tf (DFtype arg_a)
3811 +{
3812 +  fp_number_type in;
3813 +  FLO_union_type au;
3814 +
3815 +  au.value = arg_a;
3816 +  unpack_d (&au, &in);
3817 +
3818 +  return __make_tp (in.class, in.sign, in.normal_exp,
3819 +                   ((UTItype) in.fraction.ll) << D_T_BITOFF);
3820 +}
3821 +#endif /* L_sf_to_df */
3822 +
3823 +#ifdef TFLOAT
3824 +#if defined(L_make_tf)
3825 +TFtype
3826 +__make_tp(fp_class_type class,
3827 +            unsigned int sign,
3828 +            int exp, 
3829 +            UTItype frac)
3830 +{
3831 +  fp_number_type in;
3832 +
3833 +  in.class = class;
3834 +  in.sign = sign;
3835 +  in.normal_exp = exp;
3836 +  in.fraction.ll = frac;
3837 +  return pack_d (&in);
3838 +}
3839 +#endif /* L_make_tf */
3840 +
3841 +#if defined(L_tf_to_df)
3842 +DFtype
3843 +tf_to_df (TFtype arg_a)
3844 +{
3845 +  fp_number_type in;
3846 +  UDItype sffrac;
3847 +  FLO_union_type au;
3848 +
3849 +  au.value = arg_a;
3850 +  unpack_d (&au, &in);
3851 +
3852 +  sffrac = in.fraction.ll >> D_T_BITOFF;
3853 +
3854 +  /* We set the lowest guard bit in SFFRAC if we discarded any non
3855 +     zero bits.  */
3856 +  if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)
3857 +    sffrac |= 1;
3858 +
3859 +  return __make_dp (in.class, in.sign, in.normal_exp, sffrac);
3860 +}
3861 +#endif /* L_tf_to_df */
3862 +
3863 +#if defined(L_tf_to_sf)
3864 +SFtype
3865 +tf_to_sf (TFtype arg_a)
3866 +{
3867 +  fp_number_type in;
3868 +  USItype sffrac;
3869 +  FLO_union_type au;
3870 +
3871 +  au.value = arg_a;
3872 +  unpack_d (&au, &in);
3873 +
3874 +  sffrac = in.fraction.ll >> F_T_BITOFF;
3875 +
3876 +  /* We set the lowest guard bit in SFFRAC if we discarded any non
3877 +     zero bits.  */
3878 +  if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)
3879 +    sffrac |= 1;
3880 +
3881 +  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
3882 +}
3883 +#endif /* L_tf_to_sf */
3884 +#endif /* TFLOAT */
3885 +
3886 +#endif /* ! FLOAT */
3887 +#endif /* !EXTENDED_FLOAT_STUBS */
3888 --- ./gcc/gcc/libgcc2.c
3889 +++ ./gcc/gcc/libgcc2.c
3890 @@ -0,0 +1,1669 @@
3891 +/* More subroutines needed by GCC output code on some machines.  */
3892 +/* Compile this one with gcc.  */
3893 +/* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3894 +   2000, 2001, 2002, 2003  Free Software Foundation, Inc.
3895 +
3896 +This file is part of GCC.
3897 +
3898 +GCC is free software; you can redistribute it and/or modify it under
3899 +the terms of the GNU General Public License as published by the Free
3900 +Software Foundation; either version 2, or (at your option) any later
3901 +version.
3902 +
3903 +In addition to the permissions in the GNU General Public License, the
3904 +Free Software Foundation gives you unlimited permission to link the
3905 +compiled version of this file into combinations with other programs,
3906 +and to distribute those combinations without any restriction coming
3907 +from the use of this file.  (The General Public License restrictions
3908 +do apply in other respects; for example, they cover modification of
3909 +the file, and distribution when not linked into a combine
3910 +executable.)
3911 +
3912 +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
3913 +WARRANTY; without even the implied warranty of MERCHANTABILITY or
3914 +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3915 +for more details.
3916 +
3917 +You should have received a copy of the GNU General Public License
3918 +along with GCC; see the file COPYING.  If not, write to the Free
3919 +Software Foundation, 59 Temple Place - Suite 330, Boston, MA
3920 +02111-1307, USA.  */
3921 +
3922 +
3923 +/* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
3924 +   supposedly valid even though this is a "target" file.  */
3925 +#include "auto-host.h"
3926 +
3927 +/* It is incorrect to include config.h here, because this file is being
3928 +   compiled for the target, and hence definitions concerning only the host
3929 +   do not apply.  */
3930 +#include "tconfig.h"
3931 +#include "tsystem.h"
3932 +#include "coretypes.h"
3933 +#include "tm.h"
3934 +
3935 +/* Don't use `fancy_abort' here even if config.h says to use it.  */
3936 +#ifdef abort
3937 +#undef abort
3938 +#endif
3939 +
3940 +#ifdef HAVE_GAS_HIDDEN
3941 +#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
3942 +#else
3943 +#define ATTRIBUTE_HIDDEN
3944 +#endif
3945 +
3946 +#include "libgcc2.h"
3947 +\f
3948 +#ifdef DECLARE_LIBRARY_RENAMES
3949 +  DECLARE_LIBRARY_RENAMES
3950 +#endif
3951 +
3952 +#if defined (L_negdi2)
3953 +DWtype
3954 +__negdi2 (DWtype u)
3955 +{
3956 +  const DWunion uu = {.ll = u};
3957 +  const DWunion w = { {.low = -uu.s.low,
3958 +                      .high = -uu.s.high - ((UWtype) -uu.s.low > 0) } };
3959 +
3960 +  return w.ll;
3961 +}
3962 +#endif
3963 +
3964 +#ifdef L_addvsi3
3965 +Wtype
3966 +__addvsi3 (Wtype a, Wtype b)
3967 +{
3968 +  const Wtype w = a + b;
3969 +
3970 +  if (b >= 0 ? w < a : w > a)
3971 +    abort ();
3972 +
3973 +  return w;
3974 +}
3975 +#endif
3976 +\f
3977 +#ifdef L_addvdi3
3978 +DWtype
3979 +__addvdi3 (DWtype a, DWtype b)
3980 +{
3981 +  const DWtype w = a + b;
3982 +
3983 +  if (b >= 0 ? w < a : w > a)
3984 +    abort ();
3985 +
3986 +  return w;
3987 +}
3988 +#endif
3989 +\f
3990 +#ifdef L_subvsi3
3991 +Wtype
3992 +__subvsi3 (Wtype a, Wtype b)
3993 +{
3994 +  const DWtype w = a - b;
3995 +
3996 +  if (b >= 0 ? w > a : w < a)
3997 +    abort ();
3998 +
3999 +  return w;
4000 +}
4001 +#endif
4002 +\f
4003 +#ifdef L_subvdi3
4004 +DWtype
4005 +__subvdi3 (DWtype a, DWtype b)
4006 +{
4007 +  const DWtype w = a - b;
4008 +
4009 +  if (b >= 0 ? w > a : w < a)
4010 +    abort ();
4011 +
4012 +  return w;
4013 +}
4014 +#endif
4015 +\f
4016 +#ifdef L_mulvsi3
4017 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
4018 +Wtype
4019 +__mulvsi3 (Wtype a, Wtype b)
4020 +{
4021 +  const DWtype w = (DWtype) a * (DWtype) b;
4022 +
4023 +  if (((a >= 0) == (b >= 0))
4024 +      ? (UDWtype) w > (UDWtype) (((DWtype) 1 << (WORD_SIZE - 1)) - 1)
4025 +      : (UDWtype) w < (UDWtype) ((DWtype) -1 << (WORD_SIZE - 1)))
4026 +    abort ();
4027 +
4028 +  return w;
4029 +}
4030 +#endif
4031 +\f
4032 +#ifdef L_negvsi2
4033 +Wtype
4034 +__negvsi2 (Wtype a)
4035 +{
4036 +  const Wtype w = -a;
4037 +
4038 +  if (a >= 0 ? w > 0 : w < 0)
4039 +    abort ();
4040 +
4041 +   return w;
4042 +}
4043 +#endif
4044 +\f
4045 +#ifdef L_negvdi2
4046 +DWtype
4047 +__negvdi2 (DWtype a)
4048 +{
4049 +  const DWtype w = -a;
4050 +
4051 +  if (a >= 0 ? w > 0 : w < 0)
4052 +    abort ();
4053 +
4054 +  return w;
4055 +}
4056 +#endif
4057 +\f
4058 +#ifdef L_absvsi2
4059 +Wtype
4060 +__absvsi2 (Wtype a)
4061 +{
4062 +  Wtype w = a;
4063 +
4064 +  if (a < 0)
4065 +#ifdef L_negvsi2
4066 +    w = __negvsi2 (a);
4067 +#else
4068 +    w = -a;
4069 +
4070 +  if (w < 0)
4071 +    abort ();
4072 +#endif
4073 +
4074 +   return w;
4075 +}
4076 +#endif
4077 +\f
4078 +#ifdef L_absvdi2
4079 +DWtype
4080 +__absvdi2 (DWtype a)
4081 +{
4082 +  DWtype w = a;
4083 +
4084 +  if (a < 0)
4085 +#ifdef L_negvdi2
4086 +    w = __negvdi2 (a);
4087 +#else
4088 +    w = -a;
4089 +
4090 +  if (w < 0)
4091 +    abort ();
4092 +#endif
4093 +
4094 +  return w;
4095 +}
4096 +#endif
4097 +\f
4098 +#ifdef L_mulvdi3
4099 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
4100 +DWtype
4101 +__mulvdi3 (DWtype u, DWtype v)
4102 +{
4103 +  /* The unchecked multiplication needs 3 Wtype x Wtype multiplications,
4104 +     but the checked multiplication needs only two.  */
4105 +  const DWunion uu = {.ll = u};
4106 +  const DWunion vv = {.ll = v};
4107 +
4108 +  if (__builtin_expect (uu.s.high == uu.s.low >> (WORD_SIZE - 1), 1))
4109 +    {
4110 +      /* u fits in a single Wtype.  */
4111 +      if (__builtin_expect (vv.s.high == vv.s.low >> (WORD_SIZE - 1), 1))
4112 +       {
4113 +         /* v fits in a single Wtype as well.  */
4114 +         /* A single multiplication.  No overflow risk.  */
4115 +         return (DWtype) uu.s.low * (DWtype) vv.s.low;
4116 +       }
4117 +      else
4118 +       {
4119 +         /* Two multiplications.  */
4120 +         DWunion w0 = {.ll = (UDWtype) (UWtype) uu.s.low
4121 +                       * (UDWtype) (UWtype) vv.s.low};
4122 +         DWunion w1 = {.ll = (UDWtype) (UWtype) uu.s.low
4123 +                       * (UDWtype) (UWtype) vv.s.high};
4124 +
4125 +         if (vv.s.high < 0)
4126 +           w1.s.high -= uu.s.low;
4127 +         if (uu.s.low < 0)
4128 +           w1.ll -= vv.ll;
4129 +         w1.ll += (UWtype) w0.s.high;
4130 +         if (__builtin_expect (w1.s.high == w1.s.low >> (WORD_SIZE - 1), 1))
4131 +           {
4132 +             w0.s.high = w1.s.low;
4133 +             return w0.ll;
4134 +           }
4135 +       }
4136 +    }
4137 +  else
4138 +    {
4139 +      if (__builtin_expect (vv.s.high == vv.s.low >> (WORD_SIZE - 1), 1))
4140 +       {
4141 +         /* v fits into a single Wtype.  */
4142 +         /* Two multiplications.  */
4143 +         DWunion w0 = {.ll = (UDWtype) (UWtype) uu.s.low
4144 +                       * (UDWtype) (UWtype) vv.s.low};
4145 +         DWunion w1 = {.ll = (UDWtype) (UWtype) uu.s.high
4146 +                       * (UDWtype) (UWtype) vv.s.low};
4147 +
4148 +         if (uu.s.high < 0)
4149 +           w1.s.high -= vv.s.low;
4150 +         if (vv.s.low < 0)
4151 +           w1.ll -= uu.ll;
4152 +         w1.ll += (UWtype) w0.s.high;
4153 +         if (__builtin_expect (w1.s.high == w1.s.low >> (WORD_SIZE - 1), 1))
4154 +           {
4155 +             w0.s.high = w1.s.low;
4156 +             return w0.ll;
4157 +           }
4158 +       }
4159 +      else
4160 +       {
4161 +         /* A few sign checks and a single multiplication.  */
4162 +         if (uu.s.high >= 0)
4163 +           {
4164 +             if (vv.s.high >= 0)
4165 +               {
4166 +                 if (uu.s.high == 0 && vv.s.high == 0)
4167 +                   {
4168 +                     const DWtype w = (UDWtype) (UWtype) uu.s.low
4169 +                       * (UDWtype) (UWtype) vv.s.low;
4170 +                     if (__builtin_expect (w >= 0, 1))
4171 +                       return w;
4172 +                   }
4173 +               }
4174 +             else
4175 +               {
4176 +                 if (uu.s.high == 0 && vv.s.high == (Wtype) -1)
4177 +                   {
4178 +                     DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
4179 +                                   * (UDWtype) (UWtype) vv.s.low};
4180 +
4181 +                     ww.s.high -= uu.s.low;
4182 +                     if (__builtin_expect (ww.s.high < 0, 1))
4183 +                       return ww.ll;
4184 +                   }
4185 +               }
4186 +           }
4187 +         else
4188 +           {
4189 +             if (vv.s.high >= 0)
4190 +               {
4191 +                 if (uu.s.high == (Wtype) -1 && vv.s.high == 0)
4192 +                   {
4193 +                     DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
4194 +                                   * (UDWtype) (UWtype) vv.s.low};
4195 +
4196 +                     ww.s.high -= vv.s.low;
4197 +                     if (__builtin_expect (ww.s.high < 0, 1))
4198 +                       return ww.ll;
4199 +                   }
4200 +               }
4201 +             else
4202 +               {
4203 +                 if (uu.s.high == (Wtype) -1 && vv.s.high == (Wtype) - 1)
4204 +                   {
4205 +                     DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
4206 +                                   * (UDWtype) (UWtype) vv.s.low};
4207 +
4208 +                     ww.s.high -= uu.s.low;
4209 +                     ww.s.high -= vv.s.low;
4210 +                     if (__builtin_expect (ww.s.high >= 0, 1))
4211 +                       return ww.ll;
4212 +                   }
4213 +               }
4214 +           }
4215 +       }
4216 +    }
4217 +
4218 +  /* Overflow.  */
4219 +  abort ();
4220 +}
4221 +#endif
4222 +\f
4223 +
4224 +/* Unless shift functions are defined with full ANSI prototypes,
4225 +   parameter b will be promoted to int if word_type is smaller than an int.  */
4226 +#ifdef L_lshrdi3
4227 +DWtype
4228 +__lshrdi3 (DWtype u, word_type b)
4229 +{
4230 +  if (b == 0)
4231 +    return u;
4232 +
4233 +  const DWunion uu = {.ll = u};
4234 +  const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
4235 +  DWunion w;
4236 +
4237 +  if (bm <= 0)
4238 +    {
4239 +      w.s.high = 0;
4240 +      w.s.low = (UWtype) uu.s.high >> -bm;
4241 +    }
4242 +  else
4243 +    {
4244 +      const UWtype carries = (UWtype) uu.s.high << bm;
4245 +
4246 +      w.s.high = (UWtype) uu.s.high >> b;
4247 +      w.s.low = ((UWtype) uu.s.low >> b) | carries;
4248 +    }
4249 +
4250 +  return w.ll;
4251 +}
4252 +#endif
4253 +
4254 +#ifdef L_ashldi3
4255 +DWtype
4256 +__ashldi3 (DWtype u, word_type b)
4257 +{
4258 +  if (b == 0)
4259 +    return u;
4260 +
4261 +  const DWunion uu = {.ll = u};
4262 +  const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
4263 +  DWunion w;
4264 +
4265 +  if (bm <= 0)
4266 +    {
4267 +      w.s.low = 0;
4268 +      w.s.high = (UWtype) uu.s.low << -bm;
4269 +    }
4270 +  else
4271 +    {
4272 +      const UWtype carries = (UWtype) uu.s.low >> bm;
4273 +
4274 +      w.s.low = (UWtype) uu.s.low << b;
4275 +      w.s.high = ((UWtype) uu.s.high << b) | carries;
4276 +    }
4277 +
4278 +  return w.ll;
4279 +}
4280 +#endif
4281 +
4282 +#ifdef L_ashrdi3
4283 +DWtype
4284 +__ashrdi3 (DWtype u, word_type b)
4285 +{
4286 +  if (b == 0)
4287 +    return u;
4288 +
4289 +  const DWunion uu = {.ll = u};
4290 +  const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
4291 +  DWunion w;
4292 +
4293 +  if (bm <= 0)
4294 +    {
4295 +      /* w.s.high = 1..1 or 0..0 */
4296 +      w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
4297 +      w.s.low = uu.s.high >> -bm;
4298 +    }
4299 +  else
4300 +    {
4301 +      const UWtype carries = (UWtype) uu.s.high << bm;
4302 +
4303 +      w.s.high = uu.s.high >> b;
4304 +      w.s.low = ((UWtype) uu.s.low >> b) | carries;
4305 +    }
4306 +
4307 +  return w.ll;
4308 +}
4309 +#endif
4310 +\f
4311 +#ifdef L_ffssi2
4312 +#undef int
4313 +extern int __ffsSI2 (UWtype u);
4314 +int
4315 +__ffsSI2 (UWtype u)
4316 +{
4317 +  UWtype count;
4318 +
4319 +  if (u == 0)
4320 +    return 0;
4321 +
4322 +  count_trailing_zeros (count, u);
4323 +  return count + 1;
4324 +}
4325 +#endif
4326 +\f
4327 +#ifdef L_ffsdi2
4328 +#undef int
4329 +extern int __ffsDI2 (DWtype u);
4330 +int
4331 +__ffsDI2 (DWtype u)
4332 +{
4333 +  const DWunion uu = {.ll = u};
4334 +  UWtype word, count, add;
4335 +
4336 +  if (uu.s.low != 0)
4337 +    word = uu.s.low, add = 0;
4338 +  else if (uu.s.high != 0)
4339 +    word = uu.s.high, add = BITS_PER_UNIT * sizeof (Wtype);
4340 +  else
4341 +    return 0;
4342 +
4343 +  count_trailing_zeros (count, word);
4344 +  return count + add + 1;
4345 +}
4346 +#endif
4347 +\f
4348 +#ifdef L_muldi3
4349 +DWtype
4350 +__muldi3 (DWtype u, DWtype v)
4351 +{
4352 +  const DWunion uu = {.ll = u};
4353 +  const DWunion vv = {.ll = v};
4354 +  DWunion w = {.ll = __umulsidi3 (uu.s.low, vv.s.low)};
4355 +
4356 +  w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high
4357 +              + (UWtype) uu.s.high * (UWtype) vv.s.low);
4358 +
4359 +  return w.ll;
4360 +}
4361 +#endif
4362 +\f
4363 +#if (defined (L_udivdi3) || defined (L_divdi3) || \
4364 +     defined (L_umoddi3) || defined (L_moddi3))
4365 +#if defined (sdiv_qrnnd)
4366 +#define L_udiv_w_sdiv
4367 +#endif
4368 +#endif
4369 +
4370 +#ifdef L_udiv_w_sdiv
4371 +#if defined (sdiv_qrnnd)
4372 +#if (defined (L_udivdi3) || defined (L_divdi3) || \
4373 +     defined (L_umoddi3) || defined (L_moddi3))
4374 +static inline __attribute__ ((__always_inline__))
4375 +#endif
4376 +UWtype
4377 +__udiv_w_sdiv (UWtype *rp, UWtype a1, UWtype a0, UWtype d)
4378 +{
4379 +  UWtype q, r;
4380 +  UWtype c0, c1, b1;
4381 +
4382 +  if ((Wtype) d >= 0)
4383 +    {
4384 +      if (a1 < d - a1 - (a0 >> (W_TYPE_SIZE - 1)))
4385 +       {
4386 +         /* dividend, divisor, and quotient are nonnegative */
4387 +         sdiv_qrnnd (q, r, a1, a0, d);
4388 +       }
4389 +      else
4390 +       {
4391 +         /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d */
4392 +         sub_ddmmss (c1, c0, a1, a0, d >> 1, d << (W_TYPE_SIZE - 1));
4393 +         /* Divide (c1*2^32 + c0) by d */
4394 +         sdiv_qrnnd (q, r, c1, c0, d);
4395 +         /* Add 2^31 to quotient */
4396 +         q += (UWtype) 1 << (W_TYPE_SIZE - 1);
4397 +       }
4398 +    }
4399 +  else
4400 +    {
4401 +      b1 = d >> 1;                     /* d/2, between 2^30 and 2^31 - 1 */
4402 +      c1 = a1 >> 1;                    /* A/2 */
4403 +      c0 = (a1 << (W_TYPE_SIZE - 1)) + (a0 >> 1);
4404 +
4405 +      if (a1 < b1)                     /* A < 2^32*b1, so A/2 < 2^31*b1 */
4406 +       {
4407 +         sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
4408 +
4409 +         r = 2*r + (a0 & 1);           /* Remainder from A/(2*b1) */
4410 +         if ((d & 1) != 0)
4411 +           {
4412 +             if (r >= q)
4413 +               r = r - q;
4414 +             else if (q - r <= d)
4415 +               {
4416 +                 r = r - q + d;
4417 +                 q--;
4418 +               }
4419 +             else
4420 +               {
4421 +                 r = r - q + 2*d;
4422 +                 q -= 2;
4423 +               }
4424 +           }
4425 +       }
4426 +      else if (c1 < b1)                        /* So 2^31 <= (A/2)/b1 < 2^32 */
4427 +       {
4428 +         c1 = (b1 - 1) - c1;
4429 +         c0 = ~c0;                     /* logical NOT */
4430 +
4431 +         sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */
4432 +
4433 +         q = ~q;                       /* (A/2)/b1 */
4434 +         r = (b1 - 1) - r;
4435 +
4436 +         r = 2*r + (a0 & 1);           /* A/(2*b1) */
4437 +
4438 +         if ((d & 1) != 0)
4439 +           {
4440 +             if (r >= q)
4441 +               r = r - q;
4442 +             else if (q - r <= d)
4443 +               {
4444 +                 r = r - q + d;
4445 +                 q--;
4446 +               }
4447 +             else
4448 +               {
4449 +                 r = r - q + 2*d;
4450 +                 q -= 2;
4451 +               }
4452 +           }
4453 +       }
4454 +      else                             /* Implies c1 = b1 */
4455 +       {                               /* Hence a1 = d - 1 = 2*b1 - 1 */
4456 +         if (a0 >= -d)
4457 +           {
4458 +             q = -1;
4459 +             r = a0 + d;
4460 +           }
4461 +         else
4462 +           {
4463 +             q = -2;
4464 +             r = a0 + 2*d;
4465 +           }
4466 +       }
4467 +    }
4468 +
4469 +  *rp = r;
4470 +  return q;
4471 +}
4472 +#else
4473 +/* If sdiv_qrnnd doesn't exist, define dummy __udiv_w_sdiv.  */
4474 +UWtype
4475 +__udiv_w_sdiv (UWtype *rp __attribute__ ((__unused__)),
4476 +              UWtype a1 __attribute__ ((__unused__)),
4477 +              UWtype a0 __attribute__ ((__unused__)),
4478 +              UWtype d __attribute__ ((__unused__)))
4479 +{
4480 +  return 0;
4481 +}
4482 +#endif
4483 +#endif
4484 +\f
4485 +#if (defined (L_udivdi3) || defined (L_divdi3) || \
4486 +     defined (L_umoddi3) || defined (L_moddi3))
4487 +#define L_udivmoddi4
4488 +#endif
4489 +
4490 +#ifdef L_clz
4491 +const UQItype __clz_tab[] =
4492 +{
4493 +  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,
4494 +  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,
4495 +  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,
4496 +  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,
4497 +  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,
4498 +  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,
4499 +  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,
4500 +  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,
4501 +};
4502 +#endif
4503 +\f
4504 +#ifdef L_clzsi2
4505 +#undef int
4506 +extern int __clzSI2 (UWtype x);
4507 +int
4508 +__clzSI2 (UWtype x)
4509 +{
4510 +  Wtype ret;
4511 +
4512 +  count_leading_zeros (ret, x);
4513 +
4514 +  return ret;
4515 +}
4516 +#endif
4517 +\f
4518 +#ifdef L_clzdi2
4519 +#undef int
4520 +extern int __clzDI2 (UDWtype x);
4521 +int
4522 +__clzDI2 (UDWtype x)
4523 +{
4524 +  const DWunion uu = {.ll = x};
4525 +  UWtype word;
4526 +  Wtype ret, add;
4527 +
4528 +  if (uu.s.high)
4529 +    word = uu.s.high, add = 0;
4530 +  else
4531 +    word = uu.s.low, add = W_TYPE_SIZE;
4532 +
4533 +  count_leading_zeros (ret, word);
4534 +  return ret + add;
4535 +}
4536 +#endif
4537 +\f
4538 +#ifdef L_ctzsi2
4539 +#undef int
4540 +extern int __ctzSI2 (UWtype x);
4541 +int
4542 +__ctzSI2 (UWtype x)
4543 +{
4544 +  Wtype ret;
4545 +
4546 +  count_trailing_zeros (ret, x);
4547 +
4548 +  return ret;
4549 +}
4550 +#endif
4551 +\f
4552 +#ifdef L_ctzdi2
4553 +#undef int
4554 +extern int __ctzDI2 (UDWtype x);
4555 +int
4556 +__ctzDI2 (UDWtype x)
4557 +{
4558 +  const DWunion uu = {.ll = x};
4559 +  UWtype word;
4560 +  Wtype ret, add;
4561 +
4562 +  if (uu.s.low)
4563 +    word = uu.s.low, add = 0;
4564 +  else
4565 +    word = uu.s.high, add = W_TYPE_SIZE;
4566 +
4567 +  count_trailing_zeros (ret, word);
4568 +  return ret + add;
4569 +}
4570 +#endif
4571 +
4572 +#if (defined (L_popcountsi2) || defined (L_popcountdi2)        \
4573 +     || defined (L_popcount_tab))
4574 +extern const UQItype __popcount_tab[] ATTRIBUTE_HIDDEN;
4575 +#endif
4576 +
4577 +#ifdef L_popcount_tab
4578 +const UQItype __popcount_tab[] =
4579 +{
4580 +    0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
4581 +    1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
4582 +    1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
4583 +    2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
4584 +    1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
4585 +    2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
4586 +    2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
4587 +    3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,
4588 +};
4589 +#endif
4590 +\f
4591 +#ifdef L_popcountsi2
4592 +#undef int
4593 +extern int __popcountSI2 (UWtype x);
4594 +int
4595 +__popcountSI2 (UWtype x)
4596 +{
4597 +  UWtype i, ret = 0;
4598 +
4599 +  for (i = 0; i < W_TYPE_SIZE; i += 8)
4600 +    ret += __popcount_tab[(x >> i) & 0xff];
4601 +
4602 +  return ret;
4603 +}
4604 +#endif
4605 +\f
4606 +#ifdef L_popcountdi2
4607 +#undef int
4608 +extern int __popcountDI2 (UDWtype x);
4609 +int
4610 +__popcountDI2 (UDWtype x)
4611 +{
4612 +  UWtype i, ret = 0;
4613 +
4614 +  for (i = 0; i < 2*W_TYPE_SIZE; i += 8)
4615 +    ret += __popcount_tab[(x >> i) & 0xff];
4616 +
4617 +  return ret;
4618 +}
4619 +#endif
4620 +\f
4621 +#ifdef L_paritysi2
4622 +#undef int
4623 +extern int __paritySI2 (UWtype x);
4624 +int
4625 +__paritySI2 (UWtype x)
4626 +{
4627 +#if W_TYPE_SIZE > 64
4628 +# error "fill out the table"
4629 +#endif
4630 +#if W_TYPE_SIZE > 32
4631 +  x ^= x >> 32;
4632 +#endif
4633 +#if W_TYPE_SIZE > 16
4634 +  x ^= x >> 16;
4635 +#endif
4636 +  x ^= x >> 8;
4637 +  x ^= x >> 4;
4638 +  x &= 0xf;
4639 +  return (0x6996 >> x) & 1;
4640 +}
4641 +#endif
4642 +\f
4643 +#ifdef L_paritydi2
4644 +#undef int
4645 +extern int __parityDI2 (UDWtype x);
4646 +int
4647 +__parityDI2 (UDWtype x)
4648 +{
4649 +  const DWunion uu = {.ll = x};
4650 +  UWtype nx = uu.s.low ^ uu.s.high;
4651 +
4652 +#if W_TYPE_SIZE > 64
4653 +# error "fill out the table"
4654 +#endif
4655 +#if W_TYPE_SIZE > 32
4656 +  nx ^= nx >> 32;
4657 +#endif
4658 +#if W_TYPE_SIZE > 16
4659 +  nx ^= nx >> 16;
4660 +#endif
4661 +  nx ^= nx >> 8;
4662 +  nx ^= nx >> 4;
4663 +  nx &= 0xf;
4664 +  return (0x6996 >> nx) & 1;
4665 +}
4666 +#endif
4667 +
4668 +#ifdef L_udivmoddi4
4669 +
4670 +#if (defined (L_udivdi3) || defined (L_divdi3) || \
4671 +     defined (L_umoddi3) || defined (L_moddi3))
4672 +static inline __attribute__ ((__always_inline__))
4673 +#endif
4674 +UDWtype
4675 +__udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
4676 +{
4677 +  const DWunion nn = {.ll = n};
4678 +  const DWunion dd = {.ll = d};
4679 +  DWunion rr;
4680 +  UWtype d0, d1, n0, n1, n2;
4681 +  UWtype q0, q1;
4682 +  UWtype b, bm;
4683 +
4684 +  d0 = dd.s.low;
4685 +  d1 = dd.s.high;
4686 +  n0 = nn.s.low;
4687 +  n1 = nn.s.high;
4688 +
4689 +#if !UDIV_NEEDS_NORMALIZATION
4690 +  if (d1 == 0)
4691 +    {
4692 +      if (d0 > n1)
4693 +       {
4694 +         /* 0q = nn / 0D */
4695 +
4696 +         udiv_qrnnd (q0, n0, n1, n0, d0);
4697 +         q1 = 0;
4698 +
4699 +         /* Remainder in n0.  */
4700 +       }
4701 +      else
4702 +       {
4703 +         /* qq = NN / 0d */
4704 +
4705 +         if (d0 == 0)
4706 +           d0 = 1 / d0;        /* Divide intentionally by zero.  */
4707 +
4708 +         udiv_qrnnd (q1, n1, 0, n1, d0);
4709 +         udiv_qrnnd (q0, n0, n1, n0, d0);
4710 +
4711 +         /* Remainder in n0.  */
4712 +       }
4713 +
4714 +      if (rp != 0)
4715 +       {
4716 +         rr.s.low = n0;
4717 +         rr.s.high = 0;
4718 +         *rp = rr.ll;
4719 +       }
4720 +    }
4721 +
4722 +#else /* UDIV_NEEDS_NORMALIZATION */
4723 +
4724 +  if (d1 == 0)
4725 +    {
4726 +      if (d0 > n1)
4727 +       {
4728 +         /* 0q = nn / 0D */
4729 +
4730 +         count_leading_zeros (bm, d0);
4731 +
4732 +         if (bm != 0)
4733 +           {
4734 +             /* Normalize, i.e. make the most significant bit of the
4735 +                denominator set.  */
4736 +
4737 +             d0 = d0 << bm;
4738 +             n1 = (n1 << bm) | (n0 >> (W_TYPE_SIZE - bm));
4739 +             n0 = n0 << bm;
4740 +           }
4741 +
4742 +         udiv_qrnnd (q0, n0, n1, n0, d0);
4743 +         q1 = 0;
4744 +
4745 +         /* Remainder in n0 >> bm.  */
4746 +       }
4747 +      else
4748 +       {
4749 +         /* qq = NN / 0d */
4750 +
4751 +         if (d0 == 0)
4752 +           d0 = 1 / d0;        /* Divide intentionally by zero.  */
4753 +
4754 +         count_leading_zeros (bm, d0);
4755 +
4756 +         if (bm == 0)
4757 +           {
4758 +             /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
4759 +                conclude (the most significant bit of n1 is set) /\ (the
4760 +                leading quotient digit q1 = 1).
4761 +
4762 +                This special case is necessary, not an optimization.
4763 +                (Shifts counts of W_TYPE_SIZE are undefined.)  */
4764 +
4765 +             n1 -= d0;
4766 +             q1 = 1;
4767 +           }
4768 +         else
4769 +           {
4770 +             /* Normalize.  */
4771 +
4772 +             b = W_TYPE_SIZE - bm;
4773 +
4774 +             d0 = d0 << bm;
4775 +             n2 = n1 >> b;
4776 +             n1 = (n1 << bm) | (n0 >> b);
4777 +             n0 = n0 << bm;
4778 +
4779 +             udiv_qrnnd (q1, n1, n2, n1, d0);
4780 +           }
4781 +
4782 +         /* n1 != d0...  */
4783 +
4784 +         udiv_qrnnd (q0, n0, n1, n0, d0);
4785 +
4786 +         /* Remainder in n0 >> bm.  */
4787 +       }
4788 +
4789 +      if (rp != 0)
4790 +       {
4791 +         rr.s.low = n0 >> bm;
4792 +         rr.s.high = 0;
4793 +         *rp = rr.ll;
4794 +       }
4795 +    }
4796 +#endif /* UDIV_NEEDS_NORMALIZATION */
4797 +
4798 +  else
4799 +    {
4800 +      if (d1 > n1)
4801 +       {
4802 +         /* 00 = nn / DD */
4803 +
4804 +         q0 = 0;
4805 +         q1 = 0;
4806 +
4807 +         /* Remainder in n1n0.  */
4808 +         if (rp != 0)
4809 +           {
4810 +             rr.s.low = n0;
4811 +             rr.s.high = n1;
4812 +             *rp = rr.ll;
4813 +           }
4814 +       }
4815 +      else
4816 +       {
4817 +         /* 0q = NN / dd */
4818 +
4819 +         count_leading_zeros (bm, d1);
4820 +         if (bm == 0)
4821 +           {
4822 +             /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
4823 +                conclude (the most significant bit of n1 is set) /\ (the
4824 +                quotient digit q0 = 0 or 1).
4825 +
4826 +                This special case is necessary, not an optimization.  */
4827 +
4828 +             /* The condition on the next line takes advantage of that
4829 +                n1 >= d1 (true due to program flow).  */
4830 +             if (n1 > d1 || n0 >= d0)
4831 +               {
4832 +                 q0 = 1;
4833 +                 sub_ddmmss (n1, n0, n1, n0, d1, d0);
4834 +               }
4835 +             else
4836 +               q0 = 0;
4837 +
4838 +             q1 = 0;
4839 +
4840 +             if (rp != 0)
4841 +               {
4842 +                 rr.s.low = n0;
4843 +                 rr.s.high = n1;
4844 +                 *rp = rr.ll;
4845 +               }
4846 +           }
4847 +         else
4848 +           {
4849 +             UWtype m1, m0;
4850 +             /* Normalize.  */
4851 +
4852 +             b = W_TYPE_SIZE - bm;
4853 +
4854 +             d1 = (d1 << bm) | (d0 >> b);
4855 +             d0 = d0 << bm;
4856 +             n2 = n1 >> b;
4857 +             n1 = (n1 << bm) | (n0 >> b);
4858 +             n0 = n0 << bm;
4859 +
4860 +             udiv_qrnnd (q0, n1, n2, n1, d1);
4861 +             umul_ppmm (m1, m0, q0, d0);
4862 +
4863 +             if (m1 > n1 || (m1 == n1 && m0 > n0))
4864 +               {
4865 +                 q0--;
4866 +                 sub_ddmmss (m1, m0, m1, m0, d1, d0);
4867 +               }
4868 +
4869 +             q1 = 0;
4870 +
4871 +             /* Remainder in (n1n0 - m1m0) >> bm.  */
4872 +             if (rp != 0)
4873 +               {
4874 +                 sub_ddmmss (n1, n0, n1, n0, m1, m0);
4875 +                 rr.s.low = (n1 << b) | (n0 >> bm);
4876 +                 rr.s.high = n1 >> bm;
4877 +                 *rp = rr.ll;
4878 +               }
4879 +           }
4880 +       }
4881 +    }
4882 +
4883 +  const DWunion ww = {{.low = q0, .high = q1}};
4884 +  return ww.ll;
4885 +}
4886 +#endif
4887 +
4888 +#ifdef L_divdi3
4889 +DWtype
4890 +__divdi3 (DWtype u, DWtype v)
4891 +{
4892 +  word_type c = 0;
4893 +  DWunion uu = {.ll = u};
4894 +  DWunion vv = {.ll = v};
4895 +  DWtype w;
4896 +
4897 +  if (uu.s.high < 0)
4898 +    c = ~c,
4899 +    uu.ll = -uu.ll;
4900 +  if (vv.s.high < 0)
4901 +    c = ~c,
4902 +    vv.ll = -vv.ll;
4903 +
4904 +  w = __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) 0);
4905 +  if (c)
4906 +    w = -w;
4907 +
4908 +  return w;
4909 +}
4910 +#endif
4911 +
4912 +#ifdef L_moddi3
4913 +DWtype
4914 +__moddi3 (DWtype u, DWtype v)
4915 +{
4916 +  word_type c = 0;
4917 +  DWunion uu = {.ll = u};
4918 +  DWunion vv = {.ll = v};
4919 +  DWtype w;
4920 +
4921 +  if (uu.s.high < 0)
4922 +    c = ~c,
4923 +    uu.ll = -uu.ll;
4924 +  if (vv.s.high < 0)
4925 +    vv.ll = -vv.ll;
4926 +
4927 +  (void) __udivmoddi4 (uu.ll, vv.ll, &w);
4928 +  if (c)
4929 +    w = -w;
4930 +
4931 +  return w;
4932 +}
4933 +#endif
4934 +
4935 +#ifdef L_umoddi3
4936 +UDWtype
4937 +__umoddi3 (UDWtype u, UDWtype v)
4938 +{
4939 +  UDWtype w;
4940 +
4941 +  (void) __udivmoddi4 (u, v, &w);
4942 +
4943 +  return w;
4944 +}
4945 +#endif
4946 +
4947 +#ifdef L_udivdi3
4948 +UDWtype
4949 +__udivdi3 (UDWtype n, UDWtype d)
4950 +{
4951 +  return __udivmoddi4 (n, d, (UDWtype *) 0);
4952 +}
4953 +#endif
4954 +\f
4955 +#ifdef L_cmpdi2
4956 +word_type
4957 +__cmpdi2 (DWtype a, DWtype b)
4958 +{
4959 +  const DWunion au = {.ll = a};
4960 +  const DWunion bu = {.ll = b};
4961 +
4962 +  if (au.s.high < bu.s.high)
4963 +    return 0;
4964 +  else if (au.s.high > bu.s.high)
4965 +    return 2;
4966 +  if ((UWtype) au.s.low < (UWtype) bu.s.low)
4967 +    return 0;
4968 +  else if ((UWtype) au.s.low > (UWtype) bu.s.low)
4969 +    return 2;
4970 +  return 1;
4971 +}
4972 +#endif
4973 +
4974 +#ifdef L_ucmpdi2
4975 +word_type
4976 +__ucmpdi2 (DWtype a, DWtype b)
4977 +{
4978 +  const DWunion au = {.ll = a};
4979 +  const DWunion bu = {.ll = b};
4980 +
4981 +  if ((UWtype) au.s.high < (UWtype) bu.s.high)
4982 +    return 0;
4983 +  else if ((UWtype) au.s.high > (UWtype) bu.s.high)
4984 +    return 2;
4985 +  if ((UWtype) au.s.low < (UWtype) bu.s.low)
4986 +    return 0;
4987 +  else if ((UWtype) au.s.low > (UWtype) bu.s.low)
4988 +    return 2;
4989 +  return 1;
4990 +}
4991 +#endif
4992 +\f
4993 +#if defined(L_fixunstfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
4994 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
4995 +#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
4996 +
4997 +DWtype
4998 +__fixunstfDI (TFtype a)
4999 +{
5000 +  if (a < 0)
5001 +    return 0;
5002 +
5003 +  /* Compute high word of result, as a flonum.  */
5004 +  const TFtype b = (a / HIGH_WORD_COEFF);
5005 +  /* Convert that to fixed (but not to DWtype!),
5006 +     and shift it into the high word.  */
5007 +  UDWtype v = (UWtype) b;
5008 +  v <<= WORD_SIZE;
5009 +  /* Remove high part from the TFtype, leaving the low part as flonum.  */
5010 +  a -= (TFtype)v;
5011 +  /* Convert that to fixed (but not to DWtype!) and add it in.
5012 +     Sometimes A comes out negative.  This is significant, since
5013 +     A has more bits than a long int does.  */
5014 +  if (a < 0)
5015 +    v -= (UWtype) (- a);
5016 +  else
5017 +    v += (UWtype) a;
5018 +  return v;
5019 +}
5020 +#endif
5021 +
5022 +#if defined(L_fixtfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
5023 +DWtype
5024 +__fixtfdi (TFtype a)
5025 +{
5026 +  if (a < 0)
5027 +    return - __fixunstfDI (-a);
5028 +  return __fixunstfDI (a);
5029 +}
5030 +#endif
5031 +
5032 +#if defined(L_fixunsxfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96)
5033 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
5034 +#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
5035 +
5036 +DWtype
5037 +__fixunsxfDI (XFtype a)
5038 +{
5039 +  if (a < 0)
5040 +    return 0;
5041 +
5042 +  /* Compute high word of result, as a flonum.  */
5043 +  const XFtype b = (a / HIGH_WORD_COEFF);
5044 +  /* Convert that to fixed (but not to DWtype!),
5045 +     and shift it into the high word.  */
5046 +  UDWtype v = (UWtype) b;
5047 +  v <<= WORD_SIZE;
5048 +  /* Remove high part from the XFtype, leaving the low part as flonum.  */
5049 +  a -= (XFtype)v;
5050 +  /* Convert that to fixed (but not to DWtype!) and add it in.
5051 +     Sometimes A comes out negative.  This is significant, since
5052 +     A has more bits than a long int does.  */
5053 +  if (a < 0)
5054 +    v -= (UWtype) (- a);
5055 +  else
5056 +    v += (UWtype) a;
5057 +  return v;
5058 +}
5059 +#endif
5060 +
5061 +#if defined(L_fixxfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96)
5062 +DWtype
5063 +__fixxfdi (XFtype a)
5064 +{
5065 +  if (a < 0)
5066 +    return - __fixunsxfDI (-a);
5067 +  return __fixunsxfDI (a);
5068 +}
5069 +#endif
5070 +
5071 +#ifdef L_fixunsdfdi
5072 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
5073 +#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
5074 +
5075 +DWtype
5076 +__fixunsdfDI (DFtype a)
5077 +{
5078 +  /* Get high part of result.  The division here will just moves the radix
5079 +     point and will not cause any rounding.  Then the conversion to integral
5080 +     type chops result as desired.  */
5081 +  const UWtype hi = a / HIGH_WORD_COEFF;
5082 +
5083 +  /* Get low part of result.  Convert `hi' to floating type and scale it back,
5084 +     then subtract this from the number being converted.  This leaves the low
5085 +     part.  Convert that to integral type.  */
5086 +  const UWtype lo = (a - ((DFtype) hi) * HIGH_WORD_COEFF);
5087 +
5088 +  /* Assemble result from the two parts.  */
5089 +  return ((UDWtype) hi << WORD_SIZE) | lo;
5090 +}
5091 +#endif
5092 +
5093 +#ifdef L_fixdfdi
5094 +DWtype
5095 +__fixdfdi (DFtype a)
5096 +{
5097 +  if (a < 0)
5098 +    return - __fixunsdfDI (-a);
5099 +  return __fixunsdfDI (a);
5100 +}
5101 +#endif
5102 +
5103 +#ifdef L_fixunssfdi
5104 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
5105 +#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
5106 +
5107 +DWtype
5108 +__fixunssfDI (SFtype original_a)
5109 +{
5110 +  /* Convert the SFtype to a DFtype, because that is surely not going
5111 +     to lose any bits.  Some day someone else can write a faster version
5112 +     that avoids converting to DFtype, and verify it really works right.  */
5113 +  const DFtype a = original_a;
5114 +
5115 +  /* Get high part of result.  The division here will just moves the radix
5116 +     point and will not cause any rounding.  Then the conversion to integral
5117 +     type chops result as desired.  */
5118 +  const UWtype hi = a / HIGH_WORD_COEFF;
5119 +
5120 +  /* Get low part of result.  Convert `hi' to floating type and scale it back,
5121 +     then subtract this from the number being converted.  This leaves the low
5122 +     part.  Convert that to integral type.  */
5123 +  const UWtype lo = (a - ((DFtype) hi) * HIGH_WORD_COEFF);
5124 +
5125 +  /* Assemble result from the two parts.  */
5126 +  return ((UDWtype) hi << WORD_SIZE) | lo;
5127 +}
5128 +#endif
5129 +
5130 +#ifdef L_fixsfdi
5131 +DWtype
5132 +__fixsfdi (SFtype a)
5133 +{
5134 +  if (a < 0)
5135 +    return - __fixunssfDI (-a);
5136 +  return __fixunssfDI (a);
5137 +}
5138 +#endif
5139 +
5140 +#if defined(L_floatdixf) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96)
5141 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
5142 +#define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
5143 +#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
5144 +
5145 +XFtype
5146 +__floatdixf (DWtype u)
5147 +{
5148 +  XFtype d = (Wtype) (u >> WORD_SIZE);
5149 +  d *= HIGH_HALFWORD_COEFF;
5150 +  d *= HIGH_HALFWORD_COEFF;
5151 +  d += (UWtype) (u & (HIGH_WORD_COEFF - 1));
5152 +
5153 +  return d;
5154 +}
5155 +#endif
5156 +
5157 +#if defined(L_floatditf) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
5158 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
5159 +#define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
5160 +#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
5161 +
5162 +TFtype
5163 +__floatditf (DWtype u)
5164 +{
5165 +  TFtype d = (Wtype) (u >> WORD_SIZE);
5166 +  d *= HIGH_HALFWORD_COEFF;
5167 +  d *= HIGH_HALFWORD_COEFF;
5168 +  d += (UWtype) (u & (HIGH_WORD_COEFF - 1));
5169 +
5170 +  return d;
5171 +}
5172 +#endif
5173 +
5174 +#ifdef L_floatdidf
5175 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
5176 +#define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
5177 +#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
5178 +
5179 +DFtype
5180 +__floatdidf (DWtype u)
5181 +{
5182 +  DFtype d = (Wtype) (u >> WORD_SIZE);
5183 +  d *= HIGH_HALFWORD_COEFF;
5184 +  d *= HIGH_HALFWORD_COEFF;
5185 +  d += (UWtype) (u & (HIGH_WORD_COEFF - 1));
5186 +
5187 +  return d;
5188 +}
5189 +#endif
5190 +
5191 +#ifdef L_floatdisf
5192 +#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
5193 +#define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
5194 +#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
5195 +
5196 +#define DI_SIZE (sizeof (DWtype) * BITS_PER_UNIT)
5197 +#define DF_SIZE DBL_MANT_DIG
5198 +#define SF_SIZE FLT_MANT_DIG
5199 +
5200 +SFtype
5201 +__floatdisf (DWtype u)
5202 +{
5203 +  /* Protect against double-rounding error.
5204 +     Represent any low-order bits, that might be truncated in DFmode,
5205 +     by a bit that won't be lost.  The bit can go in anywhere below the
5206 +     rounding position of the SFmode.  A fixed mask and bit position
5207 +     handles all usual configurations.  It doesn't handle the case
5208 +     of 128-bit DImode, however.  */
5209 +  if (DF_SIZE < DI_SIZE
5210 +      && DF_SIZE > (DI_SIZE - DF_SIZE + SF_SIZE))
5211 +    {
5212 +#define REP_BIT ((UDWtype) 1 << (DI_SIZE - DF_SIZE))
5213 +      if (! (- ((DWtype) 1 << DF_SIZE) < u
5214 +            && u < ((DWtype) 1 << DF_SIZE)))
5215 +       {
5216 +         if ((UDWtype) u & (REP_BIT - 1))
5217 +           {
5218 +             u &= ~ (REP_BIT - 1);
5219 +             u |= REP_BIT;
5220 +           }
5221 +       }
5222 +    }
5223 +  /* Do the calculation in DFmode
5224 +     so that we don't lose any of the precision of the high word
5225 +     while multiplying it.  */
5226 +  DFtype f = (Wtype) (u >> WORD_SIZE);
5227 +  f *= HIGH_HALFWORD_COEFF;
5228 +  f *= HIGH_HALFWORD_COEFF;
5229 +  f += (UWtype) (u & (HIGH_WORD_COEFF - 1));
5230 +
5231 +  return (SFtype) f;
5232 +}
5233 +#endif
5234 +
5235 +#if defined(L_fixunsxfsi) && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
5236 +/* Reenable the normal types, in case limits.h needs them.  */
5237 +#undef char
5238 +#undef short
5239 +#undef int
5240 +#undef long
5241 +#undef unsigned
5242 +#undef float
5243 +#undef double
5244 +#undef MIN
5245 +#undef MAX
5246 +#include <limits.h>
5247 +
5248 +UWtype
5249 +__fixunsxfSI (XFtype a)
5250 +{
5251 +  if (a >= - (DFtype) Wtype_MIN)
5252 +    return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
5253 +  return (Wtype) a;
5254 +}
5255 +#endif
5256 +
5257 +#ifdef L_fixunsdfsi
5258 +/* Reenable the normal types, in case limits.h needs them.  */
5259 +#undef char
5260 +#undef short
5261 +#undef int
5262 +#undef long
5263 +#undef unsigned
5264 +#undef float
5265 +#undef double
5266 +#undef MIN
5267 +#undef MAX
5268 +#include <limits.h>
5269 +
5270 +UWtype
5271 +__fixunsdfSI (DFtype a)
5272 +{
5273 +  if (a >= - (DFtype) Wtype_MIN)
5274 +    return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
5275 +  return (Wtype) a;
5276 +}
5277 +#endif
5278 +
5279 +#ifdef L_fixunssfsi
5280 +/* Reenable the normal types, in case limits.h needs them.  */
5281 +#undef char
5282 +#undef short
5283 +#undef int
5284 +#undef long
5285 +#undef unsigned
5286 +#undef float
5287 +#undef double
5288 +#undef MIN
5289 +#undef MAX
5290 +#include <limits.h>
5291 +
5292 +UWtype
5293 +__fixunssfSI (SFtype a)
5294 +{
5295 +  if (a >= - (SFtype) Wtype_MIN)
5296 +    return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
5297 +  return (Wtype) a;
5298 +}
5299 +#endif
5300 +\f
5301 +/* From here on down, the routines use normal data types.  */
5302 +
5303 +#define SItype bogus_type
5304 +#define USItype bogus_type
5305 +#define DItype bogus_type
5306 +#define UDItype bogus_type
5307 +#define SFtype bogus_type
5308 +#define DFtype bogus_type
5309 +#undef Wtype
5310 +#undef UWtype
5311 +#undef HWtype
5312 +#undef UHWtype
5313 +#undef DWtype
5314 +#undef UDWtype
5315 +
5316 +#undef char
5317 +#undef short
5318 +#undef int
5319 +#undef long
5320 +#undef unsigned
5321 +#undef float
5322 +#undef double
5323 +\f
5324 +#ifdef L__gcc_bcmp
5325 +
5326 +/* Like bcmp except the sign is meaningful.
5327 +   Result is negative if S1 is less than S2,
5328 +   positive if S1 is greater, 0 if S1 and S2 are equal.  */
5329 +
5330 +int
5331 +__gcc_bcmp (const unsigned char *s1, const unsigned char *s2, size_t size)
5332 +{
5333 +  while (size > 0)
5334 +    {
5335 +      const unsigned char c1 = *s1++, c2 = *s2++;
5336 +      if (c1 != c2)
5337 +       return c1 - c2;
5338 +      size--;
5339 +    }
5340 +  return 0;
5341 +}
5342 +
5343 +#endif
5344 +\f
5345 +/* __eprintf used to be used by GCC's private version of <assert.h>.
5346 +   We no longer provide that header, but this routine remains in libgcc.a
5347 +   for binary backward compatibility.  Note that it is not included in
5348 +   the shared version of libgcc.  */
5349 +#ifdef L_eprintf
5350 +#ifndef inhibit_libc
5351 +
5352 +#undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch.  */
5353 +#include <stdio.h>
5354 +
5355 +void
5356 +__eprintf (const char *string, const char *expression,
5357 +          unsigned int line, const char *filename)
5358 +{
5359 +  fprintf (stderr, string, expression, line, filename);
5360 +  fflush (stderr);
5361 +  abort ();
5362 +}
5363 +
5364 +#endif
5365 +#endif
5366 +
5367 +\f
5368 +#ifdef L_clear_cache
5369 +/* Clear part of an instruction cache.  */
5370 +
5371 +void
5372 +__clear_cache (char *beg __attribute__((__unused__)),
5373 +              char *end __attribute__((__unused__)))
5374 +{
5375 +#ifdef CLEAR_INSN_CACHE
5376 +  CLEAR_INSN_CACHE (beg, end);
5377 +#endif /* CLEAR_INSN_CACHE */
5378 +}
5379 +
5380 +#endif /* L_clear_cache */
5381 +\f
5382 +#ifdef L_trampoline
5383 +
5384 +/* Jump to a trampoline, loading the static chain address.  */
5385 +
5386 +#if defined(WINNT) && ! defined(__CYGWIN__) && ! defined (_UWIN)
5387 +
5388 +long
5389 +getpagesize (void)
5390 +{
5391 +#ifdef _ALPHA_
5392 +  return 8192;
5393 +#else
5394 +  return 4096;
5395 +#endif
5396 +}
5397 +
5398 +#ifdef __i386__
5399 +extern int VirtualProtect (char *, int, int, int *) __attribute__((stdcall));
5400 +#endif
5401 +
5402 +int
5403 +mprotect (char *addr, int len, int prot)
5404 +{
5405 +  int np, op;
5406 +
5407 +  if (prot == 7)
5408 +    np = 0x40;
5409 +  else if (prot == 5)
5410 +    np = 0x20;
5411 +  else if (prot == 4)
5412 +    np = 0x10;
5413 +  else if (prot == 3)
5414 +    np = 0x04;
5415 +  else if (prot == 1)
5416 +    np = 0x02;
5417 +  else if (prot == 0)
5418 +    np = 0x01;
5419 +
5420 +  if (VirtualProtect (addr, len, np, &op))
5421 +    return 0;
5422 +  else
5423 +    return -1;
5424 +}
5425 +
5426 +#endif /* WINNT && ! __CYGWIN__ && ! _UWIN */
5427 +
5428 +#ifdef TRANSFER_FROM_TRAMPOLINE
5429 +TRANSFER_FROM_TRAMPOLINE
5430 +#endif
5431 +#endif /* L_trampoline */
5432 +\f
5433 +#ifndef __CYGWIN__
5434 +#ifdef L__main
5435 +
5436 +#include "gbl-ctors.h"
5437 +/* Some systems use __main in a way incompatible with its use in gcc, in these
5438 +   cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
5439 +   give the same symbol without quotes for an alternative entry point.  You
5440 +   must define both, or neither.  */
5441 +#ifndef NAME__MAIN
5442 +#define NAME__MAIN "__main"
5443 +#define SYMBOL__MAIN __main
5444 +#endif
5445 +
5446 +#ifdef INIT_SECTION_ASM_OP
5447 +#undef HAS_INIT_SECTION
5448 +#define HAS_INIT_SECTION
5449 +#endif
5450 +
5451 +#if !defined (HAS_INIT_SECTION) || !defined (OBJECT_FORMAT_ELF)
5452 +
5453 +/* Some ELF crosses use crtstuff.c to provide __CTOR_LIST__, but use this
5454 +   code to run constructors.  In that case, we need to handle EH here, too.  */
5455 +
5456 +#ifdef EH_FRAME_SECTION_NAME
5457 +#include "unwind-dw2-fde.h"
5458 +extern unsigned char __EH_FRAME_BEGIN__[];
5459 +#endif
5460 +
5461 +/* Run all the global destructors on exit from the program.  */
5462 +
5463 +void
5464 +__do_global_dtors (void)
5465 +{
5466 +#ifdef DO_GLOBAL_DTORS_BODY
5467 +  DO_GLOBAL_DTORS_BODY;
5468 +#else
5469 +  static func_ptr *p = __DTOR_LIST__ + 1;
5470 +  while (*p)
5471 +    {
5472 +      p++;
5473 +      (*(p-1)) ();
5474 +    }
5475 +#endif
5476 +#if defined (EH_FRAME_SECTION_NAME) && !defined (HAS_INIT_SECTION)
5477 +  {
5478 +    static int completed = 0;
5479 +    if (! completed)
5480 +      {
5481 +       completed = 1;
5482 +       __deregister_frame_info (__EH_FRAME_BEGIN__);
5483 +      }
5484 +  }
5485 +#endif
5486 +}
5487 +#endif
5488 +
5489 +#ifndef HAS_INIT_SECTION
5490 +/* Run all the global constructors on entry to the program.  */
5491 +
5492 +void
5493 +__do_global_ctors (void)
5494 +{
5495 +#ifdef EH_FRAME_SECTION_NAME
5496 +  {
5497 +    static struct object object;
5498 +    __register_frame_info (__EH_FRAME_BEGIN__, &object);
5499 +  }
5500 +#endif
5501 +  DO_GLOBAL_CTORS_BODY;
5502 +  atexit (__do_global_dtors);
5503 +}
5504 +#endif /* no HAS_INIT_SECTION */
5505 +
5506 +#if !defined (HAS_INIT_SECTION) || defined (INVOKE__main)
5507 +/* Subroutine called automatically by `main'.
5508 +   Compiling a global function named `main'
5509 +   produces an automatic call to this function at the beginning.
5510 +
5511 +   For many systems, this routine calls __do_global_ctors.
5512 +   For systems which support a .init section we use the .init section
5513 +   to run __do_global_ctors, so we need not do anything here.  */
5514 +
5515 +extern void SYMBOL__MAIN (void);
5516 +void
5517 +SYMBOL__MAIN (void)
5518 +{
5519 +  /* Support recursive calls to `main': run initializers just once.  */
5520 +  static int initialized;
5521 +  if (! initialized)
5522 +    {
5523 +      initialized = 1;
5524 +      __do_global_ctors ();
5525 +    }
5526 +}
5527 +#endif /* no HAS_INIT_SECTION or INVOKE__main */
5528 +
5529 +#endif /* L__main */
5530 +#endif /* __CYGWIN__ */
5531 +\f
5532 +#ifdef L_ctors
5533 +
5534 +#include "gbl-ctors.h"
5535 +
5536 +/* Provide default definitions for the lists of constructors and
5537 +   destructors, so that we don't get linker errors.  These symbols are
5538 +   intentionally bss symbols, so that gld and/or collect will provide
5539 +   the right values.  */
5540 +
5541 +/* We declare the lists here with two elements each,
5542 +   so that they are valid empty lists if no other definition is loaded.
5543 +
5544 +   If we are using the old "set" extensions to have the gnu linker
5545 +   collect ctors and dtors, then we __CTOR_LIST__ and __DTOR_LIST__
5546 +   must be in the bss/common section.
5547 +
5548 +   Long term no port should use those extensions.  But many still do.  */
5549 +#if !defined(INIT_SECTION_ASM_OP) && !defined(CTOR_LISTS_DEFINED_EXTERNALLY)
5550 +#if defined (TARGET_ASM_CONSTRUCTOR) || defined (USE_COLLECT2)
5551 +func_ptr __CTOR_LIST__[2] = {0, 0};
5552 +func_ptr __DTOR_LIST__[2] = {0, 0};
5553 +#else
5554 +func_ptr __CTOR_LIST__[2];
5555 +func_ptr __DTOR_LIST__[2];
5556 +#endif
5557 +#endif /* no INIT_SECTION_ASM_OP and not CTOR_LISTS_DEFINED_EXTERNALLY */
5558 +#endif /* L_ctors */
5559 +
5560 --- ./gcc/gcc/libgcc2.h
5561 +++ ./gcc/gcc/libgcc2.h
5562 @@ -0,0 +1,310 @@
5563 +/* Header file for libgcc2.c.  */
5564 +/* Copyright (C) 2000, 2001
5565 +   Free Software Foundation, Inc.
5566 +
5567 +This file is part of GCC.
5568 +
5569 +GCC is free software; you can redistribute it and/or modify it under
5570 +the terms of the GNU General Public License as published by the Free
5571 +Software Foundation; either version 2, or (at your option) any later
5572 +version.
5573 +
5574 +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
5575 +WARRANTY; without even the implied warranty of MERCHANTABILITY or
5576 +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5577 +for more details.
5578 +
5579 +You should have received a copy of the GNU General Public License
5580 +along with GCC; see the file COPYING.  If not, write to the Free
5581 +Software Foundation, 59 Temple Place - Suite 330, Boston, MA
5582 +02111-1307, USA.  */
5583 +
5584 +/* As a special exception, if you link this library with other files,
5585 +   some of which are compiled with GCC, to produce an executable,
5586 +   this library does not by itself cause the resulting executable
5587 +   to be covered by the GNU General Public License.
5588 +   This exception does not however invalidate any other reasons why
5589 +   the executable file might be covered by the GNU General Public License.  */
5590 +
5591 +
5592 +#ifndef GCC_LIBGCC2_H
5593 +#define GCC_LIBGCC2_H
5594 +
5595 +extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t);
5596 +extern void __clear_cache (char *, char *);
5597 +extern void __eprintf (const char *, const char *, unsigned int, const char *)
5598 +  __attribute__ ((__noreturn__));
5599 +
5600 +struct exception_descriptor;
5601 +extern short int __get_eh_table_language (struct exception_descriptor *);
5602 +extern short int __get_eh_table_version (struct exception_descriptor *);
5603 +
5604 +/* Permit the tm.h file to select the endianness to use just for this
5605 +   file.  This is used when the endianness is determined when the
5606 +   compiler is run.  */
5607 +
5608 +#ifndef LIBGCC2_WORDS_BIG_ENDIAN
5609 +#define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
5610 +#endif
5611 +
5612 +#ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
5613 +#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
5614 +#endif
5615 +
5616 +#ifndef MIN_UNITS_PER_WORD
5617 +#define MIN_UNITS_PER_WORD UNITS_PER_WORD
5618 +#endif
5619 +
5620 +/* In the first part of this file, we are interfacing to calls generated
5621 +   by the compiler itself.  These calls pass values into these routines
5622 +   which have very specific modes (rather than very specific types), and
5623 +   these compiler-generated calls also expect any return values to have
5624 +   very specific modes (rather than very specific types).  Thus, we need
5625 +   to avoid using regular C language type names in this part of the file
5626 +   because the sizes for those types can be configured to be anything.
5627 +   Instead we use the following special type names.  */
5628 +
5629 +typedef                 int QItype     __attribute__ ((mode (QI)));
5630 +typedef unsigned int UQItype   __attribute__ ((mode (QI)));
5631 +typedef                 int HItype     __attribute__ ((mode (HI)));
5632 +typedef unsigned int UHItype   __attribute__ ((mode (HI)));
5633 +#if MIN_UNITS_PER_WORD > 1
5634 +/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1.  */
5635 +typedef         int SItype     __attribute__ ((mode (SI)));
5636 +typedef unsigned int USItype   __attribute__ ((mode (SI)));
5637 +#if LONG_LONG_TYPE_SIZE > 32
5638 +/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2.  */
5639 +typedef                 int DItype     __attribute__ ((mode (DI)));
5640 +typedef unsigned int UDItype   __attribute__ ((mode (DI)));
5641 +#if MIN_UNITS_PER_WORD > 4
5642 +/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4.  */
5643 +typedef                 int TItype     __attribute__ ((mode (TI)));
5644 +typedef unsigned int UTItype   __attribute__ ((mode (TI)));
5645 +#endif
5646 +#endif
5647 +#endif
5648 +
5649 +#if BITS_PER_UNIT == 8
5650 +
5651 +typedef        float SFtype    __attribute__ ((mode (SF)));
5652 +typedef                float DFtype    __attribute__ ((mode (DF)));
5653 +
5654 +#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
5655 +typedef                float XFtype    __attribute__ ((mode (XF)));
5656 +#endif
5657 +#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
5658 +typedef                float TFtype    __attribute__ ((mode (TF)));
5659 +#endif
5660 +
5661 +#else /* BITS_PER_UNIT != 8 */
5662 +
5663 +/* On dsp's there are usually qf/hf/tqf modes used instead of the above.
5664 +   For now we don't support them in libgcc2.c.  */
5665 +
5666 +#undef L_fixdfdi
5667 +#undef L_fixsfdi
5668 +#undef L_fixtfdi
5669 +#undef L_fixunsdfdi
5670 +#undef L_fixunsdfsi
5671 +#undef L_fixunssfdi
5672 +#undef L_fixunssfsi
5673 +#undef L_fixunstfdi
5674 +#undef L_fixunsxfdi
5675 +#undef L_fixunsxfsi
5676 +#undef L_fixxfdi
5677 +#undef L_floatdidf
5678 +#undef L_floatdisf
5679 +#undef L_floatditf
5680 +#undef L_floatdixf
5681 +
5682 +#endif /* BITS_PER_UNIT != 8 */
5683 +
5684 +typedef int word_type __attribute__ ((mode (__word__)));
5685 +
5686 +/* Make sure that we don't accidentally use any normal C language built-in
5687 +   type names in the first part of this file.  Instead we want to use *only*
5688 +   the type names defined above.  The following macro definitions insure
5689 +   that if we *do* accidentally use some normal C language built-in type name,
5690 +   we will get a syntax error.  */
5691 +
5692 +#define char bogus_type
5693 +#define short bogus_type
5694 +#define int bogus_type
5695 +#define long bogus_type
5696 +#define unsigned bogus_type
5697 +#define float bogus_type
5698 +#define double bogus_type
5699 +
5700 +#if MIN_UNITS_PER_WORD > 4
5701 +#define W_TYPE_SIZE (8 * BITS_PER_UNIT)
5702 +#define Wtype  DItype
5703 +#define UWtype UDItype
5704 +#define HWtype DItype
5705 +#define UHWtype        UDItype
5706 +#define DWtype TItype
5707 +#define UDWtype        UTItype
5708 +#define __NW(a,b)      __ ## a ## di ## b
5709 +#define __NDW(a,b)     __ ## a ## ti ## b
5710 +#elif MIN_UNITS_PER_WORD > 2 \
5711 +      || (MIN_UNITS_PER_WORD > 1 && LONG_LONG_TYPE_SIZE > 32)
5712 +#define W_TYPE_SIZE (4 * BITS_PER_UNIT)
5713 +#define Wtype  SItype
5714 +#define UWtype USItype
5715 +#define HWtype SItype
5716 +#define UHWtype        USItype
5717 +#define DWtype DItype
5718 +#define UDWtype        UDItype
5719 +#define __NW(a,b)      __ ## a ## si ## b
5720 +#define __NDW(a,b)     __ ## a ## di ## b
5721 +#elif MIN_UNITS_PER_WORD > 1
5722 +#define W_TYPE_SIZE (2 * BITS_PER_UNIT)
5723 +#define Wtype  HItype
5724 +#define UWtype UHItype
5725 +#define HWtype HItype
5726 +#define UHWtype        UHItype
5727 +#define DWtype SItype
5728 +#define UDWtype        USItype
5729 +#define __NW(a,b)      __ ## a ## hi ## b
5730 +#define __NDW(a,b)     __ ## a ## si ## b
5731 +#else
5732 +#define W_TYPE_SIZE BITS_PER_UNIT
5733 +#define Wtype  QItype
5734 +#define UWtype  UQItype
5735 +#define HWtype QItype
5736 +#define UHWtype        UQItype
5737 +#define DWtype HItype
5738 +#define UDWtype        UHItype
5739 +#define __NW(a,b)      __ ## a ## qi ## b
5740 +#define __NDW(a,b)     __ ## a ## hi ## b
5741 +#endif
5742 +
5743 +#define Wtype_MAX ((Wtype)(((UWtype)1 << (W_TYPE_SIZE - 1)) - 1))
5744 +#define Wtype_MIN (- Wtype_MAX - 1)
5745 +
5746 +#define __muldi3       __NDW(mul,3)
5747 +#define __divdi3       __NDW(div,3)
5748 +#define __udivdi3      __NDW(udiv,3)
5749 +#define __moddi3       __NDW(mod,3)
5750 +#define __umoddi3      __NDW(umod,3)
5751 +#define __negdi2       __NDW(neg,2)
5752 +#define __lshrdi3      __NDW(lshr,3)
5753 +#define __ashldi3      __NDW(ashl,3)
5754 +#define __ashrdi3      __NDW(ashr,3)
5755 +#define __cmpdi2       __NDW(cmp,2)
5756 +#define __ucmpdi2      __NDW(ucmp,2)
5757 +#define __udivmoddi4   __NDW(udivmod,4)
5758 +#define __fixunstfDI   __NDW(fixunstf,)
5759 +#define __fixtfdi      __NDW(fixtf,)
5760 +#define __fixunsxfDI   __NDW(fixunsxf,)
5761 +#define __fixxfdi      __NDW(fixxf,)
5762 +#define __fixunsdfDI   __NDW(fixunsdf,)
5763 +#define __fixdfdi      __NDW(fixdf,)
5764 +#define __fixunssfDI   __NDW(fixunssf,)
5765 +#define __fixsfdi      __NDW(fixsf,)
5766 +#define __floatdixf    __NDW(float,xf)
5767 +#define __floatditf    __NDW(float,tf)
5768 +#define __floatdidf    __NDW(float,df)
5769 +#define __floatdisf    __NDW(float,sf)
5770 +#define __fixunsxfSI   __NW(fixunsxf,)
5771 +#define __fixunstfSI   __NW(fixunstf,)
5772 +#define __fixunsdfSI   __NW(fixunsdf,)
5773 +#define __fixunssfSI   __NW(fixunssf,)
5774 +
5775 +#define __ffsSI2       __NW(ffs,2)
5776 +#define __clzSI2       __NW(clz,2)
5777 +#define __ctzSI2       __NW(ctz,2)
5778 +#define __popcountSI2  __NW(popcount,2)
5779 +#define __paritySI2    __NW(parity,2)
5780 +#define __ffsDI2       __NDW(ffs,2)
5781 +#define __clzDI2       __NDW(clz,2)
5782 +#define __ctzDI2       __NDW(ctz,2)
5783 +#define __popcountDI2  __NDW(popcount,2)
5784 +#define __parityDI2    __NDW(parity,2)
5785 +
5786 +extern DWtype __muldi3 (DWtype, DWtype);
5787 +extern DWtype __divdi3 (DWtype, DWtype);
5788 +extern UDWtype __udivdi3 (UDWtype, UDWtype);
5789 +extern UDWtype __umoddi3 (UDWtype, UDWtype);
5790 +extern DWtype __moddi3 (DWtype, DWtype);
5791 +
5792 +/* __udivmoddi4 is static inline when building other libgcc2 portions.  */
5793 +#if (!defined (L_udivdi3) && !defined (L_divdi3) && \
5794 +     !defined (L_umoddi3) && !defined (L_moddi3))
5795 +extern UDWtype __udivmoddi4 (UDWtype, UDWtype, UDWtype *);
5796 +#endif
5797 +
5798 +/* __negdi2 is static inline when building other libgcc2 portions.  */
5799 +#if !defined(L_divdi3) && !defined(L_moddi3)
5800 +extern DWtype __negdi2 (DWtype);
5801 +#endif
5802 +
5803 +extern DWtype __lshrdi3 (DWtype, word_type);
5804 +extern DWtype __ashldi3 (DWtype, word_type);
5805 +extern DWtype __ashrdi3 (DWtype, word_type);
5806 +
5807 +/* __udiv_w_sdiv is static inline when building other libgcc2 portions.  */
5808 +#if (!defined(L_udivdi3) && !defined(L_divdi3) && \
5809 +     !defined(L_umoddi3) && !defined(L_moddi3))
5810 +extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);
5811 +#endif
5812 +
5813 +extern word_type __cmpdi2 (DWtype, DWtype);
5814 +extern word_type __ucmpdi2 (DWtype, DWtype);
5815 +
5816 +extern Wtype __absvsi2 (Wtype);
5817 +extern DWtype __absvdi2 (DWtype);
5818 +extern Wtype __addvsi3 (Wtype, Wtype);
5819 +extern DWtype __addvdi3 (DWtype, DWtype);
5820 +extern Wtype __subvsi3 (Wtype, Wtype);
5821 +extern DWtype __subvdi3 (DWtype, DWtype);
5822 +extern Wtype __mulvsi3 (Wtype, Wtype);
5823 +extern DWtype __mulvdi3 (DWtype, DWtype);
5824 +extern Wtype __negvsi2 (Wtype);
5825 +extern DWtype __negvdi2 (DWtype);
5826 +
5827 +#if BITS_PER_UNIT == 8
5828 +extern DWtype __fixdfdi (DFtype);
5829 +extern DWtype __fixsfdi (SFtype);
5830 +extern DFtype __floatdidf (DWtype);
5831 +extern SFtype __floatdisf (DWtype);
5832 +extern UWtype __fixunsdfSI (DFtype);
5833 +extern UWtype __fixunssfSI (SFtype);
5834 +extern DWtype __fixunsdfDI (DFtype);
5835 +extern DWtype __fixunssfDI (SFtype);
5836 +
5837 +#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 96
5838 +extern DWtype __fixxfdi (XFtype);
5839 +extern DWtype __fixunsxfDI (XFtype);
5840 +extern XFtype __floatdixf (DWtype);
5841 +extern UWtype __fixunsxfSI (XFtype);
5842 +#endif
5843 +
5844 +#if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
5845 +extern DWtype __fixunstfDI (TFtype);
5846 +extern DWtype __fixtfdi (TFtype);
5847 +extern TFtype __floatditf (DWtype);
5848 +#endif
5849 +#endif /* BITS_PER_UNIT == 8 */
5850 +
5851 +/* DWstructs are pairs of Wtype values in the order determined by
5852 +   LIBGCC2_WORDS_BIG_ENDIAN.  */
5853 +
5854 +#if LIBGCC2_WORDS_BIG_ENDIAN
5855 +  struct DWstruct {Wtype high, low;};
5856 +#else
5857 +  struct DWstruct {Wtype low, high;};
5858 +#endif
5859 +
5860 +/* We need this union to unpack/pack DImode values, since we don't have
5861 +   any arithmetic yet.  Incoming DImode parameters are stored into the
5862 +   `ll' field, and the unpacked result is read from the struct `s'.  */
5863 +
5864 +typedef union
5865 +{
5866 +  struct DWstruct s;
5867 +  DWtype ll;
5868 +} DWunion;
5869 +
5870 +#include "longlong.h"
5871 +
5872 +#endif /* ! GCC_LIBGCC2_H */
5873 --- ./gcc/gcc/longlong.h
5874 +++ ./gcc/gcc/longlong.h
5875 @@ -0,0 +1,1360 @@
5876 +/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
5877 +   Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000
5878 +   Free Software Foundation, Inc.
5879 +
5880 +   This definition file is free software; you can redistribute it
5881 +   and/or modify it under the terms of the GNU General Public
5882 +   License as published by the Free Software Foundation; either
5883 +   version 2, or (at your option) any later version.
5884 +
5885 +   This definition file is distributed in the hope that it will be
5886 +   useful, but WITHOUT ANY WARRANTY; without even the implied
5887 +   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5888 +   See the GNU General Public License for more details.
5889 +
5890 +   You should have received a copy of the GNU General Public License
5891 +   along with this program; if not, write to the Free Software
5892 +   Foundation, Inc., 59 Temple Place - Suite 330,
5893 +   Boston, MA 02111-1307, USA.  */
5894 +
5895 +/* You have to define the following before including this file:
5896 +
5897 +   UWtype -- An unsigned type, default type for operations (typically a "word")
5898 +   UHWtype -- An unsigned type, at least half the size of UWtype.
5899 +   UDWtype -- An unsigned type, at least twice as large a UWtype
5900 +   W_TYPE_SIZE -- size in bits of UWtype
5901 +
5902 +   UQItype -- Unsigned 8 bit type.
5903 +   SItype, USItype -- Signed and unsigned 32 bit types.
5904 +   DItype, UDItype -- Signed and unsigned 64 bit types.
5905 +
5906 +   On a 32 bit machine UWtype should typically be USItype;
5907 +   on a 64 bit machine, UWtype should typically be UDItype.
5908 +*/
5909 +
5910 +#define __BITS4 (W_TYPE_SIZE / 4)
5911 +#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
5912 +#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
5913 +#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
5914 +
5915 +#ifndef W_TYPE_SIZE
5916 +#define W_TYPE_SIZE    32
5917 +#define UWtype         USItype
5918 +#define UHWtype                USItype
5919 +#define UDWtype                UDItype
5920 +#endif
5921 +
5922 +/* Define auxiliary asm macros.
5923 +
5924 +   1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) multiplies two
5925 +   UWtype integers MULTIPLER and MULTIPLICAND, and generates a two UWtype
5926 +   word product in HIGH_PROD and LOW_PROD.
5927 +
5928 +   2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
5929 +   UDWtype product.  This is just a variant of umul_ppmm.
5930 +
5931 +   3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
5932 +   denominator) divides a UDWtype, composed by the UWtype integers
5933 +   HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
5934 +   in QUOTIENT and the remainder in REMAINDER.  HIGH_NUMERATOR must be less
5935 +   than DENOMINATOR for correct operation.  If, in addition, the most
5936 +   significant bit of DENOMINATOR must be 1, then the pre-processor symbol
5937 +   UDIV_NEEDS_NORMALIZATION is defined to 1.
5938 +
5939 +   4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
5940 +   denominator).  Like udiv_qrnnd but the numbers are signed.  The quotient
5941 +   is rounded towards 0.
5942 +
5943 +   5) count_leading_zeros(count, x) counts the number of zero-bits from the
5944 +   msb to the first nonzero bit in the UWtype X.  This is the number of
5945 +   steps X needs to be shifted left to set the msb.  Undefined for X == 0,
5946 +   unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
5947 +
5948 +   6) count_trailing_zeros(count, x) like count_leading_zeros, but counts
5949 +   from the least significant end.
5950 +
5951 +   7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
5952 +   high_addend_2, low_addend_2) adds two UWtype integers, composed by
5953 +   HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
5954 +   respectively.  The result is placed in HIGH_SUM and LOW_SUM.  Overflow
5955 +   (i.e. carry out) is not stored anywhere, and is lost.
5956 +
5957 +   8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
5958 +   high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
5959 +   composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
5960 +   LOW_SUBTRAHEND_2 respectively.  The result is placed in HIGH_DIFFERENCE
5961 +   and LOW_DIFFERENCE.  Overflow (i.e. carry out) is not stored anywhere,
5962 +   and is lost.
5963 +
5964 +   If any of these macros are left undefined for a particular CPU,
5965 +   C macros are used.  */
5966 +
5967 +/* The CPUs come in alphabetical order below.
5968 +
5969 +   Please add support for more CPUs here, or improve the current support
5970 +   for the CPUs below!
5971 +   (E.g. WE32100, IBM360.)  */
5972 +
5973 +#if defined (__GNUC__) && !defined (NO_ASM)
5974 +
5975 +/* We sometimes need to clobber "cc" with gcc2, but that would not be
5976 +   understood by gcc1.  Use cpp to avoid major code duplication.  */
5977 +#if __GNUC__ < 2
5978 +#define __CLOBBER_CC
5979 +#define __AND_CLOBBER_CC
5980 +#else /* __GNUC__ >= 2 */
5981 +#define __CLOBBER_CC : "cc"
5982 +#define __AND_CLOBBER_CC , "cc"
5983 +#endif /* __GNUC__ < 2 */
5984 +
5985 +#if defined (__alpha) && W_TYPE_SIZE == 64
5986 +#define umul_ppmm(ph, pl, m0, m1) \
5987 +  do {                                                                 \
5988 +    UDItype __m0 = (m0), __m1 = (m1);                                  \
5989 +    (ph) = __builtin_alpha_umulh (__m0, __m1);                         \
5990 +    (pl) = __m0 * __m1;                                                        \
5991 +  } while (0)
5992 +#define UMUL_TIME 46
5993 +#ifndef LONGLONG_STANDALONE
5994 +#define udiv_qrnnd(q, r, n1, n0, d) \
5995 +  do { UDItype __r;                                                    \
5996 +    (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                                \
5997 +    (r) = __r;                                                         \
5998 +  } while (0)
5999 +extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
6000 +#define UDIV_TIME 220
6001 +#endif /* LONGLONG_STANDALONE */
6002 +#ifdef __alpha_cix__
6003 +#define count_leading_zeros(COUNT,X)   ((COUNT) = __builtin_clzl (X))
6004 +#define count_trailing_zeros(COUNT,X)  ((COUNT) = __builtin_ctzl (X))
6005 +#define COUNT_LEADING_ZEROS_0 64
6006 +#else
6007 +extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN;
6008 +#define count_leading_zeros(COUNT,X) \
6009 +  do {                                                                 \
6010 +    UDItype __xr = (X), __t, __a;                                      \
6011 +    __t = __builtin_alpha_cmpbge (0, __xr);                            \
6012 +    __a = __clz_tab[__t ^ 0xff] - 1;                                   \
6013 +    __t = __builtin_alpha_extbl (__xr, __a);                           \
6014 +    (COUNT) = 64 - (__clz_tab[__t] + __a*8);                           \
6015 +  } while (0)
6016 +#define count_trailing_zeros(COUNT,X) \
6017 +  do {                                                                 \
6018 +    UDItype __xr = (X), __t, __a;                                      \
6019 +    __t = __builtin_alpha_cmpbge (0, __xr);                            \
6020 +    __t = ~__t & -~__t;                                                        \
6021 +    __a = ((__t & 0xCC) != 0) * 2;                                     \
6022 +    __a += ((__t & 0xF0) != 0) * 4;                                    \
6023 +    __a += ((__t & 0xAA) != 0);                                                \
6024 +    __t = __builtin_alpha_extbl (__xr, __a);                           \
6025 +    __a <<= 3;                                                         \
6026 +    __t &= -__t;                                                       \
6027 +    __a += ((__t & 0xCC) != 0) * 2;                                    \
6028 +    __a += ((__t & 0xF0) != 0) * 4;                                    \
6029 +    __a += ((__t & 0xAA) != 0);                                                \
6030 +    (COUNT) = __a;                                                     \
6031 +  } while (0)
6032 +#endif /* __alpha_cix__ */
6033 +#endif /* __alpha */
6034 +
6035 +#if defined (__arc__) && W_TYPE_SIZE == 32
6036 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6037 +  __asm__ ("add.f      %1, %4, %5\n\tadc       %0, %2, %3"             \
6038 +          : "=r" ((USItype) (sh)),                                     \
6039 +            "=&r" ((USItype) (sl))                                     \
6040 +          : "%r" ((USItype) (ah)),                                     \
6041 +            "rIJ" ((USItype) (bh)),                                    \
6042 +            "%r" ((USItype) (al)),                                     \
6043 +            "rIJ" ((USItype) (bl)))
6044 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6045 +  __asm__ ("sub.f      %1, %4, %5\n\tsbc       %0, %2, %3"             \
6046 +          : "=r" ((USItype) (sh)),                                     \
6047 +            "=&r" ((USItype) (sl))                                     \
6048 +          : "r" ((USItype) (ah)),                                      \
6049 +            "rIJ" ((USItype) (bh)),                                    \
6050 +            "r" ((USItype) (al)),                                      \
6051 +            "rIJ" ((USItype) (bl)))
6052 +/* Call libgcc routine.  */
6053 +#define umul_ppmm(w1, w0, u, v) \
6054 +do {                                                                   \
6055 +  DWunion __w;                                                         \
6056 +  __w.ll = __umulsidi3 (u, v);                                         \
6057 +  w1 = __w.s.high;                                                     \
6058 +  w0 = __w.s.low;                                                      \
6059 +} while (0)
6060 +#define __umulsidi3 __umulsidi3
6061 +UDItype __umulsidi3 (USItype, USItype);
6062 +#endif
6063 +
6064 +#if defined (__arm__) && W_TYPE_SIZE == 32
6065 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6066 +  __asm__ ("adds       %1, %4, %5\n\tadc       %0, %2, %3"             \
6067 +          : "=r" ((USItype) (sh)),                                     \
6068 +            "=&r" ((USItype) (sl))                                     \
6069 +          : "%r" ((USItype) (ah)),                                     \
6070 +            "rI" ((USItype) (bh)),                                     \
6071 +            "%r" ((USItype) (al)),                                     \
6072 +            "rI" ((USItype) (bl)))
6073 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6074 +  __asm__ ("subs       %1, %4, %5\n\tsbc       %0, %2, %3"             \
6075 +          : "=r" ((USItype) (sh)),                                     \
6076 +            "=&r" ((USItype) (sl))                                     \
6077 +          : "r" ((USItype) (ah)),                                      \
6078 +            "rI" ((USItype) (bh)),                                     \
6079 +            "r" ((USItype) (al)),                                      \
6080 +            "rI" ((USItype) (bl)))
6081 +#define umul_ppmm(xh, xl, a, b) \
6082 +{register USItype __t0, __t1, __t2;                                    \
6083 +  __asm__ ("%@ Inlined umul_ppmm\n"                                    \
6084 +          "    mov     %2, %5, lsr #16\n"                              \
6085 +          "    mov     %0, %6, lsr #16\n"                              \
6086 +          "    bic     %3, %5, %2, lsl #16\n"                          \
6087 +          "    bic     %4, %6, %0, lsl #16\n"                          \
6088 +          "    mul     %1, %3, %4\n"                                   \
6089 +          "    mul     %4, %2, %4\n"                                   \
6090 +          "    mul     %3, %0, %3\n"                                   \
6091 +          "    mul     %0, %2, %0\n"                                   \
6092 +          "    adds    %3, %4, %3\n"                                   \
6093 +          "    addcs   %0, %0, #65536\n"                               \
6094 +          "    adds    %1, %1, %3, lsl #16\n"                          \
6095 +          "    adc     %0, %0, %3, lsr #16"                            \
6096 +          : "=&r" ((USItype) (xh)),                                    \
6097 +            "=r" ((USItype) (xl)),                                     \
6098 +            "=&r" (__t0), "=&r" (__t1), "=r" (__t2)                    \
6099 +          : "r" ((USItype) (a)),                                       \
6100 +            "r" ((USItype) (b)));}
6101 +#define UMUL_TIME 20
6102 +#define UDIV_TIME 100
6103 +#endif /* __arm__ */
6104 +
6105 +#if defined (__hppa) && W_TYPE_SIZE == 32
6106 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6107 +  __asm__ ("add %4,%5,%1\n\taddc %2,%3,%0"                             \
6108 +          : "=r" ((USItype) (sh)),                                     \
6109 +            "=&r" ((USItype) (sl))                                     \
6110 +          : "%rM" ((USItype) (ah)),                                    \
6111 +            "rM" ((USItype) (bh)),                                     \
6112 +            "%rM" ((USItype) (al)),                                    \
6113 +            "rM" ((USItype) (bl)))
6114 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6115 +  __asm__ ("sub %4,%5,%1\n\tsubb %2,%3,%0"                             \
6116 +          : "=r" ((USItype) (sh)),                                     \
6117 +            "=&r" ((USItype) (sl))                                     \
6118 +          : "rM" ((USItype) (ah)),                                     \
6119 +            "rM" ((USItype) (bh)),                                     \
6120 +            "rM" ((USItype) (al)),                                     \
6121 +            "rM" ((USItype) (bl)))
6122 +#if defined (_PA_RISC1_1)
6123 +#define umul_ppmm(w1, w0, u, v) \
6124 +  do {                                                                 \
6125 +    union                                                              \
6126 +      {                                                                        \
6127 +       UDItype __f;                                                    \
6128 +       struct {USItype __w1, __w0;} __w1w0;                            \
6129 +      } __t;                                                           \
6130 +    __asm__ ("xmpyu %1,%2,%0"                                          \
6131 +            : "=x" (__t.__f)                                           \
6132 +            : "x" ((USItype) (u)),                                     \
6133 +              "x" ((USItype) (v)));                                    \
6134 +    (w1) = __t.__w1w0.__w1;                                            \
6135 +    (w0) = __t.__w1w0.__w0;                                            \
6136 +     } while (0)
6137 +#define UMUL_TIME 8
6138 +#else
6139 +#define UMUL_TIME 30
6140 +#endif
6141 +#define UDIV_TIME 40
6142 +#define count_leading_zeros(count, x) \
6143 +  do {                                                                 \
6144 +    USItype __tmp;                                                     \
6145 +    __asm__ (                                                          \
6146 +       "ldi            1,%0\n"                                         \
6147 +"      extru,=         %1,15,16,%%r0           ; Bits 31..16 zero?\n"  \
6148 +"      extru,tr        %1,15,16,%1             ; No.  Shift down, skip add.\n"\
6149 +"      ldo             16(%0),%0               ; Yes.  Perform add.\n" \
6150 +"      extru,=         %1,23,8,%%r0            ; Bits 15..8 zero?\n"   \
6151 +"      extru,tr        %1,23,8,%1              ; No.  Shift down, skip add.\n"\
6152 +"      ldo             8(%0),%0                ; Yes.  Perform add.\n" \
6153 +"      extru,=         %1,27,4,%%r0            ; Bits 7..4 zero?\n"    \
6154 +"      extru,tr        %1,27,4,%1              ; No.  Shift down, skip add.\n"\
6155 +"      ldo             4(%0),%0                ; Yes.  Perform add.\n" \
6156 +"      extru,=         %1,29,2,%%r0            ; Bits 3..2 zero?\n"    \
6157 +"      extru,tr        %1,29,2,%1              ; No.  Shift down, skip add.\n"\
6158 +"      ldo             2(%0),%0                ; Yes.  Perform add.\n" \
6159 +"      extru           %1,30,1,%1              ; Extract bit 1.\n"     \
6160 +"      sub             %0,%1,%0                ; Subtract it.\n"       \
6161 +       : "=r" (count), "=r" (__tmp) : "1" (x));                        \
6162 +  } while (0)
6163 +#endif
6164 +
6165 +#if (defined (__i370__) || defined (__s390__) || defined (__mvs__)) && W_TYPE_SIZE == 32
6166 +#define smul_ppmm(xh, xl, m0, m1) \
6167 +  do {                                                                 \
6168 +    union {DItype __ll;                                                        \
6169 +          struct {USItype __h, __l;} __i;                              \
6170 +         } __x;                                                        \
6171 +    __asm__ ("lr %N0,%1\n\tmr %0,%2"                                   \
6172 +            : "=&r" (__x.__ll)                                         \
6173 +            : "r" (m0), "r" (m1));                                     \
6174 +    (xh) = __x.__i.__h; (xl) = __x.__i.__l;                            \
6175 +  } while (0)
6176 +#define sdiv_qrnnd(q, r, n1, n0, d) \
6177 +  do {                                                                 \
6178 +    union {DItype __ll;                                                        \
6179 +          struct {USItype __h, __l;} __i;                              \
6180 +         } __x;                                                        \
6181 +    __x.__i.__h = n1; __x.__i.__l = n0;                                        \
6182 +    __asm__ ("dr %0,%2"                                                        \
6183 +            : "=r" (__x.__ll)                                          \
6184 +            : "0" (__x.__ll), "r" (d));                                \
6185 +    (q) = __x.__i.__l; (r) = __x.__i.__h;                              \
6186 +  } while (0)
6187 +#endif
6188 +
6189 +#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
6190 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6191 +  __asm__ ("addl %5,%1\n\tadcl %3,%0"                                  \
6192 +          : "=r" ((USItype) (sh)),                                     \
6193 +            "=&r" ((USItype) (sl))                                     \
6194 +          : "%0" ((USItype) (ah)),                                     \
6195 +            "g" ((USItype) (bh)),                                      \
6196 +            "%1" ((USItype) (al)),                                     \
6197 +            "g" ((USItype) (bl)))
6198 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6199 +  __asm__ ("subl %5,%1\n\tsbbl %3,%0"                                  \
6200 +          : "=r" ((USItype) (sh)),                                     \
6201 +            "=&r" ((USItype) (sl))                                     \
6202 +          : "0" ((USItype) (ah)),                                      \
6203 +            "g" ((USItype) (bh)),                                      \
6204 +            "1" ((USItype) (al)),                                      \
6205 +            "g" ((USItype) (bl)))
6206 +#define umul_ppmm(w1, w0, u, v) \
6207 +  __asm__ ("mull %3"                                                   \
6208 +          : "=a" ((USItype) (w0)),                                     \
6209 +            "=d" ((USItype) (w1))                                      \
6210 +          : "%0" ((USItype) (u)),                                      \
6211 +            "rm" ((USItype) (v)))
6212 +#define udiv_qrnnd(q, r, n1, n0, dv) \
6213 +  __asm__ ("divl %4"                                                   \
6214 +          : "=a" ((USItype) (q)),                                      \
6215 +            "=d" ((USItype) (r))                                       \
6216 +          : "0" ((USItype) (n0)),                                      \
6217 +            "1" ((USItype) (n1)),                                      \
6218 +            "rm" ((USItype) (dv)))
6219 +#define count_leading_zeros(count, x) \
6220 +  do {                                                                 \
6221 +    USItype __cbtmp;                                                   \
6222 +    __asm__ ("bsrl %1,%0"                                              \
6223 +            : "=r" (__cbtmp) : "rm" ((USItype) (x)));                  \
6224 +    (count) = __cbtmp ^ 31;                                            \
6225 +  } while (0)
6226 +#define count_trailing_zeros(count, x) \
6227 +  __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x)))
6228 +#define UMUL_TIME 40
6229 +#define UDIV_TIME 40
6230 +#endif /* 80x86 */
6231 +
6232 +#if defined (__i960__) && W_TYPE_SIZE == 32
6233 +#define umul_ppmm(w1, w0, u, v) \
6234 +  ({union {UDItype __ll;                                               \
6235 +          struct {USItype __l, __h;} __i;                              \
6236 +         } __xx;                                                       \
6237 +  __asm__ ("emul       %2,%1,%0"                                       \
6238 +          : "=d" (__xx.__ll)                                           \
6239 +          : "%dI" ((USItype) (u)),                                     \
6240 +            "dI" ((USItype) (v)));                                     \
6241 +  (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
6242 +#define __umulsidi3(u, v) \
6243 +  ({UDItype __w;                                                       \
6244 +    __asm__ ("emul     %2,%1,%0"                                       \
6245 +            : "=d" (__w)                                               \
6246 +            : "%dI" ((USItype) (u)),                                   \
6247 +              "dI" ((USItype) (v)));                                   \
6248 +    __w; })
6249 +#endif /* __i960__ */
6250 +
6251 +#if defined (__M32R__) && W_TYPE_SIZE == 32
6252 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6253 +  /* The cmp clears the condition bit.  */ \
6254 +  __asm__ ("cmp %0,%0\n\taddx %1,%5\n\taddx %0,%3"                     \
6255 +          : "=r" ((USItype) (sh)),                                     \
6256 +            "=&r" ((USItype) (sl))                                     \
6257 +          : "0" ((USItype) (ah)),                                      \
6258 +            "r" ((USItype) (bh)),                                      \
6259 +            "1" ((USItype) (al)),                                      \
6260 +            "r" ((USItype) (bl))                                       \
6261 +          : "cbit")
6262 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6263 +  /* The cmp clears the condition bit.  */ \
6264 +  __asm__ ("cmp %0,%0\n\tsubx %1,%5\n\tsubx %0,%3"                     \
6265 +          : "=r" ((USItype) (sh)),                                     \
6266 +            "=&r" ((USItype) (sl))                                     \
6267 +          : "0" ((USItype) (ah)),                                      \
6268 +            "r" ((USItype) (bh)),                                      \
6269 +            "1" ((USItype) (al)),                                      \
6270 +            "r" ((USItype) (bl))                                       \
6271 +          : "cbit")
6272 +#endif /* __M32R__ */
6273 +
6274 +#if defined (__mc68000__) && W_TYPE_SIZE == 32
6275 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6276 +  __asm__ ("add%.l %5,%1\n\taddx%.l %3,%0"                             \
6277 +          : "=d" ((USItype) (sh)),                                     \
6278 +            "=&d" ((USItype) (sl))                                     \
6279 +          : "%0" ((USItype) (ah)),                                     \
6280 +            "d" ((USItype) (bh)),                                      \
6281 +            "%1" ((USItype) (al)),                                     \
6282 +            "g" ((USItype) (bl)))
6283 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6284 +  __asm__ ("sub%.l %5,%1\n\tsubx%.l %3,%0"                             \
6285 +          : "=d" ((USItype) (sh)),                                     \
6286 +            "=&d" ((USItype) (sl))                                     \
6287 +          : "0" ((USItype) (ah)),                                      \
6288 +            "d" ((USItype) (bh)),                                      \
6289 +            "1" ((USItype) (al)),                                      \
6290 +            "g" ((USItype) (bl)))
6291 +
6292 +/* The '020, '030, '040 and CPU32 have 32x32->64 and 64/32->32q-32r.  */
6293 +#if defined (__mc68020__) || defined(mc68020) \
6294 +       || defined(__mc68030__) || defined(mc68030) \
6295 +       || defined(__mc68040__) || defined(mc68040) \
6296 +       || defined(__mcpu32__) || defined(mcpu32)
6297 +#define umul_ppmm(w1, w0, u, v) \
6298 +  __asm__ ("mulu%.l %3,%1:%0"                                          \
6299 +          : "=d" ((USItype) (w0)),                                     \
6300 +            "=d" ((USItype) (w1))                                      \
6301 +          : "%0" ((USItype) (u)),                                      \
6302 +            "dmi" ((USItype) (v)))
6303 +#define UMUL_TIME 45
6304 +#define udiv_qrnnd(q, r, n1, n0, d) \
6305 +  __asm__ ("divu%.l %4,%1:%0"                                          \
6306 +          : "=d" ((USItype) (q)),                                      \
6307 +            "=d" ((USItype) (r))                                       \
6308 +          : "0" ((USItype) (n0)),                                      \
6309 +            "1" ((USItype) (n1)),                                      \
6310 +            "dmi" ((USItype) (d)))
6311 +#define UDIV_TIME 90
6312 +#define sdiv_qrnnd(q, r, n1, n0, d) \
6313 +  __asm__ ("divs%.l %4,%1:%0"                                          \
6314 +          : "=d" ((USItype) (q)),                                      \
6315 +            "=d" ((USItype) (r))                                       \
6316 +          : "0" ((USItype) (n0)),                                      \
6317 +            "1" ((USItype) (n1)),                                      \
6318 +            "dmi" ((USItype) (d)))
6319 +
6320 +#else /* not mc68020 */
6321 +#if defined(__mcoldfire__)
6322 +#define umul_ppmm(xh, xl, a, b) \
6323 +  __asm__ ("| Inlined umul_ppmm\n"                                     \
6324 +          "    move%.l %2,%/d0\n"                                      \
6325 +          "    move%.l %3,%/d1\n"                                      \
6326 +          "    move%.l %/d0,%/d2\n"                                    \
6327 +          "    swap    %/d0\n"                                         \
6328 +          "    move%.l %/d1,%/d3\n"                                    \
6329 +          "    swap    %/d1\n"                                         \
6330 +          "    move%.w %/d2,%/d4\n"                                    \
6331 +          "    mulu    %/d3,%/d4\n"                                    \
6332 +          "    mulu    %/d1,%/d2\n"                                    \
6333 +          "    mulu    %/d0,%/d3\n"                                    \
6334 +          "    mulu    %/d0,%/d1\n"                                    \
6335 +          "    move%.l %/d4,%/d0\n"                                    \
6336 +          "    clr%.w  %/d0\n"                                         \
6337 +          "    swap    %/d0\n"                                         \
6338 +          "    add%.l  %/d0,%/d2\n"                                    \
6339 +          "    add%.l  %/d3,%/d2\n"                                    \
6340 +          "    jcc     1f\n"                                           \
6341 +          "    add%.l  %#65536,%/d1\n"                                 \
6342 +          "1:  swap    %/d2\n"                                         \
6343 +          "    moveq   %#0,%/d0\n"                                     \
6344 +          "    move%.w %/d2,%/d0\n"                                    \
6345 +          "    move%.w %/d4,%/d2\n"                                    \
6346 +          "    move%.l %/d2,%1\n"                                      \
6347 +          "    add%.l  %/d1,%/d0\n"                                    \
6348 +          "    move%.l %/d0,%0"                                        \
6349 +          : "=g" ((USItype) (xh)),                                     \
6350 +            "=g" ((USItype) (xl))                                      \
6351 +          : "g" ((USItype) (a)),                                       \
6352 +            "g" ((USItype) (b))                                        \
6353 +          : "d0", "d1", "d2", "d3", "d4")
6354 +#define UMUL_TIME 100
6355 +#define UDIV_TIME 400
6356 +#else /* not ColdFire */
6357 +/* %/ inserts REGISTER_PREFIX, %# inserts IMMEDIATE_PREFIX.  */
6358 +#define umul_ppmm(xh, xl, a, b) \
6359 +  __asm__ ("| Inlined umul_ppmm\n"                                     \
6360 +          "    move%.l %2,%/d0\n"                                      \
6361 +          "    move%.l %3,%/d1\n"                                      \
6362 +          "    move%.l %/d0,%/d2\n"                                    \
6363 +          "    swap    %/d0\n"                                         \
6364 +          "    move%.l %/d1,%/d3\n"                                    \
6365 +          "    swap    %/d1\n"                                         \
6366 +          "    move%.w %/d2,%/d4\n"                                    \
6367 +          "    mulu    %/d3,%/d4\n"                                    \
6368 +          "    mulu    %/d1,%/d2\n"                                    \
6369 +          "    mulu    %/d0,%/d3\n"                                    \
6370 +          "    mulu    %/d0,%/d1\n"                                    \
6371 +          "    move%.l %/d4,%/d0\n"                                    \
6372 +          "    eor%.w  %/d0,%/d0\n"                                    \
6373 +          "    swap    %/d0\n"                                         \
6374 +          "    add%.l  %/d0,%/d2\n"                                    \
6375 +          "    add%.l  %/d3,%/d2\n"                                    \
6376 +          "    jcc     1f\n"                                           \
6377 +          "    add%.l  %#65536,%/d1\n"                                 \
6378 +          "1:  swap    %/d2\n"                                         \
6379 +          "    moveq   %#0,%/d0\n"                                     \
6380 +          "    move%.w %/d2,%/d0\n"                                    \
6381 +          "    move%.w %/d4,%/d2\n"                                    \
6382 +          "    move%.l %/d2,%1\n"                                      \
6383 +          "    add%.l  %/d1,%/d0\n"                                    \
6384 +          "    move%.l %/d0,%0"                                        \
6385 +          : "=g" ((USItype) (xh)),                                     \
6386 +            "=g" ((USItype) (xl))                                      \
6387 +          : "g" ((USItype) (a)),                                       \
6388 +            "g" ((USItype) (b))                                        \
6389 +          : "d0", "d1", "d2", "d3", "d4")
6390 +#define UMUL_TIME 100
6391 +#define UDIV_TIME 400
6392 +#endif /* not ColdFire */
6393 +#endif /* not mc68020 */
6394 +
6395 +/* The '020, '030, '040 and '060 have bitfield insns.
6396 +   cpu32 disguises as a 68020, but lacks them.  */
6397 +#if ( defined (__mc68020__) || defined(mc68020) \
6398 +               || defined(__mc68030__) || defined(mc68030) \
6399 +               || defined(__mc68040__) || defined(mc68040) \
6400 +               || defined(__mc68060__) || defined(mc68060) ) \
6401 +       && !defined(__mcpu32__)
6402 +#define count_leading_zeros(count, x) \
6403 +  __asm__ ("bfffo %1{%b2:%b2},%0"                                      \
6404 +          : "=d" ((USItype) (count))                                   \
6405 +          : "od" ((USItype) (x)), "n" (0))
6406 +#endif
6407 +#endif /* mc68000 */
6408 +
6409 +#if defined (__m88000__) && W_TYPE_SIZE == 32
6410 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6411 +  __asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3"                  \
6412 +          : "=r" ((USItype) (sh)),                                     \
6413 +            "=&r" ((USItype) (sl))                                     \
6414 +          : "%rJ" ((USItype) (ah)),                                    \
6415 +            "rJ" ((USItype) (bh)),                                     \
6416 +            "%rJ" ((USItype) (al)),                                    \
6417 +            "rJ" ((USItype) (bl)))
6418 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6419 +  __asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3"                  \
6420 +          : "=r" ((USItype) (sh)),                                     \
6421 +            "=&r" ((USItype) (sl))                                     \
6422 +          : "rJ" ((USItype) (ah)),                                     \
6423 +            "rJ" ((USItype) (bh)),                                     \
6424 +            "rJ" ((USItype) (al)),                                     \
6425 +            "rJ" ((USItype) (bl)))
6426 +#define count_leading_zeros(count, x) \
6427 +  do {                                                                 \
6428 +    USItype __cbtmp;                                                   \
6429 +    __asm__ ("ff1 %0,%1"                                               \
6430 +            : "=r" (__cbtmp)                                           \
6431 +            : "r" ((USItype) (x)));                                    \
6432 +    (count) = __cbtmp ^ 31;                                            \
6433 +  } while (0)
6434 +#define COUNT_LEADING_ZEROS_0 63 /* sic */
6435 +#if defined (__mc88110__)
6436 +#define umul_ppmm(wh, wl, u, v) \
6437 +  do {                                                                 \
6438 +    union {UDItype __ll;                                               \
6439 +          struct {USItype __h, __l;} __i;                              \
6440 +         } __xx;                                                       \
6441 +    __asm__ ("mulu.d   %0,%1,%2"                                       \
6442 +            : "=r" (__xx.__ll)                                         \
6443 +            : "r" ((USItype) (u)),                                     \
6444 +              "r" ((USItype) (v)));                                    \
6445 +    (wh) = __xx.__i.__h;                                               \
6446 +    (wl) = __xx.__i.__l;                                               \
6447 +  } while (0)
6448 +#define udiv_qrnnd(q, r, n1, n0, d) \
6449 +  ({union {UDItype __ll;                                               \
6450 +          struct {USItype __h, __l;} __i;                              \
6451 +         } __xx;                                                       \
6452 +  USItype __q;                                                         \
6453 +  __xx.__i.__h = (n1); __xx.__i.__l = (n0);                            \
6454 +  __asm__ ("divu.d %0,%1,%2"                                           \
6455 +          : "=r" (__q)                                                 \
6456 +          : "r" (__xx.__ll),                                           \
6457 +            "r" ((USItype) (d)));                                      \
6458 +  (r) = (n0) - __q * (d); (q) = __q; })
6459 +#define UMUL_TIME 5
6460 +#define UDIV_TIME 25
6461 +#else
6462 +#define UMUL_TIME 17
6463 +#define UDIV_TIME 150
6464 +#endif /* __mc88110__ */
6465 +#endif /* __m88000__ */
6466 +
6467 +#if defined (__mips__) && W_TYPE_SIZE == 32
6468 +#define umul_ppmm(w1, w0, u, v) \
6469 +  __asm__ ("multu %2,%3"                                               \
6470 +          : "=l" ((USItype) (w0)),                                     \
6471 +            "=h" ((USItype) (w1))                                      \
6472 +          : "d" ((USItype) (u)),                                       \
6473 +            "d" ((USItype) (v)))
6474 +#define UMUL_TIME 10
6475 +#define UDIV_TIME 100
6476 +#endif /* __mips__ */
6477 +
6478 +#if defined (__ns32000__) && W_TYPE_SIZE == 32
6479 +#define umul_ppmm(w1, w0, u, v) \
6480 +  ({union {UDItype __ll;                                               \
6481 +          struct {USItype __l, __h;} __i;                              \
6482 +         } __xx;                                                       \
6483 +  __asm__ ("meid %2,%0"                                                        \
6484 +          : "=g" (__xx.__ll)                                           \
6485 +          : "%0" ((USItype) (u)),                                      \
6486 +            "g" ((USItype) (v)));                                      \
6487 +  (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
6488 +#define __umulsidi3(u, v) \
6489 +  ({UDItype __w;                                                       \
6490 +    __asm__ ("meid %2,%0"                                              \
6491 +            : "=g" (__w)                                               \
6492 +            : "%0" ((USItype) (u)),                                    \
6493 +              "g" ((USItype) (v)));                                    \
6494 +    __w; })
6495 +#define udiv_qrnnd(q, r, n1, n0, d) \
6496 +  ({union {UDItype __ll;                                               \
6497 +          struct {USItype __l, __h;} __i;                              \
6498 +         } __xx;                                                       \
6499 +  __xx.__i.__h = (n1); __xx.__i.__l = (n0);                            \
6500 +  __asm__ ("deid %2,%0"                                                        \
6501 +          : "=g" (__xx.__ll)                                           \
6502 +          : "0" (__xx.__ll),                                           \
6503 +            "g" ((USItype) (d)));                                      \
6504 +  (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
6505 +#define count_trailing_zeros(count,x) \
6506 +  do {                                                                 \
6507 +    __asm__ ("ffsd     %2,%0"                                          \
6508 +            : "=r" ((USItype) (count))                                 \
6509 +            : "0" ((USItype) 0),                                       \
6510 +              "r" ((USItype) (x)));                                    \
6511 +  } while (0)
6512 +#endif /* __ns32000__ */
6513 +
6514 +/* FIXME: We should test _IBMR2 here when we add assembly support for the
6515 +   system vendor compilers.
6516 +   FIXME: What's needed for gcc PowerPC VxWorks?  __vxworks__ is not good
6517 +   enough, since that hits ARM and m68k too.  */
6518 +#if (defined (_ARCH_PPC)       /* AIX */                               \
6519 +     || defined (_ARCH_PWR)    /* AIX */                               \
6520 +     || defined (_ARCH_COM)    /* AIX */                               \
6521 +     || defined (__powerpc__)  /* gcc */                               \
6522 +     || defined (__POWERPC__)  /* BEOS */                              \
6523 +     || defined (__ppc__)      /* Darwin */                            \
6524 +     || defined (PPC)          /* GNU/Linux, SysV */                   \
6525 +     ) && W_TYPE_SIZE == 32
6526 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6527 +  do {                                                                 \
6528 +    if (__builtin_constant_p (bh) && (bh) == 0)                                \
6529 +      __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2"          \
6530 +            : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
6531 +    else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)                \
6532 +      __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2"          \
6533 +            : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
6534 +    else                                                               \
6535 +      __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3"         \
6536 +            : "=r" (sh), "=&r" (sl)                                    \
6537 +            : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl));              \
6538 +  } while (0)
6539 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6540 +  do {                                                                 \
6541 +    if (__builtin_constant_p (ah) && (ah) == 0)                                \
6542 +      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2"      \
6543 +              : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
6544 +    else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0)                \
6545 +      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2"      \
6546 +              : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
6547 +    else if (__builtin_constant_p (bh) && (bh) == 0)                   \
6548 +      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2"                \
6549 +              : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
6550 +    else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)                \
6551 +      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2"                \
6552 +              : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
6553 +    else                                                               \
6554 +      __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2"     \
6555 +              : "=r" (sh), "=&r" (sl)                                  \
6556 +              : "r" (ah), "r" (bh), "rI" (al), "r" (bl));              \
6557 +  } while (0)
6558 +#define count_leading_zeros(count, x) \
6559 +  __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
6560 +#define COUNT_LEADING_ZEROS_0 32
6561 +#if defined (_ARCH_PPC) || defined (__powerpc__) || defined (__POWERPC__) \
6562 +  || defined (__ppc__) || defined (PPC)
6563 +#define umul_ppmm(ph, pl, m0, m1) \
6564 +  do {                                                                 \
6565 +    USItype __m0 = (m0), __m1 = (m1);                                  \
6566 +    __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1));     \
6567 +    (pl) = __m0 * __m1;                                                        \
6568 +  } while (0)
6569 +#define UMUL_TIME 15
6570 +#define smul_ppmm(ph, pl, m0, m1) \
6571 +  do {                                                                 \
6572 +    SItype __m0 = (m0), __m1 = (m1);                                   \
6573 +    __asm__ ("mulhw %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1));      \
6574 +    (pl) = __m0 * __m1;                                                        \
6575 +  } while (0)
6576 +#define SMUL_TIME 14
6577 +#define UDIV_TIME 120
6578 +#elif defined (_ARCH_PWR)
6579 +#define UMUL_TIME 8
6580 +#define smul_ppmm(xh, xl, m0, m1) \
6581 +  __asm__ ("mul %0,%2,%3" : "=r" (xh), "=q" (xl) : "r" (m0), "r" (m1))
6582 +#define SMUL_TIME 4
6583 +#define sdiv_qrnnd(q, r, nh, nl, d) \
6584 +  __asm__ ("div %0,%2,%4" : "=r" (q), "=q" (r) : "r" (nh), "1" (nl), "r" (d))
6585 +#define UDIV_TIME 100
6586 +#endif
6587 +#endif /* 32-bit POWER architecture variants.  */
6588 +
6589 +/* We should test _IBMR2 here when we add assembly support for the system
6590 +   vendor compilers.  */
6591 +#if (defined (_ARCH_PPC64) || defined (__powerpc64__)) && W_TYPE_SIZE == 64
6592 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6593 +  do {                                                                 \
6594 +    if (__builtin_constant_p (bh) && (bh) == 0)                                \
6595 +      __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2"          \
6596 +            : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
6597 +    else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0)                \
6598 +      __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2"          \
6599 +            : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
6600 +    else                                                               \
6601 +      __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3"         \
6602 +            : "=r" (sh), "=&r" (sl)                                    \
6603 +            : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl));              \
6604 +  } while (0)
6605 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6606 +  do {                                                                 \
6607 +    if (__builtin_constant_p (ah) && (ah) == 0)                                \
6608 +      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2"      \
6609 +              : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
6610 +    else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0)                \
6611 +      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2"      \
6612 +              : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
6613 +    else if (__builtin_constant_p (bh) && (bh) == 0)                   \
6614 +      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2"                \
6615 +              : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
6616 +    else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0)                \
6617 +      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2"                \
6618 +              : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
6619 +    else                                                               \
6620 +      __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2"     \
6621 +              : "=r" (sh), "=&r" (sl)                                  \
6622 +              : "r" (ah), "r" (bh), "rI" (al), "r" (bl));              \
6623 +  } while (0)
6624 +#define count_leading_zeros(count, x) \
6625 +  __asm__ ("cntlzd %0,%1" : "=r" (count) : "r" (x))
6626 +#define COUNT_LEADING_ZEROS_0 64
6627 +#define umul_ppmm(ph, pl, m0, m1) \
6628 +  do {                                                                 \
6629 +    UDItype __m0 = (m0), __m1 = (m1);                                  \
6630 +    __asm__ ("mulhdu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1));     \
6631 +    (pl) = __m0 * __m1;                                                        \
6632 +  } while (0)
6633 +#define UMUL_TIME 15
6634 +#define smul_ppmm(ph, pl, m0, m1) \
6635 +  do {                                                                 \
6636 +    DItype __m0 = (m0), __m1 = (m1);                                   \
6637 +    __asm__ ("mulhd %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1));      \
6638 +    (pl) = __m0 * __m1;                                                        \
6639 +  } while (0)
6640 +#define SMUL_TIME 14  /* ??? */
6641 +#define UDIV_TIME 120 /* ??? */
6642 +#endif /* 64-bit PowerPC.  */
6643 +
6644 +#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
6645 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6646 +  __asm__ ("a %1,%5\n\tae %0,%3"                                       \
6647 +          : "=r" ((USItype) (sh)),                                     \
6648 +            "=&r" ((USItype) (sl))                                     \
6649 +          : "%0" ((USItype) (ah)),                                     \
6650 +            "r" ((USItype) (bh)),                                      \
6651 +            "%1" ((USItype) (al)),                                     \
6652 +            "r" ((USItype) (bl)))
6653 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6654 +  __asm__ ("s %1,%5\n\tse %0,%3"                                       \
6655 +          : "=r" ((USItype) (sh)),                                     \
6656 +            "=&r" ((USItype) (sl))                                     \
6657 +          : "0" ((USItype) (ah)),                                      \
6658 +            "r" ((USItype) (bh)),                                      \
6659 +            "1" ((USItype) (al)),                                      \
6660 +            "r" ((USItype) (bl)))
6661 +#define umul_ppmm(ph, pl, m0, m1) \
6662 +  do {                                                                 \
6663 +    USItype __m0 = (m0), __m1 = (m1);                                  \
6664 +    __asm__ (                                                          \
6665 +       "s      r2,r2\n"                                                \
6666 +"      mts     r10,%2\n"                                               \
6667 +"      m       r2,%3\n"                                                \
6668 +"      m       r2,%3\n"                                                \
6669 +"      m       r2,%3\n"                                                \
6670 +"      m       r2,%3\n"                                                \
6671 +"      m       r2,%3\n"                                                \
6672 +"      m       r2,%3\n"                                                \
6673 +"      m       r2,%3\n"                                                \
6674 +"      m       r2,%3\n"                                                \
6675 +"      m       r2,%3\n"                                                \
6676 +"      m       r2,%3\n"                                                \
6677 +"      m       r2,%3\n"                                                \
6678 +"      m       r2,%3\n"                                                \
6679 +"      m       r2,%3\n"                                                \
6680 +"      m       r2,%3\n"                                                \
6681 +"      m       r2,%3\n"                                                \
6682 +"      m       r2,%3\n"                                                \
6683 +"      cas     %0,r2,r0\n"                                             \
6684 +"      mfs     r10,%1"                                                 \
6685 +            : "=r" ((USItype) (ph)),                                   \
6686 +              "=r" ((USItype) (pl))                                    \
6687 +            : "%r" (__m0),                                             \
6688 +               "r" (__m1)                                              \
6689 +            : "r2");                                                   \
6690 +    (ph) += ((((SItype) __m0 >> 31) & __m1)                            \
6691 +            + (((SItype) __m1 >> 31) & __m0));                         \
6692 +  } while (0)
6693 +#define UMUL_TIME 20
6694 +#define UDIV_TIME 200
6695 +#define count_leading_zeros(count, x) \
6696 +  do {                                                                 \
6697 +    if ((x) >= 0x10000)                                                        \
6698 +      __asm__ ("clz    %0,%1"                                          \
6699 +              : "=r" ((USItype) (count))                               \
6700 +              : "r" ((USItype) (x) >> 16));                            \
6701 +    else                                                               \
6702 +      {                                                                        \
6703 +       __asm__ ("clz   %0,%1"                                          \
6704 +                : "=r" ((USItype) (count))                             \
6705 +                : "r" ((USItype) (x)));                                        \
6706 +       (count) += 16;                                                  \
6707 +      }                                                                        \
6708 +  } while (0)
6709 +#endif
6710 +
6711 +#if defined (__sh2__) && W_TYPE_SIZE == 32
6712 +#define umul_ppmm(w1, w0, u, v) \
6713 +  __asm__ (                                                            \
6714 +       "dmulu.l        %2,%3\n\tsts    macl,%1\n\tsts  mach,%0"                \
6715 +          : "=r" ((USItype)(w1)),                                      \
6716 +            "=r" ((USItype)(w0))                                       \
6717 +          : "r" ((USItype)(u)),                                        \
6718 +            "r" ((USItype)(v))                                         \
6719 +          : "macl", "mach")
6720 +#define UMUL_TIME 5
6721 +#endif
6722 +
6723 +#if defined (__SH5__) && __SHMEDIA__ && W_TYPE_SIZE == 32
6724 +#define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
6725 +#define count_leading_zeros(count, x) \
6726 +  do                                                                   \
6727 +    {                                                                  \
6728 +      UDItype x_ = (USItype)(x);                                       \
6729 +      SItype c_;                                                       \
6730 +                                                                       \
6731 +      __asm__ ("nsb %1, %0" : "=r" (c_) : "r" (x_));                   \
6732 +      (count) = c_ - 31;                                               \
6733 +    }                                                                  \
6734 +  while (0)
6735 +#define COUNT_LEADING_ZEROS_0 32
6736 +#endif
6737 +
6738 +#if defined (__sparc__) && !defined (__arch64__) && !defined (__sparcv9) \
6739 +    && W_TYPE_SIZE == 32
6740 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6741 +  __asm__ ("addcc %r4,%5,%1\n\taddx %r2,%3,%0"                         \
6742 +          : "=r" ((USItype) (sh)),                                     \
6743 +            "=&r" ((USItype) (sl))                                     \
6744 +          : "%rJ" ((USItype) (ah)),                                    \
6745 +            "rI" ((USItype) (bh)),                                     \
6746 +            "%rJ" ((USItype) (al)),                                    \
6747 +            "rI" ((USItype) (bl))                                      \
6748 +          __CLOBBER_CC)
6749 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
6750 +  __asm__ ("subcc %r4,%5,%1\n\tsubx %r2,%3,%0"                         \
6751 +          : "=r" ((USItype) (sh)),                                     \
6752 +            "=&r" ((USItype) (sl))                                     \
6753 +          : "rJ" ((USItype) (ah)),                                     \
6754 +            "rI" ((USItype) (bh)),                                     \
6755 +            "rJ" ((USItype) (al)),                                     \
6756 +            "rI" ((USItype) (bl))                                      \
6757 +          __CLOBBER_CC)
6758 +#if defined (__sparc_v8__)
6759 +#define umul_ppmm(w1, w0, u, v) \
6760 +  __asm__ ("umul %2,%3,%1;rd %%y,%0"                                   \
6761 +          : "=r" ((USItype) (w1)),                                     \
6762 +            "=r" ((USItype) (w0))                                      \
6763 +          : "r" ((USItype) (u)),                                       \
6764 +            "r" ((USItype) (v)))
6765 +#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
6766 +  __asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\
6767 +          : "=&r" ((USItype) (__q)),                                   \
6768 +            "=&r" ((USItype) (__r))                                    \
6769 +          : "r" ((USItype) (__n1)),                                    \
6770 +            "r" ((USItype) (__n0)),                                    \
6771 +            "r" ((USItype) (__d)))
6772 +#else
6773 +#if defined (__sparclite__)
6774 +/* This has hardware multiply but not divide.  It also has two additional
6775 +   instructions scan (ffs from high bit) and divscc.  */
6776 +#define umul_ppmm(w1, w0, u, v) \
6777 +  __asm__ ("umul %2,%3,%1;rd %%y,%0"                                   \
6778 +          : "=r" ((USItype) (w1)),                                     \
6779 +            "=r" ((USItype) (w0))                                      \
6780 +          : "r" ((USItype) (u)),                                       \
6781 +            "r" ((USItype) (v)))
6782 +#define udiv_qrnnd(q, r, n1, n0, d) \
6783 +  __asm__ ("! Inlined udiv_qrnnd\n"                                    \
6784 +"      wr      %%g0,%2,%%y     ! Not a delayed write for sparclite\n"  \
6785 +"      tst     %%g0\n"                                                 \
6786 +"      divscc  %3,%4,%%g1\n"                                           \
6787 +"      divscc  %%g1,%4,%%g1\n"                                         \
6788 +"      divscc  %%g1,%4,%%g1\n"                                         \
6789 +"      divscc  %%g1,%4,%%g1\n"                                         \
6790 +"      divscc  %%g1,%4,%%g1\n"                                         \
6791 +"      divscc  %%g1,%4,%%g1\n"                                         \
6792 +"      divscc  %%g1,%4,%%g1\n"                                         \
6793 +"      divscc  %%g1,%4,%%g1\n"                                         \
6794 +"      divscc  %%g1,%4,%%g1\n"                                         \
6795 +"      divscc  %%g1,%4,%%g1\n"                                         \
6796 +"      divscc  %%g1,%4,%%g1\n"                                         \
6797 +"      divscc  %%g1,%4,%%g1\n"                                         \
6798 +"      divscc  %%g1,%4,%%g1\n"                                         \
6799 +"      divscc  %%g1,%4,%%g1\n"                                         \
6800 +"      divscc  %%g1,%4,%%g1\n"                                         \
6801 +"      divscc  %%g1,%4,%%g1\n"                                         \
6802 +"      divscc  %%g1,%4,%%g1\n"                                         \
6803 +"      divscc  %%g1,%4,%%g1\n"                                         \
6804 +"      divscc  %%g1,%4,%%g1\n"                                         \
6805 +"      divscc  %%g1,%4,%%g1\n"                                         \
6806 +"      divscc  %%g1,%4,%%g1\n"                                         \
6807 +"      divscc  %%g1,%4,%%g1\n"                                         \
6808 +"      divscc  %%g1,%4,%%g1\n"                                         \
6809 +"      divscc  %%g1,%4,%%g1\n"                                         \
6810 +"      divscc  %%g1,%4,%%g1\n"                                         \
6811 +"      divscc  %%g1,%4,%%g1\n"                                         \
6812 +"      divscc  %%g1,%4,%%g1\n"                                         \
6813 +"      divscc  %%g1,%4,%%g1\n"                                         \
6814 +"      divscc  %%g1,%4,%%g1\n"                                         \
6815 +"      divscc  %%g1,%4,%%g1\n"                                         \
6816 +"      divscc  %%g1,%4,%%g1\n"                                         \
6817 +"      divscc  %%g1,%4,%0\n"                                           \
6818 +"      rd      %%y,%1\n"                                               \
6819 +"      bl,a 1f\n"                                                      \
6820 +"      add     %1,%4,%1\n"                                             \
6821 +"1:    ! End of inline udiv_qrnnd"                                     \
6822 +          : "=r" ((USItype) (q)),                                      \
6823 +            "=r" ((USItype) (r))                                       \
6824 +          : "r" ((USItype) (n1)),                                      \
6825 +            "r" ((USItype) (n0)),                                      \
6826 +            "rI" ((USItype) (d))                                       \
6827 +          : "g1" __AND_CLOBBER_CC)
6828 +#define UDIV_TIME 37
6829 +#define count_leading_zeros(count, x) \
6830 +  do {                                                                  \
6831 +  __asm__ ("scan %1,1,%0"                                               \
6832 +           : "=r" ((USItype) (count))                                   \
6833 +           : "r" ((USItype) (x)));                                     \
6834 +  } while (0)
6835 +/* Early sparclites return 63 for an argument of 0, but they warn that future
6836 +   implementations might change this.  Therefore, leave COUNT_LEADING_ZEROS_0
6837 +   undefined.  */
6838 +#else
6839 +/* SPARC without integer multiplication and divide instructions.
6840 +   (i.e. at least Sun4/20,40,60,65,75,110,260,280,330,360,380,470,490) */
6841 +#define umul_ppmm(w1, w0, u, v) \
6842 +  __asm__ ("! Inlined umul_ppmm\n"                                     \
6843 +"      wr      %%g0,%2,%%y     ! SPARC has 0-3 delay insn after a wr\n"\
6844 +"      sra     %3,31,%%o5      ! Don't move this insn\n"               \
6845 +"      and     %2,%%o5,%%o5    ! Don't move this insn\n"               \
6846 +"      andcc   %%g0,0,%%g1     ! Don't move this insn\n"               \
6847 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6848 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6849 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6850 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6851 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6852 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6853 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6854 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6855 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6856 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6857 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6858 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6859 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6860 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6861 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6862 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6863 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6864 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6865 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6866 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6867 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6868 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6869 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6870 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6871 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6872 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6873 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6874 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6875 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6876 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6877 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6878 +"      mulscc  %%g1,%3,%%g1\n"                                         \
6879 +"      mulscc  %%g1,0,%%g1\n"                                          \
6880 +"      add     %%g1,%%o5,%0\n"                                         \
6881 +"      rd      %%y,%1"                                                 \
6882 +          : "=r" ((USItype) (w1)),                                     \
6883 +            "=r" ((USItype) (w0))                                      \
6884 +          : "%rI" ((USItype) (u)),                                     \
6885 +            "r" ((USItype) (v))                                                \
6886 +          : "g1", "o5" __AND_CLOBBER_CC)
6887 +#define UMUL_TIME 39           /* 39 instructions */
6888 +/* It's quite necessary to add this much assembler for the sparc.
6889 +   The default udiv_qrnnd (in C) is more than 10 times slower!  */
6890 +#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
6891 +  __asm__ ("! Inlined udiv_qrnnd\n"                                    \
6892 +"      mov     32,%%g1\n"                                              \
6893 +"      subcc   %1,%2,%%g0\n"                                           \
6894 +"1:    bcs     5f\n"                                                   \
6895 +"       addxcc %0,%0,%0        ! shift n1n0 and a q-bit in lsb\n"      \
6896 +"      sub     %1,%2,%1        ! this kills msb of n\n"                \
6897 +"      addx    %1,%1,%1        ! so this can't give carry\n"           \
6898 +"      subcc   %%g1,1,%%g1\n"                                          \
6899 +"2:    bne     1b\n"                                                   \
6900 +"       subcc  %1,%2,%%g0\n"                                           \
6901 +"      bcs     3f\n"                                                   \
6902 +"       addxcc %0,%0,%0        ! shift n1n0 and a q-bit in lsb\n"      \
6903 +"      b       3f\n"                                                   \
6904 +"       sub    %1,%2,%1        ! this kills msb of n\n"                \
6905 +"4:    sub     %1,%2,%1\n"                                             \
6906 +"5:    addxcc  %1,%1,%1\n"                                             \
6907 +"      bcc     2b\n"                                                   \
6908 +"       subcc  %%g1,1,%%g1\n"                                          \
6909 +"! Got carry from n.  Subtract next step to cancel this carry.\n"      \
6910 +"      bne     4b\n"                                                   \
6911 +"       addcc  %0,%0,%0        ! shift n1n0 and a 0-bit in lsb\n"      \
6912 +"      sub     %1,%2,%1\n"                                             \
6913 +"3:    xnor    %0,0,%0\n"                                              \
6914 +"      ! End of inline udiv_qrnnd"                                     \
6915 +          : "=&r" ((USItype) (__q)),                                   \
6916 +            "=&r" ((USItype) (__r))                                    \
6917 +          : "r" ((USItype) (__d)),                                     \
6918 +            "1" ((USItype) (__n1)),                                    \
6919 +            "0" ((USItype) (__n0)) : "g1" __AND_CLOBBER_CC)
6920 +#define UDIV_TIME (3+7*32)     /* 7 instructions/iteration. 32 iterations.  */
6921 +#endif /* __sparclite__ */
6922 +#endif /* __sparc_v8__ */
6923 +#endif /* sparc32 */
6924 +
6925 +#if ((defined (__sparc__) && defined (__arch64__)) || defined (__sparcv9)) \
6926 +    && W_TYPE_SIZE == 64
6927 +#define add_ssaaaa(sh, sl, ah, al, bh, bl)                             \
6928 +  __asm__ ("addcc %r4,%5,%1\n\t"                                       \
6929 +          "add %r2,%3,%0\n\t"                                          \
6930 +          "bcs,a,pn %%xcc, 1f\n\t"                                     \
6931 +          "add %0, 1, %0\n"                                            \
6932 +          "1:"                                                         \
6933 +          : "=r" ((UDItype)(sh)),                                      \
6934 +            "=&r" ((UDItype)(sl))                                      \
6935 +          : "%rJ" ((UDItype)(ah)),                                     \
6936 +            "rI" ((UDItype)(bh)),                                      \
6937 +            "%rJ" ((UDItype)(al)),                                     \
6938 +            "rI" ((UDItype)(bl))                                       \
6939 +          __CLOBBER_CC)
6940 +
6941 +#define sub_ddmmss(sh, sl, ah, al, bh, bl)                             \
6942 +  __asm__ ("subcc %r4,%5,%1\n\t"                                       \
6943 +          "sub %r2,%3,%0\n\t"                                          \
6944 +          "bcs,a,pn %%xcc, 1f\n\t"                                     \
6945 +          "sub %0, 1, %0\n\t"                                          \
6946 +          "1:"                                                         \
6947 +          : "=r" ((UDItype)(sh)),                                      \
6948 +            "=&r" ((UDItype)(sl))                                      \
6949 +          : "rJ" ((UDItype)(ah)),                                      \
6950 +            "rI" ((UDItype)(bh)),                                      \
6951 +            "rJ" ((UDItype)(al)),                                      \
6952 +            "rI" ((UDItype)(bl))                                       \
6953 +          __CLOBBER_CC)
6954 +
6955 +#define umul_ppmm(wh, wl, u, v)                                                \
6956 +  do {                                                                 \
6957 +         UDItype tmp1, tmp2, tmp3, tmp4;                               \
6958 +         __asm__ __volatile__ (                                        \
6959 +                  "srl %7,0,%3\n\t"                                    \
6960 +                  "mulx %3,%6,%1\n\t"                                  \
6961 +                  "srlx %6,32,%2\n\t"                                  \
6962 +                  "mulx %2,%3,%4\n\t"                                  \
6963 +                  "sllx %4,32,%5\n\t"                                  \
6964 +                  "srl %6,0,%3\n\t"                                    \
6965 +                  "sub %1,%5,%5\n\t"                                   \
6966 +                  "srlx %5,32,%5\n\t"                                  \
6967 +                  "addcc %4,%5,%4\n\t"                                 \
6968 +                  "srlx %7,32,%5\n\t"                                  \
6969 +                  "mulx %3,%5,%3\n\t"                                  \
6970 +                  "mulx %2,%5,%5\n\t"                                  \
6971 +                  "sethi %%hi(0x80000000),%2\n\t"                      \
6972 +                  "addcc %4,%3,%4\n\t"                                 \
6973 +                  "srlx %4,32,%4\n\t"                                  \
6974 +                  "add %2,%2,%2\n\t"                                   \
6975 +                  "movcc %%xcc,%%g0,%2\n\t"                            \
6976 +                  "addcc %5,%4,%5\n\t"                                 \
6977 +                  "sllx %3,32,%3\n\t"                                  \
6978 +                  "add %1,%3,%1\n\t"                                   \
6979 +                  "add %5,%2,%0"                                       \
6980 +          : "=r" ((UDItype)(wh)),                                      \
6981 +            "=&r" ((UDItype)(wl)),                                     \
6982 +            "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4)     \
6983 +          : "r" ((UDItype)(u)),                                        \
6984 +            "r" ((UDItype)(v))                                         \
6985 +          __CLOBBER_CC);                                               \
6986 +  } while (0)
6987 +#define UMUL_TIME 96
6988 +#define UDIV_TIME 230
6989 +#endif /* sparc64 */
6990 +
6991 +#if defined (__vax__) && W_TYPE_SIZE == 32
6992 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6993 +  __asm__ ("addl2 %5,%1\n\tadwc %3,%0"                                 \
6994 +          : "=g" ((USItype) (sh)),                                     \
6995 +            "=&g" ((USItype) (sl))                                     \
6996 +          : "%0" ((USItype) (ah)),                                     \
6997 +            "g" ((USItype) (bh)),                                      \
6998 +            "%1" ((USItype) (al)),                                     \
6999 +            "g" ((USItype) (bl)))
7000 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
7001 +  __asm__ ("subl2 %5,%1\n\tsbwc %3,%0"                                 \
7002 +          : "=g" ((USItype) (sh)),                                     \
7003 +            "=&g" ((USItype) (sl))                                     \
7004 +          : "0" ((USItype) (ah)),                                      \
7005 +            "g" ((USItype) (bh)),                                      \
7006 +            "1" ((USItype) (al)),                                      \
7007 +            "g" ((USItype) (bl)))
7008 +#define umul_ppmm(xh, xl, m0, m1) \
7009 +  do {                                                                 \
7010 +    union {                                                            \
7011 +       UDItype __ll;                                                   \
7012 +       struct {USItype __l, __h;} __i;                                 \
7013 +      } __xx;                                                          \
7014 +    USItype __m0 = (m0), __m1 = (m1);                                  \
7015 +    __asm__ ("emul %1,%2,$0,%0"                                                \
7016 +            : "=r" (__xx.__ll)                                         \
7017 +            : "g" (__m0),                                              \
7018 +              "g" (__m1));                                             \
7019 +    (xh) = __xx.__i.__h;                                               \
7020 +    (xl) = __xx.__i.__l;                                               \
7021 +    (xh) += ((((SItype) __m0 >> 31) & __m1)                            \
7022 +            + (((SItype) __m1 >> 31) & __m0));                         \
7023 +  } while (0)
7024 +#define sdiv_qrnnd(q, r, n1, n0, d) \
7025 +  do {                                                                 \
7026 +    union {DItype __ll;                                                        \
7027 +          struct {SItype __l, __h;} __i;                               \
7028 +         } __xx;                                                       \
7029 +    __xx.__i.__h = n1; __xx.__i.__l = n0;                              \
7030 +    __asm__ ("ediv %3,%2,%0,%1"                                                \
7031 +            : "=g" (q), "=g" (r)                                       \
7032 +            : "g" (__xx.__ll), "g" (d));                               \
7033 +  } while (0)
7034 +#endif /* __vax__ */
7035 +
7036 +#if defined (__z8000__) && W_TYPE_SIZE == 16
7037 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
7038 +  __asm__ ("add        %H1,%H5\n\tadc  %H0,%H3"                                \
7039 +          : "=r" ((unsigned int)(sh)),                                 \
7040 +            "=&r" ((unsigned int)(sl))                                 \
7041 +          : "%0" ((unsigned int)(ah)),                                 \
7042 +            "r" ((unsigned int)(bh)),                                  \
7043 +            "%1" ((unsigned int)(al)),                                 \
7044 +            "rQR" ((unsigned int)(bl)))
7045 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
7046 +  __asm__ ("sub        %H1,%H5\n\tsbc  %H0,%H3"                                \
7047 +          : "=r" ((unsigned int)(sh)),                                 \
7048 +            "=&r" ((unsigned int)(sl))                                 \
7049 +          : "0" ((unsigned int)(ah)),                                  \
7050 +            "r" ((unsigned int)(bh)),                                  \
7051 +            "1" ((unsigned int)(al)),                                  \
7052 +            "rQR" ((unsigned int)(bl)))
7053 +#define umul_ppmm(xh, xl, m0, m1) \
7054 +  do {                                                                 \
7055 +    union {long int __ll;                                              \
7056 +          struct {unsigned int __h, __l;} __i;                         \
7057 +         } __xx;                                                       \
7058 +    unsigned int __m0 = (m0), __m1 = (m1);                             \
7059 +    __asm__ ("mult     %S0,%H3"                                        \
7060 +            : "=r" (__xx.__i.__h),                                     \
7061 +              "=r" (__xx.__i.__l)                                      \
7062 +            : "%1" (__m0),                                             \
7063 +              "rQR" (__m1));                                           \
7064 +    (xh) = __xx.__i.__h; (xl) = __xx.__i.__l;                          \
7065 +    (xh) += ((((signed int) __m0 >> 15) & __m1)                                \
7066 +            + (((signed int) __m1 >> 15) & __m0));                     \
7067 +  } while (0)
7068 +#endif /* __z8000__ */
7069 +
7070 +#endif /* __GNUC__ */
7071 +
7072 +/* If this machine has no inline assembler, use C macros.  */
7073 +
7074 +#if !defined (add_ssaaaa)
7075 +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
7076 +  do {                                                                 \
7077 +    UWtype __x;                                                                \
7078 +    __x = (al) + (bl);                                                 \
7079 +    (sh) = (ah) + (bh) + (__x < (al));                                 \
7080 +    (sl) = __x;                                                                \
7081 +  } while (0)
7082 +#endif
7083 +
7084 +#if !defined (sub_ddmmss)
7085 +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
7086 +  do {                                                                 \
7087 +    UWtype __x;                                                                \
7088 +    __x = (al) - (bl);                                                 \
7089 +    (sh) = (ah) - (bh) - (__x > (al));                                 \
7090 +    (sl) = __x;                                                                \
7091 +  } while (0)
7092 +#endif
7093 +
7094 +/* If we lack umul_ppmm but have smul_ppmm, define umul_ppmm in terms of
7095 +   smul_ppmm.  */
7096 +#if !defined (umul_ppmm) && defined (smul_ppmm)
7097 +#define umul_ppmm(w1, w0, u, v)                                                \
7098 +  do {                                                                 \
7099 +    UWtype __w1;                                                       \
7100 +    UWtype __xm0 = (u), __xm1 = (v);                                   \
7101 +    smul_ppmm (__w1, w0, __xm0, __xm1);                                        \
7102 +    (w1) = __w1 + (-(__xm0 >> (W_TYPE_SIZE - 1)) & __xm1)              \
7103 +               + (-(__xm1 >> (W_TYPE_SIZE - 1)) & __xm0);              \
7104 +  } while (0)
7105 +#endif
7106 +
7107 +/* If we still don't have umul_ppmm, define it using plain C.  */
7108 +#if !defined (umul_ppmm)
7109 +#define umul_ppmm(w1, w0, u, v)                                                \
7110 +  do {                                                                 \
7111 +    UWtype __x0, __x1, __x2, __x3;                                     \
7112 +    UHWtype __ul, __vl, __uh, __vh;                                    \
7113 +                                                                       \
7114 +    __ul = __ll_lowpart (u);                                           \
7115 +    __uh = __ll_highpart (u);                                          \
7116 +    __vl = __ll_lowpart (v);                                           \
7117 +    __vh = __ll_highpart (v);                                          \
7118 +                                                                       \
7119 +    __x0 = (UWtype) __ul * __vl;                                       \
7120 +    __x1 = (UWtype) __ul * __vh;                                       \
7121 +    __x2 = (UWtype) __uh * __vl;                                       \
7122 +    __x3 = (UWtype) __uh * __vh;                                       \
7123 +                                                                       \
7124 +    __x1 += __ll_highpart (__x0);/* this can't give carry */           \
7125 +    __x1 += __x2;              /* but this indeed can */               \
7126 +    if (__x1 < __x2)           /* did we get it? */                    \
7127 +      __x3 += __ll_B;          /* yes, add it in the proper pos.  */   \
7128 +                                                                       \
7129 +    (w1) = __x3 + __ll_highpart (__x1);                                        \
7130 +    (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0);         \
7131 +  } while (0)
7132 +#endif
7133 +
7134 +#if !defined (__umulsidi3)
7135 +#define __umulsidi3(u, v) \
7136 +  ({DWunion __w;                                                       \
7137 +    umul_ppmm (__w.s.high, __w.s.low, u, v);                           \
7138 +    __w.ll; })
7139 +#endif
7140 +
7141 +/* Define this unconditionally, so it can be used for debugging.  */
7142 +#define __udiv_qrnnd_c(q, r, n1, n0, d) \
7143 +  do {                                                                 \
7144 +    UWtype __d1, __d0, __q1, __q0;                                     \
7145 +    UWtype __r1, __r0, __m;                                            \
7146 +    __d1 = __ll_highpart (d);                                          \
7147 +    __d0 = __ll_lowpart (d);                                           \
7148 +                                                                       \
7149 +    __r1 = (n1) % __d1;                                                        \
7150 +    __q1 = (n1) / __d1;                                                        \
7151 +    __m = (UWtype) __q1 * __d0;                                                \
7152 +    __r1 = __r1 * __ll_B | __ll_highpart (n0);                         \
7153 +    if (__r1 < __m)                                                    \
7154 +      {                                                                        \
7155 +       __q1--, __r1 += (d);                                            \
7156 +       if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
7157 +         if (__r1 < __m)                                               \
7158 +           __q1--, __r1 += (d);                                        \
7159 +      }                                                                        \
7160 +    __r1 -= __m;                                                       \
7161 +                                                                       \
7162 +    __r0 = __r1 % __d1;                                                        \
7163 +    __q0 = __r1 / __d1;                                                        \
7164 +    __m = (UWtype) __q0 * __d0;                                                \
7165 +    __r0 = __r0 * __ll_B | __ll_lowpart (n0);                          \
7166 +    if (__r0 < __m)                                                    \
7167 +      {                                                                        \
7168 +       __q0--, __r0 += (d);                                            \
7169 +       if (__r0 >= (d))                                                \
7170 +         if (__r0 < __m)                                               \
7171 +           __q0--, __r0 += (d);                                        \
7172 +      }                                                                        \
7173 +    __r0 -= __m;                                                       \
7174 +                                                                       \
7175 +    (q) = (UWtype) __q1 * __ll_B | __q0;                               \
7176 +    (r) = __r0;                                                                \
7177 +  } while (0)
7178 +
7179 +/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
7180 +   __udiv_w_sdiv (defined in libgcc or elsewhere).  */
7181 +#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
7182 +#define udiv_qrnnd(q, r, nh, nl, d) \
7183 +  do {                                                                 \
7184 +    USItype __r;                                                       \
7185 +    (q) = __udiv_w_sdiv (&__r, nh, nl, d);                             \
7186 +    (r) = __r;                                                         \
7187 +  } while (0)
7188 +#endif
7189 +
7190 +/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c.  */
7191 +#if !defined (udiv_qrnnd)
7192 +#define UDIV_NEEDS_NORMALIZATION 1
7193 +#define udiv_qrnnd __udiv_qrnnd_c
7194 +#endif
7195 +
7196 +#if !defined (count_leading_zeros)
7197 +extern const UQItype __clz_tab[] ATTRIBUTE_HIDDEN;
7198 +#define count_leading_zeros(count, x) \
7199 +  do {                                                                 \
7200 +    UWtype __xr = (x);                                                 \
7201 +    UWtype __a;                                                                \
7202 +                                                                       \
7203 +    if (W_TYPE_SIZE <= 32)                                             \
7204 +      {                                                                        \
7205 +       __a = __xr < ((UWtype)1<<2*__BITS4)                             \
7206 +         ? (__xr < ((UWtype)1<<__BITS4) ? 0 : __BITS4)                 \
7207 +         : (__xr < ((UWtype)1<<3*__BITS4) ?  2*__BITS4 : 3*__BITS4);   \
7208 +      }                                                                        \
7209 +    else                                                               \
7210 +      {                                                                        \
7211 +       for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8)                  \
7212 +         if (((__xr >> __a) & 0xff) != 0)                              \
7213 +           break;                                                      \
7214 +      }                                                                        \
7215 +                                                                       \
7216 +    (count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a);            \
7217 +  } while (0)
7218 +#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
7219 +#endif
7220 +
7221 +#if !defined (count_trailing_zeros)
7222 +/* Define count_trailing_zeros using count_leading_zeros.  The latter might be
7223 +   defined in asm, but if it is not, the C version above is good enough.  */
7224 +#define count_trailing_zeros(count, x) \
7225 +  do {                                                                 \
7226 +    UWtype __ctz_x = (x);                                              \
7227 +    UWtype __ctz_c;                                                    \
7228 +    count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x);                 \
7229 +    (count) = W_TYPE_SIZE - 1 - __ctz_c;                               \
7230 +  } while (0)
7231 +#endif
7232 +
7233 +#ifndef UDIV_NEEDS_NORMALIZATION
7234 +#define UDIV_NEEDS_NORMALIZATION 0
7235 +#endif