{"id":814552,"url":"http://patchwork.ozlabs.org/api/1.2/patches/814552/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170916212331.170463-4-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170916212331.170463-4-sjg@chromium.org>","list_archive_url":null,"date":"2017-09-16T21:23:16","name":"[U-Boot,03/13] Move debug and logging support to a separate header","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e2079f3f536e1034dfc3b08be5c113f75e1e7f82","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/1.2/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":{"id":3184,"url":"http://patchwork.ozlabs.org/api/1.2/users/3184/?format=json","username":"sjg","first_name":"Simon","last_name":"Glass","email":"sjg@chromium.org"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170916212331.170463-4-sjg@chromium.org/mbox/","series":[{"id":3473,"url":"http://patchwork.ozlabs.org/api/1.2/series/3473/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3473","date":"2017-09-16T21:23:14","name":"log: Add a new logging feature","version":1,"mbox":"http://patchwork.ozlabs.org/series/3473/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814552/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814552/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"GmW0II5X\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xvlfv518Xz9sPr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 17 Sep 2017 07:25:27 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 3E026C21D19; Sat, 16 Sep 2017 21:24:30 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 317F5C21D7E;\n\tSat, 16 Sep 2017 21:24:08 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 509FBC21E05; Sat, 16 Sep 2017 21:23:59 +0000 (UTC)","from mail-oi0-f46.google.com (mail-oi0-f46.google.com\n\t[209.85.218.46])\n\tby lists.denx.de (Postfix) with ESMTPS id 13FD5C21D6A\n\tfor <u-boot@lists.denx.de>; Sat, 16 Sep 2017 21:23:56 +0000 (UTC)","by mail-oi0-f46.google.com with SMTP id g128so2369129oic.12\n\tfor <u-boot@lists.denx.de>; Sat, 16 Sep 2017 14:23:56 -0700 (PDT)","from kiwi.bld.corp.google.com ([100.101.164.89])\n\tby smtp.gmail.com with ESMTPSA id\n\te8sm5842306oic.7.2017.09.16.14.23.53\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSat, 16 Sep 2017 14:23:53 -0700 (PDT)","by kiwi.bld.corp.google.com (Postfix, from userid 121222)\n\tid 2C394140A54; Sat, 16 Sep 2017 15:23:53 -0600 (MDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=KgiAPCJOfGf076IBTGKrMjP3Nd552UQN9DYlmsKa22w=;\n\tb=GmW0II5XURb33Wjf5LHYOOoW82z1MVfplQLVpIx4JJ8eTyQ3LTgR1wao0ftFy+3Q2p\n\tLOWiFXSdvHNaT/2C56Ex7mKiGhazc5K+nL+hEn3rJhVIIhIXZDe/mtPRHlNNJhKEn6vk\n\tbMst1AZBJZ3/niN39Id+QfYp2//8mGBhfPO5+KHFiH4DlFuz90WmflqP18YcsUy4NTob\n\thqBpYpTyKTMDTBG+B0WTp7rahxpX4EVE+upHgZsHqT4bjaBGTE8Ve4bBtMSVVcogS+j/\n\t2fMvDrTy35veY+q7irheIgj/SoJLjWpLNdqUy3/3qVAsYYXNeWdJSVlUM4XmBlQzq3rn\n\t0XHg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references;\n\tbh=KgiAPCJOfGf076IBTGKrMjP3Nd552UQN9DYlmsKa22w=;\n\tb=GP0YVn+cI7fCT6clleokgiyKrvEVHB4tnID7lQ2j7pc/S6kY5x/l9s2FitbpAuw95q\n\tBDspjHHGk8O4GixZ0fHbuGHWI35Z4hrRzEyiYPGJYGrwKmM+5ivxcESFQL+0DpnbXMsu\n\tUUiNg2lvY+ui8nHIsHgUhKyYytj2yq2mPWea4+h+dilxOUGd5TMYifuuLP12Hb3j01Lu\n\tUvT5zYC6fS9Pl7u7gNRwKwN+KXL8kI+DKLOy7pj6H6KZVEHCtrV9b0UxZ04KVgersDPx\n\t7NEyDZqwvBVM3sv3CIERIdE2dMtzlRNmCo6EXeIKaX2Vf+e8hxbI8Ao5WMygUr8qp0jW\n\tyYVg==","X-Gm-Message-State":"AHPjjUhlRsMPaveXC+UPXqegymJQP4OZbmxM07R2r83/cB1gzs/wjgSP\n\tmyILAoVnlJtPIz8p","X-Google-Smtp-Source":"AOwi7QDmAwNenmcZwTlcjtJkHQn0xkk1Y4iqpxLZtRf7Yoc6Irj2VHOe9OqNTxs8qYE43rx35a0ysA==","X-Received":"by 10.202.208.135 with SMTP id j7mr5978003oiy.146.1505597034608; \n\tSat, 16 Sep 2017 14:23:54 -0700 (PDT)","From":"Simon Glass <sjg@chromium.org>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Sat, 16 Sep 2017 15:23:16 -0600","Message-Id":"<20170916212331.170463-4-sjg@chromium.org>","X-Mailer":"git-send-email 2.14.1.690.gbb1197296e-goog","In-Reply-To":"<20170916212331.170463-1-sjg@chromium.org>","References":"<20170916212331.170463-1-sjg@chromium.org>","Cc":"Tom Rini <trini@konsulko.com>, Andre Przywara <andre.przywara@arm.com>, \n\tStefan Roese <sr@denx.de>","Subject":"[U-Boot] [PATCH 03/13] Move debug and logging support to a separate\n\theader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Before adding new features, move these definitions to a separate header\nto avoid further cluttering common.h.\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n include/common.h | 64 +--------------------------------------------\n include/log.h    | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 80 insertions(+), 63 deletions(-)\n create mode 100644 include/log.h","diff":"diff --git a/include/common.h b/include/common.h\nindex aaed131671..459d273389 100644\n--- a/include/common.h\n+++ b/include/common.h\n@@ -42,69 +42,7 @@ typedef volatile unsigned char\tvu_char;\n #define CONFIG_SYS_SUPPORT_64BIT_DATA\n #endif\n \n-#ifdef DEBUG\n-#define _DEBUG\t1\n-#else\n-#define _DEBUG\t0\n-#endif\n-\n-#ifdef CONFIG_SPL_BUILD\n-#define _SPL_BUILD\t1\n-#else\n-#define _SPL_BUILD\t0\n-#endif\n-\n-/* Define this at the top of a file to add a prefix to debug messages */\n-#ifndef pr_fmt\n-#define pr_fmt(fmt) fmt\n-#endif\n-\n-/*\n- * Output a debug text when condition \"cond\" is met. The \"cond\" should be\n- * computed by a preprocessor in the best case, allowing for the best\n- * optimization.\n- */\n-#define debug_cond(cond, fmt, args...)\t\t\t\\\n-\tdo {\t\t\t\t\t\t\\\n-\t\tif (cond)\t\t\t\t\\\n-\t\t\tprintf(pr_fmt(fmt), ##args);\t\\\n-\t} while (0)\n-\n-/* Show a message if DEBUG is defined in a file */\n-#define debug(fmt, args...)\t\t\t\\\n-\tdebug_cond(_DEBUG, fmt, ##args)\n-\n-/* Show a message if not in SPL */\n-#define warn_non_spl(fmt, args...)\t\t\t\\\n-\tdebug_cond(!_SPL_BUILD, fmt, ##args)\n-\n-/*\n- * An assertion is run-time check done in debug mode only. If DEBUG is not\n- * defined then it is skipped. If DEBUG is defined and the assertion fails,\n- * then it calls panic*( which may or may not reset/halt U-Boot (see\n- * CONFIG_PANIC_HANG), It is hoped that all failing assertions are found\n- * before release, and after release it is hoped that they don't matter. But\n- * in any case these failing assertions cannot be fixed with a reset (which\n- * may just do the same assertion again).\n- */\n-void __assert_fail(const char *assertion, const char *file, unsigned line,\n-\t\t   const char *function);\n-#define assert(x) \\\n-\t({ if (!(x) && _DEBUG) \\\n-\t\t__assert_fail(#x, __FILE__, __LINE__, __func__); })\n-\n-#define error(fmt, args...) do {\t\t\t\t\t\\\n-\t\tprintf(\"ERROR: \" pr_fmt(fmt) \"\\nat %s:%d/%s()\\n\",\t\\\n-\t\t\t##args, __FILE__, __LINE__, __func__);\t\t\\\n-} while (0)\n-\n-#ifndef BUG\n-#define BUG() do { \\\n-\tprintf(\"BUG: failure at %s:%d/%s()!\\n\", __FILE__, __LINE__, __FUNCTION__); \\\n-\tpanic(\"BUG!\"); \\\n-} while (0)\n-#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)\n-#endif /* BUG */\n+#include <log.h>\n \n typedef void (interrupt_handler_t)(void *);\n \ndiff --git a/include/log.h b/include/log.h\nnew file mode 100644\nindex 0000000000..4101a74161\n--- /dev/null\n+++ b/include/log.h\n@@ -0,0 +1,79 @@\n+/*\n+ * Logging support\n+ *\n+ * Copyright (c) 2017 Google, Inc\n+ * Written by Simon Glass <sjg@chromium.org>\n+ *\n+ * SPDX-License-Identifier:\tGPL-2.0+\n+ */\n+\n+#ifndef __LOG_H\n+#define __LOG_H\n+\n+#ifdef DEBUG\n+#define _DEBUG\t1\n+#else\n+#define _DEBUG\t0\n+#endif\n+\n+#ifdef CONFIG_SPL_BUILD\n+#define _SPL_BUILD\t1\n+#else\n+#define _SPL_BUILD\t0\n+#endif\n+\n+/* Define this at the top of a file to add a prefix to debug messages */\n+#ifndef pr_fmt\n+#define pr_fmt(fmt) fmt\n+#endif\n+\n+/*\n+ * Output a debug text when condition \"cond\" is met. The \"cond\" should be\n+ * computed by a preprocessor in the best case, allowing for the best\n+ * optimization.\n+ */\n+#define debug_cond(cond, fmt, args...)\t\t\t\\\n+\tdo {\t\t\t\t\t\t\\\n+\t\tif (cond)\t\t\t\t\\\n+\t\t\tprintf(pr_fmt(fmt), ##args);\t\\\n+\t} while (0)\n+\n+/* Show a message if DEBUG is defined in a file */\n+#define debug(fmt, args...)\t\t\t\\\n+\tdebug_cond(_DEBUG, fmt, ##args)\n+\n+/* Show a message if not in SPL */\n+#define warn_non_spl(fmt, args...)\t\t\t\\\n+\tdebug_cond(!_SPL_BUILD, fmt, ##args)\n+\n+/*\n+ * An assertion is run-time check done in debug mode only. If DEBUG is not\n+ * defined then it is skipped. If DEBUG is defined and the assertion fails,\n+ * then it calls panic*( which may or may not reset/halt U-Boot (see\n+ * CONFIG_PANIC_HANG), It is hoped that all failing assertions are found\n+ * before release, and after release it is hoped that they don't matter. But\n+ * in any case these failing assertions cannot be fixed with a reset (which\n+ * may just do the same assertion again).\n+ */\n+void __assert_fail(const char *assertion, const char *file, unsigned int line,\n+\t\t   const char *function);\n+#define assert(x) \\\n+\t({ if (!(x) && _DEBUG) \\\n+\t\t__assert_fail(#x, __FILE__, __LINE__, __func__); })\n+\n+#define error(fmt, args...) do {                                        \\\n+\t\tprintf(\"ERROR: \" pr_fmt(fmt) \"\\nat %s:%d/%s()\\n\",       \\\n+\t\t\t##args, __FILE__, __LINE__, __func__);          \\\n+} while (0)\n+\n+#ifndef BUG\n+#define BUG() do { \\\n+\tprintf(\"BUG: failure at %s:%d/%s()!\\n\", __FILE__, __LINE__, \\\n+\t       __func__); \\\n+\tpanic(\"BUG!\"); \\\n+} while (0)\n+#define BUG_ON(condition) do { if (unlikely((condition) != 0)) BUG(); } \\\n+\t\twhile (0)\n+#endif /* BUG */\n+\n+#endif\n","prefixes":["U-Boot","03/13"]}