From patchwork Wed Jan 10 12:48:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 124093 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5236933qgn; Wed, 10 Jan 2018 04:51:28 -0800 (PST) X-Google-Smtp-Source: ACJfBovyXcLJGA4orT/ZgMY5ydNbW+frzjuaF0rikkNTdq6gUH0t2ZYZ6MlLU68cQ4UBWlztsc2O X-Received: by 10.98.150.204 with SMTP id s73mr12812000pfk.200.1515588688229; Wed, 10 Jan 2018 04:51:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515588688; cv=none; d=google.com; s=arc-20160816; b=IKRwsBSeDDTKqodRDjArDsGwJiGPXjb0dIOEGZBVT9k1jg3PsIMpJ0DeKY3TgCRkzb vIsdu/gmTK69r9JIbzJJ529vpyOFVT0d/3BRP7Qz8FfPNfz9te5y+9FKGhafdsGBOTFz 4yOCqTA+bfccZir+P7Uqu4stT3KH6ejnUYHE1MhYNyfr7KpZz5D2630Bm+huXunxfpBR 8fhnjd9iMSyKFs3EDrd+CnK/v89gviplqIkUctcFrusN3nxQwSZduNk3SR8Zphy150zk h1tK0HVS1me8o/Gup7SHJ0iQKHxt01gA9fXJCo8OebcOdP2/CrdcavGHCxL2tkN6EiEH w0Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=P9fXsoda5k4EO66liqE+SKWQBCGGlE75mhO5dD3ywGg=; b=CJsoHDl+XiRIjikYUXNfYvoUoNEF6ziE0vFV9ukCxP148Mcs8XoDlLiqOHkF6NSzXe YbtDRmdOmEGztz8kCBHah+lEnQ5sslhnRodmphvda6wmcczY2EjRVn/aXx0tNdE8LcuU I+fatgd0surIjyASOw2CbK9lpCfw+O7tUcIU1V9AjFqSXCUbbKLHnlsNAFipTyKBiWWC WRfb4YsOO+CP7KiozXtMH7qRagOy33lTlh7ix5QSietO4AD+RrrrRvsA+fnHHmptnFpK R8TGG4ZHQlHOXaEw2Zr6uHt9W/cs2m5rshFTLIX//t3qlzfpyvOQXObVMYF7AuwoUQzT Xzkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=vjEEscaE; spf=pass (google.com: domain of libc-alpha-return-89015-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89015-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b25si2535657pgn.721.2018.01.10.04.51.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 04:51:28 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-89015-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=vjEEscaE; spf=pass (google.com: domain of libc-alpha-return-89015-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89015-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=F4ZdxsTw9MLa7ZzK8CH6WOmUNp8XSvx FRs2DQcwm3ny6dqh11wOIhgqIbg3f5s/B674UYowREQlPjVSjbZ4j6y588O2sP3V oS493ox0kiVGqCGTEHiXd4lWkIPNybnC5L0NqquLEXMxsRihDDgY0r6bCSc21hcX 4cv8/T7ChUdA= 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:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=H/H3+VrUS+3blXADHRVguswTlvo=; b=vjEEs caEAZt6ws3jbMhDEA2Xb4053/TtDz0OUwSgdJdQtsleM+5n1dHUA/Kg9oHhX2rCB tnMxrFX/1HwgwOjcnwTsfgP9TQX12ygNvdZmLNyjyiIRjSlRVFL0oHmKo9s7PuwD 1n1j1YOXIMQR93f1umwxPZiu9lBw7tdQHYNRd4= Received: (qmail 657 invoked by alias); 10 Jan 2018 12:48:48 -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 128130 invoked by uid 89); 10 Jan 2018 12:48:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f196.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=P9fXsoda5k4EO66liqE+SKWQBCGGlE75mhO5dD3ywGg=; b=o6Y4URcAGjxM9N9cURR1g6snnMWz6YEl+gUF5ZhTNuPVosSVSzZGLMEGGXCIiOufWn Gg8v/aC912Ruzmn+jKvCUH6ktmjgm9yY2ulCC7zavZU2Mi3PJgsHsEpXPcOOyH/Qfrka byMIxcs2iAHN+mYUA/zZgAp5MrVG2xNA2W+JPkujpD58blPPPg7I0lsMDCfjsYt3lpcC udWkvC684lk3j8tR623fjBc5MB+RzAmSPvU2pyJ3pP0jLThBoEMshOOqrspiznZzADlu yuzKfj+e/hmdOX0luNDtr/Muy+tIQtoJDz4NzHC7ja05iP1EixLHeOgKeSwoBR92CEW4 ZkOA== X-Gm-Message-State: AKwxytdBWcDGBHVssBSokc7pp+bxN10uJ931XzRidHC4f/v3gOUk46Hz 0qgN8P/p+v9Ql0JqypZSAs9Hz3+jCIU= X-Received: by 10.55.119.132 with SMTP id s126mr25934079qkc.250.1515588516945; Wed, 10 Jan 2018 04:48:36 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 18/18] sh: Add string-fzb.h Date: Wed, 10 Jan 2018 10:48:02 -0200 Message-Id: <1515588482-15744-19-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1515588482-15744-1-git-send-email-adhemerval.zanella@linaro.org> References: <1515588482-15744-1-git-send-email-adhemerval.zanella@linaro.org> Use the SH cmp/str on has_{zero,eq,zero_eq}. Checked on sh4-linux-gnu. Adhemerval Zanella * sysdeps/sh/string-fzb.h: New file. --- sysdeps/sh/string-fzb.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 sysdeps/sh/string-fzb.h -- 2.7.4 diff --git a/sysdeps/sh/string-fzb.h b/sysdeps/sh/string-fzb.h new file mode 100644 index 0000000..70d8a8f --- /dev/null +++ b/sysdeps/sh/string-fzb.h @@ -0,0 +1,53 @@ +/* Zero byte detection; boolean. SH4 version. + Copyright (C) 2018 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef STRING_FZB_H +#define STRING_FZB_H 1 + +#include + +/* Determine if any byte within X is zero. This is a pure boolean test. */ + +static inline _Bool +has_zero (op_t x) +{ + op_t zero = 0x0, ret; + asm volatile ("cmp/str %1,%2\n" + "movt %0\n" + : "=r" (ret) + : "r" (zero), "r" (x)); + return ret; +} + +/* Likewise, but for byte equality between X1 and X2. */ + +static inline _Bool +has_eq (op_t x1, op_t x2) +{ + return has_zero (x1 ^ x2); +} + +/* Likewise, but for zeros in X1 and equal bytes between X1 and X2. */ + +static inline _Bool +has_zero_eq (op_t x1, op_t x2) +{ + return has_zero (x1) | has_eq (x1, x2); +} + +#endif /* STRING_FZB_H */