summaryrefslogtreecommitdiff
path: root/util/romcc/tests/simple_test76.c
diff options
context:
space:
mode:
authorEric Biederman <ebiederm@xmission.com>2004-05-28 14:11:54 +0000
committerEric Biederman <ebiederm@xmission.com>2004-05-28 14:11:54 +0000
commit90089603393a1a67b9a4afe1f2b7237a74e1b21b (patch)
tree30a036a2a3e52bf00a57257b043872906ee5eb68 /util/romcc/tests/simple_test76.c
parent7664d1cb87876a3b7e622cf1c7e40f1fb7988c9f (diff)
downloadcoreboot-90089603393a1a67b9a4afe1f2b7237a74e1b21b.tar.xz
- Upgrade to romcc version 0.63
This includes more test cases Lots of small bug fixes A built in C preprocessor Initial support for not inlining everything __attribute__((noinline)) works Better command line options and help Constants arrays can be read at compile time Asm statements that are not volatile will now be removed when their outputs go unused Loads and stores that are not volatile will be removed when their values go unused The number of FIXMES in the code is finally starting to go down. git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1582 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/romcc/tests/simple_test76.c')
-rw-r--r--util/romcc/tests/simple_test76.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/util/romcc/tests/simple_test76.c b/util/romcc/tests/simple_test76.c
new file mode 100644
index 0000000000..4f682d37d4
--- /dev/null
+++ b/util/romcc/tests/simple_test76.c
@@ -0,0 +1,69 @@
+struct syscall_result {
+ long val;
+ int errno;
+};
+
+static struct syscall_result syscall_return(long result)
+{
+ struct syscall_result res;
+ if (((unsigned long)result) >= ((unsigned long)-125)) {
+ res.errno = - result;
+ res.val = -1;
+ } else {
+ res.errno = 0;
+ res.val = result;
+ }
+ return res;
+}
+static struct syscall_result syscall1(unsigned long nr, unsigned long arg1)
+{
+ long res;
+ asm volatile(
+ "int $0x80"
+ : "=a" (res)
+ : "a" (nr), "b" (arg1));
+ return syscall_return(res);
+
+}
+
+static struct syscall_result syscall3(unsigned long nr, unsigned long arg1, unsigned long arg2,
+ unsigned long arg3)
+{
+ long res;
+ asm volatile(
+ "int $0x80"
+ : "=a" (res)
+ : "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3));
+ return syscall_return(res);
+
+}
+
+#define NR_exit 1
+#define NR_write 4
+/* Standard file descriptors */
+#define STDIN_FILENO 0 /* Standard input */
+#define STDOUT_FILENO 1 /* Standard output */
+#define STDERR_FILENO 2 /* Standard error output */
+
+typedef long ssize_t;
+typedef unsigned long size_t;
+
+static ssize_t write(int fd, const void *buf, size_t count)
+{
+ struct syscall_result res;
+ res = syscall3(NR_write, fd, (unsigned long)buf, count);
+ return res.val;
+}
+
+static void _exit(int status)
+{
+ struct syscall_result res;
+ res = syscall1(NR_exit, status);
+}
+
+static void main(void)
+{
+ static const char msg[] = "hello world\r\n";
+ write(STDOUT_FILENO, msg, sizeof(msg));
+ _exit(0);
+}