Skip to content

Commit 77e6caa

Browse files
committed
whisper : make byteswap useable with C++17
1 parent 792c078 commit 77e6caa

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/whisper.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@
4040
#endif
4141

4242
#if defined(GGML_BIG_ENDIAN)
43-
#include <bit>
44-
4543
template<typename T>
4644
static T byteswap(T value) {
47-
return std::byteswap(value);
48-
}
49-
50-
template<>
51-
float byteswap(float value) {
52-
return std::bit_cast<float>(byteswap(std::bit_cast<std::uint32_t>(value)));
45+
T value_swapped;
46+
char * source = reinterpret_cast<char *>(&value);
47+
char * target = reinterpret_cast<char *>(&value_swapped);
48+
int size = sizeof(T);
49+
for (int i = 0; i < size; i++) {
50+
target[size - 1 - i] = source[i];
51+
}
52+
return value_swapped;
5353
}
5454

5555
template<typename T>

0 commit comments

Comments
 (0)