All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
@ 2017-11-23 16:35 Laurent Vivier
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 1/5] softfloat: add floatx80_mod() Laurent Vivier
                   ` (7 more replies)
  0 siblings, 8 replies; 22+ messages in thread
From: Laurent Vivier @ 2017-11-23 16:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Aurelien Jarno, Richard Henderson, Laurent Vivier

Implement fmod, frem, fscale, fgetman and fgetexp.

Instead of using functions of libm (v1 of this series)
and converting between host long double and floatx80 type
the new version (v2) adds new floatx80 functions in softfloat.

All the floatx80 functions are copied from "Previous",
the NeXT Computer Emulator, and written by Andreas Grabher.

Laurent Vivier (5):
  softfloat: add floatx80_mod()
  target/m68k: add fmod/frem
  softfloat: use floatx80_infinity in softfloat
  softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale()
  target-m68k: add fscale, fgetman and fgetexp

 fpu/softfloat-specialize.h |  29 +++++
 fpu/softfloat.c            | 258 ++++++++++++++++++++++++++++++++++++++++++---
 include/fpu/softfloat.h    |  13 ++-
 target/m68k/cpu.h          |   1 +
 target/m68k/fpu_helper.c   |  48 +++++++++
 target/m68k/helper.h       |   5 +
 target/m68k/translate.c    |  15 +++
 7 files changed, 355 insertions(+), 14 deletions(-)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 1/5] softfloat: add floatx80_mod()
  2017-11-23 16:35 [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Laurent Vivier
@ 2017-11-23 16:35 ` Laurent Vivier
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 2/5] target/m68k: add fmod/frem Laurent Vivier
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 22+ messages in thread
From: Laurent Vivier @ 2017-11-23 16:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Aurelien Jarno, Richard Henderson, Laurent Vivier

copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 fpu/softfloat.c         | 88 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/fpu/softfloat.h |  1 +
 2 files changed, 89 insertions(+)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 433c5dad2d..36e67e50a3 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -5701,6 +5701,94 @@ floatx80 floatx80_sqrt(floatx80 a, float_status *status)
                                 0, zExp, zSig0, zSig1, status);
 }
 
+#if defined(TARGET_M68K)
+/* This part is copied from previous:
+ *  Written by Andreas Grabher for Previous, NeXT Computer Emulator.
+ */
+
+/*----------------------------------------------------------------------------
+ | Returns the modulo remainder of the extended double-precision floating-point
+ | value `a' with respect to the corresponding value `b'.
+ *----------------------------------------------------------------------------*/
+
+floatx80 floatx80_mod(floatx80 a, floatx80 b, float_status *status)
+{
+    flag aSign, zSign;
+    int32_t aExp, bExp, expDiff;
+    uint64_t aSig0, aSig1, bSig;
+    uint64_t qTemp, term0, term1;
+
+    aSig0 = extractFloatx80Frac(a);
+    aExp = extractFloatx80Exp(a);
+    aSign = extractFloatx80Sign(a);
+    bSig = extractFloatx80Frac(b);
+    bExp = extractFloatx80Exp(b);
+
+    if (aExp == 0x7FFF) {
+        if ((uint64_t) (aSig0 << 1)
+            || ((bExp == 0x7FFF) && (uint64_t) (bSig << 1))) {
+            return propagateFloatx80NaN(a, b, status);
+        }
+        goto invalid;
+    }
+    if (bExp == 0x7FFF) {
+        if ((uint64_t) (bSig << 1)) {
+            return propagateFloatx80NaN(a, b, status);
+        }
+        return a;
+    }
+    if (bExp == 0) {
+        if (bSig == 0) {
+        invalid:
+            float_raise(float_flag_invalid, status);
+            return floatx80_default_nan(status);
+        }
+        normalizeFloatx80Subnormal(bSig, &bExp, &bSig);
+    }
+    if (aExp == 0) {
+        if ((uint64_t) (aSig0 << 1) == 0) {
+            return a;
+        }
+        normalizeFloatx80Subnormal(aSig0, &aExp, &aSig0);
+    }
+    bSig |= LIT64(0x8000000000000000);
+    zSign = aSign;
+    expDiff = aExp - bExp;
+    aSig1 = 0;
+    if (expDiff < 0) {
+        return a;
+    }
+    qTemp = (bSig <= aSig0);
+    if (qTemp) {
+        aSig0 -= bSig;
+    }
+    expDiff -= 64;
+    while (0 < expDiff) {
+        qTemp = estimateDiv128To64(aSig0, aSig1, bSig);
+        qTemp = (2 < qTemp) ? qTemp - 2 : 0;
+        mul64To128(bSig, qTemp, &term0, &term1);
+        sub128(aSig0, aSig1, term0, term1, &aSig0, &aSig1);
+        shortShift128Left(aSig0, aSig1, 62, &aSig0, &aSig1);
+    }
+    expDiff += 64;
+    if (0 < expDiff) {
+        qTemp = estimateDiv128To64(aSig0, aSig1, bSig);
+        qTemp = (2 < qTemp) ? qTemp - 2 : 0;
+        qTemp >>= 64 - expDiff;
+        mul64To128(bSig, qTemp << (64 - expDiff), &term0, &term1);
+        sub128(aSig0, aSig1, term0, term1, &aSig0, &aSig1);
+        shortShift128Left(0, bSig, 64 - expDiff, &term0, &term1);
+        while (le128(term0, term1, aSig0, aSig1)) {
+            ++qTemp;
+            sub128(aSig0, aSig1, term0, term1, &aSig0, &aSig1);
+        }
+    }
+    return
+        normalizeRoundAndPackFloatx80(
+            80, zSign, bExp + expDiff, aSig0, aSig1, status);
+}
+#endif /* TARGET_M68K */
+
 /*----------------------------------------------------------------------------
 | Returns 1 if the extended double-precision floating-point value `a' is equal
 | to the corresponding value `b', and 0 otherwise.  The invalid exception is
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 0f96a0edd1..ad6249b3df 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -623,6 +623,7 @@ floatx80 floatx80_sub(floatx80, floatx80, float_status *status);
 floatx80 floatx80_mul(floatx80, floatx80, float_status *status);
 floatx80 floatx80_div(floatx80, floatx80, float_status *status);
 floatx80 floatx80_rem(floatx80, floatx80, float_status *status);
+floatx80 floatx80_mod(floatx80 a, floatx80 b, float_status *status);
 floatx80 floatx80_sqrt(floatx80, float_status *status);
 int floatx80_eq(floatx80, floatx80, float_status *status);
 int floatx80_le(floatx80, floatx80, float_status *status);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 2/5] target/m68k: add fmod/frem
  2017-11-23 16:35 [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Laurent Vivier
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 1/5] softfloat: add floatx80_mod() Laurent Vivier
@ 2017-11-23 16:35 ` Laurent Vivier
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 3/5] softfloat: use floatx80_infinity in softfloat Laurent Vivier
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 22+ messages in thread
From: Laurent Vivier @ 2017-11-23 16:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Aurelien Jarno, Richard Henderson, Laurent Vivier

Use floatx80_mod() and floatx80_rem()

The quotient byte of the FPSR is updated with
the result of the operation.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 target/m68k/cpu.h        |  1 +
 target/m68k/fpu_helper.c | 33 +++++++++++++++++++++++++++++++++
 target/m68k/helper.h     |  2 ++
 target/m68k/translate.c  |  6 ++++++
 4 files changed, 42 insertions(+)

diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index afae5f68ac..4ba613dfbe 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -234,6 +234,7 @@ typedef enum {
 /* Quotient */
 
 #define FPSR_QT_MASK  0x00ff0000
+#define FPSR_QT_SHIFT 16
 
 /* Floating-Point Control Register */
 /* Rounding mode */
diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
index 665e7609af..dd8b6950d6 100644
--- a/target/m68k/fpu_helper.c
+++ b/target/m68k/fpu_helper.c
@@ -508,3 +508,36 @@ uint32_t HELPER(fmovemd_ld_postinc)(CPUM68KState *env, uint32_t addr,
 {
     return fmovem_postinc(env, addr, mask, cpu_ld_float64_ra);
 }
+
+static void make_quotient(CPUM68KState *env, floatx80 val)
+{
+    int32_t quotient;
+    int sign;
+
+    if (floatx80_is_any_nan(val)) {
+        return;
+    }
+
+    quotient = floatx80_to_int32(val, &env->fp_status);
+    sign = quotient < 0;
+    if (sign) {
+        quotient = -quotient;
+    }
+
+    quotient = (sign << 7) | (quotient & 0x7f);
+    env->fpsr = (env->fpsr & ~FPSR_QT_MASK) | (quotient << FPSR_QT_SHIFT);
+}
+
+void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
+{
+    res->d = floatx80_mod(val1->d, val0->d, &env->fp_status);
+
+    make_quotient(env, res->d);
+}
+
+void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
+{
+    res->d = floatx80_rem(val1->d, val0->d, &env->fp_status);
+
+    make_quotient(env, res->d);
+}
diff --git a/target/m68k/helper.h b/target/m68k/helper.h
index eebe52dae5..ff9d99ae27 100644
--- a/target/m68k/helper.h
+++ b/target/m68k/helper.h
@@ -61,6 +61,8 @@ DEF_HELPER_3(fmovemx_ld_postinc, i32, env, i32, i32)
 DEF_HELPER_3(fmovemd_st_predec, i32, env, i32, i32)
 DEF_HELPER_3(fmovemd_st_postinc, i32, env, i32, i32)
 DEF_HELPER_3(fmovemd_ld_postinc, i32, env, i32, i32)
+DEF_HELPER_4(fmod, void, env, fp, fp, fp)
+DEF_HELPER_4(frem, void, env, fp, fp, fp)
 
 DEF_HELPER_3(mac_move, void, env, i32, i32)
 DEF_HELPER_3(macmulf, i64, env, i32, i32)
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index b60909222c..66f873899f 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -4686,6 +4686,9 @@ DISAS_INSN(fpu)
     case 0x64: /* fddiv */
         gen_helper_fddiv(cpu_env, cpu_dest, cpu_src, cpu_dest);
         break;
+    case 0x21: /* fmod */
+        gen_helper_fmod(cpu_env, cpu_dest, cpu_src, cpu_dest);
+        break;
     case 0x22: /* fadd */
         gen_helper_fadd(cpu_env, cpu_dest, cpu_src, cpu_dest);
         break;
@@ -4707,6 +4710,9 @@ DISAS_INSN(fpu)
     case 0x24: /* fsgldiv */
         gen_helper_fsgldiv(cpu_env, cpu_dest, cpu_src, cpu_dest);
         break;
+    case 0x25: /* frem */
+        gen_helper_frem(cpu_env, cpu_dest, cpu_src, cpu_dest);
+        break;
     case 0x27: /* fsglmul */
         gen_helper_fsglmul(cpu_env, cpu_dest, cpu_src, cpu_dest);
         break;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 3/5] softfloat: use floatx80_infinity in softfloat
  2017-11-23 16:35 [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Laurent Vivier
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 1/5] softfloat: add floatx80_mod() Laurent Vivier
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 2/5] target/m68k: add fmod/frem Laurent Vivier
@ 2017-11-23 16:35 ` Laurent Vivier
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 4/5] softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale() Laurent Vivier
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 22+ messages in thread
From: Laurent Vivier @ 2017-11-23 16:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Aurelien Jarno, Richard Henderson, Laurent Vivier

Since f3218a8 ("softfloat: add floatx80 constants")
floatx80_infinity is defined but never used.

This patch updates floatx80 functions to use
this definition.

This allows to define a different default Infinity
value on m68k: the m68k FPU defines infinity with
all bits set to zero in the mantissa.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <rth@twiddle.net>
---
 fpu/softfloat-specialize.h | 14 ++++++++++++++
 fpu/softfloat.c            | 38 ++++++++++++++++++++++++++------------
 include/fpu/softfloat.h    |  9 +++++++--
 3 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h
index de2c5d5702..1cb3502e5a 100644
--- a/fpu/softfloat-specialize.h
+++ b/fpu/softfloat-specialize.h
@@ -178,6 +178,20 @@ floatx80 floatx80_default_nan(float_status *status)
 }
 
 /*----------------------------------------------------------------------------
+| The pattern for a default generated extended double-precision inf.
+*----------------------------------------------------------------------------*/
+
+#define floatx80_infinity_high 0x7FFF
+#if defined(TARGET_M68K)
+#define floatx80_infinity_low  LIT64(0x0000000000000000)
+#else
+#define floatx80_infinity_low  LIT64(0x8000000000000000)
+#endif
+
+const floatx80 floatx80_infinity
+    = make_floatx80_init(floatx80_infinity_high, floatx80_infinity_low);
+
+/*----------------------------------------------------------------------------
 | The pattern for a default generated quadruple-precision NaN.
 *----------------------------------------------------------------------------*/
 float128 float128_default_nan(float_status *status)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 36e67e50a3..c6289bba75 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -913,7 +913,9 @@ static floatx80 roundAndPackFloatx80(int8_t roundingPrecision, flag zSign,
                ) {
                 return packFloatx80( zSign, 0x7FFE, ~ roundMask );
             }
-            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
+            return packFloatx80(zSign,
+                                floatx80_infinity_high,
+                                floatx80_infinity_low);
         }
         if ( zExp <= 0 ) {
             isTiny =
@@ -1885,7 +1887,9 @@ floatx80 float32_to_floatx80(float32 a, float_status *status)
         if (aSig) {
             return commonNaNToFloatx80(float32ToCommonNaN(a, status), status);
         }
-        return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
+        return packFloatx80(aSign,
+                            floatx80_infinity_high,
+                            floatx80_infinity_low);
     }
     if ( aExp == 0 ) {
         if ( aSig == 0 ) return packFloatx80( aSign, 0, 0 );
@@ -3666,7 +3670,9 @@ floatx80 float64_to_floatx80(float64 a, float_status *status)
         if (aSig) {
             return commonNaNToFloatx80(float64ToCommonNaN(a, status), status);
         }
-        return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
+        return packFloatx80(aSign,
+                            floatx80_infinity_high,
+                            floatx80_infinity_low);
     }
     if ( aExp == 0 ) {
         if ( aSig == 0 ) return packFloatx80( aSign, 0, 0 );
@@ -4927,8 +4933,8 @@ int64_t floatx80_to_int64(floatx80 a, float_status *status)
         if ( shiftCount ) {
             float_raise(float_flag_invalid, status);
             if (    ! aSign
-                 || (    ( aExp == 0x7FFF )
-                      && ( aSig != LIT64( 0x8000000000000000 ) ) )
+                 || ((aExp == floatx80_infinity_high)
+                     && (aSig != floatx80_infinity_low))
                ) {
                 return LIT64( 0x7FFFFFFFFFFFFFFF );
             }
@@ -5235,7 +5241,9 @@ static floatx80 addFloatx80Sigs(floatx80 a, floatx80 b, flag zSign,
             if ((uint64_t)(bSig << 1)) {
                 return propagateFloatx80NaN(a, b, status);
             }
-            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
+            return packFloatx80(zSign,
+                                floatx80_infinity_high,
+                                floatx80_infinity_low);
         }
         if ( aExp == 0 ) ++expDiff;
         shift64ExtraRightJamming( aSig, 0, - expDiff, &aSig, &zSig1 );
@@ -5310,7 +5318,8 @@ static floatx80 subFloatx80Sigs(floatx80 a, floatx80 b, flag zSign,
         if ((uint64_t)(bSig << 1)) {
             return propagateFloatx80NaN(a, b, status);
         }
-        return packFloatx80( zSign ^ 1, 0x7FFF, LIT64( 0x8000000000000000 ) );
+        return packFloatx80(zSign ^ 1, floatx80_infinity_high,
+                            floatx80_infinity_low);
     }
     if ( aExp == 0 ) ++expDiff;
     shift128RightJamming( aSig, 0, - expDiff, &aSig, &zSig1 );
@@ -5415,7 +5424,8 @@ floatx80 floatx80_mul(floatx80 a, floatx80 b, float_status *status)
             return propagateFloatx80NaN(a, b, status);
         }
         if ( ( bExp | bSig ) == 0 ) goto invalid;
-        return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
+        return packFloatx80(zSign, floatx80_infinity_high,
+                                   floatx80_infinity_low);
     }
     if ( bExp == 0x7FFF ) {
         if ((uint64_t)(bSig << 1)) {
@@ -5426,7 +5436,8 @@ floatx80 floatx80_mul(floatx80 a, floatx80 b, float_status *status)
             float_raise(float_flag_invalid, status);
             return floatx80_default_nan(status);
         }
-        return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
+        return packFloatx80(zSign, floatx80_infinity_high,
+                                   floatx80_infinity_low);
     }
     if ( aExp == 0 ) {
         if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 );
@@ -5480,7 +5491,8 @@ floatx80 floatx80_div(floatx80 a, floatx80 b, float_status *status)
             }
             goto invalid;
         }
-        return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
+        return packFloatx80(zSign, floatx80_infinity_high,
+                                   floatx80_infinity_low);
     }
     if ( bExp == 0x7FFF ) {
         if ((uint64_t)(bSig << 1)) {
@@ -5496,7 +5508,8 @@ floatx80 floatx80_div(floatx80 a, floatx80 b, float_status *status)
                 return floatx80_default_nan(status);
             }
             float_raise(float_flag_divbyzero, status);
-            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
+            return packFloatx80(zSign, floatx80_infinity_high,
+                                       floatx80_infinity_low);
         }
         normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
     }
@@ -6407,7 +6420,8 @@ floatx80 float128_to_floatx80(float128 a, float_status *status)
         if ( aSig0 | aSig1 ) {
             return commonNaNToFloatx80(float128ToCommonNaN(a, status), status);
         }
-        return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
+        return packFloatx80(aSign, floatx80_infinity_high,
+                                   floatx80_infinity_low);
     }
     if ( aExp == 0 ) {
         if ( ( aSig0 | aSig1 ) == 0 ) return packFloatx80( aSign, 0, 0 );
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index ad6249b3df..413cdb20cb 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -614,6 +614,11 @@ float64 floatx80_to_float64(floatx80, float_status *status);
 float128 floatx80_to_float128(floatx80, float_status *status);
 
 /*----------------------------------------------------------------------------
+| The pattern for an extended double-precision inf.
+*----------------------------------------------------------------------------*/
+extern const floatx80 floatx80_infinity;
+
+/*----------------------------------------------------------------------------
 | Software IEC/IEEE extended double-precision operations.
 *----------------------------------------------------------------------------*/
 floatx80 floatx80_round(floatx80 a, float_status *status);
@@ -654,7 +659,8 @@ static inline floatx80 floatx80_chs(floatx80 a)
 
 static inline int floatx80_is_infinity(floatx80 a)
 {
-    return (a.high & 0x7fff) == 0x7fff && a.low == 0x8000000000000000LL;
+    return (a.high & 0x7fff) == floatx80_infinity.high &&
+                       a.low == floatx80_infinity.low;
 }
 
 static inline int floatx80_is_neg(floatx80 a)
@@ -697,7 +703,6 @@ static inline bool floatx80_invalid_encoding(floatx80 a)
 #define floatx80_ln2 make_floatx80(0x3ffe, 0xb17217f7d1cf79acLL)
 #define floatx80_pi make_floatx80(0x4000, 0xc90fdaa22168c235LL)
 #define floatx80_half make_floatx80(0x3ffe, 0x8000000000000000LL)
-#define floatx80_infinity make_floatx80(0x7fff, 0x8000000000000000LL)
 
 /*----------------------------------------------------------------------------
 | The pattern for a default generated extended double-precision NaN.
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 4/5] softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale()
  2017-11-23 16:35 [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Laurent Vivier
                   ` (2 preceding siblings ...)
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 3/5] softfloat: use floatx80_infinity in softfloat Laurent Vivier
@ 2017-11-23 16:35 ` Laurent Vivier
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 5/5] target-m68k: add fscale, fgetman and fgetexp Laurent Vivier
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 22+ messages in thread
From: Laurent Vivier @ 2017-11-23 16:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Aurelien Jarno, Richard Henderson, Laurent Vivier

copied from previous:
Written by Andreas Grabher for Previous, NeXT Computer Emulator.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 fpu/softfloat-specialize.h |  15 ++++++
 fpu/softfloat.c            | 132 +++++++++++++++++++++++++++++++++++++++++++++
 include/fpu/softfloat.h    |   3 ++
 3 files changed, 150 insertions(+)

diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h
index 1cb3502e5a..4706a0ec3a 100644
--- a/fpu/softfloat-specialize.h
+++ b/fpu/softfloat-specialize.h
@@ -1163,6 +1163,21 @@ static floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b,
     }
 }
 
+#if defined(TARGET_M68K)
+static floatx80 propagateFloatx80NaNOneArg(floatx80 a, float_status *status)
+{
+    if (floatx80_is_signaling_nan(a, status)) {
+        float_raise(float_flag_invalid, status);
+    }
+
+    if (status->default_nan_mode) {
+        return floatx80_default_nan(status);
+    }
+
+    return floatx80_maybe_silence_nan(a, status);
+}
+#endif
+
 #ifdef NO_SIGNALING_NANS
 int float128_is_quiet_nan(float128 a_, float_status *status)
 {
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index c6289bba75..a17e849fe7 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -5800,6 +5800,138 @@ floatx80 floatx80_mod(floatx80 a, floatx80 b, float_status *status)
         normalizeRoundAndPackFloatx80(
             80, zSign, bExp + expDiff, aSig0, aSig1, status);
 }
+
+/*----------------------------------------------------------------------------
+ | Returns the mantissa of the extended double-precision floating-point
+ | value `a'.
+ *----------------------------------------------------------------------------*/
+
+floatx80 floatx80_getman(floatx80 a, float_status *status)
+{
+    flag aSign;
+    int32_t aExp;
+    uint64_t aSig;
+
+    aSig = extractFloatx80Frac(a);
+    aExp = extractFloatx80Exp(a);
+    aSign = extractFloatx80Sign(a);
+
+    if (aExp == 0x7FFF) {
+        if ((uint64_t) (aSig << 1)) {
+            return propagateFloatx80NaNOneArg(a , status);
+        }
+        float_raise(float_flag_invalid , status);
+        return floatx80_default_nan(status);
+    }
+
+    if (aExp == 0) {
+        if (aSig == 0) {
+            return packFloatx80(aSign, 0, 0);
+        }
+        normalizeFloatx80Subnormal(aSig, &aExp, &aSig);
+    }
+
+    return roundAndPackFloatx80(status->floatx80_rounding_precision, aSign,
+                                0x3FFF, aSig, 0, status);
+}
+
+/*----------------------------------------------------------------------------
+ | Returns the exponent of the extended double-precision floating-point
+ | value `a' as an extended double-precision value.
+ *----------------------------------------------------------------------------*/
+
+floatx80 floatx80_getexp(floatx80 a, float_status *status)
+{
+    flag aSign;
+    int32_t aExp;
+    uint64_t aSig;
+
+    aSig = extractFloatx80Frac(a);
+    aExp = extractFloatx80Exp(a);
+    aSign = extractFloatx80Sign(a);
+
+    if (aExp == 0x7FFF) {
+        if ((uint64_t) (aSig << 1)) {
+            return propagateFloatx80NaNOneArg(a , status);
+        }
+        float_raise(float_flag_invalid , status);
+        return floatx80_default_nan(status);
+    }
+
+    if (aExp == 0) {
+        if (aSig == 0) {
+            return packFloatx80(aSign, 0, 0);
+        }
+        normalizeFloatx80Subnormal(aSig, &aExp, &aSig);
+    }
+
+    return int32_to_floatx80(aExp - 0x3FFF, status);
+}
+
+/*----------------------------------------------------------------------------
+ | Scales extended double-precision floating-point value in operand `a' by
+ | value `b'. The function truncates the value in the second operand 'b' to
+ | an integral value and adds that value to the exponent of the operand 'a'.
+ | The operation performed according to the IEC/IEEE Standard for Binary
+ | Floating-Point Arithmetic.
+ *----------------------------------------------------------------------------*/
+
+floatx80 floatx80_scale(floatx80 a, floatx80 b, float_status *status)
+{
+    flag aSign, bSign;
+    int32_t aExp, bExp, shiftCount;
+    uint64_t aSig, bSig;
+
+    aSig = extractFloatx80Frac(a);
+    aExp = extractFloatx80Exp(a);
+    aSign = extractFloatx80Sign(a);
+    bSig = extractFloatx80Frac(b);
+    bExp = extractFloatx80Exp(b);
+    bSign = extractFloatx80Sign(b);
+
+    if (bExp == 0x7FFF) {
+        if ((uint64_t) (bSig << 1) ||
+            ((aExp == 0x7FFF) && (uint64_t) (aSig << 1))) {
+            return propagateFloatx80NaN(a, b, status);
+        }
+        float_raise(float_flag_invalid , status);
+        return floatx80_default_nan(status);
+    }
+    if (aExp == 0x7FFF) {
+        if ((uint64_t) (aSig << 1)) {
+            return propagateFloatx80NaN(a, b, status);
+        }
+        return packFloatx80(aSign, floatx80_infinity_high,
+                            floatx80_infinity_low);
+    }
+    if (aExp == 0) {
+        if (aSig == 0) {
+            return packFloatx80(aSign, 0, 0);
+        }
+        if (bExp < 0x3FFF) {
+            return a;
+        }
+        normalizeFloatx80Subnormal(aSig, &aExp, &aSig);
+    }
+
+    if (bExp < 0x3FFF) {
+        return a;
+    }
+
+    if (0x400F < bExp) {
+        aExp = bSign ? -0x6001 : 0xE000;
+        return roundAndPackFloatx80(status->floatx80_rounding_precision,
+                                    aSign, aExp, aSig, 0, status);
+    }
+
+    shiftCount = 0x403E - bExp;
+    bSig >>= shiftCount;
+    aExp = bSign ? (aExp - bSig) : (aExp + bSig);
+
+    return roundAndPackFloatx80(status->floatx80_rounding_precision,
+                                aSign, aExp, aSig, 0, status);
+
+}
 #endif /* TARGET_M68K */
 
 /*----------------------------------------------------------------------------
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 413cdb20cb..84ddcb12a1 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -630,6 +630,9 @@ floatx80 floatx80_div(floatx80, floatx80, float_status *status);
 floatx80 floatx80_rem(floatx80, floatx80, float_status *status);
 floatx80 floatx80_mod(floatx80 a, floatx80 b, float_status *status);
 floatx80 floatx80_sqrt(floatx80, float_status *status);
+floatx80 floatx80_getman(floatx80 a, float_status *status);
+floatx80 floatx80_getexp(floatx80 a, float_status *status);
+floatx80 floatx80_scale(floatx80 a, floatx80 b, float_status *status);
 int floatx80_eq(floatx80, floatx80, float_status *status);
 int floatx80_le(floatx80, floatx80, float_status *status);
 int floatx80_lt(floatx80, floatx80, float_status *status);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 5/5] target-m68k: add fscale, fgetman and fgetexp
  2017-11-23 16:35 [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Laurent Vivier
                   ` (3 preceding siblings ...)
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 4/5] softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale() Laurent Vivier
@ 2017-11-23 16:35 ` Laurent Vivier
  2017-11-29 12:49 ` [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Peter Maydell
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 22+ messages in thread
From: Laurent Vivier @ 2017-11-23 16:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Aurelien Jarno, Richard Henderson, Laurent Vivier

using floatx80_scale(), floatx80_getman() and
floatx80_getexp()

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 target/m68k/fpu_helper.c | 15 +++++++++++++++
 target/m68k/helper.h     |  3 +++
 target/m68k/translate.c  |  9 +++++++++
 3 files changed, 27 insertions(+)

diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
index dd8b6950d6..6be2b90eba 100644
--- a/target/m68k/fpu_helper.c
+++ b/target/m68k/fpu_helper.c
@@ -541,3 +541,18 @@ void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
 
     make_quotient(env, res->d);
 }
+
+void HELPER(fgetexp)(CPUM68KState *env, FPReg *res, FPReg *val)
+{
+    res->d = floatx80_getexp(val->d, &env->fp_status);
+}
+
+void HELPER(fgetman)(CPUM68KState *env, FPReg *res, FPReg *val)
+{
+    res->d = floatx80_getman(val->d, &env->fp_status);
+}
+
+void HELPER(fscale)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
+{
+    res->d = floatx80_scale(val1->d, val0->d, &env->fp_status);
+}
diff --git a/target/m68k/helper.h b/target/m68k/helper.h
index ff9d99ae27..ccdda73187 100644
--- a/target/m68k/helper.h
+++ b/target/m68k/helper.h
@@ -63,6 +63,9 @@ DEF_HELPER_3(fmovemd_st_postinc, i32, env, i32, i32)
 DEF_HELPER_3(fmovemd_ld_postinc, i32, env, i32, i32)
 DEF_HELPER_4(fmod, void, env, fp, fp, fp)
 DEF_HELPER_4(frem, void, env, fp, fp, fp)
+DEF_HELPER_3(fgetexp, void, env, fp, fp)
+DEF_HELPER_3(fgetman, void, env, fp, fp)
+DEF_HELPER_4(fscale, void, env, fp, fp, fp)
 
 DEF_HELPER_3(mac_move, void, env, i32, i32)
 DEF_HELPER_3(macmulf, i64, env, i32, i32)
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 66f873899f..c0c2e8c757 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -4677,6 +4677,12 @@ DISAS_INSN(fpu)
     case 0x5e: /* fdneg */
         gen_helper_fdneg(cpu_env, cpu_dest, cpu_src);
         break;
