Merge jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 28 Feb 2016 18:26:18 +0000
branchjv
changeset 19278 00ed0917a8a0
parent 19277 e9182dc00c6d (current diff)
parent 19268 6711c095d091 (diff)
child 19279 a087acbfab39
Merge
LongFloat.st
SmallInteger.st
--- a/LongFloat.st	Sat Feb 27 12:59:25 2016 +0000
+++ b/LongFloat.st	Sun Feb 28 18:26:18 2016 +0000
@@ -34,7 +34,7 @@
 #include <math.h>
 
 /*
- * on some systems errno is a macro ... check for it here
+ * on some systems, errno is a macro ... check for it here
  */
 #ifndef errno
  extern errno;
@@ -48,7 +48,7 @@
 # include <float.h>
 #endif
 
-#if defined(IRIX)
+#if defined(IRIX) || defined(solaris) || defined(sunos)
 # include <nan.h>
 #endif
 
@@ -58,10 +58,6 @@
 # endif
 #endif
 
-#if defined(solaris) || defined(sunos)
-# include <nan.h>
-#endif
-
 #ifdef WIN32
 /*
  * no finite(x) ?
@@ -124,7 +120,7 @@
 # endif
 #endif /* realIX */
 
-#if defined(__GNUC__) || defined(WIN32)
+#if defined(__GNUC__) || defined(__MINGW__) || defined(WIN32)
 # define LONGFLOAT      long double
 
 # if defined(linux) || defined(__osx__) || defined(WIN32)
@@ -385,7 +381,7 @@
     "creates a long double, given the eight native float bytes as an integer"
 
 %{  /* NOCONTEXT */
-    __uint64__  __unsignedLongLongIntVal(OBJ);
+    extern int __unsignedLong64IntVal(OBJ o, __uint64__ *pI);
 
     REGISTER union {
 	__uint64__  u64;
@@ -937,25 +933,25 @@
     LONGFLOAT result, val;
 
     if (__isSmallInteger(aNumber)) {
-        val = (LONGFLOAT)(__intVal(aNumber));
+	val = (LONGFLOAT)(__intVal(aNumber));
 doDiv:
-        result = __longFloatVal(self) / val;
-        __qMKLFLOAT(newFloat, result);
-        RETURN ( newFloat );
+	result = __longFloatVal(self) / val;
+	__qMKLFLOAT(newFloat, result);
+	RETURN ( newFloat );
     }
     if (aNumber != nil) {
-        if (__qIsLongFloat(aNumber)) {
-            val = __longFloatVal(aNumber);
-            goto doDiv;
-        }
-        if (__qIsShortFloat(aNumber)) {
-            val = (LONGFLOAT)(__shortFloatVal(aNumber));
-            goto doDiv;
-        }
-        if (__qIsFloatLike(aNumber)) {
-            val = (LONGFLOAT)(__floatVal(aNumber));
-            goto doDiv;
-        }
+	if (__qIsLongFloat(aNumber)) {
+	    val = __longFloatVal(aNumber);
+	    goto doDiv;
+	}
+	if (__qIsShortFloat(aNumber)) {
+	    val = (LONGFLOAT)(__shortFloatVal(aNumber));
+	    goto doDiv;
+	}
+	if (__qIsFloatLike(aNumber)) {
+	    val = (LONGFLOAT)(__floatVal(aNumber));
+	    goto doDiv;
+	}
     }
 %}.
     ^ aNumber quotientFromLongFloat:self
@@ -1401,43 +1397,43 @@
     OBJ newFloat;
 
     if (__isFloatLike(n)) {
-        __threadErrno = 0;
-        rslt = LONG_pow(__longFloatVal(self), __floatVal(n));
+	__threadErrno = 0;
+	rslt = LONG_pow(__longFloatVal(self), __floatVal(n));
 # ifdef LONG_isnan
-        if (! LONG_isnan(rslt))
+	if (! LONG_isnan(rslt))
 # endif
-        {
-            if (__threadErrno == 0) {
-                __qMKLFLOAT(newFloat, rslt);
-                RETURN ( newFloat );
-            }
-        }
+	{
+	    if (__threadErrno == 0) {
+		__qMKLFLOAT(newFloat, rslt);
+		RETURN ( newFloat );
+	    }
+	}
     }
 #else
     useFallBack = true;
 #endif
 %}.
     useFallBack notNil ifTrue:[
-        ^ super raisedTo:aNumber
+	^ super raisedTo:aNumber
     ].
 
     "/ the c-library pow functin, has a bug:
-    "/ it does not deal correctly with negative numbers. 
+    "/ it does not deal correctly with negative numbers.
     "/ I.e. it raises an error on -8^(1/3) instead of returning a negative -2
     "/ work around with a kludge:
     self < 0 ifTrue:[
-        ^ (self negated raisedTo:n) negated
+	^ (self negated raisedTo:n) negated
     ].
 
     "
      an invalid argument (not convertable to float ?)
     "
     ^ self class
-        raise:#domainErrorSignal
-        receiver:self
-        selector:#raisedTo:
-        arguments:(Array with:aNumber)
-        errorString:'bad receiver/arg in raisedTo:'
+	raise:#domainErrorSignal
+	receiver:self
+	selector:#raisedTo:
+	arguments:(Array with:aNumber)
+	errorString:'bad receiver/arg in raisedTo:'
 
     "Modified: / 16.11.2001 / 14:16:51 / cg"
 !
@@ -2066,12 +2062,12 @@
 %}.
 
     "
-        0.0 asLongFloat positive
-        -0.0 asLongFloat positive
-        1.0 asLongFloat positive
-        -1.0 asLongFloat positive
-        (1.0 uncheckedDivide: 0.0) asLongFloat positive
-        (-1.0 uncheckedDivide: 0.0) asLongFloat positive
+	0.0 asLongFloat positive
+	-0.0 asLongFloat positive
+	1.0 asLongFloat positive
+	-1.0 asLongFloat positive
+	(1.0 uncheckedDivide: 0.0) asLongFloat positive
+	(-1.0 uncheckedDivide: 0.0) asLongFloat positive
     "
 !
 
--- a/SmallInteger.st	Sat Feb 27 12:59:25 2016 +0000
+++ b/SmallInteger.st	Sun Feb 28 18:26:18 2016 +0000
@@ -997,7 +997,7 @@
 #else
     /* anding the tags doesn't change it */
     if (__isSmallInteger(anInteger)) {
-        RETURN ( ((OBJ) (((INT)self & ~(INT)anInteger) | TAG_INT)) );
+	RETURN ( ((OBJ) (((INT)self & ~(INT)anInteger) | TAG_INT)) );
     }
 #endif /* not __SCHTEAM__ */
 %}.
@@ -1212,7 +1212,7 @@
 #endif /* not __SCHTEAM__ */
 %}.
     ^ super bitInvertByte
-    
+
     "
      16r7f bitInvert
      16r7f bitInvertByte
@@ -1875,28 +1875,28 @@
 bitAt:anIntegerIndex
     "return the value of the index's bit (index starts at 1) as 0 or 1.
      Notice: the result of bitAt: on negative receivers is not
-             defined in the language standard (since the implementation
-             is free to choose any internal representation for integers)"
+	     defined in the language standard (since the implementation
+	     is free to choose any internal representation for integers)"
 
 %{  /* NOCONTEXT */
 #ifdef __SCHTEAM__
     return context._RETURN( self.bitAt(anIntegerIndex));
 #else
     if (__isSmallInteger(anIntegerIndex)) {
-        INT idx = __smallIntegerVal(anIntegerIndex);
-        if (idx > 0) {
-            if (idx > N_INT_BITS) {
-                RETURN(__mkSmallInteger(0));
-            }
-            RETURN((__smallIntegerVal(self) & ((INT)1 << (idx-1))) ? __mkSmallInteger(1) : __mkSmallInteger(0));
-        }
+	INT idx = __smallIntegerVal(anIntegerIndex);
+	if (idx > 0) {
+	    if (idx > N_INT_BITS) {
+		RETURN(__mkSmallInteger(0));
+	    }
+	    RETURN((__smallIntegerVal(self) & ((INT)1 << (idx-1))) ? __mkSmallInteger(1) : __mkSmallInteger(0));
+	}
     }
 #endif /* not __SCHTEAM__ */
 %}.
 
     ^ SubscriptOutOfBoundsError
