1 From 7152ded5219453c9ff1cd062cecbeaf4d77e4cab Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Thu, 26 May 2016 15:05:48 +0200
4 Subject: [PATCH] Use <fenv.h> instead of <fpu_control.h>
6 musl libc (http://musl-libc.org lack the non-standard <fpu_control.h>
7 header, which is used in src/os/linux/{i386,x86_64}/init.c files to
8 setup the floating point precision. This patch makes it use the
9 standard C <fenv.h> header instead.
11 Original patch at Felix Janda at
12 https://sourceforge.net/p/jamvm/patches/6/.
14 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
16 src/os/linux/i386/init.c | 12 ++++++------
17 src/os/linux/x86_64/init.c | 16 ++++++----------
18 2 files changed, 12 insertions(+), 16 deletions(-)
20 diff --git a/src/os/linux/i386/init.c b/src/os/linux/i386/init.c
21 index d9c6648..94a733e 100644
22 --- a/src/os/linux/i386/init.c
23 +++ b/src/os/linux/i386/init.c
25 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 -#include <fpu_control.h>
31 /* Change floating point precision to double (64-bit) from
32 * the extended (80-bit) Linux default. */
34 void setDoublePrecision() {
39 - cw &= ~_FPU_EXTENDED;
43 + fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */
44 + fenv.__control_word |= 0x200; /* _FPU_DOUBLE */
48 void initialisePlatform() {
49 diff --git a/src/os/linux/x86_64/init.c b/src/os/linux/x86_64/init.c
50 index 9d55229..a76a923 100644
51 --- a/src/os/linux/x86_64/init.c
52 +++ b/src/os/linux/x86_64/init.c
54 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
58 -#include <fpu_control.h>
62 /* Change the x87 FPU precision to double (64-bit) from the extended
63 (80-bit) Linux default. Note, unlike on i386, my testcases pass
67 void setDoublePrecision() {
73 - cw &= ~_FPU_EXTENDED;
78 + fenv.__control_word &= ~0x300; /*_FPU_EXTENDED */
79 + fenv.__control_word |= 0x200; /*_FPU_DOUBLE */
83 void initialisePlatform() {