From patchwork Mon May 27 11:18:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 90955 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2ECB93875435 for ; Mon, 27 May 2024 11:22:09 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id 5B7603858C31 for ; Mon, 27 May 2024 11:19:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5B7603858C31 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5B7603858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716808762; cv=none; b=UHQJlrjGqr+dRNR51I+h740rKML9mcwq8Jr2TCG3cj2Mv7jKjdzIv9PCfTGy3JSsPjWAvK90s1yUjViZxgcJoXd9Lc87FZ8cRid3hVw0vmWufO+enhT6qM5EP0yWjsmjiH7WhmQ2UaXM7u9eqxh9IFjh8mIBgpR1y4+G3LuDEzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716808762; c=relaxed/simple; bh=S1t6qqpPLTjN6wom1DriYPntWh6jicbH6flsV77jsF8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dNz+Qiis9S0NDEbuEEy6CrhUxZZfPSuQ9XnlxT0QDwpe1wCvJsScVuOewjYmgts3eE/xOAaLVZ4Ld4ZMveQiiHJPVkBhubZ4YNfPfSH73PCbdvPyzUgAS9GdRGGa6XmZJexLVpjOX3Sa6svY/3ZgZBMAtI7ux+Sblp3n2RNgJjg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-52449b7aa2bso8475708e87.3 for ; Mon, 27 May 2024 04:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1716808758; x=1717413558; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LVEFekLBL2gbkV7F9/f8RGDMXRefy1uwUmkhCG1YCNU=; b=cGr+c0QvqE60QGm3Zvpl0UW6YM5D7FF0GcWX1byKZD+h0GalEEP7uz4sH509Qm1opw Iypo+nmzY8yX4+eexZLRVNKifVB0kO9dEv6gCZIP0m02GkgyM+vaGuZdefgZqFWmVB2H 7AdZa858vfdljOfERLXUDKYlCafAoVyGVg8gW/+QxZb7xle1ChZ86pye4dBe56RBiJZi ma42clxfcayR24MvPd2Yb4rTeqhJ9rsvh0JxGjv8dN6KhyoDVrfqjdCv31dbLsng2cmL 7oUaxIL5N+66ENmg0SA+oeTxSVZvu1xm1Cs23gTKLRNUashMRez5GoJI321ngJGTjv9T Bi5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716808758; x=1717413558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LVEFekLBL2gbkV7F9/f8RGDMXRefy1uwUmkhCG1YCNU=; b=V+Xl+q+WUxYtvPKNY5nAflREW1IzvaHlsu5q+PyO4g6wXe4fKS7WoaUWFZWj0Wwzba q385ajF+PWNuf3BhdjsGZghFKR0oAvsMCJ4dyY/dfQJ2uVpi3vMDtpHlxwjRxsT3f6pF jgB6DO0BGpoFrXQTiVy0a7V8cuMxyvEqQuBlIXhwWYCJ9TmY2RThWhFHbu2whFZPXRh1 13CmcGvXqvdwewwC3rT2Qb26ws1h+KSZjYGQA2vfgme/mu4B4f7UEFje+ZHGN68XYBKr TrgMtNwC+q6fg/UKdL1f4IsXDdI97R8yCMK42A0rkxb58dfdsfybbviech5OQB/2V2Dx pTlg== X-Gm-Message-State: AOJu0YzHe7e1amrqXg9Zs8zgWL6QDFqCmzrTZskKsXKdurRaOsRluhnY mKsev7S+D3ROQNN4dmI63aQtN/JHBlDFn/mqoTkSvAeVhYA59pAXx20OuLYbjvBw1lmvebAgIhj eL39BZA== X-Google-Smtp-Source: AGHT+IFaw8/EaBAnvwa1SJY6LN9rPjR4xwnpdAzbgaojsB9Y+yb+DE/Na4w9/vkEcyF+bIcUuNXPVw== X-Received: by 2002:a05:6512:3d1d:b0:529:a0fd:a257 with SMTP id 2adb3069b0e04-529a0fdb25emr7304755e87.54.1716808758476; Mon, 27 May 2024 04:19:18 -0700 (PDT) Received: from beast.fritz.box (static.239.130.217.95.clients.your-server.de. [95.217.130.239]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5296e887b1asm519861e87.32.2024.05.27.04.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 04:19:17 -0700 (PDT) From: =?utf-8?q?Christoph_M=C3=BCllner?= To: libc-alpha@sourceware.org, Adhemerval Zanella , Palmer Dabbelt , Darius Rad , Andrew Waterman , Philipp Tomsich , Evan Green , DJ Delorie , Vineet Gupta , Kito Cheng , Jeff Law Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [PATCH v2 05/15] string/strcmp: Add mechanism to set function attributes Date: Mon, 27 May 2024 13:18:50 +0200 Message-ID: <20240527111900.1060546-6-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240527111900.1060546-1-christoph.muellner@vrull.eu> References: <20240527111900.1060546-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_MANYTO, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org This patch introduces the __CODEGEN_ATTRIBUTES macro which can be used to set function attributes when building the code. Signed-off-by: Christoph Müllner --- string/strcmp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/string/strcmp.c b/string/strcmp.c index 2bca399f52..59d7d98e5e 100644 --- a/string/strcmp.c +++ b/string/strcmp.c @@ -26,6 +26,11 @@ # define strcmp STRCMP #endif +#ifndef __CODEGEN_ATTRIBUTES +# define __CODEGEN_ATTRIBUTES +#endif + +__CODEGEN_ATTRIBUTES static inline int final_cmp (const op_t w1, const op_t w2) { @@ -35,6 +40,7 @@ final_cmp (const op_t w1, const op_t w2) /* Aligned loop: if a difference is found, exit to compare the bytes. Else if a zero is found we have equal strings. */ +__CODEGEN_ATTRIBUTES static inline int strcmp_aligned_loop (const op_t *x1, const op_t *x2, op_t w1) { @@ -55,6 +61,7 @@ strcmp_aligned_loop (const op_t *x1, const op_t *x2, op_t w1) the bytes so that we can also apply the has_zero test to see if we have already reached EOS. If we have, then we can simply fall through to the final comparison. */ +__CODEGEN_ATTRIBUTES static inline int strcmp_unaligned_loop (const op_t *x1, const op_t *x2, op_t w1, uintptr_t ofs) { @@ -98,6 +105,7 @@ strcmp_unaligned_loop (const op_t *x1, const op_t *x2, op_t w1, uintptr_t ofs) /* Compare S1 and S2, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. */ +__CODEGEN_ATTRIBUTES int strcmp (const char *p1, const char *p2) {