From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CEAC2A0579; Thu, 1 Apr 2021 21:07:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4F936406FF; Thu, 1 Apr 2021 21:07:51 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B714340696 for ; Thu, 1 Apr 2021 21:07:49 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1059) id ED07320B5680; Thu, 1 Apr 2021 12:07:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ED07320B5680 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1617304068; bh=ZROi2XIAE7cwqfbsYgOBMNZdJGoW+YglQJ/75k6eKbA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kCAooyohIB/RWGEzKl7DinL1PYuAsVpfkaFEYd4Qbt6rgICFZnFZ6/TCxxdWYRgQ/ 7dKK0jTc4EM8vGVvcf4REcqRPstlOfFyVriGpGOuTOk7upOZr5Oduf+rq9GLALUs+A P2JH7WF3HkuUn80K1I2OQr7tAv3ZsYIK0wJ0uw/8= Date: Thu, 1 Apr 2021 12:07:48 -0700 From: Narcisa Ana Maria Vasile To: Tal Shnaiderman Cc: "dev@dpdk.org" , NBU-Contact-Thomas Monjalon , "dmitry.kozliuk@gmail.com" , "khot@microsoft.com" , "navasile@microsoft.com" , "dmitrym@microsoft.com" , "roretzla@microsoft.com" , "ocardona@microsoft.com" , "bruce.richardson@intel.com" , "david.marchand@redhat.com" , "pallavi.kadam@intel.com" Message-ID: <20210401190748.GA2802@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1616802771-31578-10-git-send-email-navasile@linux.microsoft.com> <1617057640-24301-1-git-send-email-navasile@linux.microsoft.com> <1617057640-24301-4-git-send-email-navasile@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [dpdk-dev] [PATCH v5 03/10] windows/eal: translate Windows errors to errno-style errors 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 Sender: "dev" On Wed, Mar 31, 2021 at 01:56:09PM +0000, Tal Shnaiderman wrote: > > Subject: [PATCH v5 03/10] windows/eal: translate Windows errors to errno- > > style errors > > > > External email: Use caution opening links or attachments > > > > > > From: Narcisa Vasile > > > > Add function to translate Windows error codes to errno-style error codes. > > > > Signed-off-by: Narcisa Vasile > > --- > > lib/librte_eal/windows/rte_thread.c | 65 ++++++++++++++++++++++------- > > 1 file changed, 50 insertions(+), 15 deletions(-) > > > > diff --git a/lib/librte_eal/windows/rte_thread.c > > b/lib/librte_eal/windows/rte_thread.c > > index b29336cbd..e9181b47f 100644 > > --- a/lib/librte_eal/windows/rte_thread.c > > +++ b/lib/librte_eal/windows/rte_thread.c > > @@ -12,6 +12,47 @@ struct eal_tls_key { > > DWORD thread_index; > > }; > > > > +/* Translates the most common error codes related to threads */ static > > +int rte_thread_translate_win32_error(DWORD error) { > > This DWORD error will always the output of GetLastError()? If so can we move it inside the function? Yes, I think we can move the call to GetLastError() inside the function, thanks Tal. > > Also, I don't think this is a thread specific function, other implementations can use it in the future, maybe move it to rte_windows.h? I think it's better to keep these error-translation functions inside a specific module (threads, memory, etc.). The reason for that is that the same error code may mean different things in different modules. When I implemented this function I've went through all the Windows threads functions and noted down the type of errors that GetLastError() returns for them and what they mean. For a different module, a different set of errors might be more suitable, so to keep the translations as semantically compatible as possible to Linux, it's probably better to keep it at the module level (threading in this case). > > > + switch (error) { > > + case ERROR_SUCCESS: > > + return 0; > > + > > + case ERROR_INVALID_PARAMETER: > > + return EINVAL; > > + > > + case ERROR_INVALID_HANDLE: > > + return EFAULT; > > + > > + case ERROR_NOT_ENOUGH_MEMORY: > > + /* FALLTHROUGH */ > > + case ERROR_NO_SYSTEM_RESOURCES: > > + return ENOMEM; > > + > > + case ERROR_PRIVILEGE_NOT_HELD: > > + /* FALLTHROUGH */ > > + case ERROR_ACCESS_DENIED: > > + return EACCES; > > + > > + case ERROR_ALREADY_EXISTS: > > + return EEXIST; > > + > > + case ERROR_POSSIBLE_DEADLOCK: > > + return EDEADLK; > > + > > + case ERROR_INVALID_FUNCTION: > > + /* FALLTHROUGH */ > > + case ERROR_CALL_NOT_IMPLEMENTED: > > + return ENOSYS; > > + > > + default: > > + return EINVAL; > > + } > > + > > + return EINVAL; > > +} > > + > > @@ -143,7 +178,7 @@ rte_thread_value_get(rte_thread_key key) { > > void *output; > > > > This function is missing the change to rte_thread_translate_win32_error. > Aldo need to change function docu. Thanks, will fix and send v6. > > > - if (!key) { > > + if (key == NULL) { > > RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); > > rte_errno = EINVAL; > > return NULL; > > -- > > 2.30.0.vfs.0.2