ARC SDK
win32.h
1 // -*- indent-tabs-mode: nil -*-
2 
3 // Disable doxygen as this is not part of the ARC API
5 #ifndef __ARC_WIN32_H__
6 #define __ARC_WIN32_H__
7 #define NOGDI
8 #define WINVER 0x0501 /* we support XP or higher */
9 #define WIN32_LEAN_AND_MEAN
10 
11 #include <windows.h>
12 #include <winsock2.h>
13 #include <ws2tcpip.h>
14 #undef USE_WINSOCK
15 #define USE_WINSOCK 2
16 #include <io.h>
17 #include <winsock2.h>
18 
19 /* Windows redefines CreateDirectory in winbase.h */
20 #ifdef CreateDirectory
21 #undef CreateDirectory
22 #endif
23 
24 #define SIGPIPE 13
25 #define SIGTTIN 21
26 #define SIGTTOU 22
27 #define sleep(x) Sleep((x) * 1000)
28 inline int usleep(int x) { Sleep((x + 999) / 1000); return 0; }
29 #ifndef HAVE_MKSTEMP
30 #ifdef HAVE_MKTEMP
31 inline int mkstemp(char *pattern) {
32  return mktemp(pattern) != '\0';
33 };
34 #endif
35 #endif
36 //#define mkdir(x, y) mkdir((x))
37 //#define lstat stat
38 // no windows functions
39 #define chown(x, y, z) (0)
40 #define lchown(x, y, z) (0)
41 #define fchown(x, y, z) (0)
42 #define symlink(x, y) (-1)
43 //#define link(x, y) (-1)
44 //#define readlink(x, y, z) (-1)
45 #define getuid() (0)
46 #define getgid() (0)
47 
48 // Socket errors are prefixed WSA in winsock2.h
49 #define EWOULDBLOCK WSAEWOULDBLOCK /* Operation would block */
50 #define EINPROGRESS WSAEINPROGRESS /* Operation now in progress */
51 #define EALREADY WSAEALREADY /* Operation already in progress */
52 #define ENOTSOCK WSAENOTSOCK /* Socket operation on non-socket */
53 #define EDESTADDRREQ WSAEDESTADDRREQ /* Destination address required */
54 #define EMSGSIZE WSAEMSGSIZE /* Message too long */
55 #define EPROTOTYPE WSAEPROTOTYPE /* Protocol wrong type for socket */
56 #define ENOPROTOOPT WSAENOPROTOOPT /* Protocol not available */
57 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT /* Protocol not supported */
58 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT /* Socket type not supported */
59 #define EOPNOTSUPP WSAEOPNOTSUPP /* Operation not supported on transport endpoint */
60 #define EPFNOSUPPORT WSAEPFNOSUPPORT /* Protocol family not supported */
61 #define EAFNOSUPPORT WSAEAFNOSUPPORT /* Address family not supported by protocol */
62 #define EADDRINUSE WSAEADDRINUSE /* Address already in use */
63 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL /* Cannot assign requested address */
64 #define ENETDOWN WSAENETDOWN /* Network is down */
65 #define ENETUNREACH WSAENETUNREACH /* Network is unreachable */
66 #define ENETRESET WSAENETRESET /* Network dropped connection because of reset */
67 #define ECONNABORTED WSAECONNABORTED /* Software caused connection abort */
68 #define ECONNRESET WSAECONNRESET /* Connection reset by peer */
69 #define ENOBUFS WSAENOBUFS /* No buffer space available */
70 #define EISCONN WSAEISCONN /* Transport endpoint is already connected */
71 #define ENOTCONN WSAENOTCONN /* Transport endpoint is not connected */
72 #define ESHUTDOWN WSAESHUTDOWN /* Cannot send after transport endpoint shutdown */
73 #define ETOOMANYREFS WSAETOOMANYREFS /* Too many references: cannot splice */
74 #define ETIMEDOUT WSAETIMEDOUT /* Connection timed out */
75 #define ECONNREFUSED WSAECONNREFUSED /* Connection refused */
76 #define ELOOP WSAELOOP /* Too many symbolic links encountered */
77 #define ENAMETOOLONG WSAENAMETOOLONG /* File name too long */
78 #define EHOSTDOWN WSAEHOSTDOWN /* Host is down */
79 #define EHOSTUNREACH WSAEHOSTUNREACH /* No route to host */
80 #define EUSERS WSAEUSERS /* Too many users */
81 #define EDQUOT WSAEDQUOT /* Quota exceeded */
82 #define ESTALE WSAESTALE /* Stale NFS file handle */
83 #define EREMOTE WSAEREMOTE /* Object is remote */
84 
85 inline ssize_t readlink(const char *path, char *buf, size_t bufsiz) {
86  return -1;
87 };
88 
89 #if defined(__cplusplus)
90 #include <sys/stat.h>
91 #include <sys/types.h>
92 inline int mkdir(const char *pathname, mode_t mode) {
93  return ::mkdir(pathname);
94 }
95 #endif
96 
97 inline int link(const char *oldpath, const char *newpath) {
98  return -1;
99 };
100 
101 #if defined(__cplusplus)
102 #include <sys/stat.h>
103 inline int lstat(const char *path, struct stat *buf) {
104  return ::stat(path,buf);
105 };
106 #endif
107 
108 // pwd.h does not exist on windows
109 struct passwd {
110  char *pw_name;
111  char *pw_passwd;
112  int pw_uid;
113  int pw_gid;
114  char *pw_age;
115  char *pw_comment;
116  char *pw_gecos;
117  char *pw_dir;
118  char *pw_shell;
119 };
120 
121 #endif
122 
124