sbrk.S revision 5790
122347Spst/*- 222347Spst * Copyright (c) 1990 The Regents of the University of California. 322347Spst * All rights reserved. 422347Spst * 522347Spst * This code is derived from software contributed to Berkeley by 622347Spst * William Jolitz. 722347Spst * 822347Spst * Redistribution and use in source and binary forms, with or without 922347Spst * modification, are permitted provided that the following conditions 1022347Spst * are met: 1122347Spst * 1. Redistributions of source code must retain the above copyright 1222347Spst * notice, this list of conditions and the following disclaimer. 1322347Spst * 2. Redistributions in binary form must reproduce the above copyright 1422347Spst * notice, this list of conditions and the following disclaimer in the 1522347Spst * documentation and/or other materials provided with the distribution. 1622347Spst * 3. All advertising materials mentioning features or use of this software 1722347Spst * must display the following acknowledgement: 1822347Spst * This product includes software developed by the University of 1922347Spst * California, Berkeley and its contributors. 2022347Spst * 4. Neither the name of the University nor the names of its contributors 2122347Spst * may be used to endorse or promote products derived from this software 2222347Spst * without specific prior written permission. 2322347Spst * 2422347Spst * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2522347Spst * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2622347Spst * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2722347Spst * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2822347Spst * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2922347Spst * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3022347Spst * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3122347Spst * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3222347Spst * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3322347Spst * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3422347Spst * SUCH DAMAGE. 3522347Spst * 3622347Spst * $Id: sbrk.S,v 1.1 1994/08/05 01:18:49 wollman Exp $ 3722347Spst */ 3822347Spst 3922347Spst#if defined(SYSLIBC_RCS) && !defined(lint) 4022347Spst .text 4122347Spst .asciz "$Id$" 4222347Spst#endif /* SYSLIBC_RCS and not lint */ 4322347Spst 4422347Spst#include "SYS.h" 4522347Spst 4622347Spst#define SYS_brk 17 4722347Spst 4822347Spst .globl _end 4922347Spst .globl minbrk 5022347Spst .globl curbrk 5122347Spst 5222347Spst .data 5322347Spstminbrk: .long _end 5422347Spstcurbrk: .long _end 5522347Spst .text 5622347Spst 5722347SpstENTRY(sbrk) 5822347Spst#ifdef PIC 5922347Spst movl 4(%esp),%ecx 6022347Spst PIC_PROLOGUE 6122347Spst movl PIC_GOT(curbrk),%edx 6222347Spst movl (%edx),%eax 6322347Spst PIC_EPILOGUE 6422347Spst addl %eax,4(%esp) 6522347Spst lea SYS_brk,%eax 6622347Spst LCALL(7,0) 6722347Spst jb err 6822347Spst PIC_PROLOGUE 69 movl PIC_GOT(curbrk),%edx 70 movl (%edx),%eax 71 addl %ecx,(%edx) 72 PIC_EPILOGUE 73 ret 74err: 75 jmp PIC_PLT(cerror) 76 77#else 78 79 movl 4(%esp),%ecx 80 movl curbrk,%eax 81 addl %eax,4(%esp) 82 lea SYS_brk,%eax 83 LCALL(7,0) 84 jb err 85 movl curbrk,%eax 86 addl %ecx,curbrk 87 ret 88err: 89 jmp cerror 90#endif 91