+    case 0x1e: /* fgetexp */
+        gen_helper_fgetexp(cpu_env, cpu_dest, cpu_src);
+        break;
+    case 0x1f: /* fgetman */
+        gen_helper_fgetman(cpu_env, cpu_dest, cpu_src);
+        break;
     case 0x20: /* fdiv */
         gen_helper_fdiv(cpu_env, cpu_dest, cpu_src, cpu_dest);
         break;
@@ -4713,6 +4719,9 @@ DISAS_INSN(fpu)
     case 0x25: /* frem */
         gen_helper_frem(cpu_env, cpu_dest, cpu_src, cpu_dest);
         break;
+    case 0x26: /* fscale */
+        gen_helper_fscale(cpu_env, cpu_dest, cpu_src, cpu_dest);
+        break;
     case 0x27: /* fsglmul */
         gen_helper_fsglmul(cpu_env, cpu_dest, cpu_src, cpu_dest);
         break;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-11-23 16:35 [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Laurent Vivier
                   ` (4 preceding siblings ...)
  2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 5/5] target-m68k: add fscale, fgetman and fgetexp Laurent Vivier
@ 2017-11-29 12:49 ` Peter Maydell
  2017-11-29 13:42   ` Laurent Vivier
  2017-12-06 10:24 ` Alex Bennée
  2017-12-20 18:25 ` Laurent Vivier
  7 siblings, 1 reply; 22+ messages in thread
From: Peter Maydell @ 2017-11-29 12:49 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: QEMU Developers, Thomas Huth, Aurelien Jarno, Richard Henderson

On 23 November 2017 at 16:35, Laurent Vivier <laurent@vivier.eu> wrote:
> Implement fmod, frem, fscale, fgetman and fgetexp.
>
> Instead of using functions of libm (v1 of this series)
> and converting between host long double and floatx80 type
> the new version (v2) adds new floatx80 functions in softfloat.
>
> All the floatx80 functions are copied from "Previous",
> the NeXT Computer Emulator, and written by Andreas Grabher.

Hi; what license is that code under? Can you provide
a link to the original sources that you're taking the
functions from, please?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-11-29 12:49 ` [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Peter Maydell
@ 2017-11-29 13:42   ` Laurent Vivier
  2017-11-29 13:59     ` Peter Maydell
  0 siblings, 1 reply; 22+ messages in thread
From: Laurent Vivier @ 2017-11-29 13:42 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Developers, Thomas Huth, Aurelien Jarno, Richard Henderson

Le 29/11/2017 à 13:49, Peter Maydell a écrit :
> On 23 November 2017 at 16:35, Laurent Vivier <laurent@vivier.eu> wrote:
>> Implement fmod, frem, fscale, fgetman and fgetexp.
>>
>> Instead of using functions of libm (v1 of this series)
>> and converting between host long double and floatx80 type
>> the new version (v2) adds new floatx80 functions in softfloat.
>>
>> All the floatx80 functions are copied from "Previous",
>> the NeXT Computer Emulator, and written by Andreas Grabher.
> 
> Hi; what license is that code under? Can you provide
> a link to the original sources that you're taking the
> functions from, please?

Hi,

these functions come from:

http://previous.alternative-system.com/

http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c

This is also a modified softfloat, release 2b
which is BSD license if I'm correct.

Their softfloat files seem to come from MAME

http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/README.txt

and MAME is GPL:
http://mamedev.org/legal.html

and Previous is a fork of Hatari (GPL), a fork of UAE (GPL)
https://hatari.tuxfamily.org/index.html

This code has also been copied to WinUAE (GPL), where softfloat has been
copied from QEMU:
https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp

But I think the bad news comes later:

all the other functions (sin, cos, tan, log, exp, ...) found in previous
(softfloat_fpsp.c) are "derived" from NeXT library FPSP:

http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c

/*============================================================================

 This C source file is an extension to the SoftFloat IEC/IEEE Floating-point
 Arithmetic Package, Release 2a.

 Written by Andreas Grabher for Previous, NeXT Computer Emulator.

=============================================================================*/
...
/*----------------------------------------------------------------------------
| Algorithms for transcendental functions supported by MC68881 and MC68882
| mathematical coprocessors. The functions are derived from FPSP library.
*----------------------------------------------------------------------------*/

FPSP library can be found:

https://ftp.nice.ch/pub/next/developer/hardware/m68k/

And the assembly source code is not free at all:

https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h


|		Copyright (C) Motorola, Inc. 1991
|			All Rights Reserved
|
|	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
|	The copyright notice above does not evidence any
|	actual or intended publication of such source code.


So I'm wondering what license apply to the C version found in "Previous".

Thanks,
Laurent

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-11-29 13:42   ` Laurent Vivier
@ 2017-11-29 13:59     ` Peter Maydell
  2017-11-29 14:08       ` Thomas Huth
  0 siblings, 1 reply; 22+ messages in thread
From: Peter Maydell @ 2017-11-29 13:59 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: QEMU Developers, Thomas Huth, Aurelien Jarno, Richard Henderson

On 29 November 2017 at 13:42, Laurent Vivier <laurent@vivier.eu> wrote:
> these functions come from:
>
> http://previous.alternative-system.com/
>
> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c
>
> This is also a modified softfloat, release 2b
> which is BSD license if I'm correct.

We can't use softfloat2b code (the part of the license that goes
"USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
AND ORGANIZATIONS [...] WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN
HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE" isn't
GPL compatible).

We can use softfloat2a code, which doesn't have that indemnity clause.

> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/README.txt
>
> and MAME is GPL:
> http://mamedev.org/legal.html
>
> and Previous is a fork of Hatari (GPL), a fork of UAE (GPL)
> https://hatari.tuxfamily.org/index.html
>
> This code has also been copied to WinUAE (GPL), where softfloat has been
> copied from QEMU:
> https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp

Yes, lots of projects used the softfloat2b code without realising
it wasn't GPL compatible (including QEMU -- we had a painful job
to fix things up and convert to the 2a codebase a while back).

> But I think the bad news comes later:
>
> all the other functions (sin, cos, tan, log, exp, ...) found in previous
> (softfloat_fpsp.c) are "derived" from NeXT library FPSP:
>
> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
>
> /*============================================================================
>
>  This C source file is an extension to the SoftFloat IEC/IEEE Floating-point
>  Arithmetic Package, Release 2a.
>
>  Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>
> =============================================================================*/
> ...
> /*----------------------------------------------------------------------------
> | Algorithms for transcendental functions supported by MC68881 and MC68882
> | mathematical coprocessors. The functions are derived from FPSP library.
> *----------------------------------------------------------------------------*/
>
> FPSP library can be found:
>
> https://ftp.nice.ch/pub/next/developer/hardware/m68k/
>
> And the assembly source code is not free at all:
>
> https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h
>
>
> |               Copyright (C) Motorola, Inc. 1991
> |                       All Rights Reserved
> |
> |       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
> |       The copyright notice above does not evidence any
> |       actual or intended publication of such source code.
>
>
> So I'm wondering what license apply to the C version found in "Previous".

Good question. It's clearly not copied code (since the FPSP library is
all native m68k assembly), but presumably it's the same algorithms
transliterated into C...

thanks
-- PMM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-11-29 13:59     ` Peter Maydell
@ 2017-11-29 14:08       ` Thomas Huth
  2017-11-29 14:17         ` Laurent Vivier
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas Huth @ 2017-11-29 14:08 UTC (permalink / raw)
  To: Peter Maydell, Laurent Vivier
  Cc: QEMU Developers, Andreas Grabher, Aurelien Jarno, Richard Henderson

On 29.11.2017 14:59, Peter Maydell wrote:
> On 29 November 2017 at 13:42, Laurent Vivier <laurent@vivier.eu> wrote:
>> these functions come from:
>>
>> http://previous.alternative-system.com/
>>
>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c
>>
>> This is also a modified softfloat, release 2b
>> which is BSD license if I'm correct.
> 
> We can't use softfloat2b code (the part of the license that goes
> "USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
> AND ORGANIZATIONS [...] WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN
> HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE" isn't
> GPL compatible).
> 
> We can use softfloat2a code, which doesn't have that indemnity clause.

Sigh. That's why WinUAE and Hatari immediately switched back to
softfloat2a (derived from QEMU) after we've identified the problem
there. Looks like the Previous folks forgot to do that step, too :-(

>> This code has also been copied to WinUAE (GPL), where softfloat has been
>> copied from QEMU:
>> https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp
> 
> Yes, lots of projects used the softfloat2b code without realising
> it wasn't GPL compatible (including QEMU -- we had a painful job
> to fix things up and convert to the 2a codebase a while back).
> 
>> But I think the bad news comes later:
>>
>> all the other functions (sin, cos, tan, log, exp, ...) found in previous
>> (softfloat_fpsp.c) are "derived" from NeXT library FPSP:
>>
>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
>>
>> /*============================================================================
>>
>>  This C source file is an extension to the SoftFloat IEC/IEEE Floating-point
>>  Arithmetic Package, Release 2a.
>>
>>  Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>>
>> =============================================================================*/
>> ...
>> /*----------------------------------------------------------------------------
>> | Algorithms for transcendental functions supported by MC68881 and MC68882
>> | mathematical coprocessors. The functions are derived from FPSP library.
>> *----------------------------------------------------------------------------*/
>>
>> FPSP library can be found:
>>
>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/
>>
>> And the assembly source code is not free at all:
>>
>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h
>>
>>
>> |               Copyright (C) Motorola, Inc. 1991
>> |                       All Rights Reserved
>> |
>> |       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
>> |       The copyright notice above does not evidence any
>> |       actual or intended publication of such source code.
>>
>>
>> So I'm wondering what license apply to the C version found in "Previous".
> 
> Good question. It's clearly not copied code (since the FPSP library is
> all native m68k assembly), but presumably it's the same algorithms
> transliterated into C...

There also seem to be other versions of that library available, e.g.:

https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/l_fpsp.h

Maybe Andreas (now on CC: ) could clarify which version he used / how
the C sources were developed?

 Thomas

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-11-29 14:08       ` Thomas Huth
@ 2017-11-29 14:17         ` Laurent Vivier
  2017-11-29 15:19           ` Thomas Huth
  0 siblings, 1 reply; 22+ messages in thread
From: Laurent Vivier @ 2017-11-29 14:17 UTC (permalink / raw)
  To: Thomas Huth, Peter Maydell
  Cc: QEMU Developers, Andreas Grabher, Aurelien Jarno, Richard Henderson

Le 29/11/2017 à 15:08, Thomas Huth a écrit :
> On 29.11.2017 14:59, Peter Maydell wrote:
>> On 29 November 2017 at 13:42, Laurent Vivier <laurent@vivier.eu> wrote:
>>> these functions come from:
>>>
>>> http://previous.alternative-system.com/
>>>
>>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c
>>>
>>> This is also a modified softfloat, release 2b
>>> which is BSD license if I'm correct.
>>
>> We can't use softfloat2b code (the part of the license that goes
>> "USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
>> AND ORGANIZATIONS [...] WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN
>> HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE" isn't
>> GPL compatible).
>>
>> We can use softfloat2a code, which doesn't have that indemnity clause.
> 
> Sigh. That's why WinUAE and Hatari immediately switched back to
> softfloat2a (derived from QEMU) after we've identified the problem
> there. Looks like the Previous folks forgot to do that step, too :-(
> 
>>> This code has also been copied to WinUAE (GPL), where softfloat has been
>>> copied from QEMU:
>>> https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp
>>
>> Yes, lots of projects used the softfloat2b code without realising
>> it wasn't GPL compatible (including QEMU -- we had a painful job
>> to fix things up and convert to the 2a codebase a while back).
>>
>>> But I think the bad news comes later:
>>>
>>> all the other functions (sin, cos, tan, log, exp, ...) found in previous
>>> (softfloat_fpsp.c) are "derived" from NeXT library FPSP:
>>>
>>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
>>>
>>> /*============================================================================
>>>
>>>  This C source file is an extension to the SoftFloat IEC/IEEE Floating-point
>>>  Arithmetic Package, Release 2a.
>>>
>>>  Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>>>
>>> =============================================================================*/
>>> ...
>>> /*----------------------------------------------------------------------------
>>> | Algorithms for transcendental functions supported by MC68881 and MC68882
>>> | mathematical coprocessors. The functions are derived from FPSP library.
>>> *----------------------------------------------------------------------------*/
>>>
>>> FPSP library can be found:
>>>
>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/
>>>
>>> And the assembly source code is not free at all:
>>>
>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h
>>>
>>>
>>> |               Copyright (C) Motorola, Inc. 1991
>>> |                       All Rights Reserved
>>> |
>>> |       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
>>> |       The copyright notice above does not evidence any
>>> |       actual or intended publication of such source code.
>>>
>>>
>>> So I'm wondering what license apply to the C version found in "Previous".
>>
>> Good question. It's clearly not copied code (since the FPSP library is
>> all native m68k assembly), but presumably it's the same algorithms
>> transliterated into C...
> 
> There also seem to be other versions of that library available, e.g.:
> 
> https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/l_fpsp.h
> 
> Maybe Andreas (now on CC: ) could clarify which version he used / how
> the C sources were developed?

Thank you Thomas,

This seems to be the same code re-licensed to:

MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
M68000 Hi-Performance Microprocessor Division
M68040 Software Package

M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
All rights reserved.

THE SOFTWARE is provided on an "AS IS" basis and without warranty.
To the maximum extent permitted by applicable law,
MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
PARTICULAR PURPOSE and any warranty against infringement with
regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
and any accompanying written materials.

To the maximum extent permitted by applicable law,
IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
SOFTWARE.  Motorola assumes no responsibility for the maintenance
and support of the SOFTWARE.

You are hereby granted a copyright license to use, modify, and
distribute the SOFTWARE so long as this entire notice is retained
without alteration in any modified and/or redistributed versions,
and that such modified versions are clearly identified as such.
No licenses are granted by implication, estoppel or otherwise
under any patents or trademarks of Motorola, Inc.

Laurent

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-11-29 14:17         ` Laurent Vivier
@ 2017-11-29 15:19           ` Thomas Huth
  2017-12-05  8:56             ` william lin
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas Huth @ 2017-11-29 15:19 UTC (permalink / raw)
  To: Laurent Vivier, Peter Maydell
  Cc: Andreas Grabher, QEMU Developers, Aurelien Jarno, Richard Henderson

