[vlc-devel] [PATCH 13/18] Implement vlc_poll() on OS/2
KO Myung-Hun
komh78 at gmail.com
Fri Oct 21 15:15:06 CEST 2011
Rémi Denis-Courmont wrote:
> On Thu, 20 Oct 2011 21:30:20 +0900, KO Myung-Hun <komh at chollian.net>
> wrote:
>> ---
>> configure.ac | 2 +-
>> src/Makefile.am | 1 +
>> src/os2/poll.c | 115
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> src/win32/poll.c | 6 ---
>> 4 files changed, 117 insertions(+), 7 deletions(-)
>> create mode 100644 src/os2/poll.c
>>
>> diff --git a/configure.ac b/configure.ac
>> index ffc1dee..4687149 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -576,7 +576,7 @@ dnl Check for poll
>> AC_SEARCH_LIBS(poll, [poll], [
>> AC_DEFINE(HAVE_POLL, 1, [Define to 1 if the OS has poll().])
>> ], [
>> - AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"], [
>> + AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce" -a
> "${SYS}"
>> != "os2"], [
>> AC_MSG_ERROR([poll() is required.])
>> ])
>> ])
>> diff --git a/src/Makefile.am b/src/Makefile.am
>> index 0e617e2..347afdf 100644
>> --- a/src/Makefile.am
>> +++ b/src/Makefile.am
>> @@ -281,6 +281,7 @@ SOURCES_libvlc_os2 = \
>> misc/atomic.c \
>> posix/filesystem.c \
>> posix/plugin.c \
>> + os2/poll.c \
>> os2/thread.c \
>> os2/specific.c \
>> $(NULL)
>> diff --git a/src/os2/poll.c b/src/os2/poll.c
>> new file mode 100644
>> index 0000000..7a87658
>> --- /dev/null
>> +++ b/src/os2/poll.c
>> @@ -0,0 +1,115 @@
>>
> Either you need this...
>
>> + if (nfds > FD_SETSIZE)
>> + {
>> + errno = EINVAL;
>> + return -1;
>> + }
>> +
>> +resume:
>> + val = -1;
>> + vlc_testcancel ();
>> +
>> + FD_ZERO (&rdset);
>> + FD_ZERO (&wrset);
>> + FD_ZERO (&exset);
>> + for (unsigned i = 0; i < nfds; i++)
>> + {
>> + int fd = fds[i].fd;
>> +
>> + if (fds[i].fd >= FD_SETSIZE)
>> + {
>> + errno = EINVAL;
>> + return -1;
>> + }
>
> ...or you need that, depending how FD_SET() and FD_ISSET() are
> implemented. But I don't see why you'd need both checks.
>
I think, it's possible that nfds is less than fd of fds, logically.
For examples, FD_SETSIZE is 2048, fds[ 0 ].fd = 2049 and nfds = 1.
>> +
>> + if (val < fd)
>> + val = fd;
>> +
>> + if (fds[i].events & POLLIN)
>> + FD_SET (fd, &rdset);
>> + if (fds[i].events & POLLOUT)
>> + FD_SET (fd, &wrset);
>> + if (fds[i].events & POLLPRI)
>> + FD_SET (fd, &exset);
>> + }
>> +
>> +#ifndef HAVE_ALERTABLE_SELECT
>> +# warning FIXME! Fix cancellation and remove this crap.
>
> Nobody bothered to fix this bug in the VLC for Windows. Indeed,
> WSAWaitForMultipleEvents(), WaitForMultipleObjectsEx(), or on Vista
> possibly WSAPoll() should be used instead of plain old select(). I don't
> know OS/2, but there ought to be a better way than this.
>
I know, there are no equivalent OS/2 APIs to WSAWaitForMultipleEvents(),
WaitForMultipleObjectEx() and WSAPoll() of Win32 working on socket.
If I find such APIs, I'll fix this then.
--
KO Myung-Hun
Using Mozilla SeaMonkey 2.0.14
Under OS/2 Warp 4 for Korean with FixPak #15
On AMD ThunderBird 1GHz with 512 MB RAM
Korean OS/2 User Community : http://www.ecomstation.co.kr
More information about the vlc-devel
mailing list