symbian-qemu-0.9.1-12/qemu-symbian-svp/tests/cris/sys.c
author mikek
Mon, 05 Jul 2010 15:30:26 +0100
branchGCC_SURGE
changeset 87 42ae69d3c4a8
parent 1 2fb8b9db1c86
permissions -rw-r--r--
1) Fix for Bug 3157 - Compilation error in gui_common.h 2) Fix for Bug 3158 - Compilation error in qemu-char.c 3) Fix for Bug 3160 - [GCCE] Illegal instruction in baseport/syborg/bootstrap/syborg.s 4) Fix for Bug 3162 - [GCCE] VFP math support needs excluded to build syborg ROM 5) Fix for Bug 3163 - [GCCE] Syborg baseport build breaks when EPOCROOT is not filesystem root 6) Fix for Bug 3164 - [GCCE] baseport/syborg/bld.inf needs to discriminate GCCE from ARMCC

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

static inline int mystrlen(char *s) {
	int i = 0;
	while (s[i])
		i++;
	return i;
}

void pass(void) {
	char s[] = "passed.\n";
	write (1, s, sizeof (s) - 1);
	exit (0);
}

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);
}

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;
}

void exit (int status) {
	asm volatile ("moveq 1, $r9\n" /* NR_exit.  */
		      "break 13\n");
	while(1)
		;
}

ssize_t write (int fd, const void *buf, size_t count) {
	int r;
	asm ("move.d %0, $r10\n"
	     "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");
	asm ("move.d $r10, %0\n" : "=r" (r));
	return r;
}