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 C9EC5A054F; Mon, 27 Jun 2022 18:56:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD34A4282F; Mon, 27 Jun 2022 18:56:11 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id DC7C340A7A for ; Mon, 27 Jun 2022 18:56:08 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 28BBA20CD16E; Mon, 27 Jun 2022 09:56:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 28BBA20CD16E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1656348968; bh=X2QPhIUcWWqZHaZR1Bo8X3tFpbBX/B7nnq1b4dwY2Xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OPNcb7BCQGmH4e5+IeG08orF0EOTvlfZf+jwa7PrU416wjkOykO+r7MgiTI9pg4/q oONLyvLRjWU+QzorFZSPf+3IuWbvTvsAJ6eOEtvsvHuMsf54llUNkYWIWzR31EP+Px Yas/gJ7oKNCbS96EIDNh5nNxNQg7zOos9vrV+9UA= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, dmitry.kozliuk@gmail.com, anatoly.burakov@intel.com, Tyler Retzlaff , Narcisa Vasile Subject: [PATCH v4 3/6] eal: add basic rte thread ID equal API Date: Mon, 27 Jun 2022 09:56:03 -0700 Message-Id: <1656348966-10194-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1656348966-10194-1-git-send-email-roretzla@linux.microsoft.com> References: <1654783134-13303-1-git-send-email-roretzla@linux.microsoft.com> <1656348966-10194-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 Add rte_thread_equal() that tests if two rte_thread_id are equal. Signed-off-by: Narcisa Vasile Signed-off-by: Tyler Retzlaff Acked-by: Chengwen Feng --- lib/eal/include/rte_thread.h | 19 +++++++++++++++++++ lib/eal/unix/rte_thread.c | 6 ++++++ lib/eal/version.map | 1 + lib/eal/windows/rte_thread.c | 6 ++++++ 4 files changed, 32 insertions(+) diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h index 3c8ff50..8359c1c 100644 --- a/lib/eal/include/rte_thread.h +++ b/lib/eal/include/rte_thread.h @@ -144,6 +144,25 @@ int rte_thread_create(rte_thread_t *thread_id, __rte_experimental rte_thread_t rte_thread_self(void); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Check if 2 thread ids are equal. + * + * @param t1 + * First thread id. + * + * @param t2 + * Second thread id. + * + * @return + * If the ids are equal, return nonzero. + * Otherwise, return 0. + */ +__rte_experimental +int rte_thread_equal(rte_thread_t t1, rte_thread_t t2); + #ifdef RTE_HAS_CPUSET /** diff --git a/lib/eal/unix/rte_thread.c b/lib/eal/unix/rte_thread.c index d4c1a7f..37ebfcf 100644 --- a/lib/eal/unix/rte_thread.c +++ b/lib/eal/unix/rte_thread.c @@ -210,6 +210,12 @@ struct thread_routine_ctx { return pthread_detach((pthread_t)thread_id.opaque_id); } +int +rte_thread_equal(rte_thread_t t1, rte_thread_t t2) +{ + return pthread_equal((pthread_t)t1.opaque_id, (pthread_t)t2.opaque_id); +} + rte_thread_t rte_thread_self(void) { diff --git a/lib/eal/version.map b/lib/eal/version.map index b404343..b5dc7f1 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -432,6 +432,7 @@ EXPERIMENTAL { # added in 22.11 rte_thread_create; rte_thread_detach; + rte_thread_equal; rte_thread_join; }; diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c index ad71be4..1bc648e 100644 --- a/lib/eal/windows/rte_thread.c +++ b/lib/eal/windows/rte_thread.c @@ -287,6 +287,12 @@ struct thread_routine_ctx { return 0; } +int +rte_thread_equal(rte_thread_t t1, rte_thread_t t2) +{ + return t1.opaque_id == t2.opaque_id; +} + rte_thread_t rte_thread_self(void) { -- 1.8.3.1