On 29.11.2017 15:17, Laurent Vivier wrote:
> Le 29/11/2017 à 15:08, Thomas Huth a écrit :
>> On 29.11.2017 14:59, Peter Maydell wrote:
>>> On 29 November 2017 at 13:42, Laurent Vivier <laurent@vivier.eu> wrote:
>>>> these functions come from:
>>>>
>>>> http://previous.alternative-system.com/
>>>>
>>>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c
>>>>
>>>> This is also a modified softfloat, release 2b
>>>> which is BSD license if I'm correct.
>>>
>>> We can't use softfloat2b code (the part of the license that goes
>>> "USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
>>> AND ORGANIZATIONS [...] WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN
>>> HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE" isn't
>>> GPL compatible).
>>>
>>> We can use softfloat2a code, which doesn't have that indemnity clause.
>>
>> Sigh. That's why WinUAE and Hatari immediately switched back to
>> softfloat2a (derived from QEMU) after we've identified the problem
>> there. Looks like the Previous folks forgot to do that step, too :-(
>>
>>>> This code has also been copied to WinUAE (GPL), where softfloat has been
>>>> copied from QEMU:
>>>> https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp
>>>
>>> Yes, lots of projects used the softfloat2b code without realising
>>> it wasn't GPL compatible (including QEMU -- we had a painful job
>>> to fix things up and convert to the 2a codebase a while back).
>>>
>>>> But I think the bad news comes later:
>>>>
>>>> all the other functions (sin, cos, tan, log, exp, ...) found in previous
>>>> (softfloat_fpsp.c) are "derived" from NeXT library FPSP:
>>>>
>>>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
>>>>
>>>> /*============================================================================
>>>>
>>>>  This C source file is an extension to the SoftFloat IEC/IEEE Floating-point
>>>>  Arithmetic Package, Release 2a.
>>>>
>>>>  Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>>>>
>>>> =============================================================================*/
>>>> ...
>>>> /*----------------------------------------------------------------------------
>>>> | Algorithms for transcendental functions supported by MC68881 and MC68882
>>>> | mathematical coprocessors. The functions are derived from FPSP library.
>>>> *----------------------------------------------------------------------------*/
>>>>
>>>> FPSP library can be found:
>>>>
>>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/
>>>>
>>>> And the assembly source code is not free at all:
>>>>
>>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h
>>>>
>>>>
>>>> |               Copyright (C) Motorola, Inc. 1991
>>>> |                       All Rights Reserved
>>>> |
>>>> |       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
>>>> |       The copyright notice above does not evidence any
>>>> |       actual or intended publication of such source code.
>>>>
>>>>
>>>> So I'm wondering what license apply to the C version found in "Previous".
>>>
>>> Good question. It's clearly not copied code (since the FPSP library is
>>> all native m68k assembly), but presumably it's the same algorithms
>>> transliterated into C...
>>
>> There also seem to be other versions of that library available, e.g.:
>>
>> https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/l_fpsp.h
>>
>> Maybe Andreas (now on CC: ) could clarify which version he used / how
>> the C sources were developed?
> 
> Thank you Thomas,
> 
> This seems to be the same code re-licensed to:
> 
> MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
> M68000 Hi-Performance Microprocessor Division
> M68040 Software Package
> 
> M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
> All rights reserved.
> 
> THE SOFTWARE is provided on an "AS IS" basis and without warranty.
> To the maximum extent permitted by applicable law,
> MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
> INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
> PARTICULAR PURPOSE and any warranty against infringement with
> regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
> and any accompanying written materials.
> 
> To the maximum extent permitted by applicable law,
> IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
> (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
> PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
> OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
> SOFTWARE.  Motorola assumes no responsibility for the maintenance
> and support of the SOFTWARE.
> 
> You are hereby granted a copyright license to use, modify, and
> distribute the SOFTWARE so long as this entire notice is retained
> without alteration in any modified and/or redistributed versions,
> and that such modified versions are clearly identified as such.
> No licenses are granted by implication, estoppel or otherwise
> under any patents or trademarks of Motorola, Inc.

IANAL, but to me that sounds like it is compatible to the GPL, so I
think there should not be a problem if the C sources are based on these
assembler sources?

 Thomas

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-11-29 15:19           ` Thomas Huth
@ 2017-12-05  8:56             ` william lin
  2017-12-05  9:46               ` Laurent Vivier
  0 siblings, 1 reply; 22+ messages in thread
From: william lin @ 2017-12-05  8:56 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Laurent Vivier, Peter Maydell, Andreas Grabher, QEMU Developers,
	Aurelien Jarno, Richard Henderson

On Wed, Nov 29, 2017 at 9:19 AM, Thomas Huth <huth@tuxfamily.org> wrote:

> On 29.11.2017 15:17, Laurent Vivier wrote:
> > Le 29/11/2017 à 15:08, Thomas Huth a écrit :
> >> On 29.11.2017 14:59, Peter Maydell wrote:
> >>> On 29 November 2017 at 13:42, Laurent Vivier <laurent@vivier.eu>
> wrote:
> >>>> these functions come from:
> >>>>
> >>>> http://previous.alternative-system.com/
> >>>>
> >>>> http://svn.code.sf.net/p/previous/code/trunk/src/
> softfloat/softfloat.c
> >>>>
> >>>> This is also a modified softfloat, release 2b
> >>>> which is BSD license if I'm correct.
> >>>
> >>> We can't use softfloat2b code (the part of the license that goes
> >>> "USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
> >>> AND ORGANIZATIONS [...] WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN
> >>> HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE" isn't
> >>> GPL compatible).
> >>>
> >>> We can use softfloat2a code, which doesn't have that indemnity clause.
> >>
> >> Sigh. That's why WinUAE and Hatari immediately switched back to
> >> softfloat2a (derived from QEMU) after we've identified the problem
> >> there. Looks like the Previous folks forgot to do that step, too :-(
> >>
> >>>> This code has also been copied to WinUAE (GPL), where softfloat has
> been
> >>>> copied from QEMU:
> >>>> https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp
> >>>
> >>> Yes, lots of projects used the softfloat2b code without realising
> >>> it wasn't GPL compatible (including QEMU -- we had a painful job
> >>> to fix things up and convert to the 2a codebase a while back).
> >>>
> >>>> But I think the bad news comes later:
> >>>>
> >>>> all the other functions (sin, cos, tan, log, exp, ...) found in
> previous
> >>>> (softfloat_fpsp.c) are "derived" from NeXT library FPSP:
> >>>>
> >>>> http://svn.code.sf.net/p/previous/code/trunk/src/
> softfloat/softfloat_fpsp.c
> >>>>
> >>>> /*==========================================================
> ==================
> >>>>
> >>>>  This C source file is an extension to the SoftFloat IEC/IEEE
> Floating-point
> >>>>  Arithmetic Package, Release 2a.
> >>>>
> >>>>  Written by Andreas Grabher for Previous, NeXT Computer Emulator.
> >>>>
> >>>> ============================================================
> =================*/
> >>>> ...
> >>>> /*----------------------------------------------------------
> ------------------
> >>>> | Algorithms for transcendental functions supported by MC68881 and
> MC68882
> >>>> | mathematical coprocessors. The functions are derived from FPSP
> library.
> >>>> *-----------------------------------------------------------
> -----------------*/
> >>>>
> >>>> FPSP library can be found:
> >>>>
> >>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/
> >>>>
> >>>> And the assembly source code is not free at all:
> >>>>
> >>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/_
> libFPSP.1.p2.N.s/l_fpsp.h
> >>>>
> >>>>
> >>>> |               Copyright (C) Motorola, Inc. 1991
> >>>> |                       All Rights Reserved
> >>>> |
> >>>> |       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
> >>>> |       The copyright notice above does not evidence any
> >>>> |       actual or intended publication of such source code.
> >>>>
> >>>>
> >>>> So I'm wondering what license apply to the C version found in
> "Previous".
> >>>
> >>> Good question. It's clearly not copied code (since the FPSP library is
> >>> all native m68k assembly), but presumably it's the same algorithms
> >>> transliterated into C...
> >>
> >> There also seem to be other versions of that library available, e.g.:
> >>
> >> https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/
> arch/m68k/fpsp/l_fpsp.h
> >>
> >> Maybe Andreas (now on CC: ) could clarify which version he used / how
> >> the C sources were developed?
> >
> > Thank you Thomas,
> >
> > This seems to be the same code re-licensed to:
> >
> > MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
> > M68000 Hi-Performance Microprocessor Division
> > M68040 Software Package
> >
> > M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
> > All rights reserved.
> >
> > THE SOFTWARE is provided on an "AS IS" basis and without warranty.
> > To the maximum extent permitted by applicable law,
> > MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
> > INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
> > PARTICULAR PURPOSE and any warranty against infringement with
> > regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
> > and any accompanying written materials.
> >
> > To the maximum extent permitted by applicable law,
> > IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
> > (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
> > PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
> > OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
> > SOFTWARE.  Motorola assumes no responsibility for the maintenance
> > and support of the SOFTWARE.
> >
> > You are hereby granted a copyright license to use, modify, and
> > distribute the SOFTWARE so long as this entire notice is retained
> > without alteration in any modified and/or redistributed versions,
> > and that such modified versions are clearly identified as such.
> > No licenses are granted by implication, estoppel or otherwise
> > under any patents or trademarks of Motorola, Inc.
>
> IANAL, but to me that sounds like it is compatible to the GPL, so I
> think there should not be a problem if the C sources are based on these
> assembler sources?
>
>  Thomas
>
>


After looking into all these files, I noticed that the previous code:

http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c

uses SoftFloat 2b code for the helper functions:
http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.h

I'm not familiar with licensing but to me it appears that Andreas Grabher
has his code as an extension to the wrong release of SoftFloat.

>>>>
/*============================================================================
>>>>
>>>>  This C source file is an extension to the SoftFloat IEC/IEEE
>>>> Floating-point
>>>>  Arithmetic Package, Release 2a.
>>>>
>>>>  Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>>>>
>>>>
=============================================================================*/
>>>> ...
>>>>
/*----------------------------------------------------------------------------
>>>> | Algorithms for transcendental functions supported by MC68881 and
MC68882
>>>> | mathematical coprocessors. The functions are derived from FPSP
library.
>>>>
*----------------------------------------------------------------------------*/

So we can't use these C code directly as it uses helpers from 2b. However,
would it be
ok to write our own set of C code along with the necessary helpers using
the C and asm
code as reference? (would be part of 2a)

William
(https://lists.gnu.org/archive/html/qemu-devel/2017-11/msg05422.html)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-12-05  8:56             ` william lin
@ 2017-12-05  9:46               ` Laurent Vivier
  2017-12-05 17:42                 ` Andreas Grabher
  0 siblings, 1 reply; 22+ messages in thread
From: Laurent Vivier @ 2017-12-05  9:46 UTC (permalink / raw)
  To: william lin, Thomas Huth
  Cc: Peter Maydell, Andreas Grabher, QEMU Developers, Aurelien Jarno,
	Richard Henderson

Le 05/12/2017 à 09:56, william lin a écrit :
> On Wed, Nov 29, 2017 at 9:19 AM, Thomas Huth <huth@tuxfamily.org
> <mailto:huth@tuxfamily.org>> wrote:
> 
>     On 29.11.2017 15:17, Laurent Vivier wrote:
>     > Le 29/11/2017 à 15:08, Thomas Huth a écrit :
>     >> On 29.11.2017 14:59, Peter Maydell wrote:
>     >>> On 29 November 2017 at 13:42, Laurent Vivier <laurent@vivier.eu
>     <mailto:laurent@vivier.eu>> wrote:
>     >>>> these functions come from:
>     >>>>
>     >>>> http://previous.alternative-system.com/
>     <http://previous.alternative-system.com/>
>     >>>>
>     >>>>
>     http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c
>     <http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c>
>     >>>>
>     >>>> This is also a modified softfloat, release 2b
>     >>>> which is BSD license if I'm correct.
>     >>>
>     >>> We can't use softfloat2b code (the part of the license that goes
>     >>> "USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
>     >>> AND ORGANIZATIONS [...] WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN
>     >>> HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE" isn't
>     >>> GPL compatible).
>     >>>
>     >>> We can use softfloat2a code, which doesn't have that indemnity
>     clause.
>     >>
>     >> Sigh. That's why WinUAE and Hatari immediately switched back to
>     >> softfloat2a (derived from QEMU) after we've identified the problem
>     >> there. Looks like the Previous folks forgot to do that step, too :-(
>     >>
>     >>>> This code has also been copied to WinUAE (GPL), where softfloat
>     has been
>     >>>> copied from QEMU:
>     >>>>
>     https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp <https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp>
>     >>>
>     >>> Yes, lots of projects used the softfloat2b code without realising
>     >>> it wasn't GPL compatible (including QEMU -- we had a painful job
>     >>> to fix things up and convert to the 2a codebase a while back).
>     >>>
>     >>>> But I think the bad news comes later:
>     >>>>
>     >>>> all the other functions (sin, cos, tan, log, exp, ...) found in
>     previous
>     >>>> (softfloat_fpsp.c) are "derived" from NeXT library FPSP:
>     >>>>
>     >>>>
>     http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
>     <http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c>
>     >>>>
>     >>>>
>     /*============================================================================
>     >>>>
>     >>>>  This C source file is an extension to the SoftFloat IEC/IEEE
>     Floating-point
>     >>>>  Arithmetic Package, Release 2a.
>     >>>>
>     >>>>  Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>     >>>>
>     >>>>
>     =============================================================================*/
>     >>>> ...
>     >>>>
>     /*----------------------------------------------------------------------------
>     >>>> | Algorithms for transcendental functions supported by MC68881
>     and MC68882
>     >>>> | mathematical coprocessors. The functions are derived from
>     FPSP library.
>     >>>>
>     *----------------------------------------------------------------------------*/
>     >>>>
>     >>>> FPSP library can be found:
>     >>>>
>     >>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/
>     <https://ftp.nice.ch/pub/next/developer/hardware/m68k/>
>     >>>>
>     >>>> And the assembly source code is not free at all:
>     >>>>
>     >>>>
>     https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h
>     <https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h>
>     >>>>
>     >>>>
>     >>>> |               Copyright (C) Motorola, Inc. 1991
>     >>>> |                       All Rights Reserved
>     >>>> |
>     >>>> |       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
>     >>>> |       The copyright notice above does not evidence any
>     >>>> |       actual or intended publication of such source code.
>     >>>>
>     >>>>
>     >>>> So I'm wondering what license apply to the C version found in
>     "Previous".
>     >>>
>     >>> Good question. It's clearly not copied code (since the FPSP
>     library is
>     >>> all native m68k assembly), but presumably it's the same algorithms
>     >>> transliterated into C...
>     >>
>     >> There also seem to be other versions of that library available, e.g.:
>     >>
>     >>
>     https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/l_fpsp.h
>     <https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/l_fpsp.h>
>     >>
>     >> Maybe Andreas (now on CC: ) could clarify which version he used / how
>     >> the C sources were developed?
>     >
>     > Thank you Thomas,
>     >
>     > This seems to be the same code re-licensed to:
>     >
>     > MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
>     > M68000 Hi-Performance Microprocessor Division
>     > M68040 Software Package
>     >
>     > M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
>     > All rights reserved.
>     >
>     > THE SOFTWARE is provided on an "AS IS" basis and without warranty.
>     > To the maximum extent permitted by applicable law,
>     > MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
>     > INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
>     > PARTICULAR PURPOSE and any warranty against infringement with
>     > regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
>     > and any accompanying written materials.
>     >
>     > To the maximum extent permitted by applicable law,
>     > IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
>     > (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
>     > PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
>     > OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
>     > SOFTWARE.  Motorola assumes no responsibility for the maintenance
>     > and support of the SOFTWARE.
>     >
>     > You are hereby granted a copyright license to use, modify, and
>     > distribute the SOFTWARE so long as this entire notice is retained
>     > without alteration in any modified and/or redistributed versions,
>     > and that such modified versions are clearly identified as such.
>     > No licenses are granted by implication, estoppel or otherwise
>     > under any patents or trademarks of Motorola, Inc.
> 
>     IANAL, but to me that sounds like it is compatible to the GPL, so I
>     think there should not be a problem if the C sources are based on these
>     assembler sources?
> 
>      Thomas
> 
> 
> 
> 
> After looking into all these files, I noticed that the previous code:
> 
> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
> 
> uses SoftFloat 2b code for the helper functions:
> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.h
> 
> I'm not familiar with licensing but to me it appears that Andreas Grabher
> has his code as an extension to the wrong release of SoftFloat.
> 
>>>>>
> /*============================================================================
>>>>>
>>>>>  This C source file is an extension to the SoftFloat IEC/IEEE 
>>>>> Floating-point
>>>>>  Arithmetic Package, Release 2a.
>>>>>
>>>>>  Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>>>>>
>>>>>
> =============================================================================*/
>>>>> ...
>>>>>
> /*----------------------------------------------------------------------------
>>>>> | Algorithms for transcendental functions supported by MC68881 and
> MC68882
>>>>> | mathematical coprocessors. The functions are derived from FPSP
> library.
>>>>>
> *----------------------------------------------------------------------------*/
> 
> So we can't use these C code directly as it uses helpers from 2b.
> However, would it be 
> ok to write our own set of C code along with the necessary helpers using
> the C and asm 
> code as reference? (would be part of 2a)

I've ported all the functions written by Andreas to QEMU/softfloat 2a
and it doesn't need any helpers from 2b.

What we need to know is what is the license of his code and if it has
been written based on the NetBSD code (BSD license) or from the libFPSP
(proprietary code) [but I think the code is the same...]

Thanks,
Laurent

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-12-05  9:46               ` Laurent Vivier
@ 2017-12-05 17:42                 ` Andreas Grabher
  2017-12-05 20:01                   ` Laurent Vivier
  0 siblings, 1 reply; 22+ messages in thread
From: Andreas Grabher @ 2017-12-05 17:42 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: william lin, Thomas Huth, Peter Maydell, QEMU Developers,
	Aurelien Jarno, Richard Henderson


Am 05.12.2017 um 10:46 schrieb Laurent Vivier <laurent@vivier.eu>:

> Le 05/12/2017 à 09:56, william lin a écrit :
>> On Wed, Nov 29, 2017 at 9:19 AM, Thomas Huth <huth@tuxfamily.org
>> <mailto:huth@tuxfamily.org>> wrote:
>> 
>>    On 29.11.2017 15:17, Laurent Vivier wrote:
>>> Le 29/11/2017 à 15:08, Thomas Huth a écrit :
>>>> On 29.11.2017 14:59, Peter Maydell wrote:
>>>>> On 29 November 2017 at 13:42, Laurent Vivier <laurent@vivier.eu
>>    <mailto:laurent@vivier.eu>> wrote:
>>>>>> these functions come from:
>>>>>> 
>>>>>> http://previous.alternative-system.com/
>>    <http://previous.alternative-system.com/>
>>>>>> 
>>>>>> 
>>    http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c
>>    <http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c>
>>>>>> 
>>>>>> This is also a modified softfloat, release 2b
>>>>>> which is BSD license if I'm correct.
>>>>> 
>>>>> We can't use softfloat2b code (the part of the license that goes
>>>>> "USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
>>>>> AND ORGANIZATIONS [...] WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN
>>>>> HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE" isn't
>>>>> GPL compatible).
>>>>> 
>>>>> We can use softfloat2a code, which doesn't have that indemnity
>>    clause.
>>>> 
>>>> Sigh. That's why WinUAE and Hatari immediately switched back to
>>>> softfloat2a (derived from QEMU) after we've identified the problem
>>>> there. Looks like the Previous folks forgot to do that step, too :-(
>>>> 
>>>>>> This code has also been copied to WinUAE (GPL), where softfloat
>>    has been
>>>>>> copied from QEMU:
>>>>>> 
>>    https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp <https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp>
>>>>> 
>>>>> Yes, lots of projects used the softfloat2b code without realising
>>>>> it wasn't GPL compatible (including QEMU -- we had a painful job
>>>>> to fix things up and convert to the 2a codebase a while back).
>>>>> 
>>>>>> But I think the bad news comes later:
>>>>>> 
>>>>>> all the other functions (sin, cos, tan, log, exp, ...) found in
>>    previous
>>>>>> (softfloat_fpsp.c) are "derived" from NeXT library FPSP:
>>>>>> 
>>>>>> 
>>    http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
>>    <http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c>
>>>>>> 
>>>>>> 
>>    /*============================================================================
>>>>>> 
>>>>>>   This C source file is an extension to the SoftFloat IEC/IEEE
>>    Floating-point
>>>>>>   Arithmetic Package, Release 2a.
>>>>>> 
>>>>>>   Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>>>>>> 
>>>>>> 
>>    =============================================================================*/
>>>>>> ...
>>>>>> 
>>    /*----------------------------------------------------------------------------
>>>>>> | Algorithms for transcendental functions supported by MC68881
>>    and MC68882
>>>>>> | mathematical coprocessors. The functions are derived from
>>    FPSP library.
>>>>>> 
>>    *----------------------------------------------------------------------------*/
>>>>>> 
>>>>>> FPSP library can be found:
>>>>>> 
>>>>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/
>>    <https://ftp.nice.ch/pub/next/developer/hardware/m68k/>
>>>>>> 
>>>>>> And the assembly source code is not free at all:
>>>>>> 
>>>>>> 
>>    https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h
>>    <https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h>
>>>>>> 
>>>>>> 
>>>>>> |               Copyright (C) Motorola, Inc. 1991
>>>>>> |                       All Rights Reserved
>>>>>> |
>>>>>> |       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
>>>>>> |       The copyright notice above does not evidence any
>>>>>> |       actual or intended publication of such source code.
>>>>>> 
>>>>>> 
>>>>>> So I'm wondering what license apply to the C version found in
>>    "Previous".
>>>>> 
>>>>> Good question. It's clearly not copied code (since the FPSP
>>    library is
>>>>> all native m68k assembly), but presumably it's the same algorithms
>>>>> transliterated into C...
>>>> 
>>>> There also seem to be other versions of that library available, e.g.:
>>>> 
>>>> 
>>    https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/l_fpsp.h
>>    <https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/l_fpsp.h>
>>>> 
>>>> Maybe Andreas (now on CC: ) could clarify which version he used / how
>>>> the C sources were developed?
>>> 
>>> Thank you Thomas,
>>> 
>>> This seems to be the same code re-licensed to:
>>> 
>>> MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
>>> M68000 Hi-Performance Microprocessor Division
>>> M68040 Software Package
>>> 
>>> M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
>>> All rights reserved.
>>> 
>>> THE SOFTWARE is provided on an "AS IS" basis and without warranty.
>>> To the maximum extent permitted by applicable law,
>>> MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
>>> INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
>>> PARTICULAR PURPOSE and any warranty against infringement with
>>> regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
>>> and any accompanying written materials.
>>> 
>>> To the maximum extent permitted by applicable law,
>>> IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
>>> (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
>>> PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
>>> OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
>>> SOFTWARE.  Motorola assumes no responsibility for the maintenance
>>> and support of the SOFTWARE.
>>> 
>>> You are hereby granted a copyright license to use, modify, and
>>> distribute the SOFTWARE so long as this entire notice is retained
>>> without alteration in any modified and/or redistributed versions,
>>> and that such modified versions are clearly identified as such.
>>> No licenses are granted by implication, estoppel or otherwise
>>> under any patents or trademarks of Motorola, Inc.
>> 
>>    IANAL, but to me that sounds like it is compatible to the GPL, so I
>>    think there should not be a problem if the C sources are based on these
>>    assembler sources?
>> 
>>     Thomas
>> 
>> 
>> 
>> 
>> After looking into all these files, I noticed that the previous code:
>> 
>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
>> 
>> uses SoftFloat 2b code for the helper functions:
>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.h
>> 
>> I'm not familiar with licensing but to me it appears that Andreas Grabher
>> has his code as an extension to the wrong release of SoftFloat.
>> 
>>>>>> 
>> /*============================================================================
>>>>>> 
>>>>>>   This C source file is an extension to the SoftFloat IEC/IEEE 
>>>>>> Floating-point
>>>>>>   Arithmetic Package, Release 2a.
>>>>>> 
>>>>>>   Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>>>>>> 
>>>>>> 
>> =============================================================================*/
>>>>>> ...
>>>>>> 
>> /*----------------------------------------------------------------------------
>>>>>> | Algorithms for transcendental functions supported by MC68881 and
>> MC68882
>>>>>> | mathematical coprocessors. The functions are derived from FPSP
>> library.
>>>>>> 
>> *----------------------------------------------------------------------------*/
>> 
>> So we can't use these C code directly as it uses helpers from 2b.
>> However, would it be 
>> ok to write our own set of C code along with the necessary helpers using
>> the C and asm 
>> code as reference? (would be part of 2a)
> 
> I've ported all the functions written by Andreas to QEMU/softfloat 2a
> and it doesn't need any helpers from 2b.
> 
> What we need to know is what is the license of his code and if it has
> been written based on the NetBSD code (BSD license) or from the libFPSP
> (proprietary code) [but I think the code is the same...]
> 
> Thanks,
> Laurent


AFAIK SoftFloat 2a and 2b are identical, except for the license headers. So i don't see any need to rewrite any code. Just replace the headers.

I did translate the FPSP functions from this release of NetBSD:

|	$NetBSD: copyright.s,v 1.2 1994/10/26 07:48:57 cgd Exp $

.text
.ascii	"MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP\n"
.ascii	"M68000 Hi-Performance Microprocessor Division\n"
.ascii	"M68040 Software Package\n"
.ascii	"\n"
.ascii	"M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.\n"
.ascii	"All rights reserved.\n"
.ascii	"\n"
.ascii	"THE SOFTWARE is provided on an \"AS IS\" basis and without warranty.\n"
.ascii	"To the maximum extent permitted by applicable law,\n"
.ascii	"MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,\n"
.ascii	"INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A\n"
.ascii	"PARTICULAR PURPOSE and any warranty against infringement with\n"
.ascii	"regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)\n"
.ascii	"and any accompanying written materials. \n"
.ascii	"\n"
.ascii	"To the maximum extent permitted by applicable law,\n"
.ascii	"IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER\n"
.ascii	"(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS\n"
.ascii	"PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR\n"
.ascii	"OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE\n"
.ascii	"SOFTWARE.  Motorola assumes no responsibility for the maintenance\n"
.ascii	"and support of the SOFTWARE.  \n"
.ascii	"\n"
.ascii	"You are hereby granted a copyright license to use, modify, and\n"
.ascii	"distribute the SOFTWARE so long as this entire notice is retained\n"
.ascii	"without alteration in any modified and/or redistributed versions,\n"
.ascii	"and that such modified versions are clearly identified as such.\n"
.ascii	"No licenses are granted by implication, estoppel or otherwise\n"
.ascii	"under any patents or trademarks of Motorola, Inc.\n"


Anyway i still think we generally violate some copyrights just by emulating the 68k. I can't imagine we are allowed to copy Motorola's CPU design in software and give it away. In its 68030 and 68040 users's manuals it tells:

"... Motorola does not assume any liability arising out of the application or use of any product or circuit described herein; neither does it convey any license under its patent rights nor the rights of others. ..." 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-12-05 17:42                 ` Andreas Grabher
@ 2017-12-05 20:01                   ` Laurent Vivier
  2017-12-05 21:24                     ` william lin
  0 siblings, 1 reply; 22+ messages in thread
From: Laurent Vivier @ 2017-12-05 20:01 UTC (permalink / raw)
  To: Andreas Grabher
  Cc: william lin, Thomas Huth, Peter Maydell, QEMU Developers,
	Aurelien Jarno, Richard Henderson

Le 05/12/2017 à 18:42, Andreas Grabher a écrit :
> 
> Am 05.12.2017 um 10:46 schrieb Laurent Vivier <laurent@vivier.eu
> <mailto:laurent@vivier.eu>>:
> 
>> Le 05/12/2017 à 09:56, william lin a écrit :
>>> On Wed, Nov 29, 2017 at 9:19 AM, Thomas Huth <huth@tuxfamily.org
>>> <mailto:huth@tuxfamily.org>
>>> <mailto:huth@tuxfamily.org>> wrote:
>>>
>>>    On 29.11.2017 15:17, Laurent Vivier wrote:
>>>> Le 29/11/2017 à 15:08, Thomas Huth a écrit :
>>>>> On 29.11.2017 14:59, Peter Maydell wrote:
>>>>>> On 29 November 2017 at 13:42, Laurent Vivier <laurent@vivier.eu
>>>>>> <mailto:laurent@vivier.eu>
>>>    <mailto:laurent@vivier.eu>> wrote:
>>>>>>> these functions come from:
>>>>>>>
>>>>>>> http://previous.alternative-system.com/
>>>    <http://previous.alternative-system.com/>
>>>>>>>
>>>>>>>
>>>    http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c
>>>    <http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.c>
>>>>>>>
>>>>>>> This is also a modified softfloat, release 2b
>>>>>>> which is BSD license if I'm correct.
>>>>>>
>>>>>> We can't use softfloat2b code (the part of the license that goes
>>>>>> "USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
>>>>>> AND ORGANIZATIONS [...] WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN
>>>>>> HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE" isn't
>>>>>> GPL compatible).
>>>>>>
>>>>>> We can use softfloat2a code, which doesn't have that indemnity
>>>    clause.
>>>>>
>>>>> Sigh. That's why WinUAE and Hatari immediately switched back to
>>>>> softfloat2a (derived from QEMU) after we've identified the problem
>>>>> there. Looks like the Previous folks forgot to do that step, too :-(
>>>>>
>>>>>>> This code has also been copied to WinUAE (GPL), where softfloat
>>>    has been
>>>>>>> copied from QEMU:
>>>>>>>
>>>    https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp
>>> <https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp>
>>>>>>
>>>>>> Yes, lots of projects used the softfloat2b code without realising
>>>>>> it wasn't GPL compatible (including QEMU -- we had a painful job
>>>>>> to fix things up and convert to the 2a codebase a while back).
>>>>>>
>>>>>>> But I think the bad news comes later:
>>>>>>>
>>>>>>> all the other functions (sin, cos, tan, log, exp, ...) found in
>>>    previous
>>>>>>> (softfloat_fpsp.c) are "derived" from NeXT library FPSP:
>>>>>>>
>>>>>>>
>>>    http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
>>>    <http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c>
>>>>>>>
>>>>>>>
>>>    /*============================================================================
>>>>>>>
>>>>>>>   This C source file is an extension to the SoftFloat IEC/IEEE
>>>    Floating-point
>>>>>>>   Arithmetic Package, Release 2a.
>>>>>>>
>>>>>>>   Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>>>>>>>
>>>>>>>
>>>    =============================================================================*/
>>>>>>> ...
>>>>>>>
>>>    /*----------------------------------------------------------------------------
>>>>>>> | Algorithms for transcendental functions supported by MC68881
>>>    and MC68882
>>>>>>> | mathematical coprocessors. The functions are derived from
>>>    FPSP library.
>>>>>>>
>>>    *----------------------------------------------------------------------------*/
>>>>>>>
>>>>>>> FPSP library can be found:
>>>>>>>
>>>>>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/
>>>    <https://ftp.nice.ch/pub/next/developer/hardware/m68k/>
>>>>>>>
>>>>>>> And the assembly source code is not free at all:
>>>>>>>
>>>>>>>
>>>    https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h
>>>    <https://ftp.nice.ch/pub/next/developer/hardware/m68k/_libFPSP.1.p2.N.s/l_fpsp.h>
>>>>>>>
>>>>>>>
>>>>>>> |               Copyright (C) Motorola, Inc. 1991
>>>>>>> |                       All Rights Reserved
>>>>>>> |
>>>>>>> |       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
>>>>>>> |       The copyright notice above does not evidence any
>>>>>>> |       actual or intended publication of such source code.
>>>>>>>
>>>>>>>
>>>>>>> So I'm wondering what license apply to the C version found in
>>>    "Previous".
>>>>>>
>>>>>> Good question. It's clearly not copied code (since the FPSP
>>>    library is
>>>>>> all native m68k assembly), but presumably it's the same algorithms
>>>>>> transliterated into C...
>>>>>
>>>>> There also seem to be other versions of that library available, e.g.:
>>>>>
>>>>>
>>>    https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/l_fpsp.h
>>>    <https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/m68k/fpsp/l_fpsp.h>
>>>>>
>>>>> Maybe Andreas (now on CC: ) could clarify which version he used / how
>>>>> the C sources were developed?
>>>>
>>>> Thank you Thomas,
>>>>
>>>> This seems to be the same code re-licensed to:
>>>>
>>>> MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
>>>> M68000 Hi-Performance Microprocessor Division
>>>> M68040 Software Package
>>>>
>>>> M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
>>>> All rights reserved.
>>>>
>>>> THE SOFTWARE is provided on an "AS IS" basis and without warranty.
>>>> To the maximum extent permitted by applicable law,
>>>> MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
>>>> INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
>>>> PARTICULAR PURPOSE and any warranty against infringement with
>>>> regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
>>>> and any accompanying written materials.
>>>>
>>>> To the maximum extent permitted by applicable law,
>>>> IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
>>>> (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
>>>> PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
>>>> OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
>>>> SOFTWARE.  Motorola assumes no responsibility for the maintenance
>>>> and support of the SOFTWARE.
>>>>
>>>> You are hereby granted a copyright license to use, modify, and
>>>> distribute the SOFTWARE so long as this entire notice is retained
>>>> without alteration in any modified and/or redistributed versions,
>>>> and that such modified versions are clearly identified as such.
>>>> No licenses are granted by implication, estoppel or otherwise
>>>> under any patents or trademarks of Motorola, Inc.
>>>
>>>    IANAL, but to me that sounds like it is compatible to the GPL, so I
>>>    think there should not be a problem if the C sources are based on
>>> these
>>>    assembler sources?
>>>
>>>     Thomas
>>>
>>>
>>>
>>>
>>> After looking into all these files, I noticed that the previous code:
>>>
>>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat_fpsp.c
>>>
>>> uses SoftFloat 2b code for the helper functions:
>>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.h
>>>
>>> I'm not familiar with licensing but to me it appears that Andreas Grabher
>>> has his code as an extension to the wrong release of SoftFloat.
>>>
>>>>>>>
>>> /*============================================================================
>>>>>>>
>>>>>>>   This C source file is an extension to the SoftFloat IEC/IEEE 
>>>>>>> Floating-point
>>>>>>>   Arithmetic Package, Release 2a.
>>>>>>>
>>>>>>>   Written by Andreas Grabher for Previous, NeXT Computer Emulator.
>>>>>>>
>>>>>>>
>>> =============================================================================*/
>>>>>>> ...
>>>>>>>
>>> /*----------------------------------------------------------------------------
>>>>>>> | Algorithms for transcendental functions supported by MC68881 and
>>> MC68882
>>>>>>> | mathematical coprocessors. The functions are derived from FPSP
>>> library.
>>>>>>>
>>> *----------------------------------------------------------------------------*/
>>>
>>> So we can't use these C code directly as it uses helpers from 2b.
>>> However, would it be 
>>> ok to write our own set of C code along with the necessary helpers using
>>> the C and asm 
>>> code as reference? (would be part of 2a)
>>
>> I've ported all the functions written by Andreas to QEMU/softfloat 2a
>> and it doesn't need any helpers from 2b.
>>
>> What we need to know is what is the license of his code and if it has
>> been written based on the NetBSD code (BSD license) or from the libFPSP
>> (proprietary code) [but I think the code is the same...]
>>
>> Thanks,
>> Laurent
> 
> 
> AFAIK SoftFloat 2a and 2b are identical, except for the license headers.
> So i don't see any need to rewrite any code. Just replace the headers.
> 
> I did translate the FPSP functions from this release of NetBSD:

Thank you for your answer (and your work).

> |$NetBSD: copyright.s,v 1.2 1994/10/26 07:48:57 cgd Exp $
> 
> .text
> .ascii"MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP\n"
> .ascii"M68000 Hi-Performance Microprocessor Division\n"
> .ascii"M68040 Software Package\n"
> .ascii"\n"
> .ascii"M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.\n"
> .ascii"All rights reserved.\n"
> .ascii"\n"
> .ascii"THE SOFTWARE is provided on an \"AS IS\" basis and without
> warranty.\n"
> .ascii"To the maximum extent permitted by applicable law,\n"
> .ascii"MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,\n"
> .ascii"INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A\n"
> .ascii"PARTICULAR PURPOSE and any warranty against infringement with\n"
> .ascii"regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)\n"
> .ascii"and any accompanying written materials. \n"
> .ascii"\n"
> .ascii"To the maximum extent permitted by applicable law,\n"
> .ascii"IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER\n"
> .ascii"(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS\n"
> .ascii"PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR\n"
> .ascii"OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE\n"
> .ascii"SOFTWARE.  Motorola assumes no responsibility for the maintenance\n"
> .ascii"and support of the SOFTWARE.  \n"
> .ascii"\n"
> .ascii"You are hereby granted a copyright license to use, modify, and\n"
> .ascii"distribute the SOFTWARE so long as this entire notice is retained\n"
> .ascii"without alteration in any modified and/or redistributed versions,\n"
> .ascii"and that such modified versions are clearly identified as such.\n"
> .ascii"No licenses are granted by implication, estoppel or otherwise\n"
> .ascii"under any patents or trademarks of Motorola, Inc.\n"
> 
> 
> Anyway i still think we generally violate some copyrights just by
> emulating the 68k. I can't imagine we are allowed to copy Motorola's CPU
> design in software and give it away. In its 68030 and 68040 users's
> manuals it tells:
> 
> "... Motorola does not assume any liability arising out of the
> application or use of any product or circuit described herein; neither
> does it convey any license under its patent rights nor the rights of
> others. ..." 

I'm not a lawyer, and this is only my opinion, but I think our case is
covered by EU Directive 2009/24 [1]:

(15) The unauthorised reproduction, translation, adaptation or
transformation of the form of the code in which a copy of a computer
program has been made available constitutes an infringement of the
exclusive rights of the author. Nevertheless, circumstances may exist
when such a reproduction of the code and translation of its form are
indispensable to obtain the necessary information to achieve the
interoperability of an independently created program with other
programs. It has therefore to be considered that, in these limited
circumstances only, performance of the acts of reproduction and
translation by or on behalf of a person having a right to use a copy of
the program is legitimate and compatible with fair practice and must
therefore be deemed not to require the authorisation of the rightholder.
An objective of this exception is to make it possible to connect all
components of a computer system, including those of different
manufacturers, so that they can work together. Such an exception to the
author's exclusive rights may not be used in a way which prejudices the
legitimate interests of the rightholder or which conflicts with a normal
exploitation of the program.

Thanks,
Laurent

[1] http://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX:32009L0024

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-12-05 20:01                   ` Laurent Vivier
@ 2017-12-05 21:24                     ` william lin
  2017-12-06  8:20                       ` Laurent Vivier
  0 siblings, 1 reply; 22+ messages in thread
From: william lin @ 2017-12-05 21:24 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: Andreas Grabher, Thomas Huth, Peter Maydell, QEMU Developers,
	Aurelien Jarno, Richard Henderson

On Tue, Dec 5, 2017 at 2:01 PM, Laurent Vivier <laurent@vivier.eu> wrote:

> Le 05/12/2017 à 18:42, Andreas Grabher a écrit :
> >
> > Am 05.12.2017 um 10:46 schrieb Laurent Vivier <laurent@vivier.eu
> > <mailto:laurent@vivier.eu>>:
> >
> >> Le 05/12/2017 à 09:56, william lin a écrit :
> >>> On Wed, Nov 29, 2017 at 9:19 AM, Thomas Huth <huth@tuxfamily.org
> >>> <mailto:huth@tuxfamily.org>
> >>> <mailto:huth@tuxfamily.org>> wrote:
> >>>
> >>>    On 29.11.2017 15:17, Laurent Vivier wrote:
> >>>> Le 29/11/2017 à 15:08, Thomas Huth a écrit :
> >>>>> On 29.11.2017 14:59, Peter Maydell wrote:
> >>>>>> On 29 November 2017 at 13:42, Laurent Vivier <laurent@vivier.eu
> >>>>>> <mailto:laurent@vivier.eu>
> >>>    <mailto:laurent@vivier.eu>> wrote:
> >>>>>>> these functions come from:
> >>>>>>>
> >>>>>>> http://previous.alternative-system.com/
> >>>    <http://previous.alternative-system.com/>
> >>>>>>>
> >>>>>>>
> >>>    http://svn.code.sf.net/p/previous/code/trunk/src/
> softfloat/softfloat.c
> >>>    <http://svn.code.sf.net/p/previous/code/trunk/src/
> softfloat/softfloat.c>
> >>>>>>>
> >>>>>>> This is also a modified softfloat, release 2b
> >>>>>>> which is BSD license if I'm correct.
> >>>>>>
> >>>>>> We can't use softfloat2b code (the part of the license that goes
> >>>>>> "USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
> >>>>>> AND ORGANIZATIONS [...] WHO FURTHERMORE EFFECTIVELY INDEMNIFY JOHN
> >>>>>> HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE" isn't
> >>>>>> GPL compatible).
> >>>>>>
> >>>>>> We can use softfloat2a code, which doesn't have that indemnity
> >>>    clause.
> >>>>>
> >>>>> Sigh. That's why WinUAE and Hatari immediately switched back to
> >>>>> softfloat2a (derived from QEMU) after we've identified the problem
> >>>>> there. Looks like the Previous folks forgot to do that step, too :-(
> >>>>>
> >>>>>>> This code has also been copied to WinUAE (GPL), where softfloat
> >>>    has been
> >>>>>>> copied from QEMU:
> >>>>>>>
> >>>    https://github.com/tonioni/WinUAE/blob/master/softfloat/
> softfloat.cpp
> >>> <https://github.com/tonioni/WinUAE/blob/master/softfloat/softfloat.cpp
> >
> >>>>>>
> >>>>>> Yes, lots of projects used the softfloat2b code without realising
> >>>>>> it wasn't GPL compatible (including QEMU -- we had a painful job
> >>>>>> to fix things up and convert to the 2a codebase a while back).
> >>>>>>
> >>>>>>> But I think the bad news comes later:
> >>>>>>>
> >>>>>>> all the other functions (sin, cos, tan, log, exp, ...) found in
> >>>    previous
> >>>>>>> (softfloat_fpsp.c) are "derived" from NeXT library FPSP:
> >>>>>>>
> >>>>>>>
> >>>    http://svn.code.sf.net/p/previous/code/trunk/src/
> softfloat/softfloat_fpsp.c
> >>>    <http://svn.code.sf.net/p/previous/code/trunk/src/
> softfloat/softfloat_fpsp.c>
> >>>>>>>
> >>>>>>>
> >>>    /*=======================================================
> =====================
> >>>>>>>
> >>>>>>>   This C source file is an extension to the SoftFloat IEC/IEEE
> >>>    Floating-point
> >>>>>>>   Arithmetic Package, Release 2a.
> >>>>>>>
> >>>>>>>   Written by Andreas Grabher for Previous, NeXT Computer Emulator.
> >>>>>>>
> >>>>>>>
> >>>    =========================================================
> ====================*/
> >>>>>>> ...
> >>>>>>>
> >>>    /*-------------------------------------------------------
> ---------------------
> >>>>>>> | Algorithms for transcendental functions supported by MC68881
> >>>    and MC68882
> >>>>>>> | mathematical coprocessors. The functions are derived from
> >>>    FPSP library.
> >>>>>>>
> >>>    *--------------------------------------------------------
> --------------------*/
> >>>>>>>
> >>>>>>> FPSP library can be found:
> >>>>>>>
> >>>>>>> https://ftp.nice.ch/pub/next/developer/hardware/m68k/
> >>>    <https://ftp.nice.ch/pub/next/developer/hardware/m68k/>
> >>>>>>>
> >>>>>>> And the assembly source code is not free at all:
> >>>>>>>
> >>>>>>>
> >>>    https://ftp.nice.ch/pub/next/developer/hardware/m68k/_
> libFPSP.1.p2.N.s/l_fpsp.h
> >>>    <https://ftp.nice.ch/pub/next/developer/hardware/m68k/_
> libFPSP.1.p2.N.s/l_fpsp.h>
> >>>>>>>
> >>>>>>>
> >>>>>>> |               Copyright (C) Motorola, Inc. 1991
> >>>>>>> |                       All Rights Reserved
> >>>>>>> |
> >>>>>>> |       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
> >>>>>>> |       The copyright notice above does not evidence any
> >>>>>>> |       actual or intended publication of such source code.
> >>>>>>>
> >>>>>>>
> >>>>>>> So I'm wondering what license apply to the C version found in
> >>>    "Previous".
> >>>>>>
> >>>>>> Good question. It's clearly not copied code (since the FPSP
> >>>    library is
> >>>>>> all native m68k assembly), but presumably it's the same algorithms
> >>>>>> transliterated into C...
> >>>>>
> >>>>> There also seem to be other versions of that library available, e.g.:
> >>>>>
> >>>>>
> >>>    https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/
> arch/m68k/fpsp/l_fpsp.h
> >>>    <https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/
> sys/arch/m68k/fpsp/l_fpsp.h>
> >>>>>
> >>>>> Maybe Andreas (now on CC: ) could clarify which version he used / how
> >>>>> the C sources were developed?
> >>>>
> >>>> Thank you Thomas,
> >>>>
> >>>> This seems to be the same code re-licensed to:
> >>>>
> >>>> MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
> >>>> M68000 Hi-Performance Microprocessor Division
> >>>> M68040 Software Package
> >>>>
> >>>> M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
> >>>> All rights reserved.
> >>>>
> >>>> THE SOFTWARE is provided on an "AS IS" basis and without warranty.
> >>>> To the maximum extent permitted by applicable law,
> >>>> MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
> >>>> INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
> >>>> PARTICULAR PURPOSE and any warranty against infringement with
> >>>> regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
> >>>> and any accompanying written materials.
> >>>>
> >>>> To the maximum extent permitted by applicable law,
> >>>> IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
> >>>> (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
> >>>> PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
> >>>> OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
> >>>> SOFTWARE.  Motorola assumes no responsibility for the maintenance
> >>>> and support of the SOFTWARE.
> >>>>
> >>>> You are hereby granted a copyright license to use, modify, and
> >>>> distribute the SOFTWARE so long as this entire notice is retained
> >>>> without alteration in any modified and/or redistributed versions,
> >>>> and that such modified versions are clearly identified as such.
> >>>> No licenses are granted by implication, estoppel or otherwise
> >>>> under any patents or trademarks of Motorola, Inc.
> >>>
> >>>    IANAL, but to me that sounds like it is compatible to the GPL, so I
> >>>    think there should not be a problem if the C sources are based on
> >>> these
> >>>    assembler sources?
> >>>
> >>>     Thomas
> >>>
> >>>
> >>>
> >>>
> >>> After looking into all these files, I noticed that the previous code:
> >>>
> >>> http://svn.code.sf.net/p/previous/code/trunk/src/
> softfloat/softfloat_fpsp.c
> >>>
> >>> uses SoftFloat 2b code for the helper functions:
> >>> http://svn.code.sf.net/p/previous/code/trunk/src/softfloat/softfloat.h
> >>>
> >>> I'm not familiar with licensing but to me it appears that Andreas
> Grabher
> >>> has his code as an extension to the wrong release of SoftFloat.
> >>>
> >>>>>>>
> >>> /*==========================================================
> ==================
> >>>>>>>
> >>>>>>>   This C source file is an extension to the SoftFloat IEC/IEEE
> >>>>>>> Floating-point
> >>>>>>>   Arithmetic Package, Release 2a.
> >>>>>>>
> >>>>>>>   Written by Andreas Grabher for Previous, NeXT Computer Emulator.
> >>>>>>>
> >>>>>>>
> >>> ============================================================
> =================*/
> >>>>>>> ...
> >>>>>>>
> >>> /*----------------------------------------------------------
> ------------------
> >>>>>>> | Algorithms for transcendental functions supported by MC68881 and
> >>> MC68882
> >>>>>>> | mathematical coprocessors. The functions are derived from FPSP
> >>> library.
> >>>>>>>
> >>> *-----------------------------------------------------------
> -----------------*/
> >>>
> >>> So we can't use these C code directly as it uses helpers from 2b.
> >>> However, would it be
> >>> ok to write our own set of C code along with the necessary helpers
> using
> >>> the C and asm
> >>> code as reference? (would be part of 2a)
> >>
> >> I've ported all the functions written by Andreas to QEMU/softfloat 2a
> >> and it doesn't need any helpers from 2b.
> >>
> >> What we need to know is what is the license of his code and if it has
> >> been written based on the NetBSD code (BSD license) or from the libFPSP
> >> (proprietary code) [but I think the code is the same...]
> >>
> >> Thanks,
> >> Laurent
>

The functions we are looking for in particular are the transcendental and
trig functions
for floatx80. (sin, cos, twotox, etc..)

For some context:
We need and implementation of those  functions for x86 as it currently
converts floatx80 to
double before calling into glibc and then converting back to floatx80. This
results
in inaccuracies for calculations that use x87 instructions for intermediate
operations.
(https://bugs.launchpad.net/qemu/+bug/645662)


I searched through the archive and found your code for this patch:

https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg03766.html

...

+void HELPER(sincos_FP0_FP1)(CPUM68KState *env)
+{
+    floatx80 res;
+    long double val, valsin, valcos;
+
+    val = floatx80_to_ldouble(FP0_to_floatx80(env));
+
+    sincosl(val, &valsin, &valcos);
+    res = ldouble_to_floatx80(valsin);
+    floatx80_to_FP0(env, res);
+    res = ldouble_to_floatx80(valcos);
+    floatx80_to_FP1(env, res);
+}

...

In relation to the bug, this implementation would provide more accurate
results, but not be consistent with actual x87 hardware.

If these are not the code you are referring to, then can you please point
to us the
correct ones?

Thanks
William

>
> > AFAIK SoftFloat 2a and 2b are identical, except for the license headers.
> > So i don't see any need to rewrite any code. Just replace the headers.
> >
> > I did translate the FPSP functions from this release of NetBSD:
>
> Thank you for your answer (and your work).
>
> > |$NetBSD: copyright.s,v 1.2 1994/10/26 07:48:57 cgd Exp $
> >
> > .text
> > .ascii"MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP\n"
> > .ascii"M68000 Hi-Performance Microprocessor Division\n"
> > .ascii"M68040 Software Package\n"
> > .ascii"\n"
> > .ascii"M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.\n"
> > .ascii"All rights reserved.\n"
> > .ascii"\n"
> > .ascii"THE SOFTWARE is provided on an \"AS IS\" basis and without
> > warranty.\n"
> > .ascii"To the maximum extent permitted by applicable law,\n"
> > .ascii"MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,\n"
> > .ascii"INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
> A\n"
> > .ascii"PARTICULAR PURPOSE and any warranty against infringement with\n"
> > .ascii"regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS
> THEREOF)\n"
> > .ascii"and any accompanying written materials. \n"
> > .ascii"\n"
> > .ascii"To the maximum extent permitted by applicable law,\n"
> > .ascii"IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER\n"
> > .ascii"(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS\n"
> > .ascii"PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,
> OR\n"
> > .ascii"OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE
> THE\n"
> > .ascii"SOFTWARE.  Motorola assumes no responsibility for the
> maintenance\n"
> > .ascii"and support of the SOFTWARE.  \n"
> > .ascii"\n"
> > .ascii"You are hereby granted a copyright license to use, modify, and\n"
> > .ascii"distribute the SOFTWARE so long as this entire notice is
> retained\n"
> > .ascii"without alteration in any modified and/or redistributed
> versions,\n"
> > .ascii"and that such modified versions are clearly identified as such.\n"
> > .ascii"No licenses are granted by implication, estoppel or otherwise\n"
> > .ascii"under any patents or trademarks of Motorola, Inc.\n"
> >
> >
> > Anyway i still think we generally violate some copyrights just by
> > emulating the 68k. I can't imagine we are allowed to copy Motorola's CPU
> > design in software and give it away. In its 68030 and 68040 users's
> > manuals it tells:
> >
> > "... Motorola does not assume any liability arising out of the
> > application or use of any product or circuit described herein; neither
> > does it convey any license under its patent rights nor the rights of
> > others. ..."
>
> I'm not a lawyer, and this is only my opinion, but I think our case is
> covered by EU Directive 2009/24 [1]:
>
> (15) The unauthorised reproduction, translation, adaptation or
> transformation of the form of the code in which a copy of a computer
> program has been made available constitutes an infringement of the
> exclusive rights of the author. Nevertheless, circumstances may exist
> when such a reproduction of the code and translation of its form are
> indispensable to obtain the necessary information to achieve the
> interoperability of an independently created program with other
> programs. It has therefore to be considered that, in these limited
> circumstances only, performance of the acts of reproduction and
> translation by or on behalf of a person having a right to use a copy of
> the program is legitimate and compatible with fair practice and must
> therefore be deemed not to require the authorisation of the rightholder.
> An objective of this exception is to make it possible to connect all
> components of a computer system, including those of different
> manufacturers, so that they can work together. Such an exception to the
> author's exclusive rights may not be used in a way which prejudices the
> legitimate interests of the rightholder or which conflicts with a normal
> exploitation of the program.
>
> Thanks,
> Laurent
>
> [1] http://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?
> uri=CELEX:32009L0024
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-12-05 21:24                     ` william lin
@ 2017-12-06  8:20                       ` Laurent Vivier
  0 siblings, 0 replies; 22+ messages in thread
From: Laurent Vivier @ 2017-12-06  8:20 UTC (permalink / raw)
  To: william lin
  Cc: Andreas Grabher, Thomas Huth, Peter Maydell, QEMU Developers,
	Aurelien Jarno, Richard Henderson

Le 05/12/2017 à 22:24, william lin a écrit :
> 
> 
> On Tue, Dec 5, 2017 at 2:01 PM, Laurent Vivier <laurent@vivier.eu
> <mailto:laurent@vivier.eu>> wrote:
> 
>     Le 05/12/2017 à 18:42, Andreas Grabher a écrit :
>     >
>     > Am 05.12.2017 um 10:46 schrieb Laurent Vivier <laurent@vivier.eu <mailto:laurent@vivier.eu>
>     > <mailto:laurent@vivier.eu <mailto:laurent@vivier.eu>>>:
>     >
>     >> Le 05/12/2017 à 09:56, william lin a écrit :
>     >>> On Wed, Nov 29, 2017 at 9:19 AM, Thomas Huth <huth@tuxfamily.org
>     <mailto:huth@tuxfamily.org>
>     >>> <mailto:huth@tuxfamily.org <mailto:huth@tuxfamily.org>>
>     >>> <mailto:huth@tuxfamily.org <mailto:huth@tuxfamily.org>>> wrote:
>     >>>
>     >>>    On 29.11.2017 15:17, Laurent Vivier wrote:
...
>     >>>
>     >>> So we can't use these C code directly as it uses helpers from 2b.
>     >>> However, would it be 
>     >>> ok to write our own set of C code along with the necessary
>     helpers using
>     >>> the C and asm 
>     >>> code as reference? (would be part of 2a)
>     >>
>     >> I've ported all the functions written by Andreas to QEMU/softfloat 2a
>     >> and it doesn't need any helpers from 2b.
>     >>
>     >> What we need to know is what is the license of his code and if it has
>     >> been written based on the NetBSD code (BSD license) or from the
>     libFPSP
>     >> (proprietary code) [but I think the code is the same...]
>     >>
>     >> Thanks,
>     >> Laurent
> 
> 
> The functions we are looking for in particular are the transcendental
> and trig functions
> for floatx80. (sin, cos, twotox, etc..)
> 
> For some context:
> We need and implementation of those  functions for x86 as it currently
> converts floatx80 to
> double before calling into glibc and then converting back to floatx80.
> This results 
> in inaccuracies for calculations that use x87 instructions for
> intermediate operations.
> (https://bugs.launchpad.net/qemu/+bug/645662)
> 
> 
> I searched through the archive and found your code for this patch:
> 
> https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg03766.html
> 
> ...
> 
> +void HELPER(sincos_FP0_FP1)(CPUM68KState *env)
> +{
> +    floatx80 res;
> +    long double val, valsin, valcos;
> +
> +    val = floatx80_to_ldouble(FP0_to_floatx80(env));
> +
> +    sincosl(val, &valsin, &valcos);
> +    res = ldouble_to_floatx80(valsin);
> +    floatx80_to_FP0(env, res);
> +    res = ldouble_to_floatx80(valcos);
> +    floatx80_to_FP1(env, res);
> +}
> 
> ...
> 
> In relation to the bug, this implementation would provide more accurate 
> results, but not be consistent with actual x87 hardware.
> 
> If these are not the code you are referring to, then can you please
> point to us the 
> correct ones?

The code ported from "previous" to QEMU can be found here:

https://github.com/vivier/qemu-m68k/blob/m68k-dev/fpu/softfloat.c#L7422

but it needs some more polishing.

Thanks,
Laurent

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-11-23 16:35 [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Laurent Vivier
                   ` (5 preceding siblings ...)
  2017-11-29 12:49 ` [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Peter Maydell
@ 2017-12-06 10:24 ` Alex Bennée
  2017-12-15  8:29   ` william lin
  2017-12-20 18:25 ` Laurent Vivier
  7 siblings, 1 reply; 22+ messages in thread
From: Alex Bennée @ 2017-12-06 10:24 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-devel, Thomas Huth, Aurelien Jarno, Richard Henderson


Laurent Vivier <laurent@vivier.eu> writes:

> Implement fmod, frem, fscale, fgetman and fgetexp.
>
> Instead of using functions of libm (v1 of this series)
> and converting between host long double and floatx80 type
> the new version (v2) adds new floatx80 functions in softfloat.

68k used 80bit float, well TIL ;-)