-            raiseRequestWith:anIntegerIndex
-            errorString:'index out of bounds'
+	    raiseRequestWith:anIntegerIndex
+	    errorString:'index out of bounds'
 
     "
      16r000000001 bitAt:0 -> error
@@ -1916,9 +1916,9 @@
     |mask|
 
     anIntegerIndex <= 0 ifTrue:[
-        ^ SubscriptOutOfBoundsSignal
-                raiseRequestWith:anIntegerIndex
-                errorString:'index out of bounds'
+	^ SubscriptOutOfBoundsSignal
+		raiseRequestWith:anIntegerIndex
+		errorString:'index out of bounds'
     ].
     (anIntegerIndex > SmallInteger maxBits) ifTrue:[^ 0].
     mask := 1 bitShift:(anIntegerIndex - 1).
@@ -1936,21 +1936,21 @@
 %{  /* NOCONTEXT */
 #ifndef __SCHTEAM__
     if (__isSmallInteger(anInteger)) {
-        int index = __intVal(anInteger);
-
-        if (index > 0) {
+	int index = __intVal(anInteger);
+
+	if (index > 0) {
 # if __POINTER_SIZE__ == 8
-            if (index <= 62)
+	    if (index <= 62)
 # else
-            if (index <= 30)
+	    if (index <= 30)
 # endif
-            {
-                INT mask = __MASKSMALLINT( ((INT)1 << (index-1)));
-
-                RETURN ( ((OBJ) ((INT)self & ~(INT)mask)) );
-            }
-            RETURN (self);  /* nothing to do ... */
-        }
+	    {
+		INT mask = __MASKSMALLINT( ((INT)1 << (index-1)));
+
+		RETURN ( ((OBJ) ((INT)self & ~(INT)mask)) );
+	    }
+	    RETURN (self);  /* nothing to do ... */
+	}
     }
 #endif /* not __SCHTEAM__ */
 %}.
@@ -1984,20 +1984,20 @@
 %{  /* NOCONTEXT */
 #ifndef __SCHTEAM__
     if (__isSmallInteger(anInteger)) {
-        int index = __intVal(anInteger);
-
-        if (index > 0) {
+	int index = __intVal(anInteger);
+
+	if (index > 0) {
 # if __POINTER_SIZE__ == 8
-            if (index <= 62)
+	    if (index <= 62)
 # else
-            if (index <= 30)
+	    if (index <= 30)
 # endif
-            {
-                INT mask = __MASKSMALLINT((INT)1 << (index-1));
-
-                RETURN ( ((OBJ) ((INT)self ^ (INT)mask)) );
-            }
-        }
+	    {
+		INT mask = __MASKSMALLINT((INT)1 << (index-1));
+
+		RETURN ( ((OBJ) ((INT)self ^ (INT)mask)) );
+	    }
+	}
     }
 #endif /* not __SCHTEAM__ */
 %}.
@@ -2026,20 +2026,20 @@
 %{  /* NOCONTEXT */
 #ifndef __SCHTEAM__
     if (__isSmallInteger(anInteger)) {
-        int index = __intVal(anInteger);
-
-        if (index > 0) {
+	int index = __intVal(anInteger);
+
+	if (index > 0) {
 # if __POINTER_SIZE__ == 8
-            if (index <= 62)
+	    if (index <= 62)
 # else
-            if (index <= 30)
+	    if (index <= 30)
 # endif
-            {
-                INT mask = __MASKSMALLINT((INT)1 << (index-1));
-
-                RETURN ( ((OBJ) ((INT)self | (INT)mask)) );
-            }
-        }
+	    {
+		INT mask = __MASKSMALLINT((INT)1 << (index-1));
+
+		RETURN ( ((OBJ) ((INT)self | (INT)mask)) );
+	    }
+	}
     }
 #endif /* not __SCHTEAM__ */
 %}.
