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 208E3A034F; Wed, 31 Mar 2021 15:56:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A195D140EE8; Wed, 31 Mar 2021 15:56:13 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-eopbgr770088.outbound.protection.outlook.com [40.107.77.88]) by mails.dpdk.org (Postfix) with ESMTP id 6C515140EDB for ; Wed, 31 Mar 2021 15:56:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A7t2Kcd+pM9UlVQnLNHCPXBLOwLFhYjYFaKErVARxzePUeWQ9eZXppyvPg9CP1Fk4+RfbrXzARwvBRJEYVyh+xTJgkrwViEPcjJmF3I8IUBo8uCE+tR2LWR1mhmAb7SkhWVkFM5MTbMoC9r5Y7qKj1y61LLL5+zMyzTTN+oDopncfa38GQI99aI5HhTDvgmQqmBmlFWGRFnvYRsB0dqPjIqaJBNuliVYYvfRu04pUBjyLtwYK1RNfdT2vOCjhFvQaZ3z1/EU6Tpxe3NxPSc4zcWNLLOBICqwdakRzLxyHudujR4vH8ieW7iz6oifvwyKuUe6lwJpgTguXfGzDpywkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RYrv1VO7m73hHpjldoxJwVL8v+TmWoFxrIjbUWyv7iI=; b=JtSxpqWJ3Va/CWfITgMP6Ki0H/v+hyqSzsXofnvGLzAgCEE7VgFTkclQ7AfXVwjOlEBhlCjJF8iScmFQ3+Iz0T3CN8hgX95IjECgO+ng6hcyRBv/j4UgKcsyCUf1yKZXwjcD5aofpXJoV4royr5dPwEHCxM1xTWiTtjrKf11huEwsl5d+qSbNIHuMYrlBO5PAbGYsLwPUL28g9HfmhR+NK/3EGBa2PqeRC8jZi64rTkO28PscROTvazVfh+Ccki4y2+DxNDhBsbtZHQxdanOxkUSl7Hin0mJVr+1CDdyY+BDh2xd6o+bJvVOo15BcCvNNGTSQeIQg1WTBkLQsmv6UQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RYrv1VO7m73hHpjldoxJwVL8v+TmWoFxrIjbUWyv7iI=; b=qUWtwPEN+iWABW+MNvobrrF44hUumiyjgN35OQ26JRxnscyCeVlXwI63io++pnaSY2nyGffa0GMNQ0EMUKHaqsUdDq9Mi5CWOgo6donK2MR/7WuIyHWHP77uCO61fcME6S8DI5HjC1zW+3Gu85qY459RKHI7kal5OLLC/+5qRN8uG7xxgUVk78tMsTXwk3S43P1zXew/vGsgl8VeLOdT5h7Q6lWhGQW5tVzrcBqZUQEhWT/cN31hLiSTGZ+U62dZqmNXReEHlcR+cehxsPlN1YIylCJS4qnf4IXCSPdT8eLNWjb8x53z71jn3sQ3YX0etsbZi0/Es/cV8SAQ2eFQLg== Received: from DM6PR12MB3945.namprd12.prod.outlook.com (2603:10b6:5:1c2::27) by DM5PR1201MB0169.namprd12.prod.outlook.com (2603:10b6:4:55::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Wed, 31 Mar 2021 13:56:09 +0000 Received: from DM6PR12MB3945.namprd12.prod.outlook.com ([fe80::9d62:2f16:264b:285d]) by DM6PR12MB3945.namprd12.prod.outlook.com ([fe80::9d62:2f16:264b:285d%5]) with mapi id 15.20.3977.033; Wed, 31 Mar 2021 13:56:09 +0000 From: Tal Shnaiderman To: Narcisa Ana Maria Vasile , "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" CC: "bruce.richardson@intel.com" , "david.marchand@redhat.com" , "pallavi.kadam@intel.com" Thread-Topic: [PATCH v5 03/10] windows/eal: translate Windows errors to errno-style errors Thread-Index: AQHXJOyP/NKDexPtBkCzznVMKqdjRqqeG09Q Date: Wed, 31 Mar 2021 13:56:09 +0000 Message-ID: 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> In-Reply-To: <1617057640-24301-4-git-send-email-navasile@linux.microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linux.microsoft.com; dkim=none (message not signed) header.d=none;linux.microsoft.com; dmarc=none action=none header.from=nvidia.com; x-originating-ip: [5.29.59.30] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a6f16097-a967-49cf-ef56-08d8f44cbcd4 x-ms-traffictypediagnostic: DM5PR1201MB0169: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-transport-forked: True x-ms-oob-tlc-oobclassifiers: OLM:4303; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: LVLFoIqPShbbTZQF9nJtAn7rTmBKEBLv3mEh9dkBORPdNAyjZaecZhH4vs0DhS/QcMuGdKWis2/kkYTpyxf5BYp5nz9FEXll40RFHUSr8VpLip5aoIz0JflQcntOEdIZ7Adawym3AJiZuWjbQkPpHSsYsHspariBWI8E/q2xbJtClvvsqlvDO4wddumYsOWE2GO1nM3eBWK/BUG+zi/Z0Y7TDfyEfMA8Hb1gJLa6pzN8Fx8o1N7kVXJ+yOuTjI9OEpmyDqsre3ICqr8MozOndszc+q4X34kzR0+BUvOGZoAa+INC80PTSwehYqPGzueYnCw8djcKXpZOM5zvyiC3iM73cW+098TwkVxOL0vHqHLRe7xbp3GOlY2QKV0tQIeYDO9yaPF1G7m8xwRODWT753QIYDsrvVcw5MG3YfAmelbOJ8zr+AXWx8t50vTPCEgxa6uCGd0gyPwHuFDOB83xdkpsLaeock/jFFR13/hG+VzIO3lP9GZMbn7op8TRghPlyRVC9NQL/i8+FDwrLWL50s+QTRq7wFzS803DgUdavMzlsnp/pZQv56VWlWxFO401aYomYd9eNYam5bUrZ5WxLNiDvgko5Q/Vjl1iQIgdl8Cwa4gMLiG1h8F+utpyrH+2JbrVkAMqQeqXkQRWgtSjaGJRvEmczZDassIKpNudM9o= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB3945.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(346002)(396003)(376002)(39860400002)(7696005)(26005)(478600001)(186003)(38100700001)(55016002)(83380400001)(316002)(7416002)(6506007)(71200400001)(2906002)(9686003)(66946007)(76116006)(66476007)(86362001)(64756008)(33656002)(8676002)(5660300002)(66556008)(110136005)(8936002)(66446008)(4326008)(52536014)(54906003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?/afTB1E8YL6OsGROV5GQhool5S7JNGml1JYRmU3f7dZnT8A/jVNr+xxQ1pKG?= =?us-ascii?Q?ETpj4BkPIVBp1Ly4tui6LxvfViSMwrAfsvswBFORnjtK1GfVwXnm2ZTYEKs3?= =?us-ascii?Q?mfrBlso9muUSPA29dvks3Dw1c+PJOQeCRQld2sJyeU8pP/pbC2ky2ttX1Uv6?= =?us-ascii?Q?J28ezv5q1kGEbGolzCRY+I2Ryku1J2N5bRn9YnXB14Z/Mn87bzL2WL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alCcI+oz29Q3O33zdpMu6FGyeRc+vEmKndLP9JKpx?= =?us-ascii?Q?BFjdd6AyIQUi4vKz4Wm7sxfu9jOfS+ZS56KnDDwCEW5Pje0M1AmXKGh4zrhx?= =?us-ascii?Q?pjT0JndxdWfwfucU0TbI63N+x/inHmkXPWHXojHguA28bDb1U+jaZZTe5g2L?= =?us-ascii?Q?ozqkExrE6f77+0S14m4dbA80BujDv4uuU5yQNZNbNlREsuII6zud311vWLFh?= =?us-ascii?Q?Pps=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3945.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6f16097-a967-49cf-ef56-08d8f44cbcd4 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Mar 2021 13:56:09.4749 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: St3GoqbY+1GOE+4QADD8Du0fxHnptj7NUTcqziqYVez8kp3ttPs8UqG5u55KWo/7/2coRQvx9RfvlOUHQ33BBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0169 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" > Subject: [PATCH v5 03/10] windows/eal: translate Windows errors to errno- > style errors >=20 > External email: Use caution opening links or attachments >=20 >=20 > From: Narcisa Vasile >=20 > Add function to translate Windows error codes to errno-style error codes. >=20 > Signed-off-by: Narcisa Vasile > --- > lib/librte_eal/windows/rte_thread.c | 65 ++++++++++++++++++++++------- > 1 file changed, 50 insertions(+), 15 deletions(-) >=20 > 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; > }; >=20 > +/* 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 mov= e it inside the function? Also, I don't think this is a thread specific function, other implementatio= ns can use it in the future, maybe move it to rte_windows.h?=20 > + 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; > +} > + > rte_thread_t > rte_thread_self(void) > { > @@ -87,15 +128,13 @@ rte_thread_key_create(rte_thread_key *key, > *key =3D malloc(sizeof(**key)); > if ((*key) =3D=3D NULL) { > RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); > - rte_errno =3D ENOMEM; > - return -1; > + return ENOMEM; > } > (*key)->thread_index =3D TlsAlloc(); > if ((*key)->thread_index =3D=3D TLS_OUT_OF_INDEXES) { > RTE_LOG_WIN32_ERR("TlsAlloc()"); > free(*key); > - rte_errno =3D ENOEXEC; > - return -1; > + return rte_thread_translate_win32_error(GetLastError()); > } > return 0; > } > @@ -103,16 +142,14 @@ rte_thread_key_create(rte_thread_key *key, int > rte_thread_key_delete(rte_thread_key key) { > - if (!key) { > + if (key =3D=3D NULL) { > RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); > - rte_errno =3D EINVAL; > - return -1; > + return EINVAL; > } > if (!TlsFree(key->thread_index)) { > RTE_LOG_WIN32_ERR("TlsFree()"); > free(key); > - rte_errno =3D ENOEXEC; > - return -1; > + return rte_thread_translate_win32_error(GetLastError()); > } > free(key); > return 0; > @@ -123,17 +160,15 @@ rte_thread_value_set(rte_thread_key key, const > void *value) { > char *p; >=20 > - if (!key) { > + if (key =3D=3D NULL) { > RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); > - rte_errno =3D EINVAL; > - return -1; > + return EINVAL; > } > /* discard const qualifier */ > p =3D (char *) (uintptr_t) value; > if (!TlsSetValue(key->thread_index, p)) { > RTE_LOG_WIN32_ERR("TlsSetValue()"); > - rte_errno =3D ENOEXEC; > - return -1; > + return rte_thread_translate_win32_error(GetLastError()); > } > return 0; > } > @@ -143,7 +178,7 @@ rte_thread_value_get(rte_thread_key key) { > void *output; >=20 This function is missing the change to rte_thread_translate_win32_error. Aldo need to change function docu. > - if (!key) { > + if (key =3D=3D NULL) { > RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n"); > rte_errno =3D EINVAL; > return NULL; > -- > 2.30.0.vfs.0.2