no floating point in the kernel, also make sure we always return an int

This commit is contained in:
mbalmer 2015-10-11 09:21:15 +00:00
parent 339173929c
commit fd3d11729f
1 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: lvm.c,v 1.7 2015/10/08 13:40:16 mbalmer Exp $ */ /* $NetBSD: lvm.c,v 1.8 2015/10/11 09:21:15 mbalmer Exp $ */
/* /*
** Id: lvm.c,v 2.245 2015/06/09 15:53:35 roberto Exp ** Id: lvm.c,v 2.245 2015/06/09 15:53:35 roberto Exp
@ -315,16 +315,17 @@ static int LEintfloat (lua_Integer i, lua_Number f) {
** Return 'l < r', for numbers. ** Return 'l < r', for numbers.
*/ */
static int LTnum (const TValue *l, const TValue *r) { static int LTnum (const TValue *l, const TValue *r) {
#ifdef _KERNEL
lua_Integer li = ivalue(l);
return li < ivalue(r); /* both must be integers */
#else
if (ttisinteger(l)) { if (ttisinteger(l)) {
lua_Integer li = ivalue(l); lua_Integer li = ivalue(l);
if (ttisinteger(r)) if (ttisinteger(r))
return li < ivalue(r); /* both are integers */ return li < ivalue(r); /* both are integers */
#ifndef _KERNEL
else /* 'l' is int and 'r' is float */ else /* 'l' is int and 'r' is float */
return LTintfloat(li, fltvalue(r)); /* l < r ? */ return LTintfloat(li, fltvalue(r)); /* l < r ? */
#endif
} }
#ifndef _KERNEL
else { else {
lua_Number lf = fltvalue(l); /* 'l' must be float */ lua_Number lf = fltvalue(l); /* 'l' must be float */
if (ttisfloat(r)) if (ttisfloat(r))
@ -342,16 +343,17 @@ static int LTnum (const TValue *l, const TValue *r) {
** Return 'l <= r', for numbers. ** Return 'l <= r', for numbers.
*/ */
static int LEnum (const TValue *l, const TValue *r) { static int LEnum (const TValue *l, const TValue *r) {
#ifdef _KERNEL
lua_Integer li = ivalue(l);
return li <= ivalue(r); /* both must be integers */
#else
if (ttisinteger(l)) { if (ttisinteger(l)) {
lua_Integer li = ivalue(l); lua_Integer li = ivalue(l);
if (ttisinteger(r)) if (ttisinteger(r))
return li <= ivalue(r); /* both are integers */ return li <= ivalue(r); /* both are integers */
#ifndef _KERNEL
else /* 'l' is int and 'r' is float */ else /* 'l' is int and 'r' is float */
return LEintfloat(li, fltvalue(r)); /* l <= r ? */ return LEintfloat(li, fltvalue(r)); /* l <= r ? */
#endif
} }
#ifndef _KERNEL
else { else {
lua_Number lf = fltvalue(l); /* 'l' must be float */ lua_Number lf = fltvalue(l); /* 'l' must be float */
if (ttisfloat(r)) if (ttisfloat(r))