@@ -2118,31 +2118,31 @@
 #   define HAVE_BSWAP
 
     _asm {
-        mov eax, v
-        bswap eax
-        mov swapped, eax
+	mov eax, v
+	bswap eax
+	mov swapped, eax
     };
 #  endif
 #  if defined(USE_BSWAP) && defined(__VISUALC__)
 #   define HAVE_BSWAP
 
     _asm {
-        mov eax, v
-        xchg al, ah
-        rol eax, 16
-        xchg al, ah
-        mov swapped, eax
+	mov eax, v
+	xchg al, ah
+	rol eax, 16
+	xchg al, ah
+	mov swapped, eax
     };
 #  endif
 #  if defined(USE_BSWAP) && defined(__GNUC__)
 #   define HAVE_BSWAP
 
     asm("movl %1, %%eax \n\
-         bswap %%eax    \n\
-         movl %%eax, %0 \n\
-        "
-        : "=rm"  (swapped)
-        : "rm"   (v));
+	 bswap %%eax    \n\
+	 movl %%eax, %0 \n\
+	"
+	: "=rm"  (swapped)
+	: "rm"   (v));
 #  endif
 # endif /* __POINTER_SIZE__ == 4 */
 
@@ -2153,11 +2153,11 @@
 #   define HAVE_BSWAP
 
     asm("movq %1, %%rax \n\
-         bswap %%eax    \n\
-         movq %%rax, %0 \n\
-        "
-        : "=rm"  (swapped)
-        : "rm"   (v));
+	 bswap %%eax    \n\
+	 movq %%rax, %0 \n\
+	"
+	: "=rm"  (swapped)
+	: "rm"   (v));
 #  endif
 # endif
 
@@ -2854,8 +2854,8 @@
 #ifndef __SCHTEAM__
     INT i = __intVal(self);
 
-    if (i & 0x800000) {
-	i = i | ~0xFFFFFFL;
+    if (i & 0x800000L) {
+	i = i | ~((INT)0xFFFFFF);
     } else {
 	i = i & 0x7FFFFF;
     }
@@ -2881,7 +2881,7 @@
     INT i = __intVal(self);
 
     if (i & 0x80) {
-	i = i | ~0xFFL;
+	i = i | ~((INT)0xFF);
     } else {
 	i = i & 0x7F;
     }
@@ -2906,21 +2906,21 @@
 #ifndef __SCHTEAM__
     INT i = __intVal(self);
 
-    if (i & 0x80000000) {
-	i = i | ~0xFFFFFFFFL;
+    if (i & 0x80000000L) {
+	i = i | ~((INT)0xFFFFFFFF);
     } else {
-	i = i & 0x7FFFFFFF;
+	i = i & 0x7FFFFFFFL;
     }
 
-    RETURN (__mkSmallInteger(i));
+    RETURN (__MKINT(i));
 #endif
 %}.
     ^ self primitiveFailed
 
     "
-     16rFFFFFFFF signExtendedLongValue
-     16r80000000 signExtendedLongValue
-     16r7FFFFFFF signExtendedLongValue
+     16rFFFFFFFF signExtendedLongValue -> -1
+     16r80000000 signExtendedLongValue -> -2147483648
+     16r7FFFFFFF signExtendedLongValue -> 2147483647
     "
 !
 
@@ -2933,7 +2933,7 @@
     INT i = __intVal(self);
 
     if (i & 0x8000) {
-	i = i | ~0xFFFFL;
+	i = i | ~((INT)0xFFFF);
     } else {
 	i = i & 0x7FFF;
     }
@@ -5160,7 +5160,7 @@
     "return the power of 2 at or above the receiver.
      Useful for padding.
      Notice, that for a powerOf2, the receiver is returned.
-     Also notice, that (because it is used for padding), 
+     Also notice, that (because it is used for padding),
      0 is returned for zero."
 
 %{  /* NOCONTEXT */