!
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License").  You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
! or http://www.opensolaris.org/os/licensing.
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at usr/src/OPENSOLARIS.LICENSE.
! If applicable, add the following below this CDDL HEADER, with the
! fields enclosed by brackets "[]" replaced with your own identifying
! information: Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
!	"%Z%%M%	%I%	%E% SMI"
!	Copyright (c) 1986 by Sun Microsystems, Inc.
!
	.seg	".text"

#include "SYS.h"
#define ALIGNSIZE	8

#define	SYS_brk		17

	.global .curbrk
	.type	.curbrk,#object
	.size	.curbrk,4

	ENTRY(brk)
	add	%o0, (ALIGNSIZE-1), %o0	! round up new break to a
	andn	%o0, (ALIGNSIZE-1), %o0	! multiple of alignsize
	mov	%o0, %o2		! save new break
	mov	SYS_brk, %g1
	t	8
	CERROR(o5)
#ifdef PIC
	PIC_SETUP(o5)
	ld	[%o5 + .curbrk], %g1
	st	%o2, [%g1]
#else
	sethi	%hi(.curbrk), %g1	! save new break
	st	%o2, [%g1 + %lo(.curbrk)]
#endif
	RET
	SET_SIZE(brk)
