~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to mp/mp_divul3_word.c

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*          Copyright (C) 1994 W. Schelter
 
3
 
 
4
This file is part of GNU Common Lisp, herein referred to as GCL
 
5
 
 
6
GCL is free software; you can redistribute it and/or modify it under
 
7
the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE as published by
 
8
the Free Software Foundation; either version 2, or (at your option)
 
9
any later version.
 
10
 
 
11
GCL is distributed in the hope that it will be useful, but WITHOUT
 
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
13
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
14
for more details.
 
15
 
 
16
You should have received a copy of the GNU library general public
 
17
license along with GCL; see the file COPYING.  If not, write to the
 
18
Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
*/
 
20
 
 
21
#include "include.h"
 
22
#include "arith.h"
 
23
 
 
24
 
 
25
 
 
26
our_ulong
 
27
divul3(x,y,hi)
 
28
     our_ulong x,y,*hi;
 
29
{
 
30
#define HIBIT 0x80000000
 
31
#define HIMASK 0xffff0000
 
32
#define LOMASK 0xffff
 
33
#define HIWORD(a) (a >> 16)
 
34
/* si le compilateur est bugge, il faut mettre (a >> 16) & LOMASK) */
 
35
#define LOWORD(a) (a & LOMASK)
 
36
#define GLUE(hi, lo) ((hi << 16) + lo)
 
37
#define SPLIT(a, b, c) b = HIWORD(a); c = LOWORD(a)
 
38
 
 
39
    our_ulong v1, v2, u3, u4, q1, q2, aux, aux1, aux2,hiremainder=*hi;
 
40
    int k;
 
41
    
 
42
    for(k = 0; !(y & HIBIT); k++)
 
43
        {
 
44
            hiremainder <<= 1;
 
45
            if (x & HIBIT) hiremainder++;
 
46
            x <<= 1;
 
47
            y <<= 1;
 
48
        }
 
49
        
 
50
    SPLIT(y, v1, v2);
 
51
    SPLIT(x, u3, u4);
 
52
    
 
53
    q1 = hiremainder / v1; if (q1 & HIMASK) q1 = LOMASK;
 
54
    hiremainder -= q1 * v1;
 
55
    aux = v2 * q1;
 
56
again:
 
57
    SPLIT(aux, aux1, aux2);
 
58
    if (aux2 > u3) aux1++;
 
59
    if (aux1 > hiremainder) {q1--; hiremainder += v1; aux -= v2; goto again;}
 
60
    u3 -= aux2;
 
61
    hiremainder -= aux1;
 
62
    hiremainder <<= 16; hiremainder += u3 & LOMASK;
 
63
    
 
64
    q2 = hiremainder / v1; if (q2 & HIMASK) q2 = LOMASK;
 
65
    hiremainder -= q2 * v1;
 
66
    aux = v2 * q2;
 
67
again2:
 
68
    SPLIT(aux, aux1, aux2);
 
69
    if (aux2 > u4) aux1++;
 
70
    if (aux1 > hiremainder) {q2--; hiremainder += v1; aux -= v2; goto again2;}
 
71
    u4 -= aux2;
 
72
    hiremainder -= aux1;
 
73
    hiremainder <<= 16; hiremainder += u4 & LOMASK;
 
74
    hiremainder >>= k;
 
75
    *hi = hiremainder;
 
76
    return GLUE(q1, q2);
 
77
}
 
78
 
 
79
 
 
80