sbrk.S revision 81586
1221115Sobrien/*- 2221115Sobrien * Copyright (c) 1990 The Regents of the University of California. 3221115Sobrien * All rights reserved. 4221115Sobrien * 5221115Sobrien * This code is derived from software contributed to Berkeley by 6221115Sobrien * William Jolitz. 7221115Sobrien * 8221115Sobrien * Redistribution and use in source and binary forms, with or without 960786Sps * modification, are permitted provided that the following conditions 10237613Sdelphij * are met: 1160786Sps * 1. Redistributions of source code must retain the above copyright 12237613Sdelphij * notice, this list of conditions and the following disclaimer. 1360786Sps * 2. Redistributions in binary form must reproduce the above copyright 1460786Sps * notice, this list of conditions and the following disclaimer in the 1560786Sps * documentation and/or other materials provided with the distribution. 1660786Sps * 3. All advertising materials mentioning features or use of this software 1760786Sps * must display the following acknowledgement: 1860786Sps * This product includes software developed by the University of 19191930Sdelphij * California, Berkeley and its contributors. 2060786Sps * 4. Neither the name of the University nor the names of its contributors 2160786Sps * may be used to endorse or promote products derived from this software 2260786Sps * without specific prior written permission. 2360786Sps * 24237613Sdelphij * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2589019Sps * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2660786Sps * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2760786Sps * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2860786Sps * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2960786Sps * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3060786Sps * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3160786Sps * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3260786Sps * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3360786Sps * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3460786Sps * SUCH DAMAGE. 3560786Sps */ 3660786Sps 3760786Sps#if defined(SYSLIBC_RCS) && !defined(lint) 3860786Sps .text 3960786Sps .asciz "$FreeBSD: head/lib/libc/amd64/sys/sbrk.S 81586 2001-08-13 14:06:34Z ru $" 4060786Sps#endif /* SYSLIBC_RCS and not lint */ 4160786Sps 4260786Sps#include "SYS.h" 4360786Sps 4460786Sps .globl CNAME(end) 4560786Sps .globl HIDENAME(minbrk) 4660786Sps .globl HIDENAME(curbrk) 4760786Sps 4860786Sps .data 4960786SpsHIDENAME(minbrk): .long CNAME(end) 5060786SpsHIDENAME(curbrk): .long CNAME(end) 51170256Sdelphij .text 5260786Sps 5360786SpsENTRY(sbrk) 5460786Sps#ifdef PIC 5560786Sps movl 4(%esp),%ecx 5660786Sps PIC_PROLOGUE 5760786Sps movl PIC_GOT(HIDENAME(curbrk)),%edx 5860786Sps movl (%edx),%eax 5960786Sps PIC_EPILOGUE 6060786Sps testl %ecx,%ecx 6160786Sps jz back 6260786Sps addl %eax,4(%esp) 63237613Sdelphij lea SYS_break,%eax 64161475Sdelphij KERNCALL 65161475Sdelphij jb err 66237613Sdelphij PIC_PROLOGUE 67237613Sdelphij movl PIC_GOT(HIDENAME(curbrk)),%edx 6860786Sps movl (%edx),%eax 69170256Sdelphij addl %ecx,(%edx) 7060786Sps PIC_EPILOGUE 7160786Spsback: 7260786Sps ret 7360786Spserr: 7460786Sps PIC_PROLOGUE 7560786Sps jmp PIC_PLT(HIDENAME(cerror)) 7660786Sps 7760786Sps#else /* !PIC */ 7860786Sps 7960786Sps movl 4(%esp),%ecx 8060786Sps movl HIDENAME(curbrk),%eax 8160786Sps testl %ecx,%ecx 8260786Sps jz back 8360786Sps addl %eax,4(%esp) 8460786Sps lea SYS_break,%eax 8560786Sps KERNCALL 8660786Sps jb err 8760786Sps movl HIDENAME(curbrk),%eax 8860786Sps addl %ecx,HIDENAME(curbrk) 8960786Spsback: 9060786Sps ret 9160786Spserr: 9260786Sps jmp HIDENAME(cerror) 9360786Sps#endif /* PIC */ 9460786Sps