10Sstevel@tonic-gate/* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 56812Sraf * Common Development and Distribution License (the "License"). 66812Sraf * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 216812Sraf 220Sstevel@tonic-gate/* 236812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 27*7298SMark.J.Nelson@Sun.COM .file "memccpy.s" 280Sstevel@tonic-gate 290Sstevel@tonic-gate#include <sys/asm_linkage.h> 300Sstevel@tonic-gate 310Sstevel@tonic-gate ANSI_PRAGMA_WEAK(memccpy,function) 320Sstevel@tonic-gate 330Sstevel@tonic-gate ENTRY(memccpy) /* (void *dst, void *src, uchar_t c, size_t) */ 340Sstevel@tonic-gate.loop: 350Sstevel@tonic-gate decq %rcx / decrement bytes to go 360Sstevel@tonic-gate jl .notfound 370Sstevel@tonic-gate movb (%rsi),%dh 380Sstevel@tonic-gate movb %dh,(%rdi) / move byte 390Sstevel@tonic-gate cmpb %dh,%dl / is it the byte sought? 400Sstevel@tonic-gate je .found / yes 410Sstevel@tonic-gate 420Sstevel@tonic-gate decq %rcx / decrement bytes to go 430Sstevel@tonic-gate jl .notfound 440Sstevel@tonic-gate movb 1(%rsi),%dh 450Sstevel@tonic-gate movb %dh,1(%rdi) / move byte 460Sstevel@tonic-gate cmpb %dh,%dl / is it the byte sought? 470Sstevel@tonic-gate je .found1 / yes 480Sstevel@tonic-gate 490Sstevel@tonic-gate decq %rcx / decrement bytes to go 500Sstevel@tonic-gate jl .notfound 510Sstevel@tonic-gate movb 2(%rsi),%dh 520Sstevel@tonic-gate movb %dh,2(%rdi) / move byte 530Sstevel@tonic-gate cmpb %dh,%dl / is it the byte sought? 540Sstevel@tonic-gate je .found2 / yes 550Sstevel@tonic-gate 560Sstevel@tonic-gate decq %rcx / decrement bytes to go 570Sstevel@tonic-gate jl .notfound 580Sstevel@tonic-gate movb 3(%rsi),%dh 590Sstevel@tonic-gate movb %dh,3(%rdi) / move byte 600Sstevel@tonic-gate addq $4,%rsi 610Sstevel@tonic-gate addq $4,%rdi 620Sstevel@tonic-gate cmpb %dh,%dl / is it the byte sought? 630Sstevel@tonic-gate jne .loop / no 640Sstevel@tonic-gate decq %rdi 650Sstevel@tonic-gate 660Sstevel@tonic-gate.found: 670Sstevel@tonic-gate incq %rdi / return pointer to next byte in dest 680Sstevel@tonic-gate movq %rdi,%rax 690Sstevel@tonic-gate ret 700Sstevel@tonic-gate 710Sstevel@tonic-gate .align 4 720Sstevel@tonic-gate.found2: 730Sstevel@tonic-gate incq %rdi 740Sstevel@tonic-gate.found1: 750Sstevel@tonic-gate addq $2,%rdi / return pointer to next byte in dest 760Sstevel@tonic-gate movq %rdi,%rax 770Sstevel@tonic-gate ret 780Sstevel@tonic-gate 790Sstevel@tonic-gate .align 4 800Sstevel@tonic-gate.notfound: 810Sstevel@tonic-gate xorl %eax,%eax / search fails 820Sstevel@tonic-gate ret 830Sstevel@tonic-gate SET_SIZE(memccpy) 84