xref: /openbsd-src/lib/libc/arch/hppa/sys/brk.S (revision 01422588aea879b986d4ff8bb39988e7dd8edad8)
1*01422588Sguenther/*	$OpenBSD: brk.S,v 1.18 2016/05/30 05:18:52 guenther Exp $	*/
2c5a6c4faSmickey
3c5a6c4faSmickey/*
4c5a6c4faSmickey * Copyright (c) 1999 Michael Shalayeff
5c5a6c4faSmickey * All rights reserved.
6c5a6c4faSmickey *
7c5a6c4faSmickey * Redistribution and use in source and binary forms, with or without
8c5a6c4faSmickey * modification, are permitted provided that the following conditions
9c5a6c4faSmickey * are met:
10c5a6c4faSmickey * 1. Redistributions of source code must retain the above copyright
11c5a6c4faSmickey *    notice, this list of conditions and the following disclaimer.
12c5a6c4faSmickey * 2. Redistributions in binary form must reproduce the above copyright
13c5a6c4faSmickey *    notice, this list of conditions and the following disclaimer in the
14c5a6c4faSmickey *    documentation and/or other materials provided with the distribution.
15c5a6c4faSmickey *
16c5a6c4faSmickey * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17c5a6c4faSmickey * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18c5a6c4faSmickey * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19c5a6c4faSmickey * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
20c5a6c4faSmickey * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21c5a6c4faSmickey * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22c5a6c4faSmickey * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23c5a6c4faSmickey * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24c5a6c4faSmickey * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25c5a6c4faSmickey * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26c5a6c4faSmickey * THE POSSIBILITY OF SUCH DAMAGE.
27c5a6c4faSmickey */
28c5a6c4faSmickey
29c9d8341bSmickey#include "SYS.h"
30c9d8341bSmickey
31b6c3a27aSmickey	.import	__curbrk, data
32*01422588Sguenther	.import	_end, data
33c5a6c4faSmickey
347fcc402fSmickey	.data
35b3b7ef2eSguenther	.export	__minbrk, data
36b3b7ef2eSguenther__minbrk
37*01422588Sguenther	.long	_end
38c5a6c4faSmickey
393f373d41Sguenther	.weak	brk
40b3b7ef2eSguenther
413f373d41SguentherLEAF_ENTRY(brk)
4232b97dedSpascal#ifdef __PIC__
43b3b7ef2eSguenther	addil	LT%__minbrk, r19
44b3b7ef2eSguenther	ldw	RT%__minbrk(r1), t1
45b1011d27Smickey	ldw	0(t1), t2
46b1011d27Smickey#else
47b3b7ef2eSguenther	ldil	L%__minbrk, t1
48b3b7ef2eSguenther	ldw	R%__minbrk(t1), t2
49b1011d27Smickey#endif
507fcc402fSmickey	sub,<<	t2, arg0, r0
51c5a6c4faSmickey	copy	t2, arg0
52c5a6c4faSmickey	stw	arg0, HPPA_FRAME_ARG(0)(sp)
53c5a6c4faSmickey
54c5a6c4faSmickey	SYSCALL(break)
55c5a6c4faSmickey
56c5a6c4faSmickey	ldw	HPPA_FRAME_ARG(0)(sp), arg0
5732b97dedSpascal#ifdef __PIC__
58b1011d27Smickey	addil	LT%__curbrk, r19
59b1011d27Smickey	ldw	RT%__curbrk(r1), t1
60b1011d27Smickey	bv	r0(rp)
61b1011d27Smickey	stw     arg0, 0(t1)
62b1011d27Smickey#else
63b6c3a27aSmickey	ldil	L%__curbrk, t1
64c9d8341bSmickey	bv	r0(rp)
65b6c3a27aSmickey	stw	arg0, R%__curbrk(t1)
66b1011d27Smickey#endif
673f373d41SguentherEXIT(brk)
68c9d8341bSmickey
69c9d8341bSmickey	.end
70c5a6c4faSmickey
71