Skip to content

Commit 9cfde34

Browse files
committed
Fix armv7l BLAS interface autodetection
On armv7l, it turns out that the high bits of an `int64_t` assigned the value of a function that is actually an `int32_t` can be undefined. This interfered with the interface autodetection, so let's mask them off.
1 parent af7615a commit 9cfde34

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/autodetection.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ int32_t autodetect_blas_interface(void * isamax_addr) {
5454
pop_fake_lsame();
5555
#endif
5656

57+
// Although we declare that `isamax` returns an `int64_t`, it may not actually do so,
58+
// since if it's an LP64 binary it's probably returning an `int32_t`. Depending on the
59+
// register semantics, the high 32-bits may or may not be zeroed. We don't really care
60+
// about them, since we know the two cases we're interested in.
61+
max_idx = max_idx & 0xffffffff;
62+
5763
// This means the `isamax()` implementation saw `N < 0`, ergo it's a 64-bit library
5864
if (max_idx == 0) {
5965
return LBT_INTERFACE_ILP64;

0 commit comments

Comments
 (0)