diff options
author | jb <jb@FreeBSD.org> | 1998-06-09 23:21:05 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 1998-06-09 23:21:05 +0000 |
commit | 765df5f4d29065eac50b4bfab3407a7da8a90323 (patch) | |
tree | e14930dc53674181c346bbe0f43647669e330569 /lib/libpthread/thread/thr_read.c | |
parent | 5ed1d7e9485fa8756d1be3fdf6cfa5125ac45657 (diff) | |
download | FreeBSD-src-765df5f4d29065eac50b4bfab3407a7da8a90323.zip FreeBSD-src-765df5f4d29065eac50b4bfab3407a7da8a90323.tar.gz |
Implement compile time debug support instead of tracking file name and
line number every time a file descriptor is locked.
This looks like a big change but it isn't. It should reduce the size
of libc_r and make it run slightly faster.
Diffstat (limited to 'lib/libpthread/thread/thr_read.c')
-rw-r--r-- | lib/libpthread/thread/thr_read.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libpthread/thread/thr_read.c b/lib/libpthread/thread/thr_read.c index 76df2cf..358a620 100644 --- a/lib/libpthread/thread/thr_read.c +++ b/lib/libpthread/thread/thr_read.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: uthread_read.c,v 1.3 1997/04/01 22:44:15 jb Exp $ + * $Id: uthread_read.c,v 1.4 1998/04/29 09:59:10 jb Exp $ * */ #include <sys/types.h> @@ -46,9 +46,12 @@ read(int fd, void *buf, size_t nbytes) { int ret; + /* POSIX says to do just this: */ + if (nbytes == 0) + return (0); + /* Lock the file descriptor for read: */ - if ((ret = _thread_fd_lock(fd, FD_READ, NULL, - __FILE__, __LINE__)) == 0) { + if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { /* Perform a non-blocking read syscall: */ while ((ret = _thread_sys_read(fd, buf, nbytes)) < 0) { if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && @@ -75,7 +78,7 @@ read(int fd, void *buf, size_t nbytes) break; } } - _thread_fd_unlock(fd, FD_READ); + _FD_UNLOCK(fd, FD_READ); } return (ret); } |