diff options
-rw-r--r-- | hmatrix.cabal | 9 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c | 19 |
2 files changed, 26 insertions, 2 deletions
diff --git a/hmatrix.cabal b/hmatrix.cabal index 764198c..10c8173 100644 --- a/hmatrix.cabal +++ b/hmatrix.cabal | |||
@@ -1,5 +1,5 @@ | |||
1 | Name: hmatrix | 1 | Name: hmatrix |
2 | Version: 0.11.0.3 | 2 | Version: 0.11.0.4 |
3 | License: GPL | 3 | License: GPL |
4 | License-file: LICENSE | 4 | License-file: LICENSE |
5 | Author: Alberto Ruiz | 5 | Author: Alberto Ruiz |
@@ -87,6 +87,10 @@ flag finit | |||
87 | description: Force FPU initialization in foreing calls | 87 | description: Force FPU initialization in foreing calls |
88 | default: False | 88 | default: False |
89 | 89 | ||
90 | flag fpudebug | ||
91 | description: Check FPU stack | ||
92 | default: False | ||
93 | |||
90 | library | 94 | library |
91 | 95 | ||
92 | Build-Depends: base >= 4 && < 5, | 96 | Build-Depends: base >= 4 && < 5, |
@@ -170,6 +174,9 @@ library | |||
170 | if flag(finit) | 174 | if flag(finit) |
171 | cpp-options: -DFINIT | 175 | cpp-options: -DFINIT |
172 | 176 | ||
177 | if flag(fpudebug) | ||
178 | cc-options: -DFPUDEBUG | ||
179 | |||
173 | if impl(ghc == 7.0.1) | 180 | if impl(ghc == 7.0.1) |
174 | cpp-options: -DNONORMVTEST | 181 | cpp-options: -DNONORMVTEST |
175 | 182 | ||
diff --git a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c index f4ae0f6..77a8847 100644 --- a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c +++ b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c | |||
@@ -47,7 +47,24 @@ | |||
47 | //--------------------------------------- | 47 | //--------------------------------------- |
48 | void asm_finit() { | 48 | void asm_finit() { |
49 | #ifdef i386 | 49 | #ifdef i386 |
50 | asm("finit"); | 50 | |
51 | #if FPUDEBUG | ||
52 | uint val=0; | ||
53 | asm("fstsw" | ||
54 | : "=a" (val) | ||
55 | : "a" (val) | ||
56 | ); | ||
57 | |||
58 | val = (val%16384)/2048; // bits 13-11 | ||
59 | |||
60 | if (val != 0) { | ||
61 | printf("Warning: FPU Stack: %d\n",val); | ||
62 | asm("finit"); | ||
63 | } | ||
64 | #else | ||
65 | asm("finit"); | ||
66 | #endif | ||
67 | |||
51 | #endif | 68 | #endif |
52 | } | 69 | } |
53 | //--------------------------------------- | 70 | //--------------------------------------- |