sbrk.S revision 50476
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 *
3650476Speter * $FreeBSD: head/lib/libc/i386/sys/sbrk.S 50476 1999-08-28 00:22:10Z peter $
371849Swollman */
381849Swollman
395790Sdg#if defined(SYSLIBC_RCS) && !defined(lint)
405790Sdg	.text
4150476Speter	.asciz "$FreeBSD: head/lib/libc/i386/sys/sbrk.S 50476 1999-08-28 00:22:10Z peter $"
425790Sdg#endif /* SYSLIBC_RCS and not lint */
431849Swollman
441849Swollman#include "SYS.h"
451849Swollman
4615634Speter	.globl	CNAME(end)
4715634Speter	.globl	HIDENAME(minbrk)
4815634Speter	.globl	HIDENAME(curbrk)
491849Swollman
501849Swollman	.data
5115634SpeterHIDENAME(minbrk):	.long	CNAME(end)
5215634SpeterHIDENAME(curbrk):	.long	CNAME(end)
531849Swollman	.text
541849Swollman
551849SwollmanENTRY(sbrk)
561849Swollman#ifdef PIC
571849Swollman	movl	4(%esp),%ecx
581849Swollman	PIC_PROLOGUE
5915634Speter	movl	PIC_GOT(HIDENAME(curbrk)),%edx
601849Swollman	movl	(%edx),%eax
611849Swollman	PIC_EPILOGUE
6211183Sphk	testl	%ecx,%ecx
6311183Sphk	jz	back
641849Swollman	addl	%eax,4(%esp)
6515634Speter	lea	SYS_break,%eax
6615634Speter	KERNCALL
671849Swollman	jb	err
681849Swollman	PIC_PROLOGUE
6915634Speter	movl	PIC_GOT(HIDENAME(curbrk)),%edx
701849Swollman	movl	(%edx),%eax
711849Swollman	addl	%ecx,(%edx)
721849Swollman	PIC_EPILOGUE
7311183Sphkback:
741849Swollman	ret
751849Swollmanerr:
7615634Speter	PIC_PROLOGUE
7715634Speter	jmp	PIC_PLT(HIDENAME(cerror))
781849Swollman
7911183Sphk#else /* !PIC */
801849Swollman
811849Swollman	movl	4(%esp),%ecx
8215634Speter	movl	HIDENAME(curbrk),%eax
8311183Sphk	testl	%ecx,%ecx
8411183Sphk	jz	back
851849Swollman	addl	%eax,4(%esp)
8615634Speter	lea	SYS_break,%eax
8715634Speter	KERNCALL
881849Swollman	jb	err
8915634Speter	movl	HIDENAME(curbrk),%eax
9015634Speter	addl	%ecx,HIDENAME(curbrk)
9111183Sphkback:
921849Swollman	ret
931849Swollmanerr:
9415634Speter	jmp	HIDENAME(cerror)
9511183Sphk#endif /* PIC */
96