From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D4FF3A04BA; Wed, 7 Oct 2020 16:18:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CBBCD1BC96; Wed, 7 Oct 2020 16:17:47 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 120621BC8C for ; Wed, 7 Oct 2020 16:17:44 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from suanmingm@nvidia.com) with SMTP; 7 Oct 2020 17:17:39 +0300 Received: from nvidia.com (mtbc-r640-04.mtbc.labs.mlnx [10.75.70.9]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 097EHZPS024368; Wed, 7 Oct 2020 17:17:37 +0300 From: Suanming Mou To: Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Cc: dev@dpdk.org Date: Wed, 7 Oct 2020 22:17:28 +0800 Message-Id: <1602080249-36533-2-git-send-email-suanmingm@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602080249-36533-1-git-send-email-suanmingm@nvidia.com> References: <1601194817-208834-1-git-send-email-suanmingm@nvidia.com> <1602080249-36533-1-git-send-email-suanmingm@nvidia.com> Subject: [dpdk-dev] [PATCH v3 1/2] eal/windows: add pthread mutex lock X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add pthread mutex lock as it is needed for the thread safe rte_flow functions. Signed-off-by: Suanming Mou --- v3: - No updates. v2: - Using critical section for windows pthread mutex. --- lib/librte_eal/windows/include/pthread.h | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/librte_eal/windows/include/pthread.h b/lib/librte_eal/windows/include/pthread.h index 99013dc..644fd49 100644 --- a/lib/librte_eal/windows/include/pthread.h +++ b/lib/librte_eal/windows/include/pthread.h @@ -28,6 +28,10 @@ /* defining pthread_attr_t type on Windows since there is no in Microsoft libc*/ typedef void *pthread_attr_t; +typedef void *pthread_mutexattr_t; + +typedef CRITICAL_SECTION pthread_mutex_t; + typedef SYNCHRONIZATION_BARRIER pthread_barrier_t; #define pthread_barrier_init(barrier, attr, count) \ @@ -139,6 +143,35 @@ return 0; } +static inline int +pthread_mutex_init(pthread_mutex_t *mutex, + __rte_unused pthread_mutexattr_t *attr) +{ + InitializeCriticalSection(mutex); + return 0; +} + +static inline int +pthread_mutex_lock(pthread_mutex_t *mutex) +{ + EnterCriticalSection(mutex); + return 0; +} + +static inline int +pthread_mutex_unlock(pthread_mutex_t *mutex) +{ + LeaveCriticalSection(mutex); + return 0; +} + +static inline int +pthread_mutex_destroy(pthread_mutex_t *mutex) +{ + DeleteCriticalSection(mutex); + return 0; +} + #ifdef __cplusplus } #endif -- 1.8.3.1