Received: by 10.213.65.68 with SMTP id h4csp1742280imn; Sun, 1 Apr 2018 13:45:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx48XkKdvBRR5yYc6N/CM1Q2iQwz7ZedY56bUf3okMdl8sLTdKNnJkqqZAA9qQ2Z2oMOGPKOW X-Received: by 10.99.95.78 with SMTP id t75mr4671065pgb.330.1522615509128; Sun, 01 Apr 2018 13:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522615509; cv=none; d=google.com; s=arc-20160816; b=BL6JHci02udU/93uFskur74eqa+MQ0E2oel3aPnB/axINeAhF658UyNGzKoSGAvttr rW1N/LZLbLDc0OvZW5FF0QOh6WmTZDDGy6mEA2R/lp8ziHYeB5SS2B+U94DkV+3WvGZX AeT1n0qw8hOWIqZtXJWZCn9ZZUZ++lwUBRQn2Hb4OsIZYnMH6tXZQecYiigGrYvyqlYL kRehujIiD5sDAr6+JNcHMAhLnrdV71m1uGheGidtHiaSS602yzwvXfaum5Fabr3PJuvi u9XVGSGBZ9HL34toaNnPpoj4aPk/z5k5j/LihrowKYirJ2RBc9uZlROZvUTQOrgtvtOu GrDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject :organization:arc-authentication-results; bh=brKtnMcdWyEcCUQuuXHRhVFht9B2str39xRa7HDWh8c=; b=yxdgebfv6dWsSWrJ+K+oZuAgCwrWu8nqQilCxSV4Y4lraOWYvKUkysamGQ90Kcntwk HYxXbvbIYYcoxTAbbA5C/HAS8ixrFC9qFAcq3KELCppkAlX7dGh2Q//z4hBZth4nhI+a D2DRUOwTFxLBfdeudn6r0KndGcof3UwZGTQd+SKUC1XiDk8TF3hyX4oibGF/vaW7nDrf 5E5OstPtvn30jTk/LpGZ56j7Z23CFsJ3ZHPXK7cnu881CUb9YL6GoZcvbIgIn+Nw7030 aamMH0TFNiuKOxTsr1iV9yk/PumqXQy/Fa13xU4oR9yfMTilhKwi7Dyh5TPeqpBKYNTx Phmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t190si8743014pgt.745.2018.04.01.13.44.55; Sun, 01 Apr 2018 13:45:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754220AbeDAUnt (ORCPT + 99 others); Sun, 1 Apr 2018 16:43:49 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38264 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753901AbeDAUnr (ORCPT ); Sun, 1 Apr 2018 16:43:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 963584070214 for ; Sun, 1 Apr 2018 20:43:46 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-59.rdu2.redhat.com [10.10.120.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4675BD7DF5; Sun, 1 Apr 2018 20:43:46 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 35/45] C++: Fix static_branch_likely/unlikely() From: David Howells To: linux-kernel@vger.kernel.org Date: Sun, 01 Apr 2018 21:43:45 +0100 Message-ID: <152261542576.30503.8474929957674990486.stgit@warthog.procyon.org.uk> In-Reply-To: <152261521484.30503.16131389653845029164.stgit@warthog.procyon.org.uk> References: <152261521484.30503.16131389653845029164.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 01 Apr 2018 20:43:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 01 Apr 2018 20:43:46 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix static_branch_likely/unlikely() to use C++ function overloading to simplify the source. Signed-off-by: David Howells --- include/linux/jump_label.h | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 2168cc6b8b30..25683b1764bf 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -387,29 +387,26 @@ extern bool ____wrong_branch_error(void); * See jump_label_type() / jump_label_init_type(). */ -#define static_branch_likely(x) \ -({ \ - bool branch; \ - if (__builtin_types_compatible_p(typeof(*x), struct static_key_true)) \ - branch = !arch_static_branch(&(x)->key, true); \ - else if (__builtin_types_compatible_p(typeof(*x), struct static_key_false)) \ - branch = !arch_static_branch_jump(&(x)->key, true); \ - else \ - branch = ____wrong_branch_error(); \ - likely(branch); \ -}) -#define static_branch_unlikely(x) \ -({ \ - bool branch; \ - if (__builtin_types_compatible_p(typeof(*x), struct static_key_true)) \ - branch = arch_static_branch_jump(&(x)->key, false); \ - else if (__builtin_types_compatible_p(typeof(*x), struct static_key_false)) \ - branch = arch_static_branch(&(x)->key, false); \ - else \ - branch = ____wrong_branch_error(); \ - unlikely(branch); \ -}) +static inline bool static_branch_likely(struct static_key_true *x) +{ + return likely(!arch_static_branch(&(x)->key, true)); +} + +static inline bool static_branch_likely(struct static_key_false *x) +{ + return likely(!arch_static_branch_jump(&(x)->key, true)); +} + +static inline bool static_branch_unlikely(struct static_key_true *x) +{ + return unlikely(!arch_static_branch_jump(&(x)->key, true)); +} + +static inline bool static_branch_unlikely(struct static_key_false *x) +{ + return unlikely(!arch_static_branch(&(x)->key, true)); +} #else /* !HAVE_JUMP_LABEL */