10Sstevel@tonic-gate/* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7298SMark.J.Nelson@Sun.COM * Common Development and Distribution License (the "License"). 6*7298SMark.J.Nelson@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate/* 220Sstevel@tonic-gate * Copyright (c) 1998, by Sun Microsystems, Inc. 230Sstevel@tonic-gate * All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 26*7298SMark.J.Nelson@Sun.COM .file "alloca.s" 270Sstevel@tonic-gate 280Sstevel@tonic-gate#include <sys/asm_linkage.h> 290Sstevel@tonic-gate#include <sys/stack.h> 300Sstevel@tonic-gate 310Sstevel@tonic-gate ! 320Sstevel@tonic-gate ! o0: # bytes of space to allocate, already rounded to 0 mod 8 330Sstevel@tonic-gate ! o1: %sp-relative offset of tmp area 340Sstevel@tonic-gate ! o2: %sp-relative offset of end of tmp area 350Sstevel@tonic-gate ! 360Sstevel@tonic-gate ! we want to bump %sp by the requested size 370Sstevel@tonic-gate ! then copy the tmp area to its new home 380Sstevel@tonic-gate ! this is necessary as we could theoretically 390Sstevel@tonic-gate ! be in the middle of a complicated expression. 400Sstevel@tonic-gate ! 410Sstevel@tonic-gate ENTRY(__builtin_alloca) 420Sstevel@tonic-gate add %sp, STACK_BIAS, %g1 ! save current sp + STACK_BIAS 430Sstevel@tonic-gate sub %sp, %o0, %sp ! bump to new value 440Sstevel@tonic-gate add %sp, STACK_BIAS, %g5 450Sstevel@tonic-gate ! copy loop: should do nothing gracefully 460Sstevel@tonic-gate b 2f 470Sstevel@tonic-gate subcc %o2, %o1, %o5 ! number of bytes to move 480Sstevel@tonic-gate1: 490Sstevel@tonic-gate ldx [%g1 + %o1], %o4 ! load from old temp area 500Sstevel@tonic-gate stx %o4, [%g5 + %o1] ! store to new temp area 510Sstevel@tonic-gate add %o1, 8, %o1 520Sstevel@tonic-gate2: bg,pt %xcc, 1b 530Sstevel@tonic-gate subcc %o5, 8, %o5 540Sstevel@tonic-gate ! now return new %sp + end-of-temp 550Sstevel@tonic-gate add %sp, %o2, %o0 560Sstevel@tonic-gate retl 570Sstevel@tonic-gate add %o0, STACK_BIAS, %o0 580Sstevel@tonic-gate SET_SIZE(__builtin_alloca) 59