From patchwork Mon Mar 30 15:53:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 6122511 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4CBFB9F2EC for ; Mon, 30 Mar 2015 15:53:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6193E2035B for ; Mon, 30 Mar 2015 15:53:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 268CD20374 for ; Mon, 30 Mar 2015 15:53:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 228F26E5E2; Mon, 30 Mar 2015 08:53:46 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A33A6E5E2 for ; Mon, 30 Mar 2015 08:53:44 -0700 (PDT) Received: by wgbdm7 with SMTP id dm7so73870866wgb.1 for ; Mon, 30 Mar 2015 08:53:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=/mkSU9ZbIJMLciqZpAKNHBrfooZOzg1nmD1ZyINpyG4=; b=Shmcn+hJ11MWzLzeNa81dff40LNWwdrnDQXwuy8kNnq4ULjnBUXVybX2GITu8+Obpe q8R4KWRdOhEO5HcMARfYBeE7Z67lO5VKLwWt6wGrRkUcVT9EY06E+pgutzVqY9cmoZOy wGYhkpO5jS1msTF/m9c8l6fIwbO7Swg8GTJVH15nU747e9f/aqyddzDiDAemCuPgds3w GRy5VsjbcacBbyGjAPUxAkK0eTeEnih0hqryzHPsVmM19K304nF/WItvyNfsl5YU+p2n k4/cPrMyI2IXBf+Bki1HE1Xw+lEX6wtEVH36FgGO8U02ifuVvsPJ9q2tchkorvcN2QeC hRAg== X-Gm-Message-State: ALoCoQnKpxzxoS9UP38rL1+4oGbmZl87FmCGlBcyXcnQVdeB2piwqGQpgy9bQpe//kX7pMI86ZhA X-Received: by 10.194.62.52 with SMTP id v20mr65474029wjr.137.1427730823347; Mon, 30 Mar 2015 08:53:43 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id gd6sm16881722wib.17.2015.03.30.08.53.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2015 08:53:42 -0700 (PDT) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Mon, 30 Mar 2015 16:53:37 +0100 Message-Id: <1427730818-29044-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/2] lib: add some defines to help spatch parsing X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add simple definitions for various macros to help spatch parse the special igt control flow blocks and other macros correctly. Signed-off-by: Thomas Wood --- lib/igt-spatch.h | 41 +++++++++++++++++++++++++++++++++++++++++ lib/igt.cocci | 6 +++--- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 lib/igt-spatch.h diff --git a/lib/igt-spatch.h b/lib/igt-spatch.h new file mode 100644 index 0000000..f9d53ea --- /dev/null +++ b/lib/igt-spatch.h @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +/* various macros to help spatch parsing */ + +#error This header should only be used with spatch + +/* define igt control flow blocks as ordinary code blocks */ +#define igt_fixture +#define igt_subtest(name) +#define igt_subtest_f(f...) +#define igt_fork(child, num_children) +#define igt_fork_helper(proc) + +#define igt_main int main(int argc, char *argv) +#define igt_simple_main int main(int argc, char *argv) + +/* the third parameter of timercmp is an operator, so needs to be defined as a + * macro to be parsed correctly */ +#define timercmp(a, b, CMP) (1) diff --git a/lib/igt.cocci b/lib/igt.cocci index 156f0cf..e7bef8d 100644 --- a/lib/igt.cocci +++ b/lib/igt.cocci @@ -1,7 +1,7 @@ -// Semantic patch for common patters and their replacement by igt infrastructure -// and macros. Please run with +// Semantic patch for common patterns and their replacement by igt +// infrastructure and macros. Please run with // -// spatch --sp-file lib/igt.cocci --in-place tests/*.c +// spatch --sp-file lib/igt.cocci --macro-file lib/igt-spatch.h --in-place tests/*.c // // on your new testcase.