4632N/A * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4632N/A * This code is free software; you can redistribute it and/or modify it 4632N/A * under the terms of the GNU General Public License version 2 only, as 4632N/A * published by the Free Software Foundation. Oracle designates this 4632N/A * particular file as subject to the "Classpath" exception as provided 4632N/A * by Oracle in the LICENSE file that accompanied this code. 4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4632N/A * version 2 for more details (a copy is included in the LICENSE file that 4632N/A * You should have received a copy of the GNU General Public License version 4632N/A * 2 along with this work; if not, write to the Free Software Foundation, 4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4632N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4632N/A * Stack allocated by thread when doing blocking operation 4632N/A * Heap allocated during initialized - one entry per fd 4632N/A * The fd table and the number of file descriptors 4632N/A * This limit applies if getlimit() returns unlimited. 4632N/A * Unfortunately, this means if someone wants a higher limt 4632N/A * then they have to set an explicit limit, higher than this, 4632N/A * which is probably counter-intuitive. 4632N/A * Initialization routine (executed when library is loaded) 4632N/A * Allocate fd tables and sets up signal handler. 4632N/A * Allocate table based on the maximum number of 4632N/A "unable to allocate file descriptor table - out of memory");
4632N/A * Return the fd table for this fd or NULL is fd out 4632N/A * Start a blocking operation :- 4632N/A * Insert thread onto thread list for the fd. 4632N/A * End a blocking operation :- 4632N/A * Remove thread from thread list for the fd 4632N/A * If fd has been interrupted then set errno to EBADF 4632N/A * Close or dup2 a file descriptor ensuring that all threads blocked on 4632N/A * the file descriptor are notified via a wakeup signal. 4632N/A * fd1 >= 0 => dup2(fd1, fd2) 4632N/A * Returns -1 with errno set if operation fails. 4632N/A * Lock the fd to hold-off additional I/O on this fd. 4632N/A * Send a wakeup signal to all threads blocked on this 4632N/A * (restart if interrupted by signal) 4632N/A * Unlock without destroying errno 4632N/A * Wrapper for dup2 - same semantics as dup2 system call except 4632N/A * that any threads blocked in an I/O system call on fd2 will be 4632N/A * preempted and return -1/EBADF; 4632N/A * Wrapper for close - same semantics as close system call 4632N/A * except that any threads blocked in an I/O on fd will be 4632N/A * preempted and the I/O system call will return -1/EBADF. 4632N/A/************** Basic I/O operations here ***************/ 4632N/A * Macro to perform a blocking IO operation. Restarts 4632N/A * automatically if interrupted by signal (other than 4654N/A /* casting int *fromlen -> socklen_t* Both are ints */ 4681N/A * Wrapper for select(s, timeout). We are using select() on Mac OS due to Bug 7131399. 4632N/A * Auto restarts with adjusted timeout if interrupted by 4632N/A * signal other than our wakeup signal. 4632N/A * Check that fd hasn't been closed. 4632N/A * Pick up current time as may need to adjust timeout 4681N/A * call select on the fd. If interrupted by our wakeup signal 4632N/A * errno will be set to EBADF. 4632N/A * If interrupted then adjust timeout. If timeout 4632N/A * has expired return 0 (indicating timeout expired).