From patchwork Sun May 24 15:07:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?T25kxZllaiBCw61sa2E=?= X-Patchwork-Id: 475971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 19EA91402B9 for ; Mon, 25 May 2015 01:07:45 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=kcQwgLox; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=W1ubensSzpTEA8WG46vf3RdCutxKS SXp5F+n2xxUaUKYqHhCc5zVgZ3X+OtN65IyKwHJplX6nyupcOZa+m+s6jR6GCAqT RUrr53ZoQUc4+uOtwqEpPl/skkFGdWAawPIx0u/0Wb2NQiAFTZ941fi8lnrKo4Eh osKH0ahbGWICpg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=sRwN+icidNfQNdFlVha78XeCsek=; b=kcQ wgLoxlo/8VDMzJNw9y43aPQyudVCWjj5dHn87TggKMAaAgw5rGlhrSXfFGD7eTeC kne8AWKR6AqfER+JcQFKw8tjVIXt1wLQWhO1gzZVVdgWkbBCRjLzXEjW9CnxTgpP PPnM2Bgk9DLnPryA7Ehemkbx3L/AL+CX8ynFFD+A= Received: (qmail 19096 invoked by alias); 24 May 2015 15:07:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 19081 invoked by uid 89); 24 May 2015 15:07:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, SPF_NEUTRAL autolearn=no version=3.3.2 X-HELO: popelka.ms.mff.cuni.cz Date: Sun, 24 May 2015 17:07:15 +0200 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: libc-alpha@sourceware.org Subject: [PATCH 1/*] Move string inlines to string/string-inlines.c Message-ID: <20150524150715.GA31589@domone> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Hi, As described in header cleanup thread this is first step. It just copies inline function declarations to string-inlines.c An objdump -d produce same assembly. OK to commit? * string/string-inlines.c: Move inlines from bits/string2.h here. diff --git a/string/string-inlines.c b/string/string-inlines.c index 0445be7..3e01dc0 100644 --- a/string/string-inlines.c +++ b/string/string-inlines.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Inline string function optimizations for very old gcc versions. + Copyright (C) 1997-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,20 +16,350 @@ License along with the GNU C Library; if not, see . */ -/* and declare some extern inline - functions. These functions are declared additionally here if - inlining is not possible. */ - #undef __USE_STRING_INLINES #define __USE_STRING_INLINES #define _FORCE_INLINES #define __STRING_INLINE /* empty */ #define __NO_INLINE__ - #include -#undef index -#undef rindex -#undef __NO_INLINE__ -#include -#include +void * +__mempcpy_small (void *__dest1, + char __src0_1, char __src2_1, char __src4_1, char __src6_1, + __uint16_t __src0_2, __uint16_t __src4_2, + __uint32_t __src0_4, __uint32_t __src4_4, + size_t __srclen) +{ + union { + __uint32_t __ui; + __uint16_t __usi; + unsigned char __uc; + unsigned char __c; + } *__u = __dest1; + switch ((unsigned int) __srclen) + { + case 1: + __u->__c = __src0_1; + __u = __extension__ ((void *) __u + 1); + break; + case 2: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 2); + break; + case 3: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 2); + __u->__c = __src2_1; + __u = __extension__ ((void *) __u + 1); + break; + case 4: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + break; + case 5: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__c = __src4_1; + __u = __extension__ ((void *) __u + 1); + break; + case 6: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 2); + break; + case 7: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 2); + __u->__c = __src6_1; + __u = __extension__ ((void *) __u + 1); + break; + case 8: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__ui = __src4_4; + __u = __extension__ ((void *) __u + 4); + break; + } + return (void *) __u; +} + +char * +__strcpy_small (char *__dest, + __uint16_t __src0_2, __uint16_t __src4_2, + __uint32_t __src0_4, __uint32_t __src4_4, + size_t __srclen) +{ + union { + __uint32_t __ui; + __uint16_t __usi; + unsigned char __uc; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__uc = '\0'; + break; + case 2: + __u->__usi = __src0_2; + break; + case 3: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 2); + __u->__uc = '\0'; + break; + case 4: + __u->__ui = __src0_4; + break; + case 5: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__uc = '\0'; + break; + case 6: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + break; + case 7: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 2); + __u->__uc = '\0'; + break; + case 8: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__ui = __src4_4; + break; + } + return __dest; +} + +char * +__stpcpy_small (char *__dest, + __uint16_t __src0_2, __uint16_t __src4_2, + __uint32_t __src0_4, __uint32_t __src4_4, + size_t __srclen) +{ + union { + unsigned int __ui; + unsigned short int __usi; + unsigned char __uc; + char __c; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__uc = '\0'; + break; + case 2: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 1); + break; + case 3: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 2); + __u->__uc = '\0'; + break; + case 4: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 3); + break; + case 5: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__uc = '\0'; + break; + case 6: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 1); + break; + case 7: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 2); + __u->__uc = '\0'; + break; + case 8: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__ui = __src4_4; + __u = __extension__ ((void *) __u + 3); + break; + } + return &__u->__c; +} + +size_t +__strcspn_c1 (const char *__s, int __reject) +{ + size_t __result = 0; + while (__s[__result] != '\0' && __s[__result] != __reject) + ++__result; + return __result; +} + +size_t +__strcspn_c2 (const char *__s, int __reject1, int __reject2) +{ + size_t __result = 0; + while (__s[__result] != '\0' && __s[__result] != __reject1 + && __s[__result] != __reject2) + ++__result; + return __result; +} + +size_t +__strcspn_c3 (const char *__s, int __reject1, int __reject2, + int __reject3) +{ + size_t __result = 0; + while (__s[__result] != '\0' && __s[__result] != __reject1 + && __s[__result] != __reject2 && __s[__result] != __reject3) + ++__result; + return __result; +} + + +size_t +__strspn_c1 (const char *__s, int __accept) +{ + size_t __result = 0; + /* Please note that __accept never can be '\0'. */ + while (__s[__result] == __accept) + ++__result; + return __result; +} + +size_t +__strspn_c2 (const char *__s, int __accept1, int __accept2) +{ + size_t __result = 0; + /* Please note that __accept1 and __accept2 never can be '\0'. */ + while (__s[__result] == __accept1 || __s[__result] == __accept2) + ++__result; + return __result; +} + +size_t +__strspn_c3 (const char *__s, int __accept1, int __accept2, int __accept3) +{ + size_t __result = 0; + /* Please note that __accept1 to __accept3 never can be '\0'. */ + while (__s[__result] == __accept1 || __s[__result] == __accept2 + || __s[__result] == __accept3) + ++__result; + return __result; +} + + + +char * +__strpbrk_c2 (const char *__s, int __accept1, int __accept2) +{ + /* Please note that __accept1 and __accept2 never can be '\0'. */ + while (*__s != '\0' && *__s != __accept1 && *__s != __accept2) + ++__s; + return *__s == '\0' ? NULL : (char *) (size_t) __s; +} + +char * +__strpbrk_c3 (const char *__s, int __accept1, int __accept2, int __accept3) +{ + /* Please note that __accept1 to __accept3 never can be '\0'. */ + while (*__s != '\0' && *__s != __accept1 && *__s != __accept2 + && *__s != __accept3) + ++__s; + return *__s == '\0' ? NULL : (char *) (size_t) __s; +} + +char * +__strtok_r_1c (char *__s, char __sep, char **__nextp) +{ + char *__result; + if (__s == NULL) + __s = *__nextp; + while (*__s == __sep) + ++__s; + __result = NULL; + if (*__s != '\0') + { + __result = __s++; + while (*__s != '\0') + if (*__s++ == __sep) + { + __s[-1] = '\0'; + break; + } + } + *__nextp = __s; + return __result; +} + +char * +__strsep_1c (char **__s, char __reject) +{ + char *__retval = *__s; + if (__retval != NULL && (*__s = strchr (__retval, __reject)) != NULL) + *(*__s)++ = '\0'; + return __retval; +} + +char * +__strsep_2c (char **__s, char __reject1, char __reject2) +{ + char *__retval = *__s; + if (__retval != NULL) + { + char *__cp = __retval; + while (1) + { + if (*__cp == '\0') + { + __cp = NULL; + break; + } + if (*__cp == __reject1 || *__cp == __reject2) + { + *__cp++ = '\0'; + break; + } + ++__cp; + } + *__s = __cp; + } + return __retval; +} + +char * +__strsep_3c (char **__s, char __reject1, char __reject2, char __reject3) +{ + char *__retval = *__s; + if (__retval != NULL) + { + char *__cp = __retval; + while (1) + { + if (*__cp == '\0') + { + __cp = NULL; + break; + } + if (*__cp == __reject1 || *__cp == __reject2 || *__cp == __reject3) + { + *__cp++ = '\0'; + break; + } + ++__cp; + } + *__s = __cp; + } + return __retval; +}