From d8dd1c3326cc56a6d580b96d2cc1f40321b26134 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Tue, 13 Apr 2010 12:34:48 -0700 Subject: [PATCH] libibverbs: convert winverbs values to errno Convert status values to errno values and set errno. Signed-off-by: Sean Hefty --- trunk/inc/user/linux/_errno.h | 55 +++++++++++++++++++ .../ulp/libibverbs/include/infiniband/verbs.h | 3 + trunk/ulp/libibverbs/src/ibv_main.cpp | 31 +++++++++++ 3 files changed, 89 insertions(+) create mode 100755 trunk/inc/user/linux/_errno.h diff --git a/trunk/inc/user/linux/_errno.h b/trunk/inc/user/linux/_errno.h new file mode 100755 index 00000000..6d17e37a --- /dev/null +++ b/trunk/inc/user/linux/_errno.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2009 Intel Corp, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifndef _UNISTD_H_ +#define _UNISTD_H_ + +#include + +#define sleep(s) SleepEx(s * 1000, TRUE) + +static __inline int getdomainname(char *name, size_t len) +{ + return -1; +} + +static __inline char* getpass(char *message) +{ + static char password[128]; + + printf("%s", message); + scanf_s("%127s", password, 128); + return password; +} + +#endif /* _UNISTD_H_ */ diff --git a/trunk/ulp/libibverbs/include/infiniband/verbs.h b/trunk/ulp/libibverbs/include/infiniband/verbs.h index 780f938e..4a83b27a 100644 --- a/trunk/ulp/libibverbs/include/infiniband/verbs.h +++ b/trunk/ulp/libibverbs/include/infiniband/verbs.h @@ -1136,6 +1136,9 @@ int ibvw_get_windata(struct ibvw_windata *windata, int version); __declspec(dllexport) void ibvw_release_windata(struct ibvw_windata *windata, int version); +__declspec(dllexport) +int ibvw_errno(HRSULT hr); + #ifdef __cplusplus } #endif diff --git a/trunk/ulp/libibverbs/src/ibv_main.cpp b/trunk/ulp/libibverbs/src/ibv_main.cpp index 76216e06..f480a18a 100644 --- a/trunk/ulp/libibverbs/src/ibv_main.cpp +++ b/trunk/ulp/libibverbs/src/ibv_main.cpp @@ -55,3 +55,34 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) return TRUE; } + +__declspec(dllexport) +int ibvw_errno(HRSULT hr) +{ + switch (hr) { + case WV_SUCCESS: _set_errno(0); return 0; + case WV_PENDING: _set_errno(EALREADY); break; + case WV_IO_PENDING: _set_errno(EALREADY); break; + case WV_TIMEOUT: _set_errno(ETIMEDOUT); break; + case WV_BUFFER_OVERFLOW: _set_errno(EOVERFLOW); break; + case WV_DEVICE_BUSY: _set_errno(EBUSY); break; + case WV_ACCESS_VIOLATION: _set_errno(EACCES); break; + case WV_INVALID_HANDLE: _set_errno(EINVAL); break; + case WV_INVALID_PARAMETER: _set_errno(EINVAL); break; + case WV_NO_MEMORY: _set_errno(ENOMEM); break; + case WV_INSUFFICIENT_RESOURCES: _set_errno(ENOSPC); break; + case WV_IO_TIMEOUT: _set_errno(ETIMEDOUT); break; + case WV_NOT_SUPPORTED: _set_errno(ENOSYS); break; + case WV_CANCELLED: _set_errno(ECANCELED); break + case WV_INVALID_ADDRESS: _set_errno(EADDRNOTAVAIL); break; + case WV_ADDRESS_ALREADY_EXISTS: _set_errno(EADDRINUSE); break; + case WV_CONNECTION_REFUSED: _set_errno(ECONNREFUSED); break; + case WV_CONNECTION_INVALID: _set_errno(ENOTCONN); break; + case WV_CONNECTION_ACTIVE: _set_errno(EISCONN); break; + case WV_HOST_UNREACHABLE: _set_errno(ENETUNREACH); break; + case WV_CONNECTION_ABORTED: _set_errno(ECONNABORTED); break; + case WV_REMOTE_OP_ERROR: _set_errno(EREMOTEIO); break; + case WV_UNKNOWN_ERROR: _set_errno(eio); break; + } + return -1; +} -- 2.46.0