| @@ -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 |
51 | static bool _libc_aapcs_initialized; | | 53 | static bool _libc_aapcs_initialized; |
52 | | | 54 | |
53 | void _libc_aapcs_init(void) __attribute__((__constructor__, __used__)); | | 55 | void _libc_aapcs_init(void) __attribute__((__constructor__, __used__)); |
54 | | | 56 | |
55 | void __section(".text.startup") | | 57 | void __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 | } |