diff options
author | 2015-03-05 08:40:11 +0100 | |
---|---|---|
committer | 2015-03-05 08:40:11 +0100 | |
commit | ab9dc8369c1a80d75fe685ff058a74c8959d6960 (patch) | |
tree | 0e3300fe874db4d103aa05a698d7c076d7fd1e59 /3rdparty/mongoose/mongoose.c | |
parent | bc2b71f47f225f21e98325c189742190770b4adf (diff) |
sync with latest 3rdparty (nw)
Diffstat (limited to '3rdparty/mongoose/mongoose.c')
-rw-r--r-- | 3rdparty/mongoose/mongoose.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/3rdparty/mongoose/mongoose.c b/3rdparty/mongoose/mongoose.c index aa74d0b2d97..f437fe9141d 100644 --- a/3rdparty/mongoose/mongoose.c +++ b/3rdparty/mongoose/mongoose.c @@ -81,6 +81,8 @@ #ifdef _MSC_VER #pragma comment(lib, "ws2_32.lib") // Linking with winsock library #endif +#include <winsock2.h> +#include <ws2tcpip.h> #include <windows.h> #include <process.h> #ifndef EINPROGRESS @@ -124,7 +126,12 @@ typedef struct _stati64 ns_stat_t; #include <sys/socket.h> #include <sys/select.h> #define closesocket(x) close(x) +#ifndef __OS2__ #define __cdecl +#else +#include <sys/time.h> +typedef int socklen_t; +#endif #define INVALID_SOCKET (-1) #define to64(x) strtoll(x, NULL, 10) typedef int sock_t; @@ -1559,11 +1566,11 @@ static const struct { {NULL, 0, NULL} }; -#ifndef MONGOOSE_NO_THREADS +#ifdef MONGOOSE_ENABLE_THREADS void *mg_start_thread(void *(*f)(void *), void *p) { return ns_start_thread(f, p); } -#endif // MONGOOSE_NO_THREADS +#endif // MONGOOSE_ENABLE_THREADS #ifndef MONGOOSE_NO_MMAP #ifdef _WIN32 @@ -1579,6 +1586,37 @@ static void *mmap(void *addr, int64_t len, int prot, int flags, int fd, #define MAP_FAILED NULL #define MAP_PRIVATE 0 #define PROT_READ 0 +#elif defined(__OS2__) +static void *mmap(void *addr, int64_t len, int prot, int flags, int fd, + int offset) { + void *p; + + int pos = lseek( fd, 0, SEEK_CUR ); /* Get a current position */ + + if (pos == -1) + return NULL; + + /* Seek to offset offset */ + if (lseek( fd, offset, SEEK_SET) == -1) + return NULL; + + p = malloc(len); + + /* Read in a file */ + if (!p || read(fd, p, len) == -1) { + free(p); + p = NULL; + } + + /* Restore the position */ + lseek(fd, pos, SEEK_SET); + + return p; +} +#define munmap(x, y) free(x) +#define MAP_FAILED NULL +#define MAP_PRIVATE 0 +#define PROT_READ 0 #else #include <sys/mman.h> #endif |