Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/66219/?format=api
http://patches.dpdk.org/api/patches/66219/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200303175938.14292-2-stephen@networkplumber.org/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20200303175938.14292-2-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20200303175938.14292-2-stephen@networkplumber.org", "date": "2020-03-03T17:59:33", "name": "[1/6] eal: add portable way to check for math overflow", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "d09b6857574424c9635f96c923ff6d62aada8fa6", "submitter": { "id": 27, "url": "http://patches.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": { "id": 1766, "url": "http://patches.dpdk.org/api/users/1766/?format=api", "username": "ajitkhaparde", "first_name": "Ajit", "last_name": "Khaparde", "email": "ajit.khaparde@broadcom.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200303175938.14292-2-stephen@networkplumber.org/mbox/", "series": [ { "id": 8766, "url": "http://patches.dpdk.org/api/series/8766/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8766", "date": "2020-03-03T17:59:32", "name": "net/bnxt: bounds checking patches", "version": 1, "mbox": "http://patches.dpdk.org/series/8766/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/66219/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/66219/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 7DD9BA0571;\n\tTue, 3 Mar 2020 18:59:52 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 03F811C00E;\n\tTue, 3 Mar 2020 18:59:45 +0100 (CET)", "from mail-pf1-f194.google.com (mail-pf1-f194.google.com\n [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id AC71E1BFF4\n for <dev@dpdk.org>; Tue, 3 Mar 2020 18:59:43 +0100 (CET)", "by mail-pf1-f194.google.com with SMTP id 2so1830000pfg.12\n for <dev@dpdk.org>; Tue, 03 Mar 2020 09:59:43 -0800 (PST)", "from hermes.corp.microsoft.com (204-195-22-127.wavecable.com.\n [204.195.22.127])\n by smtp.gmail.com with ESMTPSA id w195sm22012158pfd.65.2020.03.03.09.59.41\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 03 Mar 2020 09:59:41 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20150623.gappssmtp.com; s=20150623;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=hTbR+MUCuQl/XjF9vP0peDzMe488+txf/Crskfsat+w=;\n b=rWnj2Qi2n/bFjMoFmr2MqPqa27wEu93lFDnvoNJAnXy3IvogRYrRtOKI5Kjyaa/lNb\n JwmgaCXyyZTJGNr9JCmx25BjnM4bKvram200hHEP/+7Fhw4m9d9wSb6NmG4MtDSEDwga\n E4ZjwUoTzMv+2tdJL84YDBsqbiQbleY3iYFe/M7LjHHpfk/V6OifFw2jXKSG1n1k3PrV\n tjcerweIQARxAxejxLzyA9SPebZlLT6+e+HVqxeh32LxqgQDmRMwXTRdGTWLWGmR7R8B\n oVlrkaXoMXTN7LY2AV680lSoEb3tifnznyicwkrdZPsWBSSuv3SNa963qe7z+LOnr4uy\n 076A==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20161025;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=hTbR+MUCuQl/XjF9vP0peDzMe488+txf/Crskfsat+w=;\n b=ncXg7cDw2VQ4sbZYFHc7rLxMY18lCsnUfykKJMpoZ/BajfI/SnWkEXXhEsLfddaH/r\n TmUQt/XINin0WMyTkiSaCHaQxNeFWBJ0fYJAKuQyZPSluj5Uw1ittVe2rcc595d1cGXb\n Vf1dFDkpmh9eyT2xoaU1QSvPh0yLn1c3ByqN/WVrwW4XDR4zWEsiyIC4SWxXkWJYB9pU\n xaN6xagMvybtCkYd+VyUwm137RTkPHSJZHohS2RGCePRVXS1XCqVv1YWNH5DpVFgROp8\n 0DQmBQJ8mUEejp5BMcginWM+2CNTWs+ze/ebrgI7incK9cxnq/j5Raiso5BYaS6ZgSr3\n BVnA==", "X-Gm-Message-State": "ANhLgQ3Ss6BCjPw7hmHEyXg0n8d0l657AGSDTmAhKAPlUXQ/AQd6zwH+\n BlNj/KGqjNW1WhFZlghLS/Y+kQ==", "X-Google-Smtp-Source": "\n ADFU+vtJR/SwUVeYxn1xovxIzjRjxgxDqsd8bmfIqYhxJQchQPJNkPZKxsxPWS6KOYqUEhTsxx1tEQ==", "X-Received": "by 2002:a62:1a03:: with SMTP id a3mr3985027pfa.214.1583258382707;\n Tue, 03 Mar 2020 09:59:42 -0800 (PST)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "ajit.khaparde@broadcom.com,\n\tsomnath.kotur@broadcom.com", "Cc": "dev@dpdk.org,\n\tStephen Hemminger <stephen@networkplumber.org>", "Date": "Tue, 3 Mar 2020 09:59:33 -0800", "Message-Id": "<20200303175938.14292-2-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20200303175938.14292-1-stephen@networkplumber.org>", "References": "<20200303175938.14292-1-stephen@networkplumber.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH 1/6] eal: add portable way to check for math\n\toverflow", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Clang and recent versions of GCC has builtin functions to do most math\noperations and check for wraparound. On most architectures this is a\njust a math operation followed by a branch on carry set.\n\nBut DPDK needs to be able to handle older GCC versions, and other\ncompilers so a wrapper macro is needed.\n\nChose to use a macro instead of inline functions to avoid having\nto write lots of variants for each numeric type.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/librte_eal/common/Makefile | 2 +-\n lib/librte_eal/common/include/rte_overflow.h | 74 ++++++++++++++++++++\n 2 files changed, 75 insertions(+), 1 deletion(-)\n create mode 100644 lib/librte_eal/common/include/rte_overflow.h", "diff": "diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile\nindex c2c6d92cd377..3794128b75b7 100644\n--- a/lib/librte_eal/common/Makefile\n+++ b/lib/librte_eal/common/Makefile\n@@ -13,7 +13,7 @@ INC += rte_tailq.h rte_interrupts.h rte_alarm.h\n INC += rte_string_fns.h rte_version.h\n INC += rte_eal_memconfig.h\n INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h rte_class.h\n-INC += rte_option.h\n+INC += rte_option.h rte_overflow.h\n INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h\n INC += rte_malloc.h rte_keepalive.h rte_time.h\n INC += rte_service.h rte_service_component.h\ndiff --git a/lib/librte_eal/common/include/rte_overflow.h b/lib/librte_eal/common/include/rte_overflow.h\nnew file mode 100644\nindex 000000000000..d61791371029\n--- /dev/null\n+++ b/lib/librte_eal/common/include/rte_overflow.h\n@@ -0,0 +1,74 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Microsoft Corp\n+ */\n+#ifndef RTE_OVERFLOW_H_\n+#define RTE_OVERFLOW_H_\n+/**\n+ * @file\n+ *\n+ * Math functions with overflow checking.\n+ * Wrappers for the __builtin_XXX_overflow functions that exist\n+ * in recent versions of GCC and CLANG but may not exist\n+ * in older compilers. They are macros to allow use with any\n+ * size of unsigned number.\n+ *\n+ * See:\n+ * https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html\n+ * https://github.com/nemequ/portable-snippets/tree/master/safe-math\n+ */\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+#include <stdbool.h>\n+\n+#if defined(__has_builtin)\n+# if __has_builtin(__builtin_add_overflow)\n+# define RTE_HAVE_BUILTIN_OVERFLOW\n+# endif\n+#elif defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 5000)\n+# define RTE__HAVE_BUILTIN_OVERFLOW\n+#endif\n+\n+/**\n+ * Safely add two bit unsigned numbers\n+ * @param a\n+ * One operand\n+ * @param b\n+ * Other operand\n+ * @param res\n+ * Pointer to the where result of a + b is stored.\n+ * Must not be NULL\n+ * @return\n+ * return true if the result overflows and is therefore truncated.\n+ */\n+#ifdef RTE_HAVE_BUILTIN_OVERFLOW\n+#define rte_add_overflow(a, b, res) __builtin_add_overflow(a, b, res)\n+#else\n+#define rte_add_overflow(a, b, res) ({ *res = a + b; *res < a; })\n+#endif\n+\n+/**\n+ * Safely multiply two unsigned numbers\n+ * @param a\n+ * One operand\n+ * @param b\n+ * Other operand\n+ * @param res\n+ * Pointer to the where result of a + b is stored.\n+ * Must not be NULL\n+ * @return\n+ * return true if the result overflows and is therefore truncated.\n+ */\n+#ifdef RTE_HAVE_BUILTIN_OVERFLOW\n+#define rte_mul_overflow(a, b, res) __builtin_mul_overflow(a, b, res)\n+#else\n+#define rte_mul_overflow(a, b, res) ({ *res = a * b; *res < a; })\n+#endif\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* RTE_OVERFLOW_H_ */\n", "prefixes": [ "1/6" ] }{ "id": 66219, "url": "