From patchwork Fri Mar 17 22:34:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 125246 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9D23541EC5; Fri, 17 Mar 2023 23:35:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE7564302B; Fri, 17 Mar 2023 23:34:57 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 251A740DF6 for ; Fri, 17 Mar 2023 23:34:50 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id E0E1620C343B; Fri, 17 Mar 2023 15:34:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E0E1620C343B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679092488; bh=tULtgHrSsyssrVH73k/X8BQphCCt6XTjrrTXDkuLpBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OO5ivi5lkiwRvMjNFvBBwIr0E8+sjtx4d0QcvtOgM4LbZNJ+7xUawDySS5kAl7c3D yx2RJRg3xUiO97dponGTLjsxJnC4KCrDe5ie5QnVVYxdYoRNZw3jC3VN7dK36lchjF aQLKqld1WbF4VBH1GgEAw9XgAG3CM2SVcq5Sw+Vc= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 6/6] windows: remove most pthread lifetime shim functions Date: Fri, 17 Mar 2023 15:34:20 -0700 Message-Id: <1679092460-9930-7-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679092460-9930-1-git-send-email-roretzla@linux.microsoft.com> References: <1679092460-9930-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Remove most of the pthread_xxx lifetime shim functions, only pthread_create remains while we wait for rte_ctrl_thread_create removal. Signed-off-by: Tyler Retzlaff --- lib/eal/windows/include/pthread.h | 99 --------------------------------------- 1 file changed, 99 deletions(-) diff --git a/lib/eal/windows/include/pthread.h b/lib/eal/windows/include/pthread.h index f7cf0e9..051b931 100644 --- a/lib/eal/windows/include/pthread.h +++ b/lib/eal/windows/include/pthread.h @@ -42,92 +42,6 @@ !DeleteSynchronizationBarrier(barrier) #define pthread_cancel(thread) !TerminateThread((HANDLE) thread, 0) -/* pthread function overrides */ -#define pthread_self() \ - ((pthread_t)GetCurrentThreadId()) - - -static inline int -pthread_equal(pthread_t t1, pthread_t t2) -{ - return t1 == t2; -} - -static inline int -pthread_setaffinity_np(pthread_t threadid, size_t cpuset_size, - rte_cpuset_t *cpuset) -{ - DWORD_PTR ret = 0; - HANDLE thread_handle; - - if (cpuset == NULL || cpuset_size == 0) - return -1; - - thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid); - if (thread_handle == NULL) { - RTE_LOG_WIN32_ERR("OpenThread()"); - return -1; - } - - ret = SetThreadAffinityMask(thread_handle, *cpuset->_bits); - if (ret == 0) { - RTE_LOG_WIN32_ERR("SetThreadAffinityMask()"); - goto close_handle; - } - -close_handle: - if (CloseHandle(thread_handle) == 0) { - RTE_LOG_WIN32_ERR("CloseHandle()"); - return -1; - } - return (ret == 0) ? -1 : 0; -} - -static inline int -pthread_getaffinity_np(pthread_t threadid, size_t cpuset_size, - rte_cpuset_t *cpuset) -{ - /* Workaround for the lack of a GetThreadAffinityMask() - *API in Windows - */ - DWORD_PTR prev_affinity_mask; - HANDLE thread_handle; - DWORD_PTR ret = 0; - - if (cpuset == NULL || cpuset_size == 0) - return -1; - - thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadid); - if (thread_handle == NULL) { - RTE_LOG_WIN32_ERR("OpenThread()"); - return -1; - } - - /* obtain previous mask by setting dummy mask */ - prev_affinity_mask = SetThreadAffinityMask(thread_handle, 0x1); - if (prev_affinity_mask == 0) { - RTE_LOG_WIN32_ERR("SetThreadAffinityMask()"); - goto close_handle; - } - - /* set it back! */ - ret = SetThreadAffinityMask(thread_handle, prev_affinity_mask); - if (ret == 0) { - RTE_LOG_WIN32_ERR("SetThreadAffinityMask()"); - goto close_handle; - } - - memset(cpuset, 0, cpuset_size); - *cpuset->_bits = prev_affinity_mask; - -close_handle: - if (CloseHandle(thread_handle) == 0) { - RTE_LOG_WIN32_ERR("SetThreadAffinityMask()"); - return -1; - } - return (ret == 0) ? -1 : 0; -} - static inline int pthread_create(void *threadid, const void *threadattr, void *threadfunc, void *args) @@ -145,19 +59,6 @@ } static inline int -pthread_detach(__rte_unused pthread_t thread) -{ - return 0; -} - -static inline int -pthread_join(__rte_unused pthread_t thread, - __rte_unused void **value_ptr) -{ - return 0; -} - -static inline int pthread_mutex_init(pthread_mutex_t *mutex, __rte_unused pthread_mutexattr_t *attr) {