/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
* 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
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* memset(sp, c, n)
*
* Set an array of n chars starting at sp to the character c.
* Return sp.
*
* Fast assembler language version of the following C-program for memset
* which represents the `standard' for the C-library.
*
* void *
* memset(void *sp1, int c, size_t n)
* {
* if (n != 0) {
* char *sp = sp1;
* do {
* *sp++ = (char)c;
* } while (--n != 0);
* }
* return (sp1);
* }
*
*
*
* Algorithm used:
* For small stores (6 or fewer bytes), bytes will be stored one at a time.
*
* When setting 15 or more bytes, there will be at least 8 bytes aligned
* on an 8-byte boundary. So, leading bytes will be set, then as many
* 8-byte aligned chunks as possible will be set, followed by any trailing
* bytes.
*
* For between 8 and 14 bytes (inclusive), leading odd bytes will be
* set, followed by 4-byte chunks, followed by trailing bytes.
*
* Inputs:
* o0: pointer to start of area to be set to a given value
* o1: character used to set memory at location in i0
* o2: number of bytes to be set
*
* Outputs:
* o0: pointer to start of area set (same as input value in o0)
*
*/
#include <sys/asm_linkage.h>
.align 32
.wrdbl:
b .walign
.wrword:
.wrchar:
retl
sub %o0, %g0, %o0
SET_SIZE(memset)