OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

opal_socket_errno.h
1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * $COPYRIGHT$
13 *
14 * Additional copyrights may follow
15 *
16 * $HEADER$
17 */
18 #ifndef OPAL_GET_SOCKET_ERROR_H
19 #define OPAL_GET_SOCKET_ERROR_H
20
21 /* In windows, sockets return differnt error codes than the linux counter parts. Although,
22 one can find there are some similarities in the naming, there are definite differences.
23 opal_socket_errno is defined to be errno under linux and opal_get_socket_errno under
24 windows to ensure that the code which uses errno does not have to be changed. In windows,
25 the mapping is taken care of by opal_get_socket_errno().
26
27 ANYONE USING SOCKET FUNCTIONS' RETURN VALUE PLEASE USE opal_socket_errno INSTEAD
28 OF errno FOR COMPATIBILITY */
29
30 #include <errno.h>
31 #include "opal/constants.h"
32 #ifdef __WINDOWS__
33 #define opal_socket_errno opal_get_socket_errno()
34
35 /* some of these have been defined in newer version of errno.h*/
36 #if (defined(__WINDOWS__) && !defined(_MSC_VER)) || _MSC_VER < 1600
37
38 #define EWOULDBLOCK WSAEWOULDBLOCK
39 #define EINPROGRESS WSAEINPROGRESS
40 #define EALREADY WSAEALREADY
41 #define ENOTSOCK WSAENOTSOCK
42 #define EDESTADDRREQ WSAEDESTADDRREQ
43 #define EMSGSIZE WSAEMSGSIZE
44 #define EPROTOTYPE WSAEPROTOTYPE
45 #define ENOPROTOOPT WSAENOPROTOOPT
46 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
47 #define EOPNOTSUPP WSAEOPNOTSUPP
48 #define EAFNOSUPPORT WSAEAFNOSUPPORT
49 #define EADDRINUSE WSAEADDRINUSE
50 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
51 #define ENETDOWN WSAENETDOWN
52 #define ENETUNREACH WSAENETUNREACH
53 #define ENETRESET WSAENETRESET
54 #define ECONNABORTED WSAECONNABORTED
55 #define ECONNRESET WSAECONNRESET
56 #define ENOBUFS WSAENOBUFS
57 #define EISCONN WSAEISCONN
58 #define ENOTCONN WSAENOTCONN
59 #define ETIMEDOUT WSAETIMEDOUT
60 #define ECONNREFUSED WSAECONNREFUSED
61 #define ELOOP WSAELOOP
62 #define EHOSTUNREACH WSAEHOSTUNREACH
63
64 #endif /*defined(_MSC_VER) && _MSC_VER < 1600*/
65
66 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
67 #define EPFNOSUPPORT WSAEPFNOSUPPORT
68 #define ESHUTDOWN WSAESHUTDOWN
69 #define ETOOMANYREFS WSAETOOMANYREFS
70 #define EHOSTDOWN WSAEHOSTDOWN
71 #define EPROCLIM WSAEPROCLIM
72 #define EUSERS WSAEUSERS
73 #define EDQUOT WSAEDQUOT
74 #define ESTALE WSAESTALE
75 #define EREMOTE WSAEREMOTE
76
77 /*
78 * pound define opal_get_error() to be opal_errno. so, in windows land
79 * this simply defaults to being errno
80 */
81
82 /* return directly from the case statments */
83
84 static __inline int opal_get_socket_errno(void) {
85 int ret = WSAGetLastError();
86 switch (ret) {
87 case WSAEINTR: return EINTR;
88 case WSAEBADF: return EBADF;
89 case WSAEACCES: return EACCES;
90 case WSAEFAULT: return EFAULT;
91 case WSAEINVAL: return EINVAL;
92 case WSAEMFILE: return EMFILE;
93 case WSAEWOULDBLOCK: return EWOULDBLOCK;
94 case WSAEINPROGRESS: return EINPROGRESS;
95 case WSAEALREADY: return EALREADY;
96 case WSAENOTSOCK: return ENOTSOCK;
97 case WSAEDESTADDRREQ: return EDESTADDRREQ;
98 case WSAEMSGSIZE: return EMSGSIZE;
99 case WSAEPROTOTYPE: return EPROTOTYPE;
100 case WSAENOPROTOOPT: return ENOPROTOOPT;
101 case WSAEPROTONOSUPPORT: return EPROTONOSUPPORT;
102 case WSAESOCKTNOSUPPORT: return ESOCKTNOSUPPORT;
103 case WSAEOPNOTSUPP: return EOPNOTSUPP;
104 case WSAEPFNOSUPPORT: return EPFNOSUPPORT;
105 case WSAEAFNOSUPPORT: return EAFNOSUPPORT;
106 case WSAEADDRINUSE: return EADDRINUSE;
107 case WSAEADDRNOTAVAIL: return EADDRNOTAVAIL;
108 case WSAENETDOWN: return ENETDOWN;
109 case WSAENETUNREACH: return ENETUNREACH;
110 case WSAENETRESET: return ENETRESET;
111 case WSAECONNABORTED: return ECONNABORTED;
112 case WSAECONNRESET: return ECONNRESET;
113 case WSAENOBUFS: return ENOBUFS;
114 case WSAEISCONN: return EISCONN;
115 case WSAENOTCONN: return ENOTCONN;
116 case WSAESHUTDOWN: return ESHUTDOWN;
117 case WSAETOOMANYREFS: return ETOOMANYREFS;
118 case WSAETIMEDOUT: return ETIMEDOUT;
119 case WSAECONNREFUSED: return ECONNREFUSED;
120 case WSAELOOP: return ELOOP;
121 case WSAENAMETOOLONG: return ENAMETOOLONG;
122 case WSAEHOSTDOWN: return EHOSTDOWN;
123 case WSAEHOSTUNREACH: return EHOSTUNREACH;
124 case WSAENOTEMPTY: return ENOTEMPTY;
125 case WSAEPROCLIM: return EPROCLIM;
126 case WSAEUSERS: return EUSERS;
127 case WSAEDQUOT: return EDQUOT;
128 case WSAESTALE: return ESTALE;
129 case WSAEREMOTE: return EREMOTE;
130 default: printf("Feature not implemented: %d %s\n", __LINE__, __FILE__); return OPAL_ERROR;
131 };
132 }
133
134 #else
135 #define opal_socket_errno errno
136 #endif
137
138 #endif /* OPAL_GET_ERROR_H */