diff options
author | julian <julian@FreeBSD.org> | 1996-01-22 00:02:33 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1996-01-22 00:02:33 +0000 |
commit | 619b731f5bb5e09dcf1eaf1fbd96383ca64398fd (patch) | |
tree | a89c7f50ec371cef4418259b9dccdd31ebb2f61f /lib/libc/sys/lseek.c | |
parent | 663b14fb2f3198fb0bfb62ae16b6b56c2a4dd055 (diff) | |
download | FreeBSD-src-619b731f5bb5e09dcf1eaf1fbd96383ca64398fd.zip FreeBSD-src-619b731f5bb5e09dcf1eaf1fbd96383ca64398fd.tar.gz |
Reviewed by: julian and (hsu?)
Submitted by: John Birrel(L?)
changes for threadsafe operations
Diffstat (limited to 'lib/libc/sys/lseek.c')
-rw-r--r-- | lib/libc/sys/lseek.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/libc/sys/lseek.c b/lib/libc/sys/lseek.c index 52208d1..8896ad8 100644 --- a/lib/libc/sys/lseek.c +++ b/lib/libc/sys/lseek.c @@ -37,6 +37,11 @@ static char sccsid[] = "@(#)lseek.c 8.1 (Berkeley) 6/17/93"; #include <sys/types.h> #include <sys/syscall.h> +#include <unistd.h> +#ifdef _THREAD_SAFE +#include <pthread.h> +#include "pthread_private.h" +#endif /* * This function provides 64-bit offset padding that @@ -48,7 +53,17 @@ lseek(fd, offset, whence) off_t offset; int whence; { - extern off_t __syscall(); +#ifdef _THREAD_SAFE + off_t offs; + if (_thread_fd_lock(fd, FD_RDWR, NULL,__FILE__,__LINE__) != 0) { + offs = -1; + } else { + offs = __syscall((quad_t) SYS_lseek,fd, 0, offset, whence); + _thread_fd_unlock(fd, FD_RDWR); + } + return(offs); +#else return(__syscall((quad_t)SYS_lseek, fd, 0, offset, whence)); +#endif } |