eal/windows: add pthread mutex
authorSuanming Mou <suanmingm@nvidia.com>
Thu, 15 Oct 2020 01:07:46 +0000 (09:07 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 15 Oct 2020 22:44:58 +0000 (00:44 +0200)
Add pthread mutex lock as it is needed for the thread safe rte_flow
functions.

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
Tested-by: Tal Shnaiderman <talshn@nvidia.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Ranjit Menon <ranjit.menon@intel.com>
Acked-by: Narcisa Vasile <navasile@linux.microsoft.com>
lib/librte_eal/windows/include/pthread.h

index a4ab4d0..fb11a07 100644 (file)
@@ -28,6 +28,10 @@ typedef uintptr_t pthread_t;
 /* 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) \
@@ -146,6 +150,35 @@ pthread_join(__rte_unused pthread_t thread,
        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