xref: /netbsd-src/lib/libc/arch/mips/sys/sbrk.S (revision cd85a4cc3f7f68eb4e406a17f27c2488989755fd)
1*cd85a4ccSmatt/*	$NetBSD: sbrk.S,v 1.19 2013/06/26 08:38:34 matt Exp $	*/
281b108b4Sjonathan
3ae1bfcddSglass/*-
4ae1bfcddSglass * Copyright (c) 1991, 1993
5ae1bfcddSglass *	The Regents of the University of California.  All rights reserved.
6ae1bfcddSglass *
7ae1bfcddSglass * This code is derived from software contributed to Berkeley by
8ae1bfcddSglass * Ralph Campbell.
9ae1bfcddSglass *
10ae1bfcddSglass * Redistribution and use in source and binary forms, with or without
11ae1bfcddSglass * modification, are permitted provided that the following conditions
12ae1bfcddSglass * are met:
13ae1bfcddSglass * 1. Redistributions of source code must retain the above copyright
14ae1bfcddSglass *    notice, this list of conditions and the following disclaimer.
15ae1bfcddSglass * 2. Redistributions in binary form must reproduce the above copyright
16ae1bfcddSglass *    notice, this list of conditions and the following disclaimer in the
17ae1bfcddSglass *    documentation and/or other materials provided with the distribution.
18eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors
19ae1bfcddSglass *    may be used to endorse or promote products derived from this software
20ae1bfcddSglass *    without specific prior written permission.
21ae1bfcddSglass *
22ae1bfcddSglass * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23ae1bfcddSglass * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24ae1bfcddSglass * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25ae1bfcddSglass * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26ae1bfcddSglass * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27ae1bfcddSglass * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28ae1bfcddSglass * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29ae1bfcddSglass * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30ae1bfcddSglass * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31ae1bfcddSglass * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32ae1bfcddSglass * SUCH DAMAGE.
33ae1bfcddSglass */
34ae1bfcddSglass
35946af1bcSjonathan#include "SYS.h"
36946af1bcSjonathan
37ae1bfcddSglass#if defined(LIBC_SCCS) && !defined(lint)
3822882071Smatt#if 0
3922882071Smatt	RCSID("from: @(#)sbrk.s	8.1 (Berkeley) 6/4/93")
4022882071Smatt#else
41*cd85a4ccSmatt	RCSID("$NetBSD: sbrk.S,v 1.19 2013/06/26 08:38:34 matt Exp $")
4222882071Smatt#endif
43ae1bfcddSglass#endif /* LIBC_SCCS and not lint */
44ae1bfcddSglass
456348b7d5Skleink	.globl	_C_LABEL(__curbrk)
465af7e7a9Skleink	.globl	_C_LABEL(_end)
47ae1bfcddSglass
4803f996bdSkleink#ifdef WEAK_ALIAS
4903f996bdSkleinkWEAK_ALIAS(sbrk, _sbrk)
5003f996bdSkleink#endif
5103f996bdSkleink
52ae1bfcddSglass	.data
536348b7d5Skleink_C_LABEL(__curbrk):
5422882071Smatt	PTR_WORD	_C_LABEL(_end)
55ae1bfcddSglass	.text
56ae1bfcddSglass
5703f996bdSkleinkLEAF(_sbrk)
5822882071Smatt	PIC_PROLOGUE(_sbrk)
5922882071Smatt	PTR_LA		t0, _C_LABEL(__curbrk)
60*cd85a4ccSmatt	PTR_L		t1, 0(t0)
61*cd85a4ccSmatt	PTR_ADDU	a0, a0, t1	# compute current break
6222882071Smatt	SYSTRAP(break)
63ae1bfcddSglass	bne		a3, zero, 1f
64*cd85a4ccSmatt	move		v0, t1		# return old val of curbrk from above
65be1c8594Stsutsui	PTR_LA		t0, _C_LABEL(__curbrk)
6622882071Smatt	PTR_S		a0, 0(t0)	# save current val of curbrk from above
6722882071Smatt	PIC_RETURN()
68ae1bfcddSglass1:
6922882071Smatt	PIC_TAILCALL(__cerror)
700cbe508fSsimonbEND(_sbrk)
71