summaryrefslogtreecommitdiffstats
path: root/lib/libkse/thread/thr_fcntl.c
diff options
context:
space:
mode:
authormini <mini@FreeBSD.org>2002-09-16 19:52:52 +0000
committermini <mini@FreeBSD.org>2002-09-16 19:52:52 +0000
commit6077cee24228562d15e285d132213eeb718439b7 (patch)
tree19954471d255ce812e704c80bd079f406bc31378 /lib/libkse/thread/thr_fcntl.c
parented825a4bd02ff20716e59e0da4db93b761df2734 (diff)
downloadFreeBSD-src-6077cee24228562d15e285d132213eeb718439b7.zip
FreeBSD-src-6077cee24228562d15e285d132213eeb718439b7.tar.gz
Make libpthread KSE aware.
Reviewed by: deischen, julian Approved by: -arch
Diffstat (limited to 'lib/libkse/thread/thr_fcntl.c')
-rw-r--r--lib/libkse/thread/thr_fcntl.c108
1 files changed, 3 insertions, 105 deletions
diff --git a/lib/libkse/thread/thr_fcntl.c b/lib/libkse/thread/thr_fcntl.c
index 9e78d07..33a1c2f 100644
--- a/lib/libkse/thread/thr_fcntl.c
+++ b/lib/libkse/thread/thr_fcntl.c
@@ -40,108 +40,6 @@
__weak_reference(__fcntl, fcntl);
int
-_fcntl(int fd, int cmd,...)
-{
- int flags = 0;
- int nonblock;
- int oldfd;
- int ret;
- va_list ap;
-
- /* Lock the file descriptor: */
- if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
- /* Initialise the variable argument list: */
- va_start(ap, cmd);
-
- /* Process according to file control command type: */
- switch (cmd) {
- /* Duplicate a file descriptor: */
- case F_DUPFD:
- /*
- * Get the file descriptor that the caller wants to
- * use:
- */
- oldfd = va_arg(ap, int);
-
- /* Initialise the file descriptor table entry: */
- if ((ret = __sys_fcntl(fd, cmd, oldfd)) < 0) {
- }
- /* Initialise the file descriptor table entry: */
- else if (_thread_fd_table_init(ret) != 0) {
- /* Quietly close the file: */
- __sys_close(ret);
-
- /* Reset the file descriptor: */
- ret = -1;
- } else {
- /*
- * Save the file open flags so that they can
- * be checked later:
- */
- _thread_fd_setflags(ret,
- _thread_fd_getflags(fd));
- }
- break;
- case F_SETFD:
- flags = va_arg(ap, int);
- ret = __sys_fcntl(fd, cmd, flags);
- break;
- case F_GETFD:
- ret = __sys_fcntl(fd, cmd, 0);
- break;
- case F_GETFL:
- ret = _thread_fd_getflags(fd);
- break;
- case F_SETFL:
- /*
- * Get the file descriptor flags passed by the
- * caller:
- */
- flags = va_arg(ap, int);
-
- /*
- * Check if the user wants a non-blocking file
- * descriptor:
- */
- nonblock = flags & O_NONBLOCK;
-
- /* Set the file descriptor flags: */
- if ((ret = __sys_fcntl(fd, cmd, flags | O_NONBLOCK)) != 0) {
-
- /* Get the flags so that we behave like the kernel: */
- } else if ((flags = __sys_fcntl(fd,
- F_GETFL, 0)) == -1) {
- /* Error getting flags: */
- ret = -1;
-
- /*
- * Check if the file descriptor is non-blocking
- * with respect to the user:
- */
- } else if (nonblock)
- /* A non-blocking descriptor: */
- _thread_fd_setflags(fd, flags | O_NONBLOCK);
- else
- /* Save the flags: */
- _thread_fd_setflags(fd, flags & ~O_NONBLOCK);
- break;
- default:
- /* Might want to make va_arg use a union */
- ret = __sys_fcntl(fd, cmd, va_arg(ap, void *));
- break;
- }
-
- /* Free variable arguments: */
- va_end(ap);
-
- /* Unlock the file descriptor: */
- _FD_UNLOCK(fd, FD_RDWR);
- }
- /* Return the completion status: */
- return (ret);
-}
-
-int
__fcntl(int fd, int cmd,...)
{
int ret;
@@ -154,14 +52,14 @@ __fcntl(int fd, int cmd,...)
case F_DUPFD:
case F_SETFD:
case F_SETFL:
- ret = _fcntl(fd, cmd, va_arg(ap, int));
+ ret = __sys_fcntl(fd, cmd, va_arg(ap, int));
break;
case F_GETFD:
case F_GETFL:
- ret = _fcntl(fd, cmd);
+ ret = __sys_fcntl(fd, cmd);
break;
default:
- ret = _fcntl(fd, cmd, va_arg(ap, void *));
+ ret = __sys_fcntl(fd, cmd, va_arg(ap, void *));
}
va_end(ap);
OpenPOWER on IntegriCloud