Sun Sep 8 13:15:54 2013 UTC ()
detect whether hw divide is present.


(matt)
diff -r1.6 -r1.7 src/lib/libc/arch/arm/misc/arm_initfini.c

cvs diff -r1.6 -r1.7 src/lib/libc/arch/arm/misc/arm_initfini.c (expand / switch to unified diff)

--- src/lib/libc/arch/arm/misc/arm_initfini.c 2013/09/08 12:11:56 1.6
+++ src/lib/libc/arch/arm/misc/arm_initfini.c 2013/09/08 13:15:53 1.7
@@ -19,48 +19,52 @@ @@ -19,48 +19,52 @@
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE. 27 * POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31 31
32__RCSID("$NetBSD: arm_initfini.c,v 1.6 2013/09/08 12:11:56 matt Exp $"); 32__RCSID("$NetBSD: arm_initfini.c,v 1.7 2013/09/08 13:15:53 matt Exp $");
33 33
34#include "namespace.h" 34#include "namespace.h"
35 35
36/* 36/*
37 * To properly implement setjmp/longjmp for the ARM AAPCS ABI, it has to be 37 * To properly implement setjmp/longjmp for the ARM AAPCS ABI, it has to be
38 * aware of whether there is a FPU is present or not. Regardless of whether 38 * aware of whether there is a FPU is present or not. Regardless of whether
39 * the hard-float ABI is being used, setjmp needs to save D8-D15. But it can 39 * the hard-float ABI is being used, setjmp needs to save D8-D15. But it can
40 * only do this if those instructions won't cause an exception. 40 * only do this if those instructions won't cause an exception.
41 */ 41 */
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/sysctl.h> 44#include <sys/sysctl.h>
45 45
46#include <stdbool.h> 46#include <stdbool.h>
47#include <stddef.h> 47#include <stddef.h>
48 48
49__dso_hidden int _libc_arm_fpu_present; 49__dso_hidden int _libc_arm_fpu_present;
 50#ifndef __ARM_ARCH_EXT_IDIV__
50__dso_hidden int _libc_arm_hwdiv_present; 51__dso_hidden int _libc_arm_hwdiv_present;
 52#endif
51static bool _libc_aapcs_initialized; 53static bool _libc_aapcs_initialized;
52 54
53void _libc_aapcs_init(void) __attribute__((__constructor__, __used__)); 55void _libc_aapcs_init(void) __attribute__((__constructor__, __used__));
54 56
55void __section(".text.startup") 57void __section(".text.startup")
56_libc_aapcs_init(void) 58_libc_aapcs_init(void)
57{ 59{
58 if (!_libc_aapcs_initialized) { 60 if (!_libc_aapcs_initialized) {
59 size_t len = sizeof(_libc_arm_fpu_present); 61 size_t len = sizeof(_libc_arm_fpu_present);
60 _libc_aapcs_initialized = true; 62 _libc_aapcs_initialized = true;
61 (void)sysctlbyname("machdep.fpu_present", 63 (void)sysctlbyname("machdep.fpu_present",
62 &_libc_arm_fpu_present, &len, NULL, 0); 64 &_libc_arm_fpu_present, &len, NULL, 0);
 65#ifndef __ARM_ARCH_EXT_IDIV__
63 (void)sysctlbyname("machdep.hwdiv_present", 66 (void)sysctlbyname("machdep.hwdiv_present",
64 &_libc_arm_hwdiv_present, &len, NULL, 0); 67 &_libc_arm_hwdiv_present, &len, NULL, 0);
 68#endif
65 } 69 }
66} 70}