From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: edgar.iglesias@gmail.com, michael@walle.cc, aurelien@aurel32.net,
amarkovic@wavecomp.com, shorne@gmail.com, jcmvbkbc@gmail.com,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [RFC PATCH 10/13] tests/tcg/cris: cleanup sys.c
Date: Mon, 10 Dec 2018 15:28:26 +0000 [thread overview]
Message-ID: <20181210152829.29271-11-alex.bennee@linaro.org> (raw)
In-Reply-To: <20181210152829.29271-1-alex.bennee@linaro.org>
This is a mini library which provides helper functions to the tests
which are all currently written in assembly. A bunch of minor changes:
- removed libc related headers (fedora-cris-cross is a system compiler)
- re-organised the functions to avoid forward declarations
- cleaned up brace usage
- restored exit for _fail case
- removed tabs and fixed indentation
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tests/tcg/cris/system/sys.c | 96 ++++++++++++++++++-------------------
1 file changed, 48 insertions(+), 48 deletions(-)
diff --git a/tests/tcg/cris/system/sys.c b/tests/tcg/cris/system/sys.c
index 21f08c0747..aa342335d6 100644
--- a/tests/tcg/cris/system/sys.c
+++ b/tests/tcg/cris/system/sys.c
@@ -1,59 +1,59 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static inline int mystrlen(char *s) {
- int i = 0;
- while (s[i])
- i++;
- return i;
+/*
+ * Helper functions for CRIS system tests
+ *
+ * There is no libc and only a limited set of headers.
+ */
+
+#include <stddef.h>
+
+void exit(int status)
+{
+ register unsigned int callno asm ("r9") = 1; /* NR_exit */
+
+ asm volatile ("break 13\n"
+ : /* no outputs */
+ : "r" (callno)
+ : "memory" );
+ while(1);
}
-void pass(void) {
- char s[] = "passed.\n";
- write (1, s, sizeof (s) - 1);
- exit (0);
-}
+size_t write(int fd, const void *buf, size_t count)
+{
+ register unsigned int callno asm ("r9") = 4; /* NR_write */
+ register unsigned int r10 asm ("r10") = fd;
+ register const void *r11 asm ("r11") = buf;
+ register size_t r12 asm ("r12") = count;
+ register unsigned int r asm ("r10");
-void _fail(char *reason) {
- char s[] = "\nfailed: ";
- int len = mystrlen(reason);
- write (1, s, sizeof (s) - 1);
- write (1, reason, len);
- write (1, "\n", 1);
-// exit (1);
-}
+ asm volatile ("break 13\n"
+ : "=r" (r)
+ : "r" (callno), "0" (r10), "r" (r11), "r" (r12)
+ : "memory");
-void *memset (void *s, int c, size_t n) {
- char *p = s;
- int i;
- for (i = 0; i < n; i++)
- p[i] = c;
- return p;
+ return r;
}
-void exit (int status) {
- register unsigned int callno asm ("r9") = 1; /* NR_exit */
-
- asm volatile ("break 13\n"
- :
- : "r" (callno)
- : "memory" );
- while(1)
- ;
+static inline int mystrlen(char *s)
+{
+ int i = 0;
+ while (s[i]) {
+ i++;
+ }
+ return i;
}
-ssize_t write (int fd, const void *buf, size_t count) {
- register unsigned int callno asm ("r9") = 4; /* NR_write */
- register unsigned int r10 asm ("r10") = fd;
- register const void *r11 asm ("r11") = buf;
- register size_t r12 asm ("r12") = count;
- register unsigned int r asm ("r10");
- asm volatile ("break 13\n"
- : "=r" (r)
- : "r" (callno), "0" (r10), "r" (r11), "r" (r12)
- : "memory");
+void pass(void) {
+ char s[] = "passed.\n";
+ write(1, s, sizeof (s) - 1);
+ exit(0);
+}
- return r;
+void _fail(char *reason) {
+ char s[] = "\nfailed: ";
+ int len = mystrlen(reason);
+ write(1, s, sizeof (s) - 1);
+ write(1, reason, len);
+ write(1, "\n", 1);
+ exit(1);
}
--
2.17.1
next prev parent reply other threads:[~2018-12-10 15:28 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-10 15:28 [Qemu-devel] [RFC PATCH 00/13] Enabling tcg/tests for xtensa, mips and cris Alex Bennée
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 01/13] tests/tcg: add softmmu awareness to Makefile Alex Bennée
2018-12-11 13:38 ` Richard Henderson
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 02/13] tests: enable tcg tests for softmmu Alex Bennée
2018-12-11 13:39 ` Richard Henderson
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 03/13] tests/tcg: add QEMU_OPT option for test runner Alex Bennée
2018-12-11 13:39 ` Richard Henderson
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 04/13] tests/tcg/mips: enable mips32-dsp/mips32-dspr2/mipsr5900 linux-user (WIP) Alex Bennée
2018-12-11 9:54 ` Aleksandar Markovic
2018-12-11 10:16 ` Aleksandar Markovic
2018-12-11 12:17 ` Alex Bennée
2018-12-11 13:45 ` Richard Henderson
2018-12-19 14:39 ` Aleksandar Markovic
2018-12-19 16:03 ` Alex Bennée
2018-12-27 11:22 ` Aleksandar Markovic
2018-12-28 10:28 ` Alex Bennée
2018-12-28 17:32 ` Aleksandar Markovic
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 05/13] tests/tcg/mips: enable mips64 system tests (WIP) Alex Bennée
2018-12-27 18:40 ` Aleksandar Markovic
2018-12-27 18:42 ` Aleksandar Markovic
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 06/13] tests/docker: add debian-xtensa-cross image Alex Bennée
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 07/13] tests/tcg/xtensa: enable system tests Alex Bennée
2018-12-11 0:25 ` Max Filippov
2018-12-11 11:58 ` Alex Bennée
2018-12-11 12:32 ` Max Filippov
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 08/13] tests/docker: add fedora-cris-cross compilers Alex Bennée
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 09/13] tests/tcg: split cris tests into system and user mode Alex Bennée
2018-12-11 17:47 ` Alex Bennée
2018-12-10 15:28 ` Alex Bennée [this message]
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 11/13] tests/tcg/cris: comment out the ccs test Alex Bennée
2019-01-04 14:00 ` Edgar E. Iglesias
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 12/13] tests/tcg/cris: align mul operations Alex Bennée
2018-12-10 15:28 ` [Qemu-devel] [RFC PATCH 13/13] tests/tcg: enable cris system tests Alex Bennée
2019-01-04 13:58 ` [Qemu-devel] [RFC PATCH 00/13] Enabling tcg/tests for xtensa, mips and cris Edgar E. Iglesias
2019-01-04 14:03 ` Edgar E. Iglesias
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=20181210152829.29271-11-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=amarkovic@wavecomp.com \
--cc=aurelien@aurel32.net \
--cc=edgar.iglesias@gmail.com \
--cc=jcmvbkbc@gmail.com \
--cc=michael@walle.cc \
--cc=qemu-devel@nongnu.org \
--cc=shorne@gmail.com \
/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 NNTP newsgroup(s).