Just for reference Richard and I did a sprint on hacking the softfloat
last week. The results are currently brewing in:

  https://github.com/stsquad/qemu/tree/softfloat-and-arm-fp16-v2

The main push has been to decompose 16/32/64 bit floats and have a
common set of operations. This means we work with an internal 64 bit
fractional part and then just round appropriately when we pack the
result. It's a big departure from SoftFloat2a but seeing as we are not
likely to bring in changes from upstream we felt it was worth it from a
code clarity point of view.

However we have punted touching the 80bit code and any potential
quad-precision stuff to a later date, preferably when int128_t is easier
to use. Perhaps it is worth considering that option now?

>
> All the floatx80 functions are copied from "Previous",
> the NeXT Computer Emulator, and written by Andreas Grabher.
>
> Laurent Vivier (5):
>   softfloat: add floatx80_mod()
>   target/m68k: add fmod/frem
>   softfloat: use floatx80_infinity in softfloat
>   softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale()
>   target-m68k: add fscale, fgetman and fgetexp
>
>  fpu/softfloat-specialize.h |  29 +++++
>  fpu/softfloat.c            | 258 ++++++++++++++++++++++++++++++++++++++++++---
>  include/fpu/softfloat.h    |  13 ++-
>  target/m68k/cpu.h          |   1 +
>  target/m68k/fpu_helper.c   |  48 +++++++++
>  target/m68k/helper.h       |   5 +
>  target/m68k/translate.c    |  15 +++
>  7 files changed, 355 insertions(+), 14 deletions(-)


