brk.S revision 209231
1193141Sdougb/* $NetBSD: brk.S,v 1.16 2003/08/07 16:42:17 agc Exp $ */ 2193141Sdougb 3193141Sdougb/*- 4193141Sdougb * Copyright (c) 1991, 1993 5193141Sdougb * The Regents of the University of California. All rights reserved. 6193141Sdougb * 7193141Sdougb * This code is derived from software contributed to Berkeley by 8193141Sdougb * Ralph Campbell. 9193141Sdougb * 10193141Sdougb * Redistribution and use in source and binary forms, with or without 11193141Sdougb * modification, are permitted provided that the following conditions 12193141Sdougb * are met: 13193141Sdougb * 1. Redistributions of source code must retain the above copyright 14193141Sdougb * notice, this list of conditions and the following disclaimer. 15193141Sdougb * 2. Redistributions in binary form must reproduce the above copyright 16193141Sdougb * notice, this list of conditions and the following disclaimer in the 17193141Sdougb * documentation and/or other materials provided with the distribution. 18193141Sdougb * 3. Neither the name of the University nor the names of its contributors 19193141Sdougb * may be used to endorse or promote products derived from this software 20193141Sdougb * without specific prior written permission. 21193141Sdougb * 22193141Sdougb * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23193141Sdougb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24193141Sdougb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25193141Sdougb * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26193141Sdougb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27193141Sdougb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28193141Sdougb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29193141Sdougb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30193141Sdougb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31193141Sdougb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32193141Sdougb * SUCH DAMAGE. 33193141Sdougb */ 34193141Sdougb 35193141Sdougb#include <machine/asm.h> 36193141Sdougb__FBSDID("$FreeBSD: head/lib/libc/mips/sys/brk.S 209231 2010-06-16 12:55:14Z jchandra $"); 37193141Sdougb#include "SYS.h" 38193141Sdougb 39193141Sdougb#if defined(LIBC_SCCS) && !defined(lint) 40193141Sdougb ASMSTR("from: @(#)brk.s 8.1 (Berkeley) 6/4/93") 41193141Sdougb ASMSTR("$NetBSD: brk.S,v 1.16 2003/08/07 16:42:17 agc Exp $") 42193141Sdougb#endif /* LIBC_SCCS and not lint */ 43193141Sdougb 44193141Sdougb .globl _C_LABEL(minbrk) 45193141Sdougb .globl _C_LABEL(__curbrk) 46193141Sdougb .globl _C_LABEL(_end) 47193141Sdougb 48193141Sdougb .data 49193141Sdougb_C_LABEL(minbrk): 50193141Sdougb .word _C_LABEL(_end) 51193141Sdougb 52193141Sdougb .text 53193141SdougbLEAF(__sys_brk) 54193141Sdougb WEAK_ALIAS(brk, __sys_brk) 55193141Sdougb WEAK_ALIAS(_brk, __sys_brk) 56193141Sdougb PIC_PROLOGUE(__sys_brk) 57193141Sdougb PTR_LA v0, _C_LABEL(minbrk) 58193141Sdougb PTR_L v0, 0(v0) 59193141Sdougb bgeu a0, v0, 1f 60193141Sdougb move a0, v0 # dont allow break < minbrk 61193141Sdougb1: 62193141Sdougb li v0, SYS_break 63193141Sdougb syscall 64193141Sdougb bne a3, zero, 2f 65193141Sdougb PTR_LA t0, _C_LABEL(__curbrk) 66193141Sdougb PTR_S a0, 0(t0) 67193141Sdougb move v0, zero 68193141Sdougb PIC_RETURN() 69193141Sdougb2: 70193141Sdougb PIC_TAILCALL(__cerror) 71193141SdougbEND(__sys_brk) 72193141Sdougb