From 47c548e760b6c4447f7b15e7d403060d0051b994 Mon Sep 17 00:00:00 2001 From: "R. Belmont" Date: Tue, 22 Oct 2013 13:36:20 +0000 Subject: [PATCH] SDL: OS/2 build fixes [KO Myung-Hun] --- src/lib/web/mongoose.c | 87 +++++++++++++++++++++++------------------- src/osd/sdl/sdl.mak | 2 +- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/src/lib/web/mongoose.c b/src/lib/web/mongoose.c index e037f37d4da..346c37a6d9f 100644 --- a/src/lib/web/mongoose.c +++ b/src/lib/web/mongoose.c @@ -201,15 +201,6 @@ typedef struct DIR { struct dirent result; } DIR; -#ifndef HAVE_POLL -struct pollfd { - int fd; - short events; - short revents; -}; -#define POLLIN 1 -#endif - // Mark required libraries #ifdef _MSC_VER @@ -219,7 +210,9 @@ struct pollfd { #else // UNIX specific #include #include +#ifdef HAVE_POLL #include +#endif #include #include #include @@ -260,6 +253,20 @@ typedef int SOCKET; #endif // End of Windows and UNIX specific includes +#ifdef __OS2__ +#define NO_SOCKLEN_T +#define SHUT_WR 1 +#endif + +#ifndef HAVE_POLL +struct pollfd { + int fd; + short events; + short revents; +}; +#define POLLIN 1 +#endif + #include "mongoose.h" #define MONGOOSE_VERSION "3.8" @@ -1243,37 +1250,6 @@ static struct dirent *readdir(DIR *dir) { return result; } -#ifndef HAVE_POLL -static int poll(struct pollfd *pfd, int n, int milliseconds) { - struct timeval tv; - fd_set set; - int i, result, maxfd = 0; - - tv.tv_sec = milliseconds / 1000; - tv.tv_usec = (milliseconds % 1000) * 1000; - FD_ZERO(&set); - - for (i = 0; i < n; i++) { - FD_SET((SOCKET) pfd[i].fd, &set); - pfd[i].revents = 0; - - if (pfd[i].fd > maxfd) { - maxfd = pfd[i].fd; - } - } - - if ((result = select(maxfd + 1, &set, NULL, NULL, &tv)) > 0) { - for (i = 0; i < n; i++) { - if (FD_ISSET(pfd[i].fd, &set)) { - pfd[i].revents = POLLIN; - } - } - } - - return result; -} -#endif // HAVE_POLL - #define set_close_on_exec(x) // No FD_CLOEXEC on Windows int mg_start_thread(mg_thread_func_t f, void *p) { @@ -1483,6 +1459,37 @@ static int set_non_blocking_mode(SOCKET sock) { } #endif // _WIN32 +#ifndef HAVE_POLL +static int poll(struct pollfd *pfd, int n, int milliseconds) { + struct timeval tv; + fd_set set; + int i, result, maxfd = 0; + + tv.tv_sec = milliseconds / 1000; + tv.tv_usec = (milliseconds % 1000) * 1000; + FD_ZERO(&set); + + for (i = 0; i < n; i++) { + FD_SET((SOCKET) pfd[i].fd, &set); + pfd[i].revents = 0; + + if (pfd[i].fd > maxfd) { + maxfd = pfd[i].fd; + } + } + + if ((result = select(maxfd + 1, &set, NULL, NULL, &tv)) > 0) { + for (i = 0; i < n; i++) { + if (FD_ISSET(pfd[i].fd, &set)) { + pfd[i].revents = POLLIN; + } + } + } + + return result; +} +#endif // HAVE_POLL + // Write data to the IO channel - opened file descriptor, socket or SSL // descriptor. Return number of bytes written. static int64_t push(FILE *fp, SOCKET sock, SSL *ssl, const char *buf, diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index 39c7df70dbb..604d260b416 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -642,7 +642,7 @@ endif # Win32 ifeq ($(BASE_TARGETOS),os2) INCPATH += `sdl-config --cflags` -LIBS += `sdl-config --libs` +LIBS += `sdl-config --libs` -lpthread endif # OS2