Ticket #1: poll.2.diff
File poll.2.diff, 31.4 KB (added by , 9 years ago) |
---|
-
\src\libs\Makefile.kmk
old new 24 24 # include path specific to the lib has been changed. 25 25 # 26 26 27 if1of ($(KBUILD_TARGET), os2) 28 include $(PATH_SUB_CURRENT)/zlib-1.2.6/Makefile.kmk 29 include $(PATH_SUB_CURRENT)/libxml2-2.9.2/Makefile.kmk 30 include $(PATH_SUB_CURRENT)/poll-os2/Makefile.kmk 31 endif 32 27 33 # Compression libs used by IPRT and <what was it again?>. 28 34 include $(PATH_SUB_CURRENT)/liblzf-3.4/Makefile.kmk 29 35 if !defined(VBOX_ONLY_SDK) \ -
\src\libs\poll-os2/ChangeLog
diff -urN vbox-trunk-bk\src\libs\poll-os2/ChangeLog vbox-trunk\src\libs\poll-os2/ChangeLog
old new 1 $Id: ChangeLog,v 1.1.1.1 2003/07/21 16:20:21 zarzycki Exp $ 2 3 Version 1.4 (2003-01-01) 4 5 * Now handles and ignores bad file descriptors (i.e., descriptors 6 with negative values) in poll array. Change is based on a patch 7 submitted by Dave Smith <dizzyd@jabber.org> 8 9 Version 1.3 (2002-09-30) 10 11 * Incorporated changes to Makefile for building on Mac OS/X. 12 (Thanks to Benjamin Reed <ranger@befunk.com>) 13 14 Version 1.2 (2002-05-11) 15 16 * Changed WillsCreek.com references to clapper.org. 17 * Added license info to source code comments 18 -
\src\libs\poll-os2/install.sh
diff -urN vbox-trunk-bk\src\libs\poll-os2/install.sh vbox-trunk\src\libs\poll-os2/install.sh
old new 1 #!/bin/sh 2 3 # 4 # install - install a program, script, or datafile 5 # This comes from X11R5; it is not part of GNU. 6 # 7 # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ 8 # 9 # This script is compatible with the BSD install script, but was written 10 # from scratch. 11 # 12 13 14 # set DOITPROG to echo to test this script 15 16 # Don't use :- since 4.3BSD and earlier shells don't like it. 17 doit="${DOITPROG-}" 18 19 20 # put in absolute paths if you don't have them in your path; or use env. vars. 21 22 mvprog="${MVPROG-mv}" 23 cpprog="${CPPROG-cp}" 24 chmodprog="${CHMODPROG-chmod}" 25 chownprog="${CHOWNPROG-chown}" 26 chgrpprog="${CHGRPPROG-chgrp}" 27 stripprog="${STRIPPROG-strip}" 28 rmprog="${RMPROG-rm}" 29 30 instcmd="$mvprog" 31 chmodcmd="" 32 chowncmd="" 33 chgrpcmd="" 34 stripcmd="" 35 rmcmd="$rmprog -f" 36 mvcmd="$mvprog" 37 src="" 38 dst="" 39 40 while [ x"$1" != x ]; do 41 case $1 in 42 -c) instcmd="$cpprog" 43 shift 44 continue;; 45 46 -m) chmodcmd="$chmodprog $2" 47 shift 48 shift 49 continue;; 50 51 -o) chowncmd="$chownprog $2" 52 shift 53 shift 54 continue;; 55 56 -g) chgrpcmd="$chgrpprog $2" 57 shift 58 shift 59 continue;; 60 61 -s) stripcmd="$stripprog" 62 shift 63 continue;; 64 65 *) if [ x"$src" = x ] 66 then 67 src=$1 68 else 69 dst=$1 70 fi 71 shift 72 continue;; 73 esac 74 done 75 76 if [ x"$src" = x ] 77 then 78 echo "install: no input file specified" 79 exit 1 80 fi 81 82 if [ x"$dst" = x ] 83 then 84 echo "install: no destination specified" 85 exit 1 86 fi 87 88 89 # If destination is a directory, append the input filename; if your system 90 # does not like double slashes in filenames, you may need to add some logic 91 92 if [ -d $dst ] 93 then 94 dst="$dst"/`basename $src` 95 fi 96 97 # Make a temp file name in the proper directory. 98 99 dstdir=`dirname $dst` 100 dsttmp=$dstdir/#inst.$$# 101 102 # Move or copy the file name to the temp name 103 104 $doit $instcmd $src $dsttmp 105 106 # and set any options; do chmod last to preserve setuid bits 107 108 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi 109 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi 110 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi 111 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi 112 113 # Now rename the file to the real destination. 114 115 $doit $rmcmd $dst 116 $doit $mvcmd $dsttmp $dst 117 118 119 exit 0 120 -
\src\libs\poll-os2/INSTALL
diff -urN vbox-trunk-bk\src\libs\poll-os2/INSTALL vbox-trunk\src\libs\poll-os2/INSTALL
old new 1 $Id: INSTALL,v 1.1.1.1 2003/07/21 16:20:21 zarzycki Exp $ 2 --------------------------------------------------------------------------- 3 4 Building and installing 5 6 1) Edit the Makefile, adjusting any necessary definitions. Pay specific 7 attention to the value of PREFIX and the compiler settings. 8 2) Type "make" to build the "libpoll.a" and "libpoll.so" libraries. 9 3) Type "make install" to install the shared and static libraries in 10 $(PREFIX)/lib (default: /usr/local/lib) and the poll.h header file 11 in $(PREFIX)/include (default: /usr/local/include) 12 13 14 Using the poll emulator 15 16 Compiling: 17 18 To compile a program that wants the poll.h header file, you need 19 to include the appropriate "-I" option on the compiler command line. 20 If you set PREFIX to "/usr/local", then use "-I/usr/local/include". 21 For instance: 22 23 cc -c -I/usr/local/include mypollprog.c 24 25 Linking: 26 27 To link a program that uses poll, you need to link against the 28 static or shared version of the library you built and installed. 29 Use the "-L" and "-l" options: 30 31 cc -o mypollprog mypollprog.o -L/usr/local/lib -lpoll 32 33 If you need to force static linkage, add "-static" (with gcc) to 34 force use of "libpoll.a": 35 36 cc -o mypollprog mypollprog.o -L/usr/local/lib -lpoll -static 37 --------------------------------------------------------------------------- 38 ª®æ¥ ä ©« ¥â ®¢®© áâபš -
\src\libs\poll-os2/LICENSE
diff -urN vbox-trunk-bk\src\libs\poll-os2/LICENSE vbox-trunk\src\libs\poll-os2/LICENSE
old new 1 LICENSE 2 3 $Id: LICENSE,v 1.1.1.1 2003/07/21 16:20:21 zarzycki Exp $ 4 5 This software is released under the following license: 6 7 Copyright (c) 1995-2002 Brian M. Clapper 8 All rights reserved. 9 10 Redistribution and use in source and binary forms are permitted 11 provided that: (1) source distributions retain this entire 12 copyright notice and comment; (2) modifications made to the 13 software are prominently mentioned, and a copy of the original 14 software (or a pointer to its location) are included; and (3) 15 distributions including binaries display the following 16 acknowledgement: "This product includes software developed by Brian 17 M. Clapper <bmc@clapper.org>" in the documentation or other 18 materials provided with the distribution. The name of the author 19 may not be used to endorse or promote products derived from this 20 software without specific prior written permission. 21 22 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 23 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 25 26 Effectively, this means you can do what you want with the software except 27 remove this notice or take advantage of the author's name. If you modify 28 the software and redistribute your modified version, you must indicate that 29 your version is a modification of the original, and you must provide either 30 a pointer to or a copy of the original. 31 ª®æ¥ ä ©« ¥â ®¢®© áâபš -
\src\libs\poll-os2/Makefile
diff -urN vbox-trunk-bk\src\libs\poll-os2/Makefile vbox-trunk\src\libs\poll-os2/Makefile
old new 1 # Makefile for poll(2) emulator 2 # 3 # $Id: Makefile,v 1.3 2003/08/31 18:31:28 emoy Exp $ 4 # --------------------------------------------------------------------------- 5 6 ############################################################################# 7 # Definitions that you need to edit 8 ############################################################################# 9 10 # --------------------------------------------------------------------------- 11 # Installation prefix 12 13 PREFIX = /usr/local 14 LIBDIR = $(PREFIX)/lib 15 INCDIR = $(PREFIX)/include 16 17 # --------------------------------------------------------------------------- 18 # Platform-specific bits 19 # 20 # For GNU CC on *BSD. Should work for FreeBSD, NetBSD, OpenBSD and BSD/OS 21 LINK_SHARED = $(CC) -dynamiclib 22 SHLIB_EXT = so 23 SHLIB_NOVER = $(LIB_NAME).$(SHLIB_EXT) 24 SHLIB = $(LIB_NAME).$(SHLIB_EXT).$(VERSION) 25 SHLIB_INSTALLED = $(LIBDIR)/$(LIB_NAME).$(SHLIB_EXT).$(MAJOR) 26 27 # Benjamin Reed <ranger@befunk.com>: 28 # On Mac OS X, comment out the above lines, and uncomment these instead. 29 #LINK_SHARED = $(CC) -install_name $(PREFIX)/lib/$(SHLIB) \ 30 # -compatibility_version $(COMPAT_VERSION) \ 31 # -current_version $(VERSION) -dynamiclib 32 #SHLIB_EXT = dylib 33 #SHLIB_NOVER = $(LIB_NAME).$(SHLIB_EXT) 34 #SHLIB = $(LIB_NAME).$(VERSION).$(SHLIB_EXT) 35 #SHLIB_INSTALLED= $(LIBDIR)/$(LIB_NAME).$(MAJOR).$(SHLIB_EXT) 36 37 # If you have a BSD-compatible install(1), use: 38 INSTALL = install -c 39 40 # If you do not have a BSD-compatible install(1), use: 41 #INSTALL = ./install.sh -c 42 43 # --------------------------------------------------------------------------- 44 # Compilation and Linkage 45 46 MAJOR = 1 47 MINOR = 3 48 VERSION = $(MAJOR).$(MINOR) 49 COMPAT_VERSION = $(MAJOR) 50 CC = cc 51 LIB_NAME = libpoll 52 LIB = $(LIB_NAME).a 53 COMPILE_STATIC = $(CC) $(CFLAGS) -c 54 COMPILE_SHARED = $(CC) $(CFLAGS) -c 55 RANLIB = ranlib 56 57 ############################################################################# 58 # There should be no need to edit past this point 59 ############################################################################# 60 61 .SUFFIXES: .po 62 63 .c.po: 64 $(COMPILE_SHARED) $< -o $*.po 65 .c.o: 66 $(COMPILE_STATIC) $< 67 68 all: libs 69 libs: $(SHLIB) $(LIB) 70 test: polltest 71 72 dirs: 73 @echo "creating directories..." 74 $(INSTALL) -m 755 -d $(LIBDIR) 75 $(INSTALL) -m 755 -d $(INCDIR) 76 77 install: all dirs 78 $(INSTALL) -m 755 $(SHLIB) $(LIB) $(LIBDIR) 79 ln -sf $(SHLIB) $(SHLIB_INSTALLED) 80 ln -sf $(SHLIB) $(LIBDIR)/$(SHLIB_NOVER) 81 $(INSTALL) -m 644 poll.h $(INCDIR) 82 83 clean: 84 rm -f poll.po *.o $(LIB) $(SHLIB) $(SHLIB_NOVER) polltest 85 86 $(SHLIB): poll.po 87 $(LINK_SHARED) -o $(SHLIB) poll.po 88 $(LIB): poll.o 89 ar rv $(LIB) poll.o 90 ranlib $(LIB) 91 polltest: polltest.o 92 $(CC) -o polltest polltest.o $(LIB) 93 -
\src\libs\poll-os2/Makefile.kmk
diff -urN vbox-trunk-bk\src\libs\poll-os2/Makefile.kmk vbox-trunk\src\libs\poll-os2/Makefile.kmk
old new 1 # $Id: Makefile.kmk 56301 2015-06-09 14:38:36Z vboxsync $ 2 ## @file 3 # Sub-Makefile for zlib. 4 # 5 6 # 7 # Copyright (C) 2006-2015 Oracle Corporation 8 # 9 # This file is part of VirtualBox Open Source Edition (OSE), as 10 # available from http://www.virtualbox.org. This file is free software; 11 # you can redistribute it and/or modify it under the terms of the GNU 12 # General Public License (GPL) as published by the Free Software 13 # Foundation, in version 2 as it comes in the "COPYING" file of the 14 # VirtualBox OSE distribution. VirtualBox OSE is distributed in the 15 # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 # 17 18 SUB_DEPTH = ../../.. 19 include $(KBUILD_PATH)/subheader.kmk 20 21 LIBRARIES += VBox-os2-poll 22 VBox-os2-poll_TEMPLATE = VBOXR3 23 VBox-os2-poll_INCS = . 24 VBox-os2-poll_SOURCES = \ 25 poll.c 26 27 include $(FILE_KBUILD_SUB_FOOTER) -
\src\libs\poll-os2/poll.c
diff -urN vbox-trunk-bk\src\libs\poll-os2/poll.c vbox-trunk\src\libs\poll-os2/poll.c
old new 1 /*---------------------------------------------------------------------------*\ 2 $Id: poll.c,v 1.1.1.1 2003/07/21 16:20:21 zarzycki Exp $ 3 4 NAME 5 6 poll - select(2)-based poll() emulation function for BSD systems. 7 8 SYNOPSIS 9 #include "poll.h" 10 11 struct pollfd 12 { 13 int fd; 14 short events; 15 short revents; 16 } 17 18 int poll (struct pollfd *pArray, unsigned long n_fds, int timeout) 19 20 DESCRIPTION 21 22 This file, and the accompanying "poll.h", implement the System V 23 poll(2) system call for BSD systems (which typically do not provide 24 poll()). Poll() provides a method for multiplexing input and output 25 on multiple open file descriptors; in traditional BSD systems, that 26 capability is provided by select(). While the semantics of select() 27 differ from those of poll(), poll() can be readily emulated in terms 28 of select() -- which is how this function is implemented. 29 30 REFERENCES 31 Stevens, W. Richard. Unix Network Programming. Prentice-Hall, 1990. 32 33 NOTES 34 1. This software requires an ANSI C compiler. 35 36 LICENSE 37 38 This software is released under the following license: 39 40 Copyright (c) 1995-2002 Brian M. Clapper 41 All rights reserved. 42 43 Redistribution and use in source and binary forms are 44 permitted provided that: (1) source distributions retain 45 this entire copyright notice and comment; (2) modifications 46 made to the software are prominently mentioned, and a copy 47 of the original software (or a pointer to its location) are 48 included; and (3) distributions including binaries display 49 the following acknowledgement: "This product includes 50 software developed by Brian M. Clapper <bmc@clapper.org>" 51 in the documentation or other materials provided with the 52 distribution. The name of the author may not be used to 53 endorse or promote products derived from this software 54 without specific prior written permission. 55 56 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS 57 OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE 58 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 59 PARTICULAR PURPOSE. 60 61 Effectively, this means you can do what you want with the software 62 except remove this notice or take advantage of the author's name. 63 If you modify the software and redistribute your modified version, 64 you must indicate that your version is a modification of the 65 original, and you must provide either a pointer to or a copy of the 66 original. 67 \*---------------------------------------------------------------------------*/ 68 69 70 /*---------------------------------------------------------------------------*\ 71 Includes 72 \*---------------------------------------------------------------------------*/ 73 74 #include <unistd.h> /* standard Unix definitions */ 75 #include <sys/types.h> /* system types */ 76 #include <sys/time.h> /* time definitions */ 77 #include <assert.h> /* assertion macros */ 78 #include <string.h> /* string functions */ 79 #include "poll.h" /* this package */ 80 81 /*---------------------------------------------------------------------------*\ 82 Macros 83 \*---------------------------------------------------------------------------*/ 84 85 #ifndef MAX 86 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 87 #endif 88 89 90 /*---------------------------------------------------------------------------*\ 91 Private Functions 92 \*---------------------------------------------------------------------------*/ 93 94 static int map_poll_spec 95 #if __STDC__ > 0 96 (struct pollfd *pArray, 97 unsigned long n_fds, 98 fd_set *pReadSet, 99 fd_set *pWriteSet, 100 fd_set *pExceptSet) 101 #else 102 (pArray, n_fds, pReadSet, pWriteSet, pExceptSet) 103 struct pollfd *pArray; 104 unsigned long n_fds; 105 fd_set *pReadSet; 106 fd_set *pWriteSet; 107 fd_set *pExceptSet; 108 #endif 109 { 110 register unsigned long i; /* loop control */ 111 register struct pollfd *pCur; /* current array element */ 112 register int max_fd = -1; /* return value */ 113 114 /* 115 Map the poll() structures into the file descriptor sets required 116 by select(). 117 */ 118 for (i = 0, pCur = pArray; i < n_fds; i++, pCur++) 119 { 120 /* Skip any bad FDs in the array. */ 121 122 if (pCur->fd < 0) 123 continue; 124 125 if (pCur->events & POLLIN) 126 { 127 /* "Input Ready" notification desired. */ 128 FD_SET (pCur->fd, pReadSet); 129 } 130 131 if (pCur->events & POLLOUT) 132 { 133 /* "Output Possible" notification desired. */ 134 FD_SET (pCur->fd, pWriteSet); 135 } 136 137 if (pCur->events & POLLPRI) 138 { 139 /* 140 "Exception Occurred" notification desired. (Exceptions 141 include out of band data. 142 */ 143 FD_SET (pCur->fd, pExceptSet); 144 } 145 146 max_fd = MAX (max_fd, pCur->fd); 147 } 148 149 return max_fd; 150 } 151 152 static struct timeval *map_timeout 153 #if __STDC__ > 0 154 (int poll_timeout, struct timeval *pSelTimeout) 155 #else 156 (poll_timeout, pSelTimeout) 157 int poll_timeout; 158 struct timeval *pSelTimeout; 159 #endif 160 { 161 struct timeval *pResult; 162 163 /* 164 Map the poll() timeout value into a select() timeout. The possible 165 values of the poll() timeout value, and their meanings, are: 166 167 VALUE MEANING 168 169 -1 wait indefinitely (until signal occurs) 170 0 return immediately, don't block 171 >0 wait specified number of milliseconds 172 173 select() uses a "struct timeval", which specifies the timeout in 174 seconds and microseconds, so the milliseconds value has to be mapped 175 accordingly. 176 */ 177 178 assert (pSelTimeout != (struct timeval *) NULL); 179 180 switch (poll_timeout) 181 { 182 case -1: 183 /* 184 A NULL timeout structure tells select() to wait indefinitely. 185 */ 186 pResult = (struct timeval *) NULL; 187 break; 188 189 case 0: 190 /* 191 "Return immediately" (test) is specified by all zeros in 192 a timeval structure. 193 */ 194 pSelTimeout->tv_sec = 0; 195 pSelTimeout->tv_usec = 0; 196 pResult = pSelTimeout; 197 break; 198 199 default: 200 /* Wait the specified number of milliseconds. */ 201 pSelTimeout->tv_sec = poll_timeout / 1000; /* get seconds */ 202 poll_timeout %= 1000; /* remove seconds */ 203 pSelTimeout->tv_usec = poll_timeout * 1000; /* get microseconds */ 204 pResult = pSelTimeout; 205 break; 206 } 207 208 209 return pResult; 210 } 211 212 static void map_select_results 213 #if __STDC__ > 0 214 (struct pollfd *pArray, 215 unsigned long n_fds, 216 fd_set *pReadSet, 217 fd_set *pWriteSet, 218 fd_set *pExceptSet) 219 #else 220 (pArray, n_fds, pReadSet, pWriteSet, pExceptSet) 221 struct pollfd *pArray; 222 unsigned long n_fds; 223 fd_set *pReadSet; 224 fd_set *pWriteSet; 225 fd_set *pExceptSet; 226 #endif 227 { 228 register unsigned long i; /* loop control */ 229 register struct pollfd *pCur; /* current array element */ 230 231 for (i = 0, pCur = pArray; i < n_fds; i++, pCur++) 232 { 233 /* Skip any bad FDs in the array. */ 234 235 if (pCur->fd < 0) 236 continue; 237 238 /* Exception events take priority over input events. */ 239 240 pCur->revents = 0; 241 if (FD_ISSET (pCur->fd, pExceptSet)) 242 pCur->revents |= POLLPRI; 243 244 else if (FD_ISSET (pCur->fd, pReadSet)) 245 pCur->revents |= POLLIN; 246 247 if (FD_ISSET (pCur->fd, pWriteSet)) 248 pCur->revents |= POLLOUT; 249 } 250 251 return; 252 } 253 254 /*---------------------------------------------------------------------------*\ 255 Public Functions 256 \*---------------------------------------------------------------------------*/ 257 258 int poll 259 260 #if __STDC__ > 0 261 (struct pollfd *pArray, unsigned long n_fds, int timeout) 262 #else 263 (pArray, n_fds, timeout) 264 struct pollfd *pArray; 265 unsigned long n_fds; 266 int timeout; 267 #endif 268 269 { 270 fd_set read_descs; /* input file descs */ 271 fd_set write_descs; /* output file descs */ 272 fd_set except_descs; /* exception descs */ 273 struct timeval stime; /* select() timeout value */ 274 int ready_descriptors; /* function result */ 275 int max_fd; /* maximum fd value */ 276 struct timeval *pTimeout; /* actually passed */ 277 278 FD_ZERO (&read_descs); 279 FD_ZERO (&write_descs); 280 FD_ZERO (&except_descs); 281 282 assert (pArray != (struct pollfd *) NULL); 283 284 /* Map the poll() file descriptor list in the select() data structures. */ 285 286 max_fd = map_poll_spec (pArray, n_fds, 287 &read_descs, &write_descs, &except_descs); 288 289 /* Map the poll() timeout value in the select() timeout structure. */ 290 291 pTimeout = map_timeout (timeout, &stime); 292 293 /* Make the select() call. */ 294 295 ready_descriptors = select (max_fd + 1, &read_descs, &write_descs, 296 &except_descs, pTimeout); 297 298 if (ready_descriptors >= 0) 299 { 300 map_select_results (pArray, n_fds, 301 &read_descs, &write_descs, &except_descs); 302 } 303 304 return ready_descriptors; 305 } -
\src\libs\poll-os2/poll.h
diff -urN vbox-trunk-bk\src\libs\poll-os2/poll.h vbox-trunk\src\libs\poll-os2/poll.h
old new 1 /*---------------------------------------------------------------------------*\ 2 $Id: poll.h,v 1.2 2003/09/13 00:08:18 eseidel Exp $ 3 4 NAME 5 6 poll - select(2)-based poll() emulation function for BSD systems. 7 8 SYNOPSIS 9 #include "poll.h" 10 11 struct pollfd 12 { 13 int fd; 14 short events; 15 short revents; 16 } 17 18 int poll (struct pollfd *pArray, unsigned long n_fds, int timeout) 19 20 DESCRIPTION 21 22 This file, and the accompanying "poll.c", implement the System V 23 poll(2) system call for BSD systems (which typically do not provide 24 poll()). Poll() provides a method for multiplexing input and output 25 on multiple open file descriptors; in traditional BSD systems, that 26 capability is provided by select(). While the semantics of select() 27 differ from those of poll(), poll() can be readily emulated in terms 28 of select() -- which is how this function is implemented. 29 30 REFERENCES 31 Stevens, W. Richard. Unix Network Programming. Prentice-Hall, 1990. 32 33 NOTES 34 1. This software requires an ANSI C compiler. 35 36 LICENSE 37 38 This software is released under the following license: 39 40 Copyright (c) 1995-2002 Brian M. Clapper 41 All rights reserved. 42 43 Redistribution and use in source and binary forms are 44 permitted provided that: (1) source distributions retain 45 this entire copyright notice and comment; (2) modifications 46 made to the software are prominently mentioned, and a copy 47 of the original software (or a pointer to its location) are 48 included; and (3) distributions including binaries display 49 the following acknowledgement: "This product includes 50 software developed by Brian M. Clapper <bmc@clapper.org>" 51 in the documentation or other materials provided with the 52 distribution. The name of the author may not be used to 53 endorse or promote products derived from this software 54 without specific prior written permission. 55 56 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS 57 OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE 58 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 59 PARTICULAR PURPOSE. 60 61 Effectively, this means you can do what you want with the software 62 except remove this notice or take advantage of the author's name. 63 If you modify the software and redistribute your modified version, 64 you must indicate that your version is a modification of the 65 original, and you must provide either a pointer to or a copy of the 66 original. 67 \*---------------------------------------------------------------------------*/ 68 69 #ifndef _POLL_EMUL_H_ 70 #define _POLL_EMUL_H_ 71 72 #define POLL_NO_WARN 73 74 #ifndef POLL_NO_WARN 75 #warning "poll() functionality for Mac OS X is implemented via an emulation layer on top of select(), not in the kernel directly. It is recommended that programs running under OS X 10.3 prefer select() over poll(). Configure scripts should look for the _POLL_EMUL_H_ define (instead of _POLL_H_ or _SYS_POLL_H_) and avoid implementations where poll is not implemented in the kernel." 76 #endif 77 78 #ifdef RT_OS_OS2 79 #include <sys/select.h> 80 #endif 81 82 #define POLLIN 0x01 83 #define POLLPRI 0x02 84 #define POLLOUT 0x04 85 #define POLLERR 0x08 86 #define POLLHUP 0x10 87 #define POLLNVAL 0x20 88 89 // these are taken from Linux 90 #define POLLRDNORM 0x0040 91 #define POLLRDBAND 0x0080 92 #define POLLWRNORM 0x0100 93 #define POLLWRBAND 0x0200 94 #define POLLMSG 0x0400 95 #define POLLREMOVE 0x1000 96 #define POLLRDHUP 0x2000 97 #define POLLFREE 0x4000 98 99 struct pollfd 100 { 101 int fd; 102 short events; 103 short revents; 104 }; 105 106 #ifdef __cplusplus 107 extern "C" 108 { 109 #endif 110 111 #if (__STDC__ > 0) || defined(__cplusplus) 112 extern int poll (struct pollfd *pArray, unsigned long n_fds, int timeout); 113 #else 114 extern int poll(); 115 #endif 116 117 #ifdef __cplusplus 118 } 119 #endif 120 121 #endif /* _POLL_EMUL_H_ */ -
\src\libs\poll-os2/polltest.c
diff -urN vbox-trunk-bk\src\libs\poll-os2/polltest.c vbox-trunk\src\libs\poll-os2/polltest.c
old new 1 /* $Id: polltest.c,v 1.1.1.1 2003/07/21 16:20:21 zarzycki Exp $ */ 2 #include <stdio.h> 3 #include <sys/types.h> 4 #include <sys/stat.h> 5 #include <fcntl.h> 6 #include <errno.h> 7 #include "poll.h" 8 9 #define MAX10 10 11 main (int argc, char **argv) 12 { 13 int arg; 14 int i; 15 struct pollfd array[MAX]; 16 int ready; 17 18 if ((argc == 1) || ((argc % 2) != 1) || (argc > ((MAX * 2) + 1)) ) 19 { 20 fprintf (stderr, "Usage: %s r|w file [r|w file] ...\n", argv[0]); 21 exit (1); 22 } 23 24 for (arg = 1, i = 0; arg < argc; arg += 2, i++) 25 { 26 int open_mode; 27 short poll_mask; 28 char *strMode; 29 30 if (argv[arg][0] == 'r') 31 { 32 open_mode = O_RDONLY; 33 poll_mask = POLLIN; 34 strMode = "reading"; 35 } 36 else 37 { 38 open_mode = O_WRONLY; 39 poll_mask = POLLOUT; 40 strMode = "writing"; 41 } 42 43 printf ("%2d: Opening \"%s\" for %s ...\n", i, argv[arg + 1], strMode); 44 array[i].revents = 0; 45 array[i].events |= poll_mask; 46 array[i].fd = open (argv[arg + 1], open_mode); 47 if (array[i].fd == -1) 48 { 49 fprintf (stderr, "Can't open \"%s\": errno %d\n", 50 argv[arg + 1], errno); 51 exit (1); 52 } 53 } 54 55 printf ("Polling on %d file descriptors. Timeout is indefinite ...\n", i); 56 ready = poll (array, (unsigned long) i, -1); 57 printf ("poll() returned %d.\n", ready); 58 if (ready < 0) 59 printf ("Errno = %d\n", errno); 60 61 for (arg = 1, i = 0; arg < argc; arg += 2, i++) 62 { 63 if (array[i].revents != 0) 64 { 65 printf ("%2d (\"%s\"):", i, argv[arg + 1]); 66 67 if (array[i].revents & POLLPRI) 68 printf (" EXCEPTION"); 69 if (array[i].revents & POLLIN) 70 printf (" INPUT"); 71 if (array[i].revents & POLLOUT) 72 printf (" OUTPUT"); 73 putchar ('\n'); 74 } 75 } 76 77 exit (0); 78 } -
\src\libs\poll-os2/sys/poll.h
diff -urN vbox-trunk-bk\src\libs\poll-os2/sys/poll.h vbox-trunk\src\libs\poll-os2/sys/poll.h
old new 1 /*---------------------------------------------------------------------------*\ 2 $Id: poll.h,v 1.2 2003/09/13 00:08:18 eseidel Exp $ 3 4 NAME 5 6 poll - select(2)-based poll() emulation function for BSD systems. 7 8 SYNOPSIS 9 #include "poll.h" 10 11 struct pollfd 12 { 13 int fd; 14 short events; 15 short revents; 16 } 17 18 int poll (struct pollfd *pArray, unsigned long n_fds, int timeout) 19 20 DESCRIPTION 21 22 This file, and the accompanying "poll.c", implement the System V 23 poll(2) system call for BSD systems (which typically do not provide 24 poll()). Poll() provides a method for multiplexing input and output 25 on multiple open file descriptors; in traditional BSD systems, that 26 capability is provided by select(). While the semantics of select() 27 differ from those of poll(), poll() can be readily emulated in terms 28 of select() -- which is how this function is implemented. 29 30 REFERENCES 31 Stevens, W. Richard. Unix Network Programming. Prentice-Hall, 1990. 32 33 NOTES 34 1. This software requires an ANSI C compiler. 35 36 LICENSE 37 38 This software is released under the following license: 39 40 Copyright (c) 1995-2002 Brian M. Clapper 41 All rights reserved. 42 43 Redistribution and use in source and binary forms are 44 permitted provided that: (1) source distributions retain 45 this entire copyright notice and comment; (2) modifications 46 made to the software are prominently mentioned, and a copy 47 of the original software (or a pointer to its location) are 48 included; and (3) distributions including binaries display 49 the following acknowledgement: "This product includes 50 software developed by Brian M. Clapper <bmc@clapper.org>" 51 in the documentation or other materials provided with the 52 distribution. The name of the author may not be used to 53 endorse or promote products derived from this software 54 without specific prior written permission. 55 56 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS 57 OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE 58 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 59 PARTICULAR PURPOSE. 60 61 Effectively, this means you can do what you want with the software 62 except remove this notice or take advantage of the author's name. 63 If you modify the software and redistribute your modified version, 64 you must indicate that your version is a modification of the 65 original, and you must provide either a pointer to or a copy of the 66 original. 67 \*---------------------------------------------------------------------------*/ 68 69 #ifndef _POLL_EMUL_H_ 70 #define _POLL_EMUL_H_ 71 72 #define POLL_NO_WARN 73 74 #ifndef POLL_NO_WARN 75 #warning "poll() functionality for Mac OS X is implemented via an emulation layer on top of select(), not in the kernel directly. It is recommended that programs running under OS X 10.3 prefer select() over poll(). Configure scripts should look for the _POLL_EMUL_H_ define (instead of _POLL_H_ or _SYS_POLL_H_) and avoid implementations where poll is not implemented in the kernel." 76 #endif 77 78 #ifdef RT_OS_OS2 79 #include <sys/select.h> 80 #endif 81 82 #define POLLIN 0x01 83 #define POLLPRI 0x02 84 #define POLLOUT 0x04 85 #define POLLERR 0x08 86 #define POLLHUP 0x10 87 #define POLLNVAL 0x20 88 89 // these are taken from Linux 90 #define POLLRDNORM 0x0040 91 #define POLLRDBAND 0x0080 92 #define POLLWRNORM 0x0100 93 #define POLLWRBAND 0x0200 94 #define POLLMSG 0x0400 95 #define POLLREMOVE 0x1000 96 #define POLLRDHUP 0x2000 97 #define POLLFREE 0x4000 98 99 struct pollfd 100 { 101 int fd; 102 short events; 103 short revents; 104 }; 105 106 #ifdef __cplusplus 107 extern "C" 108 { 109 #endif 110 111 #if (__STDC__ > 0) || defined(__cplusplus) 112 extern int poll (struct pollfd *pArray, unsigned long n_fds, int timeout); 113 #else 114 extern int poll(); 115 #endif 116 117 #ifdef __cplusplus 118 } 119 #endif 120 121 #endif /* _POLL_EMUL_H_ */