/*
* Copyright (c) 1982, 1986, 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Portions copyright (c) 1999, 2000
* Intel Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by the University of
* California, Berkeley, Intel Corporation, and its contributors.
*
* 4. Neither the name of University, Intel Corporation, or their respective
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS, INTEL CORPORATION AND
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS,
* INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
* $Id: select.c,v 1.1.1.1 2003/11/19 01:50:30 kyu3 Exp $
*/
#include <Library/UefiBootServicesTableLib.h>
#include <LibConfig.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
#ifndef KERNEL
#define KERNEL
#include <errno.h>
#else
#include <errno.h>
#endif
#ifdef EFI_NT_EMULATOR
#else
#endif
/** Sleep for the specified number of Microseconds.
Implements the usleep(3) function.
@param[in] Microseconds Number of microseconds to sleep.
@retval 0 Always returns zero.
**/
int
{
while ( MAX_SLEEP_DELAY < Microseconds ) {
}
return (0);
}
unsigned int
{
}
static int
int nfd,
int *nselected
)
{
int msk;
int i;
int j;
int fd;
int n;
int FdCount;
continue;
bits &= ~(1 << j);
if ( -1 == FdCount ) {
return errno;
}
if ( 0 != FdCount ) {
n++;
break;
}
}
}
}
*nselected = n;
return (0);
}
int
int nd,
)
{
if (nd < 0)
return (EINVAL);
/*
* Allocate just enough bits for the non-null fd_sets. Use the
* preallocated auto buffer if possible.
*/
nbufbytes = 0;
/*
* Assign pointers into the bit buffers and fetch the input bits.
* Put the output buffers together so that they can be bzeroed
* together.
*/
do { \
else { \
} \
} while (0)
if (nbufbytes != 0)
if (tv) {
forever = 0;
} else {
timo = 0;
forever = 1;
}
/*
* Poll for I/O events
*/
nselected = 0;
do {
/*
* Scan for pending I/O
*/
break;
/*
* Adjust timeout is needed
*/
if (timo) {
/*
* Give it a rest
*/
usleep( _SELECT_DELAY_ );
timo -= _SELECT_DELAY_;
}
/* select is not restarted after signals... */
else if (error == EWOULDBLOCK)
error = 0;
if (error == 0) {
} else {
nselected = -1;
}
return ( nselected );
}