--
Alex Bennée

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-12-06 10:24 ` Alex Bennée
@ 2017-12-15  8:29   ` william lin
  0 siblings, 0 replies; 22+ messages in thread
From: william lin @ 2017-12-15  8:29 UTC (permalink / raw)
  To: Alex Bennée
  Cc: Laurent Vivier, Thomas Huth, QEMU Developers, Aurelien Jarno,
	Richard Henderson, Wesley Wiedenmeier

Hi,

Does anyone know what is the status on this patch? In particular I
need the code from the later patches in Laurent's tree
(sin, cos, etc..) to fix the x87 fpu bug.

>From what I understand, there shouldn't be any licensing issue with the
code as implementation's algorithm was taken from the version of the
asm lib that is GPL compatible. (both versions' algorithms are identical)

As for the Softfloat libraries, Andreas is correct, they are all identical
other than the headers.


I would be happy to create a new patch thread with all the licensing
and sourcing issues summarized for the code in question, however
I'm not sure what would be the best way to go about giving Laurent
credit in the patches.

Thanks,
William

On Wed, Dec 6, 2017 at 4:24 AM, Alex Bennée <alex.bennee@linaro.org> wrote:

>
> Laurent Vivier <laurent@vivier.eu> writes:
>
> > Implement fmod, frem, fscale, fgetman and fgetexp.
> >
> > Instead of using functions of libm (v1 of this series)
> > and converting between host long double and floatx80 type
> > the new version (v2) adds new floatx80 functions in softfloat.
>
> 68k used 80bit float, well TIL ;-)
>
> Just for reference Richard and I did a sprint on hacking the softfloat
> last week. The results are currently brewing in:
>
>   https://github.com/stsquad/qemu/tree/softfloat-and-arm-fp16-v2
>
> The main push has been to decompose 16/32/64 bit floats and have a
> common set of operations. This means we work with an internal 64 bit
> fractional part and then just round appropriately when we pack the
> result. It's a big departure from SoftFloat2a but seeing as we are not
> likely to bring in changes from upstream we felt it was worth it from a
> code clarity point of view.
>
> However we have punted touching the 80bit code and any potential
> quad-precision stuff to a later date, preferably when int128_t is easier
> to use. Perhaps it is worth considering that option now?
>
> >
> > All the floatx80 functions are copied from "Previous",
> > the NeXT Computer Emulator, and written by Andreas Grabher.
> >
> > Laurent Vivier (5):
> >   softfloat: add floatx80_mod()
> >   target/m68k: add fmod/frem
> >   softfloat: use floatx80_infinity in softfloat
> >   softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale()
> >   target-m68k: add fscale, fgetman and fgetexp
> >
> >  fpu/softfloat-specialize.h |  29 +++++
> >  fpu/softfloat.c            | 258 ++++++++++++++++++++++++++++++
> ++++++++++++---
> >  include/fpu/softfloat.h    |  13 ++-
> >  target/m68k/cpu.h          |   1 +
> >  target/m68k/fpu_helper.c   |  48 +++++++++
> >  target/m68k/helper.h       |   5 +
> >  target/m68k/translate.c    |  15 +++
> >  7 files changed, 355 insertions(+), 14 deletions(-)
>
>
> --
> Alex Bennée
>
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-11-23 16:35 [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Laurent Vivier
                   ` (6 preceding siblings ...)
  2017-12-06 10:24 ` Alex Bennée
@ 2017-12-20 18:25 ` Laurent Vivier
  2017-12-29  8:21   ` Thomas Huth
  7 siblings, 1 reply; 22+ messages in thread
From: Laurent Vivier @ 2017-12-20 18:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, Aurelien Jarno, Richard Henderson, Andreas Grabher,
	william lin, Alex Bennée

Le 23/11/2017 à 17:35, Laurent Vivier a écrit :
> Implement fmod, frem, fscale, fgetman and fgetexp.
> 
> Instead of using functions of libm (v1 of this series)
> and converting between host long double and floatx80 type
> the new version (v2) adds new floatx80 functions in softfloat.
> 
> All the floatx80 functions are copied from "Previous",
> the NeXT Computer Emulator, and written by Andreas Grabher.
> 
> Laurent Vivier (5):
>   softfloat: add floatx80_mod()
>   target/m68k: add fmod/frem
>   softfloat: use floatx80_infinity in softfloat
>   softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale()
>   target-m68k: add fscale, fgetman and fgetexp
> 
>  fpu/softfloat-specialize.h |  29 +++++
>  fpu/softfloat.c            | 258 ++++++++++++++++++++++++++++++++++++++++++---
>  include/fpu/softfloat.h    |  13 ++-
>  target/m68k/cpu.h          |   1 +
>  target/m68k/fpu_helper.c   |  48 +++++++++
>  target/m68k/helper.h       |   5 +
>  target/m68k/translate.c    |  15 +++
>  7 files changed, 355 insertions(+), 14 deletions(-)
> 

I have 37 more patches coming to implement FPU for m68k. I'd really like
to go forward with that. Can I have a 'yes' or a 'no' for these 5 simple
patches? and perhaps a merge?

The license issue has been clearly solved as the code comes from
previous (GPL) and Andreas explained his work is derived from code from
the NetBSD code (Motorola (c) but compatible with the GPL), with
softfloat 2a.

Thanks,
Laurent

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3)
  2017-12-20 18:25 ` Laurent Vivier
@ 2017-12-29  8:21   ` Thomas Huth
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Huth @ 2017-12-29  8:21 UTC (permalink / raw)
  To: Laurent Vivier, qemu-devel
  Cc: Andreas Grabher, william lin, Alex Bennée, Aurelien Jarno,
	Richard Henderson, Peter Maydell

