summaryrefslogtreecommitdiffstats
path: root/lib/libkse
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libkse')
-rw-r--r--lib/libkse/thread/thr_close.c3
-rw-r--r--lib/libkse/thread/thr_exit.c2
-rw-r--r--lib/libkse/thread/thr_fcntl.c11
-rw-r--r--lib/libkse/thread/thr_private.h8
-rw-r--r--lib/libkse/thread/thr_read.c4
-rw-r--r--lib/libkse/thread/thr_readv.c4
-rw-r--r--lib/libkse/thread/thr_sig.c2
-rw-r--r--lib/libkse/thread/thr_write.c4
-rw-r--r--lib/libkse/thread/thr_writev.c4
9 files changed, 23 insertions, 19 deletions
diff --git a/lib/libkse/thread/thr_close.c b/lib/libkse/thread/thr_close.c
index 0a5bd24..22c9394 100644
--- a/lib/libkse/thread/thr_close.c
+++ b/lib/libkse/thread/thr_close.c
@@ -82,7 +82,8 @@ _close(int fd)
* using, which would then cause any reads to block
* indefinitely.
*/
- if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) {
+ if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode))
+ && (_thread_fd_getflags(fd) & O_NONBLOCK) == 0) {
/* Get the current flags: */
flags = __sys_fcntl(fd, F_GETFL, NULL);
/* Clear the nonblocking file descriptor flag: */
diff --git a/lib/libkse/thread/thr_exit.c b/lib/libkse/thread/thr_exit.c
index fd90e29..8af1c1f 100644
--- a/lib/libkse/thread/thr_exit.c
+++ b/lib/libkse/thread/thr_exit.c
@@ -69,7 +69,7 @@ void _exit(int status)
for (i = 0; i < _thread_dtablesize; i++) {
/* Check if this file descriptor is in use: */
if (_thread_fd_table[i] != NULL &&
- !(_thread_fd_table[i]->flags & O_NONBLOCK)) {
+ (_thread_fd_getflags(i) & O_NONBLOCK) == 0) {
/* Get the current flags: */
flags = __sys_fcntl(i, F_GETFL, NULL);
/* Clear the nonblocking file descriptor flag: */
diff --git a/lib/libkse/thread/thr_fcntl.c b/lib/libkse/thread/thr_fcntl.c
index 1d12c0e..a5b6405 100644
--- a/lib/libkse/thread/thr_fcntl.c
+++ b/lib/libkse/thread/thr_fcntl.c
@@ -76,9 +76,10 @@ _fcntl(int fd, int cmd,...)
} else {
/*
* Save the file open flags so that they can
- * be checked later:
+ * be checked later:
*/
- _thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags;
+ _thread_fd_setflags(ret,
+ _thread_fd_getflags(fd));
}
break;
case F_SETFD:
@@ -89,7 +90,7 @@ _fcntl(int fd, int cmd,...)
ret = __sys_fcntl(fd, cmd, 0);
break;
case F_GETFL:
- ret = _thread_fd_table[fd]->flags;
+ ret = _thread_fd_getflags(fd);
break;
case F_SETFL:
/*
@@ -119,10 +120,10 @@ _fcntl(int fd, int cmd,...)
*/
} else if (nonblock)
/* A non-blocking descriptor: */
- _thread_fd_table[fd]->flags = flags | O_NONBLOCK;
+ _thread_fd_setflags(fd, flags | O_NONBLOCK);
else
/* Save the flags: */
- _thread_fd_table[fd]->flags = flags & ~O_NONBLOCK;
+ _thread_fd_setflags(fd, flags & ~O_NONBLOCK);
break;
default:
/* Might want to make va_arg use a union */
diff --git a/lib/libkse/thread/thr_private.h b/lib/libkse/thread/thr_private.h
index ef45706..97b30b7 100644
--- a/lib/libkse/thread/thr_private.h
+++ b/lib/libkse/thread/thr_private.h
@@ -1140,8 +1140,6 @@ void _set_curthread(struct pthread *);
void *_thread_stack_alloc(size_t, size_t);
void _thread_stack_free(void *, size_t, size_t);
int _thread_create(pthread_t *,const pthread_attr_t *,void *(*start_routine)(void *),void *,pthread_t);
-int _thread_fd_lock(int, int, struct timespec *);
-int _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno);
int _mutex_cv_lock(pthread_mutex_t *);
int _mutex_cv_unlock(pthread_mutex_t *);
void _mutex_lock_backout(pthread_t);
@@ -1177,6 +1175,11 @@ void _waitq_clearactive(void);
#endif
void _thread_exit(char *, int, char *);
void _thread_exit_cleanup(void);
+int _thread_fd_getflags(int);
+int _thread_fd_lock(int, int, struct timespec *);
+int _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno);
+void _thread_fd_setflags(int, int);
+int _thread_fd_table_init(int fd);
void _thread_fd_unlock(int, int);
void _thread_fd_unlock_debug(int, int, char *, int);
void _thread_fd_unlock_owned(pthread_t);
@@ -1203,7 +1206,6 @@ void _thread_sigframe_restore(struct pthread *thread,
struct pthread_signal_frame *psf);
void _thread_start(void);
void _thread_seterrno(pthread_t, int);
-int _thread_fd_table_init(int fd);
pthread_addr_t _thread_gc(pthread_addr_t);
void _thread_enter_cancellation_point(void);
void _thread_leave_cancellation_point(void);
diff --git a/lib/libkse/thread/thr_read.c b/lib/libkse/thread/thr_read.c
index 4d81414..067befa 100644
--- a/lib/libkse/thread/thr_read.c
+++ b/lib/libkse/thread/thr_read.c
@@ -57,7 +57,7 @@ _read(int fd, void *buf, size_t nbytes)
/* Lock the file descriptor for read: */
if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) {
/* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
+ type = _thread_fd_getflags(fd) & O_ACCMODE;
/* Check if the file is not open for read: */
if (type != O_RDONLY && type != O_RDWR) {
@@ -69,7 +69,7 @@ _read(int fd, void *buf, size_t nbytes)
/* Perform a non-blocking read syscall: */
while ((ret = __sys_read(fd, buf, nbytes)) < 0) {
- if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 &&
+ if ((_thread_fd_getflags(fd) & O_NONBLOCK) == 0 &&
(errno == EWOULDBLOCK || errno == EAGAIN)) {
curthread->data.fd.fd = fd;
_thread_kern_set_timeout(NULL);
diff --git a/lib/libkse/thread/thr_readv.c b/lib/libkse/thread/thr_readv.c
index 0aa6c15..e2b79d7 100644
--- a/lib/libkse/thread/thr_readv.c
+++ b/lib/libkse/thread/thr_readv.c
@@ -52,7 +52,7 @@ _readv(int fd, const struct iovec * iov, int iovcnt)
/* Lock the file descriptor for read: */
if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) {
/* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
+ type = _thread_fd_getflags(fd) & O_ACCMODE;
/* Check if the file is not open for read: */
if (type != O_RDONLY && type != O_RDWR) {
@@ -64,7 +64,7 @@ _readv(int fd, const struct iovec * iov, int iovcnt)
/* Perform a non-blocking readv syscall: */
while ((ret = __sys_readv(fd, iov, iovcnt)) < 0) {
- if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 &&
+ if ((_thread_fd_getflags(fd) & O_NONBLOCK) == 0 &&
(errno == EWOULDBLOCK || errno == EAGAIN)) {
curthread->data.fd.fd = fd;
_thread_kern_set_timeout(NULL);
diff --git a/lib/libkse/thread/thr_sig.c b/lib/libkse/thread/thr_sig.c
index 7aa9b53..cf319c6 100644
--- a/lib/libkse/thread/thr_sig.c
+++ b/lib/libkse/thread/thr_sig.c
@@ -536,7 +536,7 @@ thread_sig_handle_special(int sig)
* Set the file descriptor to non-blocking:
*/
__sys_fcntl(i, F_SETFL,
- _thread_fd_table[i]->flags | O_NONBLOCK);
+ _thread_fd_getflags(i) | O_NONBLOCK);
}
}
/*
diff --git a/lib/libkse/thread/thr_write.c b/lib/libkse/thread/thr_write.c
index e655a34..072b989 100644
--- a/lib/libkse/thread/thr_write.c
+++ b/lib/libkse/thread/thr_write.c
@@ -59,7 +59,7 @@ _write(int fd, const void *buf, size_t nbytes)
/* Lock the file descriptor for write: */
if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
/* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
+ type = _thread_fd_getflags(fd) & O_ACCMODE;
/* Check if the file is not open for write: */
if (type != O_WRONLY && type != O_RDWR) {
@@ -70,7 +70,7 @@ _write(int fd, const void *buf, size_t nbytes)
}
/* Check if file operations are to block */
- blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
+ blocking = ((_thread_fd_getflags(fd) & O_NONBLOCK) == 0);
/*
* Loop while no error occurs and until the expected number
diff --git a/lib/libkse/thread/thr_writev.c b/lib/libkse/thread/thr_writev.c
index ec77258..b07278a 100644
--- a/lib/libkse/thread/thr_writev.c
+++ b/lib/libkse/thread/thr_writev.c
@@ -75,7 +75,7 @@ _writev(int fd, const struct iovec * iov, int iovcnt)
/* Lock the file descriptor for write: */
if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
/* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
+ type = _thread_fd_getflags(fd) & O_ACCMODE;
/* Check if the file is not open for write: */
if (type != O_WRONLY && type != O_RDWR) {
@@ -86,7 +86,7 @@ _writev(int fd, const struct iovec * iov, int iovcnt)
}
/* Check if file operations are to block */
- blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
+ blocking = ((_thread_fd_getflags(fd) & O_NONBLOCK) == 0);
/*
* Loop while no error occurs and until the expected number
OpenPOWER on IntegriCloud