From patchwork Tue Feb 13 18:34:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136663 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A9E9843B0D; Tue, 13 Feb 2024 19:36:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12F5842EC1; Tue, 13 Feb 2024 19:35:09 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 837D742E10 for ; Tue, 13 Feb 2024 19:34:55 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4ACA220B2009; Tue, 13 Feb 2024 10:34:53 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4ACA220B2009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707849294; bh=jyenPvEHcrqt6izxlPmNOVHkg7GzKVfzC7TyCETChUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FC98RWQpslWoKgs15JaBUDobbpeSDsxOpTGQr9ve6VuIdnjGuNIhCwb3rG+DSuE4f YfTDxkwIN+bjRx8xe1vIAl+8dFQ5B+58oSKzHcarg7vZtAn9vKH511X9uuLz+2KlZN IDyM85TG6fMC3aDGz4OdBAFBzuPqImaVLKg2F1BU= From: Tyler Retzlaff To: dev@dpdk.org Cc: Ajit Khaparde , Akhil Goyal , Andrew Rybchenko , Anoob Joseph , Bruce Richardson , Chaoyong He , Chenbo Xia , David Hunt , Ferruh Yigit , Harry van Haaren , Hemant Agrawal , Honnappa Nagarahalli , Jerin Jacob , Jingjing Wu , Jochen Behrens , John McNamara , Kiran Kumar K , Konstantin Ananyev , Maxime Coquelin , Nicolas Chautru , Nithin Dabilpuram , Ori Kam , Pavan Nikhilesh , Sachin Saxena , Somnath Kotur , Thomas Monjalon , Volodymyr Fialko , Zhirun Yan , david.marchand@redhat.com, Tyler Retzlaff Subject: [PATCH v2 10/21] test: use C11 alignof Date: Tue, 13 Feb 2024 10:34:41 -0800 Message-Id: <1707849292-19519-11-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707849292-19519-1-git-send-email-roretzla@linux.microsoft.com> References: <1706138276-28224-1-git-send-email-roretzla@linux.microsoft.com> <1707849292-19519-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace use of __alignof__(T) with C11 alignof(T) to improve portability between toolchains. Replace use of __alignof__(e) with C11 alignof(typeof(e)) to improve portability between toolchains Signed-off-by: Tyler Retzlaff --- app/test/test_distributor.c | 3 ++- app/test/test_graph.c | 3 ++- app/test/test_mbuf.c | 9 +++++---- app/test/test_ring_stress_impl.h | 6 ++++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 6cb27f4..d2037b7 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -5,6 +5,7 @@ #include "test.h" #include +#include #include #include #include @@ -831,7 +832,7 @@ int test_error_distributor_create_numworkers(void) static const struct rte_mbuf_dynfield seq_dynfield_desc = { .name = "test_distributor_dynfield_seq", .size = sizeof(seq_dynfield_t), - .align = __alignof__(seq_dynfield_t), + .align = alignof(seq_dynfield_t), }; seq_dynfield_offset = rte_mbuf_dynfield_register(&seq_dynfield_desc); diff --git a/app/test/test_graph.c b/app/test/test_graph.c index 3dd017e..b8409bc 100644 --- a/app/test/test_graph.c +++ b/app/test/test_graph.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -935,7 +936,7 @@ struct test_node_register { static const struct rte_mbuf_dynfield graph_dynfield_desc = { .name = "test_graph_dynfield", .size = sizeof(graph_dynfield_t), - .align = __alignof__(graph_dynfield_t), + .align = alignof(graph_dynfield_t), }; graph_dynfield_offset = rte_mbuf_dynfield_register(&graph_dynfield_desc); diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index d7393df..51ea6ef 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -5,6 +5,7 @@ #include "test.h" #include +#include #include #include #include @@ -2534,19 +2535,19 @@ struct test_case { const struct rte_mbuf_dynfield dynfield = { .name = "test-dynfield", .size = sizeof(uint8_t), - .align = __alignof__(uint8_t), + .align = alignof(uint8_t), .flags = 0, }; const struct rte_mbuf_dynfield dynfield2 = { .name = "test-dynfield2", .size = sizeof(uint16_t), - .align = __alignof__(uint16_t), + .align = alignof(uint16_t), .flags = 0, }; const struct rte_mbuf_dynfield dynfield3 = { .name = "test-dynfield3", .size = sizeof(uint8_t), - .align = __alignof__(uint8_t), + .align = alignof(uint8_t), .flags = 0, }; const struct rte_mbuf_dynfield dynfield_fail_big = { @@ -2564,7 +2565,7 @@ struct test_case { const struct rte_mbuf_dynfield dynfield_fail_flag = { .name = "test-dynfield", .size = sizeof(uint8_t), - .align = __alignof__(uint8_t), + .align = alignof(uint8_t), .flags = 1, }; const struct rte_mbuf_dynflag dynflag_fail_flag = { diff --git a/app/test/test_ring_stress_impl.h b/app/test/test_ring_stress_impl.h index 62f046a..2dec897 100644 --- a/app/test/test_ring_stress_impl.h +++ b/app/test/test_ring_stress_impl.h @@ -2,6 +2,8 @@ * Copyright(c) 2020 Intel Corporation */ +#include + #include "test_ring_stress.h" /** @@ -285,7 +287,7 @@ struct ring_elem { *data = NULL; sz = num * sizeof(*elm); - elm = rte_zmalloc(NULL, sz, __alignof__(*elm)); + elm = rte_zmalloc(NULL, sz, alignof(typeof(*elm))); if (elm == NULL) { printf("%s: alloc(%zu) for %u elems data failed", __func__, sz, num); @@ -297,7 +299,7 @@ struct ring_elem { /* alloc ring */ nr = 2 * num; sz = rte_ring_get_memsize(nr); - r = rte_zmalloc(NULL, sz, __alignof__(*r)); + r = rte_zmalloc(NULL, sz, alignof(typeof(*r))); if (r == NULL) { printf("%s: alloc(%zu) for FIFO with %u elems failed", __func__, sz, nr);