diff options
| author | Charles Forsyth <charles.forsyth@gmail.com> | 2015-05-04 13:30:44 +0100 |
|---|---|---|
| committer | Charles Forsyth <charles.forsyth@gmail.com> | 2015-05-04 13:30:44 +0100 |
| commit | 19c1b9563e510e86f2b7b53748f60f8ac761e845 (patch) | |
| tree | 6b2953cb7ff559e6da427530f65bd7d11f147337 /libkern | |
| parent | 237716b91aa163971f7ebe09fbe2e2ea76880a1e (diff) | |
remove 68000 references
Diffstat (limited to 'libkern')
| -rw-r--r-- | libkern/frexp-68000.c | 80 | ||||
| -rw-r--r-- | libkern/getfcr-68000.s | 19 | ||||
| -rw-r--r-- | libkern/memmove-68000.s | 124 | ||||
| -rw-r--r-- | libkern/memset-68000.s | 57 | ||||
| -rw-r--r-- | libkern/mkfile-68000 | 12 | ||||
| -rw-r--r-- | libkern/muldiv-68000.s | 172 | ||||
| -rw-r--r-- | libkern/nan-68000.c | 70 | ||||
| -rw-r--r-- | libkern/strchr-68000.s | 27 | ||||
| -rw-r--r-- | libkern/vlrt-68000.c | 771 |
9 files changed, 0 insertions, 1332 deletions
diff --git a/libkern/frexp-68000.c b/libkern/frexp-68000.c deleted file mode 100644 index ac22e037..00000000 --- a/libkern/frexp-68000.c +++ /dev/null @@ -1,80 +0,0 @@ -#include <u.h> -#include <libc.h> - -#define MASK 0x7ffL -#define SHIFT 20 -#define BIAS 1022L - -typedef union -{ - double d; - struct - { - long ms; - long ls; - }; -} Cheat; - -double -frexp(double d, int *ep) -{ - Cheat x; - - if(d == 0) { - *ep = 0; - return 0; - } - x.d = d; - *ep = ((x.ms >> SHIFT) & MASK) - BIAS; - x.ms &= ~(MASK << SHIFT); - x.ms |= BIAS << SHIFT; - return x.d; -} - -double -ldexp(double d, int e) -{ - Cheat x; - - if(d == 0) - return 0; - x.d = d; - e += (x.ms >> SHIFT) & MASK; - if(e <= 0) - return 0; /* underflow */ - if(e >= MASK){ /* overflow */ - if(d < 0) - return Inf(-1); - return Inf(1); - } - x.ms &= ~(MASK << SHIFT); - x.ms |= (long)e << SHIFT; - return x.d; -} - -double -modf(double d, double *ip) -{ - Cheat x; - int e; - - if(d < 1) { - if(d < 0) { - x.d = modf(-d, ip); - *ip = -*ip; - return -x.d; - } - *ip = 0; - return d; - } - x.d = d; - e = ((x.ms >> SHIFT) & MASK) - BIAS; - if(e <= SHIFT+1) { - x.ms &= ~(0x1fffffL >> e); - x.ls = 0; - } else - if(e <= SHIFT+33) - x.ls &= ~(0x7fffffffL >> (e-SHIFT-2)); - *ip = x.d; - return d - x.d; -} diff --git a/libkern/getfcr-68000.s b/libkern/getfcr-68000.s deleted file mode 100644 index 7f67d038..00000000 --- a/libkern/getfcr-68000.s +++ /dev/null @@ -1,19 +0,0 @@ -TEXT getfsr(SB), $0 - MOVL $0, R0 - MOVL FPSR, R0 - RTS - -TEXT setfsr(SB), $0 - MOVL new+0(FP), R1 - MOVL R1, FPSR - RTS - -TEXT getfcr(SB), $0 - MOVL $0, R0 - MOVL FPCR, R0 - RTS - -TEXT setfcr(SB), $0 - MOVL new+0(FP), R1 - MOVL R1, FPCR - RTS diff --git a/libkern/memmove-68000.s b/libkern/memmove-68000.s deleted file mode 100644 index efb0853e..00000000 --- a/libkern/memmove-68000.s +++ /dev/null @@ -1,124 +0,0 @@ - TEXT memmove(SB), $0 - BRA move - - TEXT memcpy(SB), $0 -move: - - MOVL n+8(FP), R0 /* count */ - BEQ return - BGT ok - MOVL 0, R0 -ok: - MOVL s1+0(FP), A2 /* dest pointer */ - MOVL s2+4(FP), A1 /* source pointer */ - - CMPL A2,A1 - BHI back - -/* - * byte-at-a-time foreward copy to - * get source (A1) alligned. - */ -f1: - MOVL A1, R1 - ANDL $3, R1 - BEQ f2 - SUBL $1, R0 - BLT return - MOVB (A1)+, (A2)+ - BRA f1 - -/* - * check that dest is alligned - * if not, just go byte-at-a-time - */ -f2: - MOVL A2, R1 - ANDL $3, R1 - BEQ f3 - SUBL $1, R0 - BLT return - BRA f5 -/* - * quad-long-at-a-time forward copy - */ -f3: - SUBL $16, R0 - BLT f4 - MOVL (A1)+, (A2)+ - MOVL (A1)+, (A2)+ - MOVL (A1)+, (A2)+ - MOVL (A1)+, (A2)+ - BRA f3 - -/* - * cleanup byte-at-a-time - */ -f4: - ADDL $15, R0 - BLT return -f5: - MOVB (A1)+, (A2)+ - SUBL $1, R0 - BGE f5 - BRA return - -return: - MOVL s1+0(FP),R0 - RTS - -/* - * everything the same, but - * copy backwards - */ -back: - ADDL R0, A1 - ADDL R0, A2 - -/* - * byte-at-a-time backward copy to - * get source (A1) alligned. - */ -b1: - MOVL A1, R1 - ANDL $3, R1 - BEQ b2 - SUBL $1, R0 - BLT return - MOVB -(A1), -(A2) - BRA b1 - -/* - * check that dest is alligned - * if not, just go byte-at-a-time - */ -b2: - MOVL A2, R1 - ANDL $3, R1 - BEQ b3 - SUBL $1, R0 - BLT return - BRA b5 -/* - * quad-long-at-a-time backward copy - */ -b3: - SUBL $16, R0 - BLT b4 - MOVL -(A1), -(A2) - MOVL -(A1), -(A2) - MOVL -(A1), -(A2) - MOVL -(A1), -(A2) - BRA b3 - -/* - * cleanup byte-at-a-time backward - */ -b4: - ADDL $15, R0 - BLT return -b5: - MOVB -(A1), -(A2) - SUBL $1, R0 - BGE b5 - BRA return diff --git a/libkern/memset-68000.s b/libkern/memset-68000.s deleted file mode 100644 index 318f61a7..00000000 --- a/libkern/memset-68000.s +++ /dev/null @@ -1,57 +0,0 @@ - TEXT memset(SB), $0 - MOVL n+8(FP), R0 - BLE return - MOVL s1+0(FP), A1 - CLRL R1 - MOVB c+7(FP), R1 - BEQ l1 - -/* - * create 4 replicated copies - * of the byte in R1 - */ - MOVL R1, R2 - ASLL $8, R2 - ORL R2, R1 - MOVL R1, R2 - SWAP R2 - ORL R2, R1 - -/* - * byte-at-a-time until alligned - */ -l1: - MOVL A1, R1 - ANDL $3, R1 - BEQ l2 - SUBL $1, R0 - BLT return - MOVB R1, (A1)+ - BRA l1 - -/* - * quad-long-at-a-time set - */ -l2: - SUBL $16, R0 - BLT l3 - MOVL R1, (A1)+ - MOVL R1, (A1)+ - MOVL R1, (A1)+ - MOVL R1, (A1)+ - BRA l2 - -/* - * cleanup byte-at-a-time - */ -l3: - ADDL $15, R0 - BLT return -l4: - MOVB R1, (A1)+ - SUBL $1, R0 - BGE l4 - -return: - MOVL s1+0(FP),R0 - RTS diff --git a/libkern/mkfile-68000 b/libkern/mkfile-68000 deleted file mode 100644 index dd5da424..00000000 --- a/libkern/mkfile-68000 +++ /dev/null @@ -1,12 +0,0 @@ -# -# 68000-specific files -# -TARGFILES=\ - frexp-68000.$O\ - getfcr-68000.$O\ - memmove-68000.$O\ - memset-68000.$O\ - nan-68000.$O\ - strchr-68000.$O\ - muldiv-68000.$O\ - vlrt-68000.$O\ diff --git a/libkern/muldiv-68000.s b/libkern/muldiv-68000.s deleted file mode 100644 index 10ef6f46..00000000 --- a/libkern/muldiv-68000.s +++ /dev/null @@ -1,172 +0,0 @@ -/* - * calls _divul with - * absolute value arguments - */ -TEXT _divsl(SB), $0 - MOVL R0, TOS - - MOVL b+4(FP), R0 - BPL y1 - NEGL R0 - MOVL R0, TOS - - MOVL a+0(FP), R0 - BPL y3 - NEGL R0 - MOVL R0, TOS - - /* neg/neg */ - JSR _divul(SB) - MOVL TOS, R0 - MOVL R0, a+0(FP) - MOVL TOS, R0 - NEGL R0 - MOVL R0, b+4(FP) - MOVL TOS, R0 - RTS - -y1: MOVL R0, TOS - - MOVL a+0(FP), R0 - BPL y2 - NEGL R0 - MOVL R0, TOS - - /* neg/pos */ - JSR _divul(SB) - MOVL TOS, R0 - NEGL R0 - MOVL R0, a+0(FP) - MOVL TOS, R0 - NEGL R0 - MOVL R0, b+4(FP) - MOVL TOS, R0 - RTS - -y2: MOVL R0, TOS - - /* pos/pos */ - JSR _divul(SB) - MOVL TOS, R0 - MOVL R0, a+0(FP) - MOVL TOS, R0 - MOVL R0, b+4(FP) - MOVL TOS, R0 - RTS - -y3: MOVL R0, TOS - - /* pos/neg */ - JSR _divul(SB) - MOVL TOS, R0 - NEGL R0 - MOVL R0, a+0(FP) - MOVL TOS, R0 - MOVL R0, b+4(FP) - MOVL TOS, R0 - RTS - -/* - * for(i=1;; i++) { - * if(den & (1<<31)) - * break; - * den <<= 1; - * } - * - * for(; i; i--) { - * quo <<= 1; - * if(num >= den) { - * num -= den; - * quo |= 1; - * } - * den >>= 1; - * } - */ -TEXT _divul(SB), $0 - MOVL R0, TOS /* i */ - MOVL R1, TOS /* num */ - MOVL R2, TOS /* den */ - MOVL R3, TOS /* quo */ - - MOVL $0, R0 - MOVL $0, R3 - MOVL a+0(FP), R1 - MOVL b+4(FP), R2 - BEQ xout - BMI x1 - - ADDL $1, R0 - LSLL $1, R2 - BPL -2(PC) - -x1: LSLL $1, R3 - CMPL R1, R2 - BCS 3(PC) - SUBL R2, R1 - ORL $1, R3 - LSRL $1, R2 - DBMI R0, x1 - - MOVL R3, a+0(FP) - MOVL R1, b+4(FP) - -xout: - MOVL TOS, R3 - MOVL TOS, R2 - MOVL TOS, R1 - MOVL TOS, R0 - RTS - -/* - * x = 0; - * for(i=0; i<32; i++) { - * if(a & 1) - * x += b; - * a >>= 1; - * b <<= 1; - * } - * a = x; - */ -TEXT _mull(SB), $0 - MOVL R0, TOS /* i */ - MOVL R1, TOS /* a */ - MOVL R2, TOS /* b */ - MOVL R3, TOS /* x */ - - MOVL a+0(FP), R1 - MOVL b+4(FP), R2 - MOVL $32, R0 - CLRL R3 - -z1: ROTRL $1, R1 - BCC 2(PC) - ADDL R2, R3 - LSLL $1, R2 - DBEQ R0, z1 - - MOVL R3, b+4(FP) - MOVL TOS, R3 - MOVL TOS, R2 - MOVL TOS, R1 - MOVL TOS, R0 - RTS - -TEXT _ccr(SB), $0 - PEA (A0) - SUBL A0, A0 - - BCC 2(PC) - LEA 1(A0), A0 - - BVC 2(PC) - LEA 2(A0), A0 - - BNE 2(PC) - LEA 4(A0), A0 - - BPL 2(PC) - LEA 8(A0), A0 - - MOVW A0, a+0(FP) - MOVL TOS, A0 - RTS diff --git a/libkern/nan-68000.c b/libkern/nan-68000.c deleted file mode 100644 index e1b3db36..00000000 --- a/libkern/nan-68000.c +++ /dev/null @@ -1,70 +0,0 @@ -#include <u.h> -#include <libc.h> - -#define NANEXP (2047<<20) -#define NANMASK (2047<<20) -#define NANSIGN (1<<31) - -double -NaN(void) -{ - union - { - double d; - long x[2]; - } a; - - a.x[0] = NANEXP; - a.x[1] = 1; - return a.d; -} - -int -isNaN(double d) -{ - union - { - double d; - long x[2]; - } a; - - a.d = d; - if((a.x[0] & NANMASK) != NANEXP) - return 0; - return !isInf(d, 0); -} - -double -Inf(int sign) -{ - union - { - double d; - long x[2]; - } a; - - a.x[0] = NANEXP; - a.x[1] = 0; - if(sign < 0) - a.x[0] |= NANSIGN; - return a.d; -} - -int -isInf(double d, int sign) -{ - union - { - double d; - long x[2]; - } a; - - a.d = d; - if(a.x[1] != 0) - return 0; - if(a.x[0] == NANEXP) - return sign >= 0; - if(a.x[0] == (NANEXP|NANSIGN)) - return sign <= 0; - return 0; -} diff --git a/libkern/strchr-68000.s b/libkern/strchr-68000.s deleted file mode 100644 index a5d4be2c..00000000 --- a/libkern/strchr-68000.s +++ /dev/null @@ -1,27 +0,0 @@ - TEXT strchr(SB), $0 - - MOVL s+0(FP), A0 - MOVB c+7(FP), R2 - BEQ null - -l: - MOVB (A0)+, R1 - BEQ out - CMPB R1, R2 - BNE l - - MOVL A0, R0 - ADDL $-1, R0 - RTS - -out: - CLRL R0 - RTS - -null: - TSTB (A0)+ - BNE null - - MOVL A0, R0 - ADDL $-1, R0 - RTS diff --git a/libkern/vlrt-68000.c b/libkern/vlrt-68000.c deleted file mode 100644 index 071aa180..00000000 --- a/libkern/vlrt-68000.c +++ /dev/null @@ -1,771 +0,0 @@ -typedef unsigned long ulong; -typedef unsigned int uint; -typedef unsigned short ushort; -typedef unsigned char uchar; -typedef signed char schar; - -#define SIGN(n) (1UL<<(n-1)) - -typedef struct Vlong Vlong; -struct Vlong -{ - union - { - struct - { - ulong hi; - ulong lo; - }; - struct - { - ushort hims; - ushort hils; - ushort loms; - ushort lols; - }; - }; -}; - -void abort(void); - -void -_addv(Vlong *r, Vlong a, Vlong b) -{ - ulong lo, hi; - - lo = a.lo + b.lo; - hi = a.hi + b.hi; - if(lo < a.lo) - hi++; - r->lo = lo; - r->hi = hi; -} - -void -_subv(Vlong *r, Vlong a, Vlong b) -{ - ulong lo, hi; - - lo = a.lo - b.lo; - hi = a.hi - b.hi; - if(lo > a.lo) - hi--; - r->lo = lo; - r->hi = hi; -} - -void -_d2v(Vlong *y, double d) -{ - union { double d; struct Vlong; } x; - ulong xhi, xlo, ylo, yhi; - int sh; - - x.d = d; - - xhi = (x.hi & 0xfffff) | 0x100000; - xlo = x.lo; - sh = 1075 - ((x.hi >> 20) & 0x7ff); - - ylo = 0; - yhi = 0; - if(sh >= 0) { - /* v = (hi||lo) >> sh */ - if(sh < 32) { - if(sh == 0) { - ylo = xlo; - yhi = xhi; - } else { - ylo = (xlo >> sh) | (xhi << (32-sh)); - yhi = xhi >> sh; - } - } else { - if(sh == 32) { - ylo = xhi; - } else - if(sh < 64) { - ylo = xhi >> (sh-32); - } - } - } else { - /* v = (hi||lo) << -sh */ - sh = -sh; - if(sh <= 10) { - ylo = xlo << sh; - yhi = (xhi << sh) | (xlo >> (32-sh)); - } else { - /* overflow */ - yhi = d; /* causes something awful */ - } - } - if(x.hi & SIGN(32)) { - if(ylo != 0) { - ylo = -ylo; - yhi = ~yhi; - } else - yhi = -yhi; - } - - y->hi = yhi; - y->lo = ylo; -} - -void -_f2v(Vlong *y, float f) -{ - - _d2v(y, f); -} - -double -_v2d(Vlong x) -{ - if(x.hi & SIGN(32)) { - if(x.lo) { - x.lo = -x.lo; - x.hi = ~x.hi; - } else - x.hi = -x.hi; - return -((long)x.hi*4294967296. + x.lo); - } - return (long)x.hi*4294967296. + x.lo; -} - -float -_v2f(Vlong x) -{ - return _v2d(x); -} - -static void -dodiv(Vlong num, Vlong den, Vlong *q, Vlong *r) -{ - ulong numlo, numhi, denhi, denlo, quohi, quolo, t; - int i; - - numhi = num.hi; - numlo = num.lo; - denhi = den.hi; - denlo = den.lo; - - /* - * get a divide by zero - */ - if(denlo==0 && denhi==0) { - numlo = numlo / denlo; - } - - /* - * set up the divisor and find the number of iterations needed - */ - if(numhi >= SIGN(32)) { - quohi = SIGN(32); - quolo = 0; - } else { - quohi = numhi; - quolo = numlo; - } - i = 0; - while(denhi < quohi || (denhi == quohi && denlo < quolo)) { - denhi = (denhi<<1) | (denlo>>31); - denlo <<= 1; - i++; - } - - quohi = 0; - quolo = 0; - for(; i >= 0; i--) { - quohi = (quohi<<1) | (quolo>>31); - quolo <<= 1; - if(numhi > denhi || (numhi == denhi && numlo >= denlo)) { - t = numlo; - numlo -= denlo; - if(numlo > t) - numhi--; - numhi -= denhi; - quolo |= 1; - } - denlo = (denlo>>1) | (denhi<<31); - denhi >>= 1; - } - - if(q) { - q->lo = quolo; - q->hi = quohi; - } - if(r) { - r->lo = numlo; - r->hi = numhi; - } -} - -void -_divvu(Vlong *q, Vlong n, Vlong d) -{ - - if(n.hi == 0 && d.hi == 0) { - q->hi = 0; - q->lo = n.lo / d.lo; - return; - } - dodiv(n, d, q, 0); -} - -void -_modvu(Vlong *r, Vlong n, Vlong d) -{ - - if(n.hi == 0 && d.hi == 0) { - r->hi = 0; - r->lo = n.lo % d.lo; - return; - } - dodiv(n, d, 0, r); -} - -static void -vneg(Vlong *v) -{ - - if(v->lo == 0) { - v->hi = -v->hi; - return; - } - v->lo = -v->lo; - v->hi = ~v->hi; -} - -void -_divv(Vlong *q, Vlong n, Vlong d) -{ - long nneg, dneg; - - if(n.hi == (((long)n.lo)>>31) && d.hi == (((long)d.lo)>>31)) { - q->lo = (long)n.lo / (long)d.lo; - q->hi = ((long)q->lo) >> 31; - return; - } - nneg = n.hi >> 31; - if(nneg) - vneg(&n); - dneg = d.hi >> 31; - if(dneg) - vneg(&d); - dodiv(n, d, q, 0); - if(nneg != dneg) - vneg(q); -} - -void -_modv(Vlong *r, Vlong n, Vlong d) -{ - long nneg, dneg; - - if(n.hi == (((long)n.lo)>>31) && d.hi == (((long)d.lo)>>31)) { - r->lo = (long)n.lo % (long)d.lo; - r->hi = ((long)r->lo) >> 31; - return; - } - nneg = n.hi >> 31; - if(nneg) - vneg(&n); - dneg = d.hi >> 31; - if(dneg) - vneg(&d); - dodiv(n, d, 0, r); - if(nneg) - vneg(r); -} - -void -_rshav(Vlong *r, Vlong a, int b) -{ - long t; - - t = a.hi; - if(b >= 32) { - r->hi = t>>31; - if(b >= 64) { - /* this is illegal re C standard */ - r->lo = t>>31; - return; - } - r->lo = t >> (b-32); - return; - } - if(b <= 0) { - r->hi = t; - r->lo = a.lo; - return; - } - r->hi = t >> b; - r->lo = (t << (32-b)) | (a.lo >> b); -} - -void -_rshlv(Vlong *r, Vlong a, int b) -{ - ulong t; - - t = a.hi; - if(b >= 32) { - r->hi = 0; - if(b >= 64) { - /* this is illegal re C standard */ - r->lo = 0; - return; - } - r->lo = t >> (b-32); - return; - } - if(b <= 0) { - r->hi = t; - r->lo = a.lo; - return; - } - r->hi = t >> b; - r->lo = (t << (32-b)) | (a.lo >> b); -} - -void -_lshv(Vlong *r, Vlong a, int b) -{ - ulong t; - - t = a.lo; - if(b >= 32) { - r->lo = 0; - if(b >= 64) { - /* this is illegal re C standard */ - r->hi = 0; - return; - } - r->hi = t << (b-32); - return; - } - if(b <= 0) { - r->lo = t; - r->hi = a.hi; - return; - } - r->lo = t << b; - r->hi = (t >> (32-b)) | (a.hi << b); -} - -void -_andv(Vlong *r, Vlong a, Vlong b) -{ - r->hi = a.hi & b.hi; - r->lo = a.lo & b.lo; -} - -void -_orv(Vlong *r, Vlong a, Vlong b) -{ - r->hi = a.hi | b.hi; - r->lo = a.lo | b.lo; -} - -void -_xorv(Vlong *r, Vlong a, Vlong b) -{ - r->hi = a.hi ^ b.hi; - r->lo = a.lo ^ b.lo; -} - -void -_negv(Vlong *r, Vlong a) -{ - if(a.lo == 0) { - r->hi = -a.hi; - r->lo = 0; - return; - } - r->hi = ~a.hi; - r->lo = -a.lo; -} - -void -_vpp(Vlong *l, Vlong *r) -{ - - l->hi = r->hi; - l->lo = r->lo; - r->lo++; - if(r->lo == 0) - r->hi++; -} - -void -_vmm(Vlong *l, Vlong *r) -{ - - l->hi = r->hi; - l->lo = r->lo; - if(r->lo == 0) - r->hi--; - r->lo--; -} - -void -_ppv(Vlong *l, Vlong *r) -{ - - r->lo++; - if(r->lo == 0) - r->hi++; - l->hi = r->hi; - l->lo = r->lo; -} - -void -_mmv(Vlong *l, Vlong *r) -{ - - if(r->lo == 0) - r->hi--; - r->lo--; - l->hi = r->hi; - l->lo = r->lo; -} - -void -_vasop(Vlong *ret, void *lv, void fn(Vlong*, Vlong, Vlong), int type, Vlong rv) -{ - Vlong t, u; - - u = *ret; - switch(type) { - default: - abort(); - break; - - case 1: /* schar */ - t.lo = *(schar*)lv; - t.hi = t.lo >> 31; - fn(&u, t, rv); - *(schar*)lv = u.lo; - break; - - case 2: /* uchar */ - t.lo = *(uchar*)lv; - t.hi = 0; - fn(&u, t, rv); - *(uchar*)lv = u.lo; - break; - - case 3: /* short */ - t.lo = *(short*)lv; - t.hi = t.lo >> 31; - fn(&u, t, rv); - *(short*)lv = u.lo; - break; - - case 4: /* ushort */ - t.lo = *(ushort*)lv; - t.hi = 0; - fn(&u, t, rv); - *(ushort*)lv = u.lo; - break; - - case 9: /* int */ - t.lo = *(int*)lv; - t.hi = t.lo >> 31; - fn(&u, t, rv); - *(int*)lv = u.lo; - break; - - case 10: /* uint */ - t.lo = *(uint*)lv; - t.hi = 0; - fn(&u, t, rv); - *(uint*)lv = u.lo; - break; - - case 5: /* long */ - t.lo = *(long*)lv; - t.hi = t.lo >> 31; - fn(&u, t, rv); - *(long*)lv = u.lo; - break; - - case 6: /* ulong */ - t.lo = *(ulong*)lv; - t.hi = 0; - fn(&u, t, rv); - *(ulong*)lv = u.lo; - break; - - case 7: /* vlong */ - case 8: /* uvlong */ - fn(&u, *(Vlong*)lv, rv); - *(Vlong*)lv = u; - break; - } - *ret = u; -} - -void -_p2v(Vlong *ret, void *p) -{ - long t; - - t = (ulong)p; - ret->lo = t; - ret->hi = 0; -} - -void -_sl2v(Vlong *ret, long sl) -{ - long t; - - t = sl; - ret->lo = t; - ret->hi = t >> 31; -} - -void -_ul2v(Vlong *ret, ulong ul) -{ - long t; - - t = ul; - ret->lo = t; - ret->hi = 0; -} - -void -_si2v(Vlong *ret, int si) -{ - long t; - - t = si; - ret->lo = t; - ret->hi = t >> 31; -} - -void -_ui2v(Vlong *ret, uint ui) -{ - long t; - - t = ui; - ret->lo = t; - ret->hi = 0; -} - -void -_sh2v(Vlong *ret, long sh) -{ - long t; - - t = (sh << 16) >> 16; - ret->lo = t; - ret->hi = t >> 31; -} - -void -_uh2v(Vlong *ret, ulong ul) -{ - long t; - - t = ul & 0xffff; - ret->lo = t; - ret->hi = 0; -} - -void -_sc2v(Vlong *ret, long uc) -{ - long t; - - t = (uc << 24) >> 24; - ret->lo = t; - ret->hi = t >> 31; -} - -void -_uc2v(Vlong *ret, ulong ul) -{ - long t; - - t = ul & 0xff; - ret->lo = t; - ret->hi = 0; -} - -long -_v2sc(Vlong rv) -{ - long t; - - t = rv.lo & 0xff; - return (t << 24) >> 24; -} - -long -_v2uc(Vlong rv) -{ - - return rv.lo & 0xff; -} - -long -_v2sh(Vlong rv) -{ - long t; - - t = rv.lo & 0xffff; - return (t << 16) >> 16; -} - -long -_v2uh(Vlong rv) -{ - - return rv.lo & 0xffff; -} - -long -_v2sl(Vlong rv) -{ - - return rv.lo; -} - -long -_v2ul(Vlong rv) -{ - - return rv.lo; -} - -long -_v2si(Vlong rv) -{ - - return rv.lo; -} - -long -_v2ui(Vlong rv) -{ - - return rv.lo; -} - -int -_testv(Vlong rv) -{ - return rv.lo || rv.hi; -} - -int -_eqv(Vlong lv, Vlong rv) -{ - return lv.lo == rv.lo && lv.hi == rv.hi; -} - -int -_nev(Vlong lv, Vlong rv) -{ - return lv.lo != rv.lo || lv.hi != rv.hi; -} - -int -_ltv(Vlong lv, Vlong rv) -{ - return (long)lv.hi < (long)rv.hi || - (lv.hi == rv.hi && lv.lo < rv.lo); -} - -int -_lev(Vlong lv, Vlong rv) -{ - return (long)lv.hi < (long)rv.hi || - (lv.hi == rv.hi && lv.lo <= rv.lo); -} - -int -_gtv(Vlong lv, Vlong rv) -{ - return (long)lv.hi > (long)rv.hi || - (lv.hi == rv.hi && lv.lo > rv.lo); -} - -int -_gev(Vlong lv, Vlong rv) -{ - return (long)lv.hi > (long)rv.hi || - (lv.hi == rv.hi && lv.lo >= rv.lo); -} - -int -_lov(Vlong lv, Vlong rv) -{ - return lv.hi < rv.hi || - (lv.hi == rv.hi && lv.lo < rv.lo); -} - -int -_lsv(Vlong lv, Vlong rv) -{ - return lv.hi < rv.hi || - (lv.hi == rv.hi && lv.lo <= rv.lo); -} - -int -_hiv(Vlong lv, Vlong rv) -{ - return lv.hi > rv.hi || - (lv.hi == rv.hi && lv.lo > rv.lo); -} - -int -_hsv(Vlong lv, Vlong rv) -{ - return lv.hi > rv.hi || - (lv.hi == rv.hi && lv.lo >= rv.lo); -} - -void -_mulv(Vlong *r, Vlong a, Vlong b) -{ - ulong ahi, alo, chi, clo, x; - int i; - - ahi = a.hi; - alo = a.lo; - chi = 0; - clo = 0; - - x = b.lo; - for(i=0; i<32; i++) { - if(x & 1) { - chi += ahi; - clo += alo; - if(clo < alo) - chi++; - } - ahi <<= 1; - if(alo & SIGN(32)) - ahi += 1; - alo <<= 1; - x >>= 1; - } - - /* - * same, but - * alo is known to be 0 - * can stop when x == 0 - */ - for(x=b.hi; x; x>>=1) { - if(x & 1) - chi += ahi; - ahi <<= 1; - } - - r->hi = chi; - r->lo = clo; -} |
