2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * __align_cpy_2(s1, s2, len) 2N/A * Copy s2 to s1, always copy n bytes. 2N/A * Note: this does not work for overlapped copies, bcopy() does 2N/A * This routine is copied from memcpy.s, with all values doubled. 2N/A * No attempt has been made to improve the comments or performance. 2N/A.aldst: andcc %g5, 6, %o5 ! align the destination address 2N/A.ald: bz,pn %xcc, .w4cp 2N/A.w3cp: ldx [%o1], %o4 2N/A andn %o2, 6, %o3 ! o3 is aligned word count 2N/A sub %o1, %g5, %o1 ! g5 gets the difference 2N/A1: sllx %o4, 16, %g1 ! save residual bytes 2N/A srlx %o4, 48, %o5 ! merge with residual 2N/A sub %o1, 6, %o1 ! used two bytes of last word read 2N/A.w1cp: srlx %o4, 16, %o5 2N/A sub %o1, %g5, %o1 ! g5 gets the difference 2N/A2: sllx %o4, 48, %g1 ! save residual bytes 2N/A srlx %o4, 16, %o5 ! merge with residual 2N/A sub %o1, 2, %o1 ! used six bytes of last word read 2N/A.w2cp: ldx [%o1], %o4 2N/A andn %o2, 6, %o3 ! o3 is aligned word count 2N/A sub %o1, %g5, %o1 ! g5 gets the difference 2N/A3: sllx %o4, 32, %g1 ! save residual bytes 2N/A srlx %o4, 32, %o5 ! merge with residual 2N/A sub %o1, 4, %o1 ! used four bytes of last word read 2N/A.w4cp: andn %o2, 6, %o3 ! o3 is aligned word count 2N/A sub %o1, %g5, %o1 ! g5 gets the difference 2N/A1: ldx [%o1+%g5], %o4 ! read from address 2N/A deccc 8, %o3 ! decrement count 2N/A stx %o4, [%g5] ! write at destination address 2N/A inc 8, %g5 ! increment to address 2N/A and %o2, 6, %o2 ! number of leftover bytes, if any 2N/A ! differenced byte copy, works with any alignment 2N/A sub %o1, %g5, %o1 ! g5 gets the difference 2N/A4: sth %o4, [%g5] ! write to address 2N/A inc 2, %g5 ! inc to address 2N/A7: deccc 2, %o2 ! decrement count 2N/A bge,a,pt %xcc,4b ! loop till done 2N/A lduh [%o1+%g5], %o4 ! read from address 2N/A SET_SIZE(__align_cpy_2)