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 2E600A04DB; Wed, 14 Oct 2020 18:45:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 02BAD1D92B; Wed, 14 Oct 2020 18:45:22 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id A93A4160 for ; Wed, 14 Oct 2020 18:45:19 +0200 (CEST) IronPort-SDR: FEl7Jn7MlmfpXYB2tGMr6kkNOb3rx7ehn+GKzy6aSGCn7JsCG8dR2YXrV+m/1CdKZ7SwRyb/wt OEXCuZzcG3gA== X-IronPort-AV: E=McAfee;i="6000,8403,9774"; a="166263219" X-IronPort-AV: E=Sophos;i="5.77,375,1596524400"; d="scan'208";a="166263219" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 09:45:17 -0700 IronPort-SDR: XdF/UkNp5wmk0MowPp03/SdjODRV/wSkYhKNih2DrSuBTK8FFghW+87wtnXqMqocqD0E/HiXcK 8Etxbn7LLAWA== X-IronPort-AV: E=Sophos;i="5.77,375,1596524400"; d="scan'208";a="530901539" Received: from rmenon-desk.amr.corp.intel.com (HELO [10.166.30.253]) ([10.166.30.253]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 09:45:17 -0700 To: Suanming Mou , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Cc: dev@dpdk.org References: <1601194817-208834-1-git-send-email-suanmingm@nvidia.com> <1602206243-157603-1-git-send-email-suanmingm@nvidia.com> <1602206243-157603-2-git-send-email-suanmingm@nvidia.com> From: Ranjit Menon Message-ID: <51798f2b-438d-58a0-8111-0c33a11ba0e1@intel.com> Date: Wed, 14 Oct 2020 09:45:16 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <1602206243-157603-2-git-send-email-suanmingm@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [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" On 10/8/2020 6:17 PM, Suanming Mou wrote: > 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 Acked-by: Ranjit Menon