On 20.12.2017 19:25, Laurent Vivier wrote:
> Le 23/11/2017 à 17:35, Laurent Vivier a écrit :
>> Implement fmod, frem, fscale, fgetman and fgetexp.
>>
>> Instead of using functions of libm (v1 of this series)
>> and converting between host long double and floatx80 type
>> the new version (v2) adds new floatx80 functions in softfloat.
>>
>> All the floatx80 functions are copied from "Previous",
>> the NeXT Computer Emulator, and written by Andreas Grabher.
>>
>> Laurent Vivier (5):
>>   softfloat: add floatx80_mod()
>>   target/m68k: add fmod/frem
>>   softfloat: use floatx80_infinity in softfloat
>>   softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale()
>>   target-m68k: add fscale, fgetman and fgetexp
>>
>>  fpu/softfloat-specialize.h |  29 +++++
>>  fpu/softfloat.c            | 258 ++++++++++++++++++++++++++++++++++++++++++---
>>  include/fpu/softfloat.h    |  13 ++-
>>  target/m68k/cpu.h          |   1 +
>>  target/m68k/fpu_helper.c   |  48 +++++++++
>>  target/m68k/helper.h       |   5 +
>>  target/m68k/translate.c    |  15 +++
>>  7 files changed, 355 insertions(+), 14 deletions(-)
>>
> 
> I have 37 more patches coming to implement FPU for m68k. I'd really like
> to go forward with that. Can I have a 'yes' or a 'no' for these 5 simple
> patches? and perhaps a merge?

