1*39b8558cSmortimer/* $OpenBSD: sbrk.S,v 1.13 2023/01/11 01:55:17 mortimer Exp $ */ 2118f6189Smickey/* $NetBSD: sbrk.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */ 3118f6189Smickey 4118f6189Smickey/*- 5118f6189Smickey * Copyright (c) 1990 The Regents of the University of California. 6118f6189Smickey * All rights reserved. 7118f6189Smickey * 8118f6189Smickey * This code is derived from software contributed to Berkeley by 9118f6189Smickey * William Jolitz. 10118f6189Smickey * 11118f6189Smickey * Redistribution and use in source and binary forms, with or without 12118f6189Smickey * modification, are permitted provided that the following conditions 13118f6189Smickey * are met: 14118f6189Smickey * 1. Redistributions of source code must retain the above copyright 15118f6189Smickey * notice, this list of conditions and the following disclaimer. 16118f6189Smickey * 2. Redistributions in binary form must reproduce the above copyright 17118f6189Smickey * notice, this list of conditions and the following disclaimer in the 18118f6189Smickey * documentation and/or other materials provided with the distribution. 19118f6189Smickey * 3. All advertising materials mentioning features or use of this software 20118f6189Smickey * must display the following acknowledgement: 21118f6189Smickey * This product includes software developed by the University of 22118f6189Smickey * California, Berkeley and its contributors. 23118f6189Smickey * 4. Neither the name of the University nor the names of its contributors 24118f6189Smickey * may be used to endorse or promote products derived from this software 25118f6189Smickey * without specific prior written permission. 26118f6189Smickey * 27118f6189Smickey * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28118f6189Smickey * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29118f6189Smickey * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30118f6189Smickey * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31118f6189Smickey * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32118f6189Smickey * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33118f6189Smickey * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34118f6189Smickey * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35118f6189Smickey * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36118f6189Smickey * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37118f6189Smickey * SUCH DAMAGE. 38118f6189Smickey * 39118f6189Smickey * from: @(#)sbrk.s 5.1 (Berkeley) 4/23/90 40118f6189Smickey */ 41118f6189Smickey 42118f6189Smickey#include <machine/asm.h> 43118f6189Smickey 44118f6189Smickey#include "SYS.h" 45118f6189Smickey 46118f6189Smickey .globl _end 470b4d25b1Sdrahn .globl __curbrk 48b3b7ef2eSguenther .hidden __curbrk 49118f6189Smickey 50118f6189Smickey .data 51f4882b55Sderaadt__curbrk: 52f4882b55Sderaadt .quad _end 53aa797096Sguenther END(__curbrk) 54aa797096Sguenther .type __curbrk,@object 55118f6189Smickey 56ec0f1ad6SguentherENTRY_NB(sbrk) 57*39b8558cSmortimer RETGUARD_SETUP(sbrk, r11); 58*39b8558cSmortimer RETGUARD_PUSH(r11); 590b4d25b1Sdrahn movq __curbrk(%rip),%rax 608ab6d9f9Sdrahn movslq %edi,%rsi 618ab6d9f9Sdrahn movq %rsi,%rdi 62118f6189Smickey addq %rax,%rdi 63118f6189Smickey SYSTRAP(break) 64aa797096Sguenther jc 1f 650b4d25b1Sdrahn movq __curbrk(%rip),%rax 660b4d25b1Sdrahn addq %rsi,__curbrk(%rip) 67*39b8558cSmortimer jmp 2f 68aa797096Sguenther1: 69fe38b55cSguenther SET_ERRNO 70*39b8558cSmortimer2: 71*39b8558cSmortimer RETGUARD_POP(r11); 72*39b8558cSmortimer RETGUARD_CHECK(sbrk, r11); 73fe38b55cSguenther ret 74aa797096SguentherEND(sbrk) 759a9a94f4Skettenis .weak sbrk 76