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 (c) 2009, Intel Corporation 2N/A * All rights reserved. 2N/A * strlen - calculate the length of string 2N/A * This implementation uses SSE instructions to compare up to 16 bytes 2N/A * at a time looking for the end of string (null char). 2N/A * Unaligned case. Round down to 16-byte boundary before comparing 2N/A * 16 bytes for a null char. The code then compensates for any extra chars 2N/A * preceding the start of the string. 2N/A shr %
cl, %
edx /* Compensate for bytes preceding the string */ 2N/A sub %
rcx, %
rsi /* no null, adjust to next 16-byte boundary */ 2N/A add $
16, %
rsi /* prepare to search next 16 bytes */ 2N/A * Check to see if BSF is fast on this processor. If not, use a different 2N/A * exit tail to find first bit set indicating null byte match. 2N/A bsf %
edx, %
ecx /* Least significant 1 bit is index of null */ 2N/A * This exit tail does not use the bsf instruction.