IMHO the patch series is OK. So maybe simply send a pull request to
Peter (if there are no further other objections)?

 Thomas

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-12-29  8:21 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-23 16:35 [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Laurent Vivier
2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 1/5] softfloat: add floatx80_mod() Laurent Vivier
2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 2/5] target/m68k: add fmod/frem Laurent Vivier
2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 3/5] softfloat: use floatx80_infinity in softfloat Laurent Vivier
2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 4/5] softfloat: add floatx80_getman(), floatx80_getexp(), floatx80_scale() Laurent Vivier
2017-11-23 16:35 ` [Qemu-devel] [PATCH v2 5/5] target-m68k: add fscale, fgetman and fgetexp Laurent Vivier
2017-11-29 12:49 ` [Qemu-devel] [PATCH v2 0/5] target/m68k: implement 680x0 FPU (part 3) Peter Maydell
2017-11-29 13:42   ` Laurent Vivier
2017-11-29 13:59     ` Peter Maydell
2017-11-29 14:08       ` Thomas Huth
2017-11-29 14:17         ` Laurent Vivier
2017-11-29 15:19           ` Thomas Huth
2017-12-05  8:56             ` william lin
2017-12-05  9:46               ` Laurent Vivier
2017-12-05 17:42                 ` Andreas Grabher
2017-12-05 20:01                   ` Laurent Vivier
2017-12-05 21:24                     ` william lin
2017-12-06  8:20                       ` Laurent Vivier
2017-12-06 10:24 ` Alex Bennée
2017-12-15  8:29   ` william lin
2017-12-20 18:25 ` Laurent Vivier
2017-12-29  8:21   ` Thomas Huth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.