]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
libibverbs: convert winverbs values to errno
authorSean Hefty <sean.hefty@intel.com>
Tue, 13 Apr 2010 19:34:48 +0000 (12:34 -0700)
committerSean Hefty <sean.hefty@intel.com>
Tue, 13 Apr 2010 19:34:48 +0000 (12:34 -0700)
Convert status values to errno values and set errno.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
trunk/inc/user/linux/_errno.h [new file with mode: 0755]
trunk/ulp/libibverbs/include/infiniband/verbs.h
trunk/ulp/libibverbs/src/ibv_main.cpp

diff --git a/trunk/inc/user/linux/_errno.h b/trunk/inc/user/linux/_errno.h
new file mode 100755 (executable)
index 0000000..6d17e37
--- /dev/null
@@ -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 <stdio.h>
+
+#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_ */
index 780f938e2f1d4bdefbdb60c965f6f018d59e2d52..4a83b27a26d85f380c31bb0fb80565abf9040f15 100644 (file)
@@ -1136,6 +1136,9 @@ int ibvw_get_windata(struct ibvw_windata *windata, int version);
 __declspec(dllexport)\r
 void ibvw_release_windata(struct ibvw_windata *windata, int version);\r
 \r
+__declspec(dllexport)\r
+int ibvw_errno(HRSULT hr);\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
index 76216e06433c3788b2674e1cb9137beff7ee964c..f480a18ac2a4d635545f33af0bc9669e57330d1a 100644 (file)
@@ -55,3 +55,34 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 \r
        return TRUE;\r
 }\r
+\r
+__declspec(dllexport)\r
+int ibvw_errno(HRSULT hr)\r
+{\r
+       switch (hr) {\r
+       case WV_SUCCESS:                        _set_errno(0); return 0;\r
+       case WV_PENDING:                        _set_errno(EALREADY); break;\r
+       case WV_IO_PENDING:                     _set_errno(EALREADY); break;\r
+       case WV_TIMEOUT:                        _set_errno(ETIMEDOUT); break;\r
+       case WV_BUFFER_OVERFLOW:        _set_errno(EOVERFLOW); break;\r
+       case WV_DEVICE_BUSY:            _set_errno(EBUSY); break;\r
+       case WV_ACCESS_VIOLATION:       _set_errno(EACCES); break;\r
+       case WV_INVALID_HANDLE:         _set_errno(EINVAL); break;\r
+       case WV_INVALID_PARAMETER:      _set_errno(EINVAL); break;\r
+       case WV_NO_MEMORY:                      _set_errno(ENOMEM); break;\r
+       case WV_INSUFFICIENT_RESOURCES: _set_errno(ENOSPC); break;\r
+       case WV_IO_TIMEOUT:                     _set_errno(ETIMEDOUT); break;\r
+       case WV_NOT_SUPPORTED:          _set_errno(ENOSYS); break;\r
+       case WV_CANCELLED:                      _set_errno(ECANCELED); break\r
+       case WV_INVALID_ADDRESS:        _set_errno(EADDRNOTAVAIL); break;\r
+       case WV_ADDRESS_ALREADY_EXISTS: _set_errno(EADDRINUSE); break;\r
+       case WV_CONNECTION_REFUSED:     _set_errno(ECONNREFUSED); break;\r
+       case WV_CONNECTION_INVALID:     _set_errno(ENOTCONN); break;\r
+       case WV_CONNECTION_ACTIVE:      _set_errno(EISCONN); break;\r
+       case WV_HOST_UNREACHABLE:       _set_errno(ENETUNREACH); break;\r
+       case WV_CONNECTION_ABORTED:     _set_errno(ECONNABORTED); break;\r
+       case WV_REMOTE_OP_ERROR:        _set_errno(EREMOTEIO); break;\r
+       case WV_UNKNOWN_ERROR:          _set_errno(eio); break;\r
+       }\r
+       return -1;\r
+}\r