trunk/src/lib/web/mongoose.c
r241699 | r241700 | |
72 | 72 | #include <stdlib.h> |
73 | 73 | #include <string.h> |
74 | 74 | #include <time.h> |
| 75 | #ifdef __OS2__ |
| 76 | #include <sys/time.h> // struct timeval |
| 77 | #endif |
75 | 78 | #include <signal.h> |
76 | 79 | |
77 | 80 | #ifdef _WIN32 |
r241699 | r241700 | |
120 | 123 | #include <sys/socket.h> |
121 | 124 | #include <sys/select.h> |
122 | 125 | #define closesocket(x) close(x) |
| 126 | #ifdef __OS2__ |
| 127 | typedef int socklen_t; |
| 128 | #else |
123 | 129 | #define __cdecl |
| 130 | #endif |
124 | 131 | #define INVALID_SOCKET (-1) |
125 | 132 | #define to64(x) strtoll(x, NULL, 10) |
126 | 133 | typedef int sock_t; |
r241699 | r241700 | |
1170 | 1177 | #include <dlfcn.h> |
1171 | 1178 | #include <inttypes.h> |
1172 | 1179 | #include <pwd.h> |
| 1180 | #ifndef __OS2__ |
1173 | 1181 | #define O_BINARY 0 |
| 1182 | #endif |
1174 | 1183 | #define INT64_FMT PRId64 |
1175 | 1184 | typedef struct stat file_stat_t; |
1176 | 1185 | typedef pid_t process_id_t; |
r241699 | r241700 | |
5152 | 5161 | #define MAP_FAILED NULL |
5153 | 5162 | #define MAP_PRIVATE 0 |
5154 | 5163 | #define PROT_READ 0 |
| 5164 | #elif defined(__OS2__) |
| 5165 | static void *mmap(void *addr, int64_t len, int prot, int flags, int fd, |
| 5166 | int offset) { |
| 5167 | void *p; |
| 5168 | off_t curpos; |
| 5169 | |
| 5170 | p = malloc(len); |
| 5171 | if (!p) |
| 5172 | return NULL; |
| 5173 | |
| 5174 | curpos = lseek(fd, 0, SEEK_CUR); |
| 5175 | lseek(fd, offset, SEEK_SET); |
| 5176 | read(fd, p, len); |
| 5177 | lseek(fd, curpos, SEEK_SET); |
| 5178 | |
| 5179 | return p; |
| 5180 | } |
| 5181 | |
| 5182 | #define munmap(x, y) free(x) |
| 5183 | #define MAP_FAILED NULL |
| 5184 | #define MAP_PRIVATE 0 |
| 5185 | #define PROT_READ 0 |
5155 | 5186 | #else |
5156 | 5187 | #include <sys/mman.h> |
5157 | 5188 | #endif |