DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] eal/windows: add pthread TLS function support
@ 2020-12-13 20:24 Tal Shnaiderman
  2020-12-15 22:36 ` Dmitry Kozlyuk
  2020-12-17 17:49 ` [dpdk-dev] [PATCH v3] eal: add generic thread-local-storage functions Tal Shnaiderman
  0 siblings, 2 replies; 36+ messages in thread
From: Tal Shnaiderman @ 2020-12-13 20:24 UTC (permalink / raw)
  To: dev; +Cc: thomas, pallavi.kadam, dmitry.kozliuk, navasile, dmitrym

Add the following functions to the pthread shim implementation
for Windows as they are needed for thread safe rte_flow functions.

pthread_key_create.
pthread_key_delete.
pthread_getspecific.
pthread_setspecific.

Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
---
v2: fix style issues
---
 lib/librte_eal/windows/include/pthread.h | 43 ++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/lib/librte_eal/windows/include/pthread.h b/lib/librte_eal/windows/include/pthread.h
index fb11a07ce6..8fe18e6f00 100644
--- a/lib/librte_eal/windows/include/pthread.h
+++ b/lib/librte_eal/windows/include/pthread.h
@@ -34,6 +34,8 @@ typedef CRITICAL_SECTION pthread_mutex_t;
 
 typedef SYNCHRONIZATION_BARRIER pthread_barrier_t;
 
+typedef DWORD pthread_key_t;
+
 #define pthread_barrier_init(barrier, attr, count) \
 	InitializeSynchronizationBarrier(barrier, count, -1)
 #define pthread_barrier_wait(barrier) EnterSynchronizationBarrier(barrier, \
@@ -179,6 +181,47 @@ pthread_mutex_destroy(pthread_mutex_t *mutex)
 	return 0;
 }
 
+static inline int
+pthread_key_create(pthread_key_t *key,
+		    __rte_unused void (*destructor)(void *))
+{
+	*key = TlsAlloc();
+	if ((*key) == TLS_OUT_OF_INDEXES) {
+		RTE_LOG_WIN32_ERR("TlsAlloc()");
+		return -ENOMEM;
+	}
+	return 0;
+}
+
+static inline int
+pthread_key_delete(pthread_key_t key)
+{
+	if (!TlsFree(key)) {
+		RTE_LOG_WIN32_ERR("TlsFree()");
+		return -1;
+	}
+	return 0;
+}
+
+static inline void *
+pthread_getspecific(pthread_key_t key)
+{
+	return TlsGetValue(key);
+}
+
+static inline int
+pthread_setspecific(pthread_key_t key, const void *value)
+{
+	/* discard const qualifier */
+	char *p = (char *) (uintptr_t) value;
+
+	if (!TlsSetValue(key, p)) {
+		RTE_LOG_WIN32_ERR("TlsSetValue()");
+		return -1;
+	}
+	return 0;
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.16.1.windows.4


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2021-02-11  7:35 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-13 20:24 [dpdk-dev] [PATCH v2] eal/windows: add pthread TLS function support Tal Shnaiderman
2020-12-15 22:36 ` Dmitry Kozlyuk
2020-12-17 17:49 ` [dpdk-dev] [PATCH v3] eal: add generic thread-local-storage functions Tal Shnaiderman
2020-12-17 20:56   ` Dmitry Kozlyuk
2020-12-18 19:37     ` Tal Shnaiderman
2020-12-22  7:30   ` [dpdk-dev] [PATCH v4] " Tal Shnaiderman
2020-12-23  1:18     ` Dmitry Kozlyuk
2020-12-23 11:44       ` Tal Shnaiderman
2020-12-23 11:58         ` Dmitry Kozlyuk
2020-12-23 18:16           ` [dpdk-dev] [EXTERNAL] " Dmitry Malloy (MESHCHANINOV)
2020-12-26 16:08     ` [dpdk-dev] [PATCH v5] " Tal Shnaiderman
2020-12-29 23:13       ` Dmitry Kozlyuk
2020-12-30 10:04         ` Tal Shnaiderman
2020-12-30 11:12       ` [dpdk-dev] [PATCH v6] " Tal Shnaiderman
2021-01-01 22:16         ` Dmitry Kozlyuk
2021-01-05 11:53         ` Thomas Monjalon
2021-01-05 17:06       ` [dpdk-dev] [PATCH v7 0/2] support generic threading functions Tal Shnaiderman
2021-01-05 17:06         ` [dpdk-dev] [PATCH v7 1/2] eal: move thread affinity functions to new file Tal Shnaiderman
2021-01-06 14:40           ` Dmitry Kozlyuk
2021-01-06 19:45           ` [dpdk-dev] [PATCH v8 0/2] support generic threading functions Tal Shnaiderman
2021-01-06 19:45             ` [dpdk-dev] [PATCH v8 1/2] eal: move thread affinity functions to new file Tal Shnaiderman
2021-01-06 19:45             ` [dpdk-dev] [PATCH v8 2/2] eal: add generic thread-local-storage functions Tal Shnaiderman
2021-01-06 20:10               ` Dmitry Kozlyuk
2021-01-06 20:33                 ` Tal Shnaiderman
2021-01-06 20:35             ` [dpdk-dev] [PATCH v9 0/2] support generic threading functions Tal Shnaiderman
2021-01-06 20:35               ` [dpdk-dev] [PATCH v9 1/2] eal: move thread affinity functions to new file Tal Shnaiderman
2021-01-06 20:35               ` [dpdk-dev] [PATCH v9 2/2] eal: add generic thread-local-storage functions Tal Shnaiderman
2021-01-07 14:46                 ` Dmitry Kozlyuk
2021-02-10 13:33                 ` Burakov, Anatoly
2021-02-10 14:26                   ` Medvedkin, Vladimir
2021-02-11  7:34                     ` Tal Shnaiderman
2021-02-11  7:26                   ` Tal Shnaiderman
2021-01-11 22:33               ` [dpdk-dev] [PATCH v9 0/2] support generic threading functions Thomas Monjalon
2021-01-05 17:06         ` [dpdk-dev] [PATCH v7 2/2] eal: add generic thread-local-storage functions Tal Shnaiderman
2021-01-06 15:05           ` Dmitry Kozlyuk
2021-01-06 16:04             ` Tal Shnaiderman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).