mirror of
https://github.com/golang/go
synced 2024-10-04 14:31:21 -06:00
3d50aaf483
1. when executing a unsupported VFP instruction, the NetBSD kernel somehow doesn't report SIGILL, and instead just spin and spin, we add a alarm(2) to detect this case (albeit this is a kernel bug). 2. NetBSD/ARM's VFP11 support is not complete, so temporarily disable it. 3. The default gcc shipped with NetBSD-current mis-optimizes our code at -O2, so lower the optimization level to -O1 on NetBSD/ARM. R=dave, rsc CC=golang-dev https://golang.org/cl/7286044
80 lines
2.2 KiB
C
80 lines
2.2 KiB
C
// Copyright 2012 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
#include "a.h"
|
|
|
|
#ifndef __ARMEL__
|
|
char *
|
|
xgetgoarm(void)
|
|
{
|
|
return "6";
|
|
}
|
|
#else
|
|
static void useVFPv3(void);
|
|
static void useVFPv1(void);
|
|
|
|
char *
|
|
xgetgoarm(void)
|
|
{
|
|
#if defined(__NetBSD__) || defined(__FreeBSD__)
|
|
// NetBSD has buggy support for VFPv2 (incorrect inexact,
|
|
// denormial, and NaN handling). When GOARM=6, some of our
|
|
// math tests fails on Raspberry Pi.
|
|
// Thus we return "5" here for safety, the user is free
|
|
// to override.
|
|
// Note: using GOARM=6 with cgo can trigger a kernel assertion
|
|
// failure and crash NetBSD/evbarm kernel.
|
|
// FreeBSD also have broken VFP support, so disable VFP also
|
|
// on FreeBSD.
|
|
return "5";
|
|
#endif
|
|
if(xtryexecfunc(useVFPv3))
|
|
return "7";
|
|
else if(xtryexecfunc(useVFPv1))
|
|
return "6";
|
|
return "5";
|
|
}
|
|
|
|
static void
|
|
useVFPv3(void)
|
|
{
|
|
// try to run VFPv3-only "vmov.f64 d0, #112" instruction
|
|
// we can't use that instruction directly, because we
|
|
// might be compiling with a soft-float only toolchain.
|
|
//
|
|
// some newer toolchains are configured to use thumb
|
|
// by default, so we need to do some mode changing magic
|
|
// here.
|
|
// We can use "bx pc; nop" here, but GNU as(1) insists
|
|
// on warning us
|
|
// "use of r15 in bx in ARM mode is not really useful"
|
|
// so we workaround that by using "bx r0"
|
|
__asm__ __volatile__ ("mov r0, pc");
|
|
__asm__ __volatile__ ("bx r0");
|
|
__asm__ __volatile__ (".word 0xeeb70b00"); // vmov.f64 d0, #112
|
|
__asm__ __volatile__ (".word 0xe12fff1e"); // bx lr
|
|
}
|
|
|
|
static void
|
|
useVFPv1(void)
|
|
{
|
|
// try to run "vmov.f64 d0, d0" instruction
|
|
// we can't use that instruction directly, because we
|
|
// might be compiling with a soft-float only toolchain
|
|
//
|
|
// some newer toolchains are configured to use thumb
|
|
// by default, so we need to do some mode changing magic
|
|
// here.
|
|
// We can use "bx pc; nop" here, but GNU as(1) insists
|
|
// on warning us
|
|
// "use of r15 in bx in ARM mode is not really useful"
|
|
// so we workaround that by using "bx r0"
|
|
__asm__ __volatile__ ("mov r0, pc");
|
|
__asm__ __volatile__ ("bx r0");
|
|
__asm__ __volatile__ (".word 0xeeb00b40"); // vomv.f64 d0, d0
|
|
__asm__ __volatile__ (".word 0xe12fff1e"); // bx lr
|
|
}
|
|
|
|
#endif
|