sbrk.S revision 11183
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 * 3. All advertising materials mentioning features or use of this software 171849Swollman * must display the following acknowledgement: 181849Swollman * This product includes software developed by the University of 191849Swollman * California, Berkeley and its contributors. 201849Swollman * 4. Neither the name of the University nor the names of its contributors 211849Swollman * may be used to endorse or promote products derived from this software 221849Swollman * without specific prior written permission. 231849Swollman * 241849Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251849Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261849Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271849Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281849Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291849Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301849Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311849Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321849Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331849Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341849Swollman * SUCH DAMAGE. 351849Swollman * 3611183Sphk * $Id: sbrk.S,v 1.2 1995/01/23 01:30:04 davidg Exp $ 371849Swollman */ 381849Swollman 395790Sdg#if defined(SYSLIBC_RCS) && !defined(lint) 405790Sdg .text 4111183Sphk .asciz "$Id: sbrk.S,v 1.2 1995/01/23 01:30:04 davidg Exp $" 425790Sdg#endif /* SYSLIBC_RCS and not lint */ 431849Swollman 441849Swollman#include "SYS.h" 451849Swollman 461849Swollman#define SYS_brk 17 471849Swollman 481849Swollman .globl _end 491849Swollman .globl minbrk 501849Swollman .globl curbrk 511849Swollman 521849Swollman .data 531849Swollmanminbrk: .long _end 541849Swollmancurbrk: .long _end 551849Swollman .text 561849Swollman 571849SwollmanENTRY(sbrk) 581849Swollman#ifdef PIC 591849Swollman movl 4(%esp),%ecx 601849Swollman PIC_PROLOGUE 611849Swollman movl PIC_GOT(curbrk),%edx 621849Swollman movl (%edx),%eax 631849Swollman PIC_EPILOGUE 6411183Sphk testl %ecx,%ecx 6511183Sphk jz back 661849Swollman addl %eax,4(%esp) 671849Swollman lea SYS_brk,%eax 681849Swollman LCALL(7,0) 691849Swollman jb err 701849Swollman PIC_PROLOGUE 711849Swollman movl PIC_GOT(curbrk),%edx 721849Swollman movl (%edx),%eax 731849Swollman addl %ecx,(%edx) 741849Swollman PIC_EPILOGUE 7511183Sphkback: 761849Swollman ret 771849Swollmanerr: 781849Swollman jmp PIC_PLT(cerror) 791849Swollman 8011183Sphk#else /* !PIC */ 811849Swollman 821849Swollman movl 4(%esp),%ecx 831849Swollman movl curbrk,%eax 8411183Sphk testl %ecx,%ecx 8511183Sphk jz back 861849Swollman addl %eax,4(%esp) 871849Swollman lea SYS_brk,%eax 881849Swollman LCALL(7,0) 891849Swollman jb err 901849Swollman movl curbrk,%eax 911849Swollman addl %ecx,curbrk 9211183Sphkback: 931849Swollman ret 941849Swollmanerr: 951849Swollman jmp cerror 9611183Sphk#endif /* PIC */ 97