/*
 * 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1986,1987
 * LICENSED MATERIALS - PROPERTY OF IBM
 * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
 */
 # $Header:brk.c 12.0$
 # $ACIS:brk.c 12.0$
 # $Source: /ibm/acis/usr/src/lib/libc/ca/sys/RCS/brk.c,v $
#include "SYS.h"
	.globl curbrk
	.globl minbrk
	.data
	.align 2
minbrk: .long _end
curbrk: .long _end
	.text
SYSCODE(brk)
	load	r4,minbrk
	ais	r2,3		# round proposed curbrk setting
	ni	r2,r2,-4	# up to a word boundary
	c	r2,r4
	jhe	brk10
	mr	r2,r4
brk10:
	mr	r4,r2		# save new brk
	svc	17(r0)		# why is this not symbolic?
	jtb	syserror
	store	r4,curbrk,r2
	brx	r15
	lis	r2,0            

SYSCODE(sbrk)
	load	r3,curbrk
	ais	r2,3		# to next word boundary
	ni	r2,r2,-4	# mask off bottom bits
	a	r2,r3
	mr	r4,r2
	svc	17(r0)
	jtb	syserror
	mr	r2,r3
	store	r4,curbrk,r3	# no error; now we can update curbrk.
	br	r15

syserror:
	store	r2,_errno,r5	# update error number
	brx	r15		# return to caller
	cal	r2,-1(r0)

	TTNOFRM
