From owner-svn-src-all@FreeBSD.ORG Thu Jul 21 16:32:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35D8F106566C; Thu, 21 Jul 2011 16:32:14 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 247FA8FC0A; Thu, 21 Jul 2011 16:32:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6LGWE2G077362; Thu, 21 Jul 2011 16:32:14 GMT (envelope-from gnn@svn.freebsd.org) Received: (from gnn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6LGWEld077358; Thu, 21 Jul 2011 16:32:14 GMT (envelope-from gnn@svn.freebsd.org) Message-Id: <201107211632.p6LGWEld077358@svn.freebsd.org> From: "George V. Neville-Neil" Date: Thu, 21 Jul 2011 16:32:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224246 - head/lib/libc/amd64/string X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2011 16:32:14 -0000 Author: gnn Date: Thu Jul 21 16:32:13 2011 New Revision: 224246 URL: http://svn.freebsd.org/changeset/base/224246 Log: Make both stpcpy and strcpy be assembly language implementations on amd64. Submitted by: Guillaume Morin (guillaume at morinfr.org) Reviewed by: kib, jhb Approved by: re (bz) MFC after: 1 month Added: head/lib/libc/amd64/string/stpcpy.S - copied, changed from r223967, head/lib/libc/amd64/string/strcpy.S head/lib/libc/amd64/string/strcpy.c (contents, props changed) Deleted: head/lib/libc/amd64/string/strcpy.S Modified: head/lib/libc/amd64/string/Makefile.inc Modified: head/lib/libc/amd64/string/Makefile.inc ============================================================================== --- head/lib/libc/amd64/string/Makefile.inc Thu Jul 21 14:25:12 2011 (r224245) +++ head/lib/libc/amd64/string/Makefile.inc Thu Jul 21 16:32:13 2011 (r224246) @@ -1,4 +1,4 @@ # $FreeBSD$ MDSRCS+= bcmp.S bcopy.S bzero.S memcmp.S memcpy.S memmove.S memset.S \ - strcat.S strcmp.S strcpy.S + strcat.S strcmp.S stpcpy.S strcpy.c Copied and modified: head/lib/libc/amd64/string/stpcpy.S (from r223967, head/lib/libc/amd64/string/strcpy.S) ============================================================================== --- head/lib/libc/amd64/string/strcpy.S Tue Jul 12 20:38:42 2011 (r223967, copy source) +++ head/lib/libc/amd64/string/stpcpy.S Thu Jul 21 16:32:13 2011 (r224246) @@ -1,17 +1,14 @@ /* - * Written by J.T. Conklin + * Adapted by Guillaume Morin from strcpy.S + * written by J.T. Conklin * Public domain. */ #include __FBSDID("$FreeBSD$"); -#if 0 - RCSID("$NetBSD: strcpy.S,v 1.3 2004/07/19 20:04:41 drochner Exp $") -#endif - /* - * This strcpy implementation copies a byte at a time until the + * This stpcpy implementation copies a byte at a time until the * source pointer is aligned to a word boundary, it then copies by * words until it finds a word containing a zero byte, and finally * copies by bytes until the end of the string is reached. @@ -23,10 +20,11 @@ __FBSDID("$FreeBSD$"); * requirements. */ -ENTRY(strcpy) - movq %rdi,%rax - movabsq $0x0101010101010101,%r8 - movabsq $0x8080808080808080,%r9 + .globl stpcpy,__stpcpy +ENTRY(stpcpy) +__stpcpy: + movabsq $0x0101010101010101,%r8 + movabsq $0x8080808080808080,%r9 /* * Align source to a word boundary. @@ -41,6 +39,8 @@ ENTRY(strcpy) incq %rdi testb %dl,%dl jne .Lalign + movq %rdi,%rax + dec %rax ret .p2align 4 @@ -61,54 +61,56 @@ ENTRY(strcpy) */ movb %dl,(%rdi) - incq %rdi testb %dl,%dl /* 1st byte == 0? */ je .Ldone + incq %rdi shrq $8,%rdx movb %dl,(%rdi) - incq %rdi testb %dl,%dl /* 2nd byte == 0? */ je .Ldone + incq %rdi shrq $8,%rdx movb %dl,(%rdi) - incq %rdi testb %dl,%dl /* 3rd byte == 0? */ je .Ldone + incq %rdi shrq $8,%rdx movb %dl,(%rdi) - incq %rdi testb %dl,%dl /* 4th byte == 0? */ je .Ldone + incq %rdi shrq $8,%rdx movb %dl,(%rdi) - incq %rdi testb %dl,%dl /* 5th byte == 0? */ je .Ldone + incq %rdi shrq $8,%rdx movb %dl,(%rdi) - incq %rdi testb %dl,%dl /* 6th byte == 0? */ je .Ldone + incq %rdi shrq $8,%rdx movb %dl,(%rdi) - incq %rdi testb %dl,%dl /* 7th byte == 0? */ je .Ldone + incq %rdi shrq $8,%rdx movb %dl,(%rdi) incq %rdi testb %dl,%dl /* 8th byte == 0? */ jne .Lword_aligned + decq %rdi .Ldone: + movq %rdi,%rax ret -END(strcpy) - +END(stpcpy) + .section .note.GNU-stack,"",%progbits Added: head/lib/libc/amd64/string/strcpy.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/amd64/string/strcpy.c Thu Jul 21 16:32:13 2011 (r224246) @@ -0,0 +1,38 @@ +/* + * Copyright 2011 George V. Neville-Neil. All rights reserved. + * + * The compilation of software known as FreeBSD is distributed under the + * following terms: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +char *__stpcpy(char * __restrict, const char * __restrict); + +char * +strcpy(char * __restrict to, const char * __restrict from) +{ + __stpcpy(to, from); + return(to); +}