[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/26] tests/tcg/cris: cleanup sys.c
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PULL 16/26] tests/tcg/cris: cleanup sys.c |
Date: |
Tue, 12 Mar 2019 17:09:21 +0000 |
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 <address@hidden>
diff --git a/tests/tcg/cris/sys.c b/tests/tcg/cris/sys.c
index 21f08c0747..1644eecc33 100644
--- a/tests/tcg/cris/sys.c
+++ b/tests/tcg/cris/sys.c
@@ -1,59 +1,63 @@
-#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) {
+ /* do nothing */
+ };
}
-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.20.1
- [Qemu-devel] [PULL 12/26] tests/docker: add debian-xtensa-cross image, (continued)
- [Qemu-devel] [PULL 12/26] tests/docker: add debian-xtensa-cross image, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 26/26] .travis.yml: add softmmu check-tcg tests, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 19/26] tests/tcg/cris: align mul operations, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 25/26] .travis.yml: separate softfloat from check-tcg, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 13/26] tests/tcg/xtensa: enable system tests, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 06/26] tests/tcg: add softmmu awareness to Makefile, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 03/26] .travis.yml: reduce the module builds to major architectures, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 01/26] travis: Bump Xcode 10 image to 10.2, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 02/26] .travis.yml: combine docs and tools build with out-of-tree, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 09/26] tests/tcg: split run-test into user and system variants, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 16/26] tests/tcg/cris: cleanup sys.c,
Alex Bennée <=
- [Qemu-devel] [PULL 15/26] tests/docker: add fedora-cris-cross compilers, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 11/26] tests/tcg/mips: fix hello-mips compilation, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 14/26] tests/tcg/arm: add ARMv6-M UNDEFINED 32-bit instruction test, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 10/26] tests/tcg: add gdb runner variant, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 07/26] tests/tcg: enable tcg tests for softmmu, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 08/26] tests/tcg: add QEMU_OPT option for test runner, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 05/26] Makefile: explicitly pass $(BUILD_DIR) to gcovr, Alex Bennée, 2019/03/12
- [Qemu-devel] [PULL 04/26] Makefile: explicitly pass $(SRC_PATH) to gcovr, Alex Bennée, 2019/03/12
- Re: [Qemu-devel] [PULL 00/26] final testing updates for 4.0, Philippe Mathieu-Daudé, 2019/03/12