From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 654384613A; Mon, 27 Jan 2025 19:08:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 790D240A73; Mon, 27 Jan 2025 19:08:57 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id F370F4027D for ; Mon, 27 Jan 2025 19:08:53 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-216401de828so86476895ad.3 for ; Mon, 27 Jan 2025 10:08:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1738001333; x=1738606133; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2QDxHAN3wJDwxKtbOiC7+yslaqQ6Rh8Flvbnwtfkiyo=; b=ZJXs+r4/xS7mUW27t04/hnfzEY9EtLTOVRElN72Y9k3QQFNkrzsGD6lTlmGneozkOU 065mghu4BxQkyaYlTQcVRDGzZY80LxOKv6WySKE5EQUCe1J59SjMUjUd6oM2OgB9Gibc yw1f6ZrKiNeifXE6nf+WdaTXI8ntcjPRptTjkgQPTpCkfOkqN7dxhirZ/cubIevJNlVE H01wedmyK/ap4l0fIC47M8c/XPYRIpUFbxitUUwxFPomHSjvMgur0MA2T1Bwu1rsPSOi N/OGjDy9mnNEYU++NiqmAG8Ku2sUGXHJWJreVoLkNuGd/mi53TVZLXP241tmp76/reOq kQwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738001333; x=1738606133; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2QDxHAN3wJDwxKtbOiC7+yslaqQ6Rh8Flvbnwtfkiyo=; b=EK+mVWlUSidpN0dmNaYOmNAVtwF4/SNnfS7EaHEtARmWCQKGdAq06o+H27L5spmsQW c/gVQF6Fa7BIXFoi4xSZ5bN0vEGjfbQJlV0dZcnC31KUrw0mc0keyLv4d2IpivN39Vv1 85ICytrsICmLdWPRsnpLz7lcaWgk/zxLqUlqCuyOZwF2v45wdrJoYG9H8PhcRe3jmXjn 83stTOCcKdnLF2TiQnL1yfKZwIRJl2KvquZoF3nAMUZj+sWFh0e0wEkk2KjSYEhs3PzP fLG7Q3RQESG484xiBDrQVr+sSmA5ZBDK9mad0Ue+bb1scBLwdxNvYG3ekKxTJgpFf3Mx 2sQQ== X-Gm-Message-State: AOJu0YyfFDOeQlTJ5jCCuXgE0DKQ4usQLra9juvHLJMnWK9KNNlQkGU+ T19hZPXbZCRbWRV3BBNqPxAJj0SWABSOIND8kXzmtZSQFZVPQuj5FWxsw+X0E05mkpU+GEV7iQO k X-Gm-Gg: ASbGncsrt2Uwgy6Y/srSkBKL4f0CXZ9SquNe7tmZqyCaAADKYsvHXTO4AfhEaiLzm7Z DiGoECaY3PcpNyPOy4CP2JKZ1RRYN+1acNmEbE2rbuI82rIQhKgJuacGrNKlQ22emXPUpfUPYRh fyXWSIRwn68QBzd+ar2ki1opEOhls4cheRjurTMJ9FG7ZckSxVQsWqv9jfE0y7OIoBFYo6qyPn6 Pol8isg6y9oPknVH9REd597uab+L/4REN3vNRCiTl+g+wHkNrB1VwEp+steGKg/fwquJLw0W9nT HWiczUjAAMZYuRz2jn3ZWRs2Q62fl7OXOwH+XU+vK1Z9E5uhPp9YzN+eMQ== X-Google-Smtp-Source: AGHT+IHkP+4c2ZzNK9QkQcMHRPKVzWRhGiN2zgGnGXMF6SLDDtpo2wdABCTGxsBWH7Erbvs5HUz6HA== X-Received: by 2002:a17:902:dacb:b0:215:5ea2:6543 with SMTP id d9443c01a7336-21c35546dcbmr674995685ad.28.1738001333133; Mon, 27 Jan 2025 10:08:53 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da41413absm66166665ad.123.2025.01.27.10.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 10:08:52 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff Subject: [RFC 1/7] eal: add queue macro extensions from FreeBSD Date: Mon, 27 Jan 2025 10:03:55 -0800 Message-ID: <20250127180842.97907-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250127180842.97907-1-stephen@networkplumber.org> References: <20250127180842.97907-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The Linux version of sys/queue.h is frozen at an older version and is missing the _SAFE macro variants. Several drivers started introducing the own workarounds for this. Should be handled in EAL. Signed-off-by: Stephen Hemminger --- lib/eal/include/meson.build | 3 +- lib/eal/include/rte_queue.h | 174 ++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 lib/eal/include/rte_queue.h diff --git a/lib/eal/include/meson.build b/lib/eal/include/meson.build index d903577caa..75bf09381f 100644 --- a/lib/eal/include/meson.build +++ b/lib/eal/include/meson.build @@ -19,8 +19,8 @@ headers += files( 'rte_eal.h', 'rte_eal_memconfig.h', 'rte_eal_trace.h', - 'rte_errno.h', 'rte_epoll.h', + 'rte_errno.h', 'rte_fbarray.h', 'rte_hexdump.h', 'rte_hypervisor.h', @@ -38,6 +38,7 @@ headers += files( 'rte_pci_dev_features.h', 'rte_per_lcore.h', 'rte_pflock.h', + 'rte_queue.h', 'rte_random.h', 'rte_reciprocal.h', 'rte_seqcount.h', diff --git a/lib/eal/include/rte_queue.h b/lib/eal/include/rte_queue.h new file mode 100644 index 0000000000..7ec807b15d --- /dev/null +++ b/lib/eal/include/rte_queue.h @@ -0,0 +1,174 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Original Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + */ + +#ifndef _RTE_QUEUE_H_ +#define _RTE_QUEUE_H_ + +/** + * @file + * Defines macro's that exist in the FreeBSD version of queue.h + * which are missing in other versions. + */ + +#include + +/* + * This file defines four types of data structures: singly-linked lists, + * singly-linked tail queues, lists and tail queues. + * + * Below is a summary of implemented functions where: + * o means the macro exists in original version + * + means the macro is added here + * - means the macro is not available + * s means the macro is available but is slow (runs in O(n) time) + * + * SLIST LIST STAILQ TAILQ + * _HEAD o o o o + * _HEAD_INITIALIZER o o o o + * _ENTRY o o o o + * _INIT o o o o + * _EMPTY o o o o + * _FIRST o o o o + * _NEXT o o o o + * _FOREACH o o o o + * _FOREACH_FROM + + + + + * _FOREACH_SAFE + + + + + * _FOREACH_FROM_SAFE + + + + + * _FOREACH_REVERSE - - - o + * _FOREACH_REVERSE_FROM - - - + + * _FOREACH_REVERSE_SAFE - - - + + * _FOREACH_REVERSE_FROM_SAFE - - - + + * _INSERT_HEAD o o o o + * _INSERT_BEFORE - o - o + * _INSERT_AFTER o o o o + * _INSERT_TAIL - - o o + * _CONCAT s s o o + * _REMOVE_AFTER o - o - + * _REMOVE_HEAD o o o o + * _REMOVE s o s o + * + */ + + +/* + * Singly-linked List declarations. + */ +#ifndef SLIST_FOREACH_FROM +#define SLIST_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ + (var); \ + (var) = SLIST_NEXT((var), field)) +#endif + +#ifndef SLIST_FOREACH_SAFE +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SLIST_FIRST((head)); \ + (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + +#ifndef SLIST_FOREACH_FROM_SAFE +#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ + (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + + +/* + * Singly-linked Tail queue declarations. + */ +#ifndef STAILQ_FOREACH_FROM +#define STAILQ_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ + (var); \ + (var) = STAILQ_NEXT((var), field)) +#endif + +#ifndef STAILQ_FOREACH_SAFE +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = STAILQ_FIRST((head)); \ + (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + +#ifndef STAILQ_FOREACH_FROM_SAFE +#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ + (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + +/* + * List declarations. + */ +#ifndef LIST_FOREACH_FROM +#define LIST_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ + (var); \ + (var) = LIST_NEXT((var), field)) +#endif + +#ifndef LIST_FOREACH_SAFE +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = LIST_FIRST((head)); \ + (var) && ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + +#ifndef LIST_FOREACH_FROM_SAFE +#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ + (var) && ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + +/* + * Tail queue declarations. + */ +#ifndef TAILQ_FOREACH_FROM +#define TAILQ_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ + (var); \ + (var) = TAILQ_NEXT((var), field)) +#endif + +#ifndef TAILQ_FOREACH_SAFE +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = TAILQ_FIRST((head)); \ + (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + +#ifndef TAILQ_FOREACH_FROM_SAFE +#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ + (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif + +#ifndef TAILQ_FOREACH_REVERSE_FROM +#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ + for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ + (var); \ + (var) = TAILQ_PREV((var), headname, field)) +#endif + +#ifndef TAILQ_FOREACH_REVERSE_SAFE +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ + (var) = (tvar)) +#endif + +#ifndef TAILQ_FOREACH_REVERSE_FROM_SAFE +#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar)\ + for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ + (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ + (var) = (tvar)) +#endif + +#endif /* !_RTE_QUEUE_H_ */ -- 2.45.2