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