diff mbox

[2/9] tests: cris: fix syscall inline asm

Message ID 1473076452-19795-2-git-send-email-rabin.vincent@axis.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rabin Vincent Sept. 5, 2016, 11:54 a.m. UTC
From: Rabin Vincent <rabinv@axis.com>

Add the clobbered registeres to the inline asm for the write and exit
system calls.  Without the correct clobbers for the write() function,
correct failure messages are not printed succesfully on newer version of
GCC.

Signed-off-by: Rabin Vincent <rabinv@axis.com>
---
 tests/tcg/cris/sys.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Richard Henderson Sept. 5, 2016, 6:20 p.m. UTC | #1
On 09/05/2016 04:54 AM, Rabin Vincent wrote:
> From: Rabin Vincent <rabinv@axis.com>
>
> Add the clobbered registeres to the inline asm for the write and exit
> system calls.  Without the correct clobbers for the write() function,
> correct failure messages are not printed succesfully on newer version of
> GCC.
>
> Signed-off-by: Rabin Vincent <rabinv@axis.com>
> ---
>  tests/tcg/cris/sys.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/tests/tcg/cris/sys.c b/tests/tcg/cris/sys.c
> index 551c5dd..dfa5e1c 100644
> --- a/tests/tcg/cris/sys.c
> +++ b/tests/tcg/cris/sys.c
> @@ -34,7 +34,10 @@ void *memset (void *s, int c, size_t n) {
>
>  void exit (int status) {
>  	asm volatile ("moveq 1, $r9\n" /* NR_exit.  */
> -		      "break 13\n");
> +		      "break 13\n"
> +		      :
> +		      :
> +		      : "r9", "memory" );

Better to simply set up the arguments properly.  See

http://www.uclibc-ng.org/browser/uclibc-ng/libc/sysdeps/linux/cris/bits/syscalls.h?rev=3b4650a23ff372dde44c264d43af8cfa4ac88e0a


r~
diff mbox

Patch

diff --git a/tests/tcg/cris/sys.c b/tests/tcg/cris/sys.c
index 551c5dd..dfa5e1c 100644
--- a/tests/tcg/cris/sys.c
+++ b/tests/tcg/cris/sys.c
@@ -34,7 +34,10 @@  void *memset (void *s, int c, size_t n) {
 
 void exit (int status) {
 	asm volatile ("moveq 1, $r9\n" /* NR_exit.  */
-		      "break 13\n");
+		      "break 13\n"
+		      :
+		      :
+		      : "r9", "memory" );
 	while(1)
 		;
 }
@@ -45,7 +48,10 @@  ssize_t write (int fd, const void *buf, size_t count) {
 	     "move.d %1, $r11\n"
 	     "move.d %2, $r12\n"
 	     "moveq 4, $r9\n" /* NR_write.  */
-	     "break 13\n" : : "r" (fd), "r" (buf), "r" (count) : "memory");
+	     "break 13\n"
+	     :
+	     : "r" (fd), "r" (buf), "r" (count)
+	     : "r9", "r10", "r11", "r12", "memory");
 	asm ("move.d $r10, %0\n" : "=r" (r));
 	return r;
 }