2009-06-10 12:53:07 -06:00
|
|
|
// Inferno's libkern/vlrt-arm.c
|
|
|
|
// http://code.google.com/p/inferno-os/source/browse/libkern/vlrt-arm.c
|
|
|
|
//
|
|
|
|
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
|
|
|
|
// Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved.
|
|
|
|
// Portions Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
// declared here to avoid include of runtime.h
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·panicstring(char*);
|
2010-08-06 17:57:49 -06:00
|
|
|
|
2009-06-10 12:53:07 -06:00
|
|
|
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))
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicdivide(void)
|
2010-08-06 17:57:49 -06:00
|
|
|
{
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("integer divide by zero");
|
2010-08-06 17:57:49 -06:00
|
|
|
}
|
|
|
|
|
2009-06-10 12:53:07 -06:00
|
|
|
typedef struct Vlong Vlong;
|
|
|
|
struct Vlong
|
|
|
|
{
|
2009-10-12 14:35:28 -06:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ulong lo;
|
|
|
|
ulong hi;
|
|
|
|
};
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ushort lols;
|
|
|
|
ushort loms;
|
|
|
|
ushort hils;
|
|
|
|
ushort hims;
|
2010-08-06 17:57:49 -06:00
|
|
|
};
|
|
|
|
};
|
2009-06-10 12:53:07 -06:00
|
|
|
};
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·abort(void);
|
2009-06-10 12:53:07 -06:00
|
|
|
|
|
|
|
void
|
|
|
|
_addv(Vlong *r, Vlong a, Vlong b)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
ulong lo, hi;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
lo = a.lo + b.lo;
|
|
|
|
hi = a.hi + b.hi;
|
|
|
|
if(lo < a.lo)
|
|
|
|
hi++;
|
|
|
|
r->lo = lo;
|
|
|
|
r->hi = hi;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_subv(Vlong *r, Vlong a, Vlong b)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
ulong lo, hi;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
lo = a.lo - b.lo;
|
|
|
|
hi = a.hi - b.hi;
|
|
|
|
if(lo > a.lo)
|
|
|
|
hi--;
|
|
|
|
r->lo = lo;
|
|
|
|
r->hi = hi;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_d2v(Vlong *y, double d)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
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;
|
2010-11-11 20:54:35 -07:00
|
|
|
if(sh <= 11) {
|
2010-08-06 17:57:49 -06:00
|
|
|
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;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_f2v(Vlong *y, float f)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
_d2v(y, f);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
2009-10-10 23:06:26 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·float64toint64(double d, Vlong y)
|
2009-10-10 23:06:26 -06:00
|
|
|
{
|
|
|
|
_d2v(&y, d);
|
|
|
|
}
|
|
|
|
|
2010-11-11 20:54:35 -07:00
|
|
|
void
|
|
|
|
runtime·float64touint64(double d, Vlong y)
|
|
|
|
{
|
|
|
|
_d2v(&y, d);
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
_ul2d(ulong u)
|
|
|
|
{
|
|
|
|
// compensate for bug in c
|
|
|
|
if(u & SIGN(32)) {
|
|
|
|
u ^= SIGN(32);
|
|
|
|
return 2147483648. + u;
|
|
|
|
}
|
|
|
|
return u;
|
|
|
|
}
|
|
|
|
|
2009-06-10 12:53:07 -06:00
|
|
|
double
|
|
|
|
_v2d(Vlong x)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
if(x.hi & SIGN(32)) {
|
|
|
|
if(x.lo) {
|
|
|
|
x.lo = -x.lo;
|
|
|
|
x.hi = ~x.hi;
|
|
|
|
} else
|
|
|
|
x.hi = -x.hi;
|
2010-11-11 20:54:35 -07:00
|
|
|
return -(_ul2d(x.hi)*4294967296. + _ul2d(x.lo));
|
2010-08-06 17:57:49 -06:00
|
|
|
}
|
2010-11-11 20:54:35 -07:00
|
|
|
return x.hi*4294967296. + _ul2d(x.lo);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
_v2f(Vlong x)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return _v2d(x);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
2009-10-10 23:06:26 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·int64tofloat64(Vlong y, double d)
|
2009-10-10 23:06:26 -06:00
|
|
|
{
|
|
|
|
d = _v2d(y);
|
2012-05-04 11:39:09 -06:00
|
|
|
USED(&d); // FLUSH
|
2009-10-10 23:06:26 -06:00
|
|
|
}
|
|
|
|
|
2010-11-11 20:54:35 -07:00
|
|
|
void
|
|
|
|
runtime·uint64tofloat64(Vlong y, double d)
|
|
|
|
{
|
|
|
|
d = _ul2d(y.hi)*4294967296. + _ul2d(y.lo);
|
2012-05-04 11:39:09 -06:00
|
|
|
USED(&d); // FLUSH
|
2010-11-11 20:54:35 -07:00
|
|
|
}
|
2009-10-10 23:06:26 -06:00
|
|
|
|
2009-06-10 12:53:07 -06:00
|
|
|
static void
|
|
|
|
dodiv(Vlong num, Vlong den, Vlong *q, Vlong *r)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
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) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicdivide();
|
2010-08-06 17:57:49 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_divvu(Vlong *q, Vlong n, Vlong d)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
if(n.hi == 0 && d.hi == 0) {
|
|
|
|
q->hi = 0;
|
|
|
|
q->lo = n.lo / d.lo;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dodiv(n, d, q, 0);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
2009-10-06 20:00:30 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·uint64div(Vlong n, Vlong d, Vlong q)
|
2009-10-06 20:00:30 -06:00
|
|
|
{
|
|
|
|
_divvu(&q, n, d);
|
|
|
|
}
|
|
|
|
|
2009-06-10 12:53:07 -06:00
|
|
|
void
|
|
|
|
_modvu(Vlong *r, Vlong n, Vlong d)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
if(n.hi == 0 && d.hi == 0) {
|
|
|
|
r->hi = 0;
|
|
|
|
r->lo = n.lo % d.lo;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dodiv(n, d, 0, r);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
2009-10-06 20:00:30 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·uint64mod(Vlong n, Vlong d, Vlong q)
|
2009-10-06 20:00:30 -06:00
|
|
|
{
|
|
|
|
_modvu(&q, n, d);
|
|
|
|
}
|
|
|
|
|
2009-06-10 12:53:07 -06:00
|
|
|
static void
|
|
|
|
vneg(Vlong *v)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
if(v->lo == 0) {
|
|
|
|
v->hi = -v->hi;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
v->lo = -v->lo;
|
|
|
|
v->hi = ~v->hi;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_divv(Vlong *q, Vlong n, Vlong d)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long nneg, dneg;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
if(n.hi == (((long)n.lo)>>31) && d.hi == (((long)d.lo)>>31)) {
|
2009-10-15 20:41:51 -06:00
|
|
|
if((long)n.lo == -0x80000000 && (long)d.lo == -1) {
|
|
|
|
// special case: 32-bit -0x80000000 / -1 causes wrong sign
|
|
|
|
q->lo = 0x80000000;
|
|
|
|
q->hi = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
q->lo = (long)n.lo / (long)d.lo;
|
|
|
|
q->hi = ((long)q->lo) >> 31;
|
|
|
|
return;
|
2010-08-06 17:57:49 -06:00
|
|
|
}
|
|
|
|
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);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
2009-10-06 20:00:30 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·int64div(Vlong n, Vlong d, Vlong q)
|
2009-10-06 20:00:30 -06:00
|
|
|
{
|
|
|
|
_divv(&q, n, d);
|
|
|
|
}
|
|
|
|
|
2009-06-10 12:53:07 -06:00
|
|
|
void
|
|
|
|
_modv(Vlong *r, Vlong n, Vlong d)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long nneg, dneg;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
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);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
2009-10-06 20:00:30 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·int64mod(Vlong n, Vlong d, Vlong q)
|
2009-10-06 20:00:30 -06:00
|
|
|
{
|
|
|
|
_modv(&q, n, d);
|
|
|
|
}
|
|
|
|
|
2009-06-10 12:53:07 -06:00
|
|
|
void
|
|
|
|
_rshav(Vlong *r, Vlong a, int b)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
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);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_rshlv(Vlong *r, Vlong a, int b)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
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);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_lshv(Vlong *r, Vlong a, int b)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
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);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_andv(Vlong *r, Vlong a, Vlong b)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
r->hi = a.hi & b.hi;
|
|
|
|
r->lo = a.lo & b.lo;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_orv(Vlong *r, Vlong a, Vlong b)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
r->hi = a.hi | b.hi;
|
|
|
|
r->lo = a.lo | b.lo;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_xorv(Vlong *r, Vlong a, Vlong b)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
r->hi = a.hi ^ b.hi;
|
|
|
|
r->lo = a.lo ^ b.lo;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_vpp(Vlong *l, Vlong *r)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
l->hi = r->hi;
|
|
|
|
l->lo = r->lo;
|
|
|
|
r->lo++;
|
|
|
|
if(r->lo == 0)
|
|
|
|
r->hi++;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_vmm(Vlong *l, Vlong *r)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
l->hi = r->hi;
|
|
|
|
l->lo = r->lo;
|
|
|
|
if(r->lo == 0)
|
|
|
|
r->hi--;
|
|
|
|
r->lo--;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_ppv(Vlong *l, Vlong *r)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
r->lo++;
|
|
|
|
if(r->lo == 0)
|
|
|
|
r->hi++;
|
|
|
|
l->hi = r->hi;
|
|
|
|
l->lo = r->lo;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_mmv(Vlong *l, Vlong *r)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
if(r->lo == 0)
|
|
|
|
r->hi--;
|
|
|
|
r->lo--;
|
|
|
|
l->hi = r->hi;
|
|
|
|
l->lo = r->lo;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_vasop(Vlong *ret, void *lv, void fn(Vlong*, Vlong, Vlong), int type, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
Vlong t, u;
|
|
|
|
|
|
|
|
u = *ret;
|
|
|
|
switch(type) {
|
|
|
|
default:
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·abort();
|
2010-08-06 17:57:49 -06:00
|
|
|
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;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_p2v(Vlong *ret, void *p)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = (ulong)p;
|
|
|
|
ret->lo = t;
|
|
|
|
ret->hi = 0;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_sl2v(Vlong *ret, long sl)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = sl;
|
|
|
|
ret->lo = t;
|
|
|
|
ret->hi = t >> 31;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_ul2v(Vlong *ret, ulong ul)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = ul;
|
|
|
|
ret->lo = t;
|
|
|
|
ret->hi = 0;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_si2v(Vlong *ret, int si)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = si;
|
|
|
|
ret->lo = t;
|
|
|
|
ret->hi = t >> 31;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_ui2v(Vlong *ret, uint ui)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = ui;
|
|
|
|
ret->lo = t;
|
|
|
|
ret->hi = 0;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_sh2v(Vlong *ret, long sh)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = (sh << 16) >> 16;
|
|
|
|
ret->lo = t;
|
|
|
|
ret->hi = t >> 31;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_uh2v(Vlong *ret, ulong ul)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = ul & 0xffff;
|
|
|
|
ret->lo = t;
|
|
|
|
ret->hi = 0;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_sc2v(Vlong *ret, long uc)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = (uc << 24) >> 24;
|
|
|
|
ret->lo = t;
|
|
|
|
ret->hi = t >> 31;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_uc2v(Vlong *ret, ulong ul)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = ul & 0xff;
|
|
|
|
ret->lo = t;
|
|
|
|
ret->hi = 0;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
long
|
|
|
|
_v2sc(Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = rv.lo & 0xff;
|
|
|
|
return (t << 24) >> 24;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
long
|
|
|
|
_v2uc(Vlong rv)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
return rv.lo & 0xff;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
long
|
|
|
|
_v2sh(Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
long t;
|
2009-06-10 12:53:07 -06:00
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
t = rv.lo & 0xffff;
|
|
|
|
return (t << 16) >> 16;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
long
|
|
|
|
_v2uh(Vlong rv)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
return rv.lo & 0xffff;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
long
|
|
|
|
_v2sl(Vlong rv)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
return rv.lo;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
long
|
|
|
|
_v2ul(Vlong rv)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
return rv.lo;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
long
|
|
|
|
_v2si(Vlong rv)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
return rv.lo;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
long
|
|
|
|
_v2ui(Vlong rv)
|
|
|
|
{
|
|
|
|
|
2010-08-06 17:57:49 -06:00
|
|
|
return rv.lo;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_testv(Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return rv.lo || rv.hi;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_eqv(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return lv.lo == rv.lo && lv.hi == rv.hi;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_nev(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return lv.lo != rv.lo || lv.hi != rv.hi;
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_ltv(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return (long)lv.hi < (long)rv.hi ||
|
|
|
|
(lv.hi == rv.hi && lv.lo < rv.lo);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_lev(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return (long)lv.hi < (long)rv.hi ||
|
|
|
|
(lv.hi == rv.hi && lv.lo <= rv.lo);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_gtv(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return (long)lv.hi > (long)rv.hi ||
|
|
|
|
(lv.hi == rv.hi && lv.lo > rv.lo);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_gev(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return (long)lv.hi > (long)rv.hi ||
|
|
|
|
(lv.hi == rv.hi && lv.lo >= rv.lo);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_lov(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return lv.hi < rv.hi ||
|
|
|
|
(lv.hi == rv.hi && lv.lo < rv.lo);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_lsv(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return lv.hi < rv.hi ||
|
|
|
|
(lv.hi == rv.hi && lv.lo <= rv.lo);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_hiv(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return lv.hi > rv.hi ||
|
|
|
|
(lv.hi == rv.hi && lv.lo > rv.lo);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_hsv(Vlong lv, Vlong rv)
|
|
|
|
{
|
2010-08-06 17:57:49 -06:00
|
|
|
return lv.hi > rv.hi ||
|
|
|
|
(lv.hi == rv.hi && lv.lo >= rv.lo);
|
2009-06-10 12:53:07 -06:00
|
|
|
}
|