From 76fd64dc529be2b703a402e6ae7407c65a1043e0 Mon Sep 17 00:00:00 2001 From: Minero Aoki Date: Sun, 7 Dec 2008 15:55:40 +0000 Subject: [PATCH] * lib/alloca.s: alloca() implemeted. * lib/Makefile: build it. * import/alloca.hb: declare alloca. git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4103 1b9489fe-b721-0410-924e-b54b9192deb8 --- ChangeLog | 8 ++++++++ import/alloca.hb | 3 +++ lib/Makefile | 2 +- lib/alloca.s | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 import/alloca.hb create mode 100644 lib/alloca.s diff --git a/ChangeLog b/ChangeLog index 15e1ee0..1634a8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Dec 8 00:55:33 2008 Minero Aoki + + * lib/alloca.s: alloca() implemeted. + + * lib/Makefile: build it. + + * import/alloca.hb: declare alloca. + Sun Dec 7 23:26:50 2008 Minero Aoki * net: revert r4100; implementing alloca() is too difficult for diff --git a/import/alloca.hb b/import/alloca.hb new file mode 100644 index 0000000..bb55ec8 --- /dev/null +++ b/import/alloca.hb @@ -0,0 +1,3 @@ +import stddef; + +extern void* alloca(size_t len); diff --git a/lib/Makefile b/lib/Makefile index 11f4000..8959b41 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,7 +1,7 @@ CBC = ../bin/cbc CBFLAGS = -O -fPIC TARGET = libcbc.a -OBJS = stdarg.o +OBJS = stdarg.o alloca.o .SUFFIXES: .SUFFIXES: .cb .s .o diff --git a/lib/alloca.s b/lib/alloca.s new file mode 100644 index 0000000..479f522 --- /dev/null +++ b/lib/alloca.s @@ -0,0 +1,14 @@ + .text +.globl alloca + .type alloca,@function +alloca: + addl $4, %esp + movl -4(%esp), %ecx + movl (%esp), %eax + addl $3, %eax + andl $-4, %eax + subl %eax, %esp + movl %esp, %eax + addl $4, %eax + jmp *%ecx + .size alloca, .-alloca