new version from Chris Torek
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 19 Apr 1991 10:05:49 +0000 (02:05 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 19 Apr 1991 10:05:49 +0000 (02:05 -0800)
SCCS-vsn: lib/libc/vax/gen/alloca.s 5.5

usr/src/lib/libc/vax/gen/alloca.s

index 49677ce..ef78e00 100644 (file)
@@ -1,23 +1,23 @@
 /*-
 /*-
- * Copyright (c) 1983 The Regents of the University of California.
+ * Copyright (c) 1991 The Regents of the University of California.
  * All rights reserved.
  *
  * All rights reserved.
  *
- * %sccs.include.proprietary.c%
+ * %sccs.include.redist.c%
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-       .asciz "@(#)alloca.s    5.4 (Berkeley) %G%"
+       .asciz "@(#)alloca.s    5.5 (Berkeley) %G%"
 #endif /* LIBC_SCCS and not lint */
 
 #endif /* LIBC_SCCS and not lint */
 
-/* like alloc, but automatic free in return */
-
 #include "DEFS.h"
 
 ENTRY(alloca, 0)
 #include "DEFS.h"
 
 ENTRY(alloca, 0)
-       subl2   4(ap),sp        /* crude allocation */
-       movl    16(fp),r1       /* pc */
-       movq    8(fp),ap        /* new (old) ap and fp */
-       bicl2   $3,sp           /* 4-byte align */
-       addl2   $7*4,sp         /* reuse space of mscp */
-       movl    sp,r0           /* return value */
-       jmp     (r1)            /* funny return */
+       movl    4(ap),r0        # get allocation size
+       movl    16(fp),r2       # save return address before we smash it
+       movab   here,16(fp)
+       ret
+here:
+       subl2   r0,sp           # create stack space
+       bicl2   $3,sp           # align to longword boundary
+       movl    sp,r0
+       jmp     (r2)