public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Roland McGrath <roland@hack.frob.com>
To: libc-ports@sourceware.org
Subject: [PATCH roland/arm-setjmp-iwmmxt] ARM_ASSUME_NO_IWMMXT
Date: Thu, 09 Aug 2012 23:38:00 -0000	[thread overview]
Message-ID: <20120809233813.49DCA2C0CE@topped-with-meat.com> (raw)

This completes what I intend to do as far as getting the Linuxism of HWCAP
bits out of OS-independent ARM code.  It doesn't actually excise the
Linuxisms from setjmp/longjmp, which seemed like it would be a real hassle
to abstract.  Instead, it lets an OS-specific arm-features.h file define
the macro ARM_ASSUME_NO_IWMMXT to avoid the iWMMXt code in setjmp/longjmp.
If this is defined and __SOFTFP__ is not defined, then it doesn't need any
HWCAP bit magic at all.

The new macro is never set by existing (i.e. Linux) configurations.
I intend to define it in a new non-Unix port I'm working on.

Just did the basic compile test.


Thanks,
Roland


ports/ChangeLog.arm
	* sysdeps/arm/arm-features.h: Document ARM_ASSUME_NO_IWMMXT.
	* sysdeps/arm/setjmp.S: Include <arm-features.h>.
	[!ARM_ASSUME_NO_IWMMXT || __SOFTFP__]: Conditionalize hwcap
	fetching bits on this.
	[!ARM_ASSUME_NO_IWMMXT]: Conditionalize iWMMXt register use on this.
	* sysdeps/arm/__longjmp.S: Likewise.


diff --git a/ports/sysdeps/arm/__longjmp.S b/ports/sysdeps/arm/__longjmp.S
index aa5cf74..b3c2860 100644
--- a/ports/sysdeps/arm/__longjmp.S
+++ b/ports/sysdeps/arm/__longjmp.S
@@ -21,6 +21,7 @@
 #define _ASM
 #include <bits/setjmp.h>
 #include <rtld-global-offsets.h>
+#include <arm-features.h>
 
 /* __longjmp(jmpbuf, val) */
 
@@ -46,23 +47,29 @@ ENTRY (__longjmp)
 	cfi_restore (sp)
 	cfi_restore (lr)
 
-#ifdef IS_IN_rtld
+#if !defined ARM_ASSUME_NO_IWMMXT || defined __SOFTFP__
+# define NEED_HWCAP 1
+#endif
+
+#ifdef NEED_HWCAP
+# ifdef IS_IN_rtld
 	ldr	a2, 1f
 	ldr	a3, .Lrtld_local_ro
 0:	add	a2, pc, a2
 	add	a2, a2, a3
 	ldr	a2, [a2, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
-#else
-#ifdef PIC
+# else
+#  ifdef PIC
 	ldr	a2, 1f
 	ldr	a3, .Lrtld_global_ro
 0:	add	a2, pc, a2
 	ldr	a2, [a2, a3]
 	ldr	a2, [a2, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
-#else
+#  else
 	ldr	a2, .Lhwcap
 	ldr	a2, [a2, #0]
-#endif
+#  endif
+# endif
 #endif
 
 #ifdef __SOFTFP__
@@ -79,6 +86,7 @@ ENTRY (__longjmp)
 	mcr	p10, 7, a3, cr1, cr0, 0
 .Lno_vfp:
 
+#ifndef ARM_ASSUME_NO_IWMMXT
 	tst	a2, #HWCAP_ARM_IWMMXT
 	beq	.Lno_iwmmxt
 
@@ -91,22 +99,25 @@ ENTRY (__longjmp)
 	ldcl	p1, cr14, [r12], #8
 	ldcl	p1, cr15, [r12], #8
 .Lno_iwmmxt:
+#endif
 
 	DO_RET(lr)
 
-#ifdef IS_IN_rtld
+#ifdef NEED_HWCAP
+# ifdef IS_IN_rtld
 1:	.long	_GLOBAL_OFFSET_TABLE_ - 0b - 8
 .Lrtld_local_ro:
 	.long	C_SYMBOL_NAME(_rtld_local_ro)(GOTOFF)
-#else
-#ifdef PIC
+# else
+#  ifdef PIC
 1:	.long	_GLOBAL_OFFSET_TABLE_ - 0b - 8
 .Lrtld_global_ro:
 	.long	C_SYMBOL_NAME(_rtld_global_ro)(GOT)
-#else
+#  else
 .Lhwcap:
 	.long	C_SYMBOL_NAME(_dl_hwcap)
-#endif
+#  endif
+# endif
 #endif
 
 END (__longjmp)
diff --git a/ports/sysdeps/arm/arm-features.h b/ports/sysdeps/arm/arm-features.h
index 0f99b3a..41befb5 100644
--- a/ports/sysdeps/arm/arm-features.h
+++ b/ports/sysdeps/arm/arm-features.h
@@ -31,4 +31,9 @@
 # define ARM_HAVE_VFP	1
 #endif
 
+/* An OS-specific arm-features.h file may define ARM_ASSUME_NO_IWMMXT
+   to indicate at compile time that iWMMXt hardware is never present
+   at runtime (or that we never care about its state) and so need not
+   be checked for.  */
+
 #endif  /* arm-features.h */
diff --git a/ports/sysdeps/arm/setjmp.S b/ports/sysdeps/arm/setjmp.S
index 9bfacc1..dbd59dd 100644
--- a/ports/sysdeps/arm/setjmp.S
+++ b/ports/sysdeps/arm/setjmp.S
@@ -21,6 +21,7 @@
 #define _ASM
 #include <bits/setjmp.h>
 #include <rtld-global-offsets.h>
+#include <arm-features.h>
 
 ENTRY (__sigsetjmp)
 	mov	ip, r0
@@ -28,24 +29,30 @@ ENTRY (__sigsetjmp)
 	/* Save registers */
 	stmia	ip!, {v1-v6, sl, fp, sp, lr}
 
+#if !defined ARM_ASSUME_NO_IWMMXT || defined __SOFTFP__
+# define NEED_HWCAP 1
+#endif
+
+#ifdef NEED_HWCAP
 	/* Check if we have a VFP unit.  */
-#ifdef IS_IN_rtld
+# ifdef IS_IN_rtld
 	ldr	a3, 1f
 	ldr	a4, .Lrtld_local_ro
 0:	add	a3, pc, a3
 	add	a3, a3, a4
 	ldr	a3, [a3, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
-#else
-#ifdef PIC
+# else
+#  ifdef PIC
 	ldr	a3, 1f
 	ldr	a4, .Lrtld_global_ro
 0:	add	a3, pc, a3
 	ldr	a3, [a3, a4]
 	ldr	a3, [a3, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
-#else
+#  else
 	ldr	a3, .Lhwcap
 	ldr	a3, [a3, #0]
-#endif
+#  endif
+# endif
 #endif
 
 #ifdef __SOFTFP__
@@ -64,6 +71,7 @@ ENTRY (__sigsetjmp)
 	str	a4, [ip], #4
 .Lno_vfp:
 
+#ifndef ARM_ASSUME_NO_IWMMXT
 	tst	a3, #HWCAP_ARM_IWMMXT
 	beq	.Lno_iwmmxt
 
@@ -76,23 +84,26 @@ ENTRY (__sigsetjmp)
 	stcl	p1, cr14, [r12], #8
 	stcl	p1, cr15, [r12], #8
 .Lno_iwmmxt:
+#endif
 
 	/* Make a tail call to __sigjmp_save; it takes the same args.  */
 	B	PLTJMP(C_SYMBOL_NAME(__sigjmp_save))
 
-#ifdef IS_IN_rtld
+#ifdef NEED_HWCAP
+# ifdef IS_IN_rtld
 1:	.long	_GLOBAL_OFFSET_TABLE_ - 0b - 8
 .Lrtld_local_ro:
 	.long	C_SYMBOL_NAME(_rtld_local_ro)(GOTOFF)
-#else
-#ifdef PIC
+# else
+#  ifdef PIC
 1:	.long	_GLOBAL_OFFSET_TABLE_ - 0b - 8
 .Lrtld_global_ro:
 	.long	C_SYMBOL_NAME(_rtld_global_ro)(GOT)
-#else
+#  else
 .Lhwcap:
 	.long	C_SYMBOL_NAME(_dl_hwcap)
-#endif
+#  endif
+# endif
 #endif
 
 END (__sigsetjmp)

             reply	other threads:[~2012-08-09 23:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-09 23:38 Roland McGrath [this message]
2012-08-09 23:47 ` Joseph S. Myers
2012-08-09 23:48   ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120809233813.49DCA2C0CE@topped-with-meat.com \
    --to=roland@hack.frob.com \
    --cc=libc-ports@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).