sbrk.S revision 184548
11849Swollman/*- 21849Swollman * Copyright (c) 1990 The Regents of the University of California. 31849Swollman * All rights reserved. 41849Swollman * 51849Swollman * This code is derived from software contributed to Berkeley by 61849Swollman * William Jolitz. 71849Swollman * 81849Swollman * Redistribution and use in source and binary forms, with or without 91849Swollman * modification, are permitted provided that the following conditions 101849Swollman * are met: 111849Swollman * 1. Redistributions of source code must retain the above copyright 121849Swollman * notice, this list of conditions and the following disclaimer. 131849Swollman * 2. Redistributions in binary form must reproduce the above copyright 141849Swollman * notice, this list of conditions and the following disclaimer in the 151849Swollman * documentation and/or other materials provided with the distribution. 161849Swollman * 4. Neither the name of the University nor the names of its contributors 171849Swollman * may be used to endorse or promote products derived from this software 181849Swollman * without specific prior written permission. 191849Swollman * 201849Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211849Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221849Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231849Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241849Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251849Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261849Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271849Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281849Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291849Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301849Swollman * SUCH DAMAGE. 311849Swollman */ 321849Swollman 3392999Sobrien#if defined(SYSLIBC_SCCS) && !defined(lint) 3492999Sobrien .asciz "@(#)sbrk.s 5.1 (Berkeley) 4/23/90" 3592999Sobrien#endif /* SYSLIBC_SCCS and not lint */ 3692999Sobrien#include <machine/asm.h> 3792999Sobrien__FBSDID("$FreeBSD: head/lib/libc/i386/sys/sbrk.S 184548 2008-11-02 01:28:47Z peter $"); 381849Swollman 391849Swollman#include "SYS.h" 401849Swollman 41101536Skan .globl CNAME(_end) 4215634Speter .globl HIDENAME(minbrk) 4315634Speter .globl HIDENAME(curbrk) 441849Swollman 451849Swollman .data 46101536SkanHIDENAME(minbrk): .long CNAME(_end) 47101536SkanHIDENAME(curbrk): .long CNAME(_end) 481849Swollman .text 491849Swollman 501849SwollmanENTRY(sbrk) 511849Swollman#ifdef PIC 521849Swollman movl 4(%esp),%ecx 531849Swollman PIC_PROLOGUE 5415634Speter movl PIC_GOT(HIDENAME(curbrk)),%edx 551849Swollman movl (%edx),%eax 561849Swollman PIC_EPILOGUE 5711183Sphk testl %ecx,%ecx 5811183Sphk jz back 591849Swollman addl %eax,4(%esp) 6087006Sjhb mov $SYS_break,%eax 6115634Speter KERNCALL 621849Swollman jb err 631849Swollman PIC_PROLOGUE 6415634Speter movl PIC_GOT(HIDENAME(curbrk)),%edx 651849Swollman movl (%edx),%eax 661849Swollman addl %ecx,(%edx) 671849Swollman PIC_EPILOGUE 6811183Sphkback: 691849Swollman ret 701849Swollmanerr: 7115634Speter PIC_PROLOGUE 7215634Speter jmp PIC_PLT(HIDENAME(cerror)) 731849Swollman 7411183Sphk#else /* !PIC */ 751849Swollman 761849Swollman movl 4(%esp),%ecx 7715634Speter movl HIDENAME(curbrk),%eax 7811183Sphk testl %ecx,%ecx 7911183Sphk jz back 801849Swollman addl %eax,4(%esp) 8187006Sjhb mov $SYS_break,%eax 8215634Speter KERNCALL 831849Swollman jb err 8415634Speter movl HIDENAME(curbrk),%eax 8515634Speter addl %ecx,HIDENAME(curbrk) 8611183Sphkback: 871849Swollman ret 881849Swollmanerr: 8915634Speter jmp HIDENAME(cerror) 9011183Sphk#endif /* PIC */ 91184548SpeterEND(sbrk) 92