From patchwork Thu Nov 23 19:54:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 840888 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467814-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Y0XcV5+4"; dkim-atps=neutral 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 3yjVRC0wBcz9s9Y for ; Fri, 24 Nov 2017 06:55:02 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=g8SnaygQ8G7AEi8DvJvQHgR+lFy2hmgAeUW8nKnKme1U3nGmAO VBi3mr9ZMszGmHhKQKRBMjbbQrkfQVhPUzR7HTCd0vP0eIY3Ihb7i6My/KBwQbJU t07QgpEyuEirlg1e/arfagmKASw7mwgJqytk8PAbUidYZr1s9Ya+KAQQQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:cc:message-id:date:mime-version:content-type; s= default; bh=ge7FPXC42v0xDve6skDE0D5mPzo=; b=Y0XcV5+4IHN1YK7CsRB6 kPEHBB86sCWywxYYBHCzeCS876yhtQNTfxw/Eplesv6sPXUDtiR/I+qr/n8C0nAb SeDJXZj9u8ryVgFr189TrnjpYMuNlmjCnTjAo30ArQu77WKYbTK3mcUk0PmBCjeR qPPI41YNyAJMzEQFImD1sMA= Received: (qmail 40088 invoked by alias); 23 Nov 2017 19:54:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 39267 invoked by uid 89); 23 Nov 2017 19:54:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=classc, class.c, UD:class.c X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Nov 2017 19:54:51 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-03.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1eHxaE-0007ZB-2u from Tom_deVries@mentor.com ; Thu, 23 Nov 2017 11:54:50 -0800 Received: from [172.30.72.35] (137.202.0.87) by SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Thu, 23 Nov 2017 19:54:46 +0000 From: Tom de Vries To: GCC Patches Subject: [libobjc, committed] Wrap CLASS_TABLE_HASH in do {} while (0) CC: "pinskia@gmail.com" Message-ID: <4e5ce1f7-644c-ced8-6734-47d73743d3c0@mentor.com> Date: Thu, 23 Nov 2017 20:54:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) Hi, this patch wraps CLASS_TABLE_HASH in "do {} while (0)". This allows the macro to be used in if-then-elses without curly braces. Build libobcj for x86_64. Committed as obvious. Thanks, - Tom [libobjc] Wrap CLASS_TABLE_HASH in do {} while (0) 2017-11-23 Tom de Vries * class.c (CLASS_TABLE_HASH): Wrap in "do {} while (0)". --- libobjc/class.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libobjc/class.c b/libobjc/class.c index 53fb5fe..7a8f832 100644 --- a/libobjc/class.c +++ b/libobjc/class.c @@ -153,14 +153,16 @@ static objc_mutex_t __class_table_lock = NULL; string, and HASH the computed hash of the string; CLASS_NAME is untouched. */ -#define CLASS_TABLE_HASH(INDEX, HASH, CLASS_NAME) \ - HASH = 0; \ - for (INDEX = 0; CLASS_NAME[INDEX] != '\0'; INDEX++) \ - { \ - HASH = (HASH << 4) ^ (HASH >> 28) ^ CLASS_NAME[INDEX]; \ - } \ - \ - HASH = (HASH ^ (HASH >> 10) ^ (HASH >> 20)) & CLASS_TABLE_MASK; +#define CLASS_TABLE_HASH(INDEX, HASH, CLASS_NAME) \ + do { \ + HASH = 0; \ + for (INDEX = 0; CLASS_NAME[INDEX] != '\0'; INDEX++) \ + { \ + HASH = (HASH << 4) ^ (HASH >> 28) ^ CLASS_NAME[INDEX]; \ + } \ + \ + HASH = (HASH ^ (HASH >> 10) ^ (HASH >> 20)) & CLASS_TABLE_MASK; \ + } while (0) /* Setup the table. */ static void