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 E2792A04BC; Fri, 9 Oct 2020 03:17:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D4D691BDC3; Fri, 9 Oct 2020 03:17:37 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 969F21BDBD for ; Fri, 9 Oct 2020 03:17:36 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from suanmingm@nvidia.com) with SMTP; 9 Oct 2020 04:17:30 +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 0991HRrm012213; Fri, 9 Oct 2020 04:17:29 +0300 From: Suanming Mou To: Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Cc: dev@dpdk.org Date: Fri, 9 Oct 2020 09:17:22 +0800 Message-Id: <1602206243-157603-2-git-send-email-suanmingm@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602206243-157603-1-git-send-email-suanmingm@nvidia.com> References: <1601194817-208834-1-git-send-email-suanmingm@nvidia.com> <1602206243-157603-1-git-send-email-suanmingm@nvidia.com> Subject: [dpdk-dev] [PATCH v4 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 Acked-by: Dmitry Kozlyuk --- v4: - Add PTHREAD_MUTEX_INITIALIZER macro. v3: - No updates. v2: - Using critical section for windows pthread mutex. --- lib/librte_eal/windows/include/pthread.h | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/librte_eal/windows/include/pthread.h b/lib/librte_eal/windows/include/pthread.h index 99013dc..c62251f 100644 --- a/lib/librte_eal/windows/include/pthread.h +++ b/lib/librte_eal/windows/include/pthread.h @@ -28,6 +28,12 @@ /* 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; + +#define PTHREAD_MUTEX_INITIALIZER {(void *)-1, -1, 0, 0, 0, 0} + typedef SYNCHRONIZATION_BARRIER pthread_barrier_t; #define pthread_barrier_init(barrier, attr, count) \ @@ -139,6 +145,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