@@ -1872,8 +1872,7 @@ eal_auto_detect_cores(struct rte_config *cfg)
unsigned int removed = 0;
rte_cpuset_t affinity_set;
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &affinity_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &affinity_set))
CPU_ZERO(&affinity_set);
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
@@ -1901,8 +1900,7 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
}
RTE_CPU_NOT(cpuset, cpuset);
- if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- &default_set))
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &default_set))
CPU_ZERO(&default_set);
RTE_CPU_AND(cpuset, cpuset, &default_set);
@@ -6,7 +6,10 @@
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
+#ifndef RTE_EXEC_ENV_WINDOWS
#include <pthread.h>
+#endif /* RTE_EXEC_ENV_WINDOWS */
+#include <rte_thread.h>
#include <signal.h>
#include <sched.h>
#include <assert.h>
@@ -86,9 +89,8 @@ thread_update_affinity(rte_cpuset_t *cpusetp)
int
rte_thread_set_affinity(rte_cpuset_t *cpusetp)
{
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
- cpusetp) != 0) {
- RTE_LOG(ERR, EAL, "pthread_setaffinity_np failed\n");
+ if (rte_thread_set_affinity_by_id(rte_thread_self(), cpusetp) != 0) {
+ RTE_LOG(ERR, EAL, "rte_thread_set_affinity_by_id failed\n");
return -1;
}
@@ -166,6 +168,7 @@ __rte_thread_uninit(void)
RTE_PER_LCORE(_lcore_id) = LCORE_ID_ANY;
}
+#ifndef RTE_EXEC_ENV_WINDOWS
struct rte_thread_ctrl_params {
void *(*start_routine)(void *);
void *arg;
@@ -258,6 +261,7 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
return -ret;
}
+#endif
struct rte_thread_ctrl_ctx {
rte_thread_func start_routine;
@@ -357,8 +361,7 @@ rte_thread_register(void)
rte_errno = EINVAL;
return -1;
}
- if (pthread_getaffinity_np(pthread_self(), sizeof(cpuset),
- &cpuset) != 0)
+ if (rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset) != 0)
CPU_ZERO(&cpuset);
lcore_id = eal_lcore_non_eal_allocate();
if (lcore_id >= RTE_MAX_LCORE)
@@ -7,6 +7,7 @@
#include <sys/queue.h>
#include <regex.h>
+#include <pthread.h>
#include <rte_common.h>
#include <rte_errno.h>
#include <rte_lcore.h>
@@ -19,7 +19,7 @@
* Structure storing internal configuration (per-lcore)
*/
struct lcore_config {
- pthread_t thread_id; /**< pthread identifier */
+ rte_thread_t thread_id; /**< pthread identifier */
int pipe_main2worker[2]; /**< communication pipe with main */
int pipe_worker2main[2]; /**< communication pipe with main */
@@ -5,6 +5,8 @@
#include <string.h>
#include <sys/time.h>
+#include <pthread.h>
+
#include <rte_alarm.h>
#include <rte_errno.h>
#include <rte_string_fns.h>
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -667,7 +667,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
@@ -690,7 +690,7 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -854,7 +854,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -866,7 +866,7 @@ rte_eal_init(int argc, char **argv)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- config->main_lcore, thread_id, cpuset,
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -883,7 +883,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -891,10 +891,10 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- rte_thread_setname(lcore_config[i].thread_id, thread_name);
+ rte_thread_name_set(lcore_config[i].thread_id, thread_name);
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
@@ -37,7 +37,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -156,7 +156,7 @@ eal_alarm_callback(void *arg __rte_unused)
while (ap != NULL && timespec_cmp(&now, &ap->time) >= 0) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -263,8 +263,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
* finish. Otherwise we are trying to cancel
* ourselves - mark it by EINPROGRESS.
*/
- if (pthread_equal(ap->executing_id,
- pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -285,8 +285,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id,
- pthread_self()) == 0) {
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0) {
executing++;
} else {
err = EINPROGRESS;
@@ -52,7 +52,7 @@ static rte_spinlock_t intr_lock = RTE_SPINLOCK_INITIALIZER;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static volatile int kq = -1;
@@ -628,7 +628,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -737,5 +737,5 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <sched.h>
#include <pthread_np.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <sys/thr.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,7 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
- lcore_id, thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (void *)thread_id.opaque_id, cpuset, ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
@@ -362,6 +362,7 @@ __rte_experimental
void
rte_lcore_dump(FILE *f);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Set thread names.
*
@@ -393,6 +394,8 @@ int rte_thread_setname(pthread_t id, const char *name);
__rte_experimental
int rte_thread_getname(pthread_t id, char *name, size_t len);
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
/**
* Register current non-EAL thread as a lcore.
*
@@ -417,6 +420,7 @@ __rte_experimental
void
rte_thread_unregister(void);
+#ifndef RTE_EXEC_ENV_WINDOWS
/**
* Create a control thread.
*
@@ -444,6 +448,8 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
+#endif
+
#ifdef __cplusplus
}
#endif
@@ -22,7 +22,7 @@
extern "C" {
#endif
-#include <pthread.h>
+#include <rte_thread.h>
/**
* Macro to define a per lcore variable "var" of type "type", don't
@@ -9,7 +9,7 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <syslog.h>
#include <getopt.h>
#include <sys/file.h>
@@ -963,7 +963,7 @@ int
rte_eal_init(int argc, char **argv)
{
int i, fctret, ret;
- pthread_t thread_id;
+ rte_thread_t thread_id;
static uint32_t run_once;
uint32_t has_run = 0;
const char *p;
@@ -991,7 +991,7 @@ rte_eal_init(int argc, char **argv)
p = strrchr(argv[0], '/');
strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid));
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
eal_reset_internal_config(internal_conf);
@@ -1219,7 +1219,7 @@ rte_eal_init(int argc, char **argv)
eal_check_mem_on_local_socket();
- if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+ if (rte_thread_set_affinity_by_id(rte_thread_self(),
&lcore_config[config->main_lcore].cpuset) != 0) {
rte_eal_init_alert("Cannot set affinity");
rte_errno = EINVAL;
@@ -1229,8 +1229,8 @@ rte_eal_init(int argc, char **argv)
&lcore_config[config->main_lcore].cpuset);
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
- RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- config->main_lcore, (uintptr_t)thread_id, cpuset,
+ RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
+ config->main_lcore, (void *)thread_id.opaque_id, cpuset,
ret == 0 ? "" : "...");
RTE_LCORE_FOREACH_WORKER(i) {
@@ -1247,7 +1247,7 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- ret = pthread_create(&lcore_config[i].thread_id, NULL,
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
if (ret != 0)
rte_panic("Cannot create thread\n");
@@ -1255,14 +1255,14 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"lcore-worker-%d", i);
- ret = rte_thread_setname(lcore_config[i].thread_id,
- thread_name);
+ ret = rte_thread_name_set(lcore_config[i].thread_id,
+ thread_name);
if (ret != 0)
RTE_LOG(DEBUG, EAL,
"Cannot set name for lcore thread\n");
- ret = pthread_setaffinity_np(lcore_config[i].thread_id,
- sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
+ ret = rte_thread_set_affinity_by_id(lcore_config[i].thread_id,
+ &lcore_config[i].cpuset);
if (ret != 0)
rte_panic("Cannot set affinity\n");
}
@@ -48,7 +48,7 @@ struct alarm_entry {
rte_eal_alarm_callback cb_fn;
void *cb_arg;
volatile uint8_t executing;
- volatile pthread_t executing_id;
+ volatile rte_thread_t executing_id;
};
static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();
@@ -86,7 +86,7 @@ eal_alarm_callback(void *arg __rte_unused)
(ap->time.tv_sec < now.tv_sec || (ap->time.tv_sec == now.tv_sec &&
(ap->time.tv_usec * NS_PER_US) <= now.tv_nsec))) {
ap->executing = 1;
- ap->executing_id = pthread_self();
+ ap->executing_id = rte_thread_self();
rte_spinlock_unlock(&alarm_list_lk);
ap->cb_fn(ap->cb_arg);
@@ -207,7 +207,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
/* If calling from other context, mark that alarm is executing
* so loop can spin till it finish. Otherwise we are trying to
* cancel our self - mark it by EINPROGRESS */
- if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -228,7 +229,8 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)
free(ap);
count++;
ap = ap_prev;
- } else if (pthread_equal(ap->executing_id, pthread_self()) == 0)
+ } else if (rte_thread_equal(ap->executing_id,
+ rte_thread_self()) == 0)
executing++;
else
err = EINPROGRESS;
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <sys/queue.h>
#include <stdarg.h>
#include <unistd.h>
@@ -97,7 +97,7 @@ static union intr_pipefds intr_pipe;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
/* VFIO interrupts */
#ifdef VFIO_PRESENT
@@ -1167,7 +1167,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -1570,5 +1570,5 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
+#include <rte_thread.h>
#include <sched.h>
#include <sys/queue.h>
#include <sys/syscall.h>
@@ -73,15 +74,16 @@ eal_thread_loop(__rte_unused void *arg)
char c;
int n, ret;
unsigned lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -94,7 +96,8 @@ eal_thread_loop(__rte_unused void *arg)
ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset, ret == 0 ? "" : "...");
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset,
+ ret == 0 ? "" : "...");
rte_eal_trace_thread_lcore_ready(lcore_id, cpuset);
@@ -12,7 +12,7 @@
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/queue.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <errno.h>
#include <rte_common.h>
@@ -80,7 +80,7 @@ static uint64_t eal_hpet_resolution_hz = 0;
/* Incremented 4 times during one 32bits hpet full count */
static uint32_t eal_hpet_msb;
-static pthread_t msb_inc_thread_id;
+static rte_thread_t msb_inc_thread_id;
/*
* This function runs on a specific thread to update a global variable
@@ -185,7 +185,7 @@ rte_eal_hpet_init(int make_default)
/* create a thread that will increment a global variable for
* msb (hpet is 32 bits by default under linux) */
- ret = rte_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc", NULL,
+ ret = rte_thread_ctrl_thread_create(&msb_inc_thread_id, "hpet-msb-inc",
hpet_msb_inc, NULL);
if (ret != 0) {
RTE_LOG(ERR, EAL, "ERROR: Cannot create HPET timer thread!\n");
@@ -21,7 +21,7 @@ DPDK_21 {
rte_cpu_get_flag_enabled;
rte_cpu_get_flag_name;
rte_cpu_is_supported; # WINDOWS_NO_EXPORT
- rte_ctrl_thread_create;
+ rte_ctrl_thread_create; # WINDOWS_NO_EXPORT
rte_cycles_vmware_tsc_map; # WINDOWS_NO_EXPORT
rte_delay_us;
rte_delay_us_block;
@@ -193,7 +193,7 @@ DPDK_21 {
rte_sys_gettid;
rte_thread_get_affinity;
rte_thread_set_affinity;
- rte_thread_setname;
+ rte_thread_setname; # WINDOWS_NO_EXPORT
rte_uuid_compare; # WINDOWS_NO_EXPORT
rte_uuid_is_null; # WINDOWS_NO_EXPORT
rte_uuid_parse; # WINDOWS_NO_EXPORT
@@ -391,7 +391,9 @@ rte_eal_init(int argc, char **argv)
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
- if (eal_thread_create(&lcore_config[i].thread_id) != 0)
+ ret = rte_thread_create(&lcore_config[i].thread_id, NULL,
+ eal_thread_loop, NULL);
+ if (ret != 0)
rte_panic("Cannot create thread\n");
}
@@ -7,7 +7,7 @@
#include "eal_private.h"
#include "eal_windows.h"
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static HANDLE intr_iocp;
@@ -63,7 +63,7 @@ rte_eal_intr_init(void)
return -1;
}
- ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
+ ret = rte_thread_ctrl_thread_create(&intr_thread, "eal-intr-thread",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -76,7 +76,7 @@ rte_eal_intr_init(void)
int
rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
int
@@ -92,9 +92,9 @@ eal_intr_thread_schedule(void (*func)(void *arg), void *arg)
{
HANDLE handle;
- handle = OpenThread(THREAD_ALL_ACCESS, FALSE, intr_thread);
+ handle = OpenThread(THREAD_ALL_ACCESS, FALSE, intr_thread.opaque_id);
if (handle == NULL) {
- RTE_LOG_WIN32_ERR("OpenThread(%llu)", intr_thread);
+ RTE_LOG_WIN32_ERR("OpenThread(%llu)", intr_thread.opaque_id);
return -ENOENT;
}
@@ -60,15 +60,16 @@ eal_thread_loop(void *arg __rte_unused)
char c;
int n, ret;
unsigned int lcore_id;
- pthread_t thread_id;
+ rte_thread_t thread_id;
int m2w, w2m;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
- thread_id = pthread_self();
+ thread_id = rte_thread_self();
/* retrieve our lcore_id from the configuration structure */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
- if (thread_id == lcore_config[lcore_id].thread_id)
+ if (rte_thread_equal(thread_id,
+ lcore_config[lcore_id].thread_id))
break;
}
if (lcore_id == RTE_MAX_LCORE)
@@ -80,7 +81,7 @@ eal_thread_loop(void *arg __rte_unused)
__rte_thread_init(lcore_id, &lcore_config[lcore_id].cpuset);
RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%zx;cpuset=[%s])\n",
- lcore_id, (uintptr_t)thread_id, cpuset);
+ lcore_id, (uintptr_t)thread_id.opaque_id, cpuset);
/* read on our pipe to get commands */
while (1) {
@@ -122,35 +123,9 @@ eal_thread_loop(void *arg __rte_unused)
}
}
-/* function to create threads */
-int
-eal_thread_create(pthread_t *thread)
-{
- HANDLE th;
-
- th = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE)(ULONG_PTR)eal_thread_loop,
- NULL, 0, (LPDWORD)thread);
- if (!th)
- return -1;
-
- SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
- SetThreadPriority(th, THREAD_PRIORITY_NORMAL);
-
- return 0;
-}
-
/* get current thread ID */
int
rte_sys_gettid(void)
{
return GetCurrentThreadId();
}
-
-int
-rte_thread_setname(__rte_unused pthread_t id, __rte_unused const char *name)
-{
- /* TODO */
- /* This is a stub, not the expected result */
- return 0;
-}
@@ -35,16 +35,6 @@
*/
int eal_create_cpu_map(void);
-/**
- * Create a thread.
- *
- * @param thread
- * The location to store the thread id if successful.
- * @return
- * 0 for success, -1 if the thread is not created.
- */
-int eal_thread_create(pthread_t *thread);
-
/**
* Get system NUMA node number for a socket ID.
*
@@ -28,6 +28,7 @@
#include <windows.h>
#include <basetsd.h>
+#include <processthreadsapi.h>
#include <psapi.h>
#include <setupapi.h>
#include <winioctl.h>
@@ -594,7 +594,7 @@ rte_thread_name_set(rte_thread_t thread_id, const char *name)
}
count = mbstowcs(w_name, name, RTE_THREAD_MAX_DESCRIPTION_LENGTH);
- if (count < 0) {
+ if (count == (size_t) (-1)) {
RTE_LOG(DEBUG, EAL, "Invalid thread name!\n");
ret = EINVAL;
goto cleanup;
@@ -526,7 +526,7 @@ rte_eth_dev_allocate(const char *name)
strlcpy(eth_dev->data->name, name, sizeof(eth_dev->data->name));
eth_dev->data->port_id = port_id;
eth_dev->data->mtu = RTE_ETHER_MTU;
- pthread_mutex_init(ð_dev->data->flow_ops_mutex, NULL);
+ rte_thread_mutex_init(ð_dev->data->flow_ops_mutex);
unlock:
rte_spinlock_unlock(ð_dev_shared_data->ownership_lock);
@@ -600,7 +600,7 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
rte_free(eth_dev->data->mac_addrs);
rte_free(eth_dev->data->hash_mac_addrs);
rte_free(eth_dev->data->dev_private);
- pthread_mutex_destroy(ð_dev->data->flow_ops_mutex);
+ rte_thread_mutex_destroy(ð_dev->data->flow_ops_mutex);
memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
}
@@ -5,7 +5,7 @@
#ifndef _RTE_ETHDEV_CORE_H_
#define _RTE_ETHDEV_CORE_H_
-#include <pthread.h>
+#include <rte_thread.h>
/**
* @file
@@ -182,7 +182,7 @@ struct rte_eth_dev_data {
* Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
*/
- pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex. */
+ rte_thread_mutex flow_ops_mutex; /**< rte_flow ops mutex. */
uint64_t reserved_64s[4]; /**< Reserved for future fields */
void *reserved_ptrs[4]; /**< Reserved for future fields */
} __rte_cache_aligned;
@@ -226,14 +226,14 @@ static inline void
fts_enter(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_lock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_lock(&dev->data->flow_ops_mutex);
}
static inline void
fts_exit(struct rte_eth_dev *dev)
{
if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE))
- pthread_mutex_unlock(&dev->data->flow_ops_mutex);
+ rte_thread_mutex_unlock(&dev->data->flow_ops_mutex);
}
static int
@@ -7,6 +7,7 @@
#endif
#include <unistd.h>
+#include <pthread.h>
#include <rte_cycles.h>
#include <rte_common.h>
#include <rte_dev.h>
@@ -12,6 +12,7 @@
#include <numaif.h>
#endif
+#include <pthread.h>
#include <rte_errno.h>
#include <rte_ethdev.h>
#include <rte_log.h>