summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2021-09-23 15:42:12 +1000
committerChris Johns <chrisj@rtems.org>2021-09-23 15:42:12 +1000
commit2e5f808b09459e5287b39135f06a79f05c1194c9 (patch)
treeb839ea3d9534598bc403a9e7cabdbbf9fdd565a3
parentrtemsbsd/open: Correctly open a mount directory (diff)
downloadrtems-libbsd-2e5f808b09459e5287b39135f06a79f05c1194c9.tar.bz2
rtemsbsd/syscalls: Remove pipe()
- This call is provided by RTEMS and that is preferred Closes #4518
-rw-r--r--rtemsbsd/rtems/rtems-bsd-syscall-api.c52
-rwxr-xr-xtestsuite/selectpollkqueue01/test_main.c155
2 files changed, 0 insertions, 207 deletions
diff --git a/rtemsbsd/rtems/rtems-bsd-syscall-api.c b/rtemsbsd/rtems/rtems-bsd-syscall-api.c
index 3ff73dc1..76fc8ad7 100644
--- a/rtemsbsd/rtems/rtems-bsd-syscall-api.c
+++ b/rtemsbsd/rtems/rtems-bsd-syscall-api.c
@@ -442,58 +442,6 @@ listen(int socket, int backlog)
}
int
-pipe(int fildes[2])
-{
- struct thread *td = rtems_bsd_get_curthread_or_null();
- rtems_libio_t *iop[2];
- int error;
- if (RTEMS_BSD_SYSCALL_TRACE) {
- printf("bsd: sys: pipe: %d\n", socket);
- }
- if (td == NULL) {
- return rtems_bsd_error_to_status_and_errno(ENOMEM);
- }
- iop[0] = rtems_bsd_libio_iop_allocate();
- if (iop[0] == NULL) {
- return rtems_bsd_error_to_status_and_errno(ENFILE);
- }
- iop[1] = rtems_bsd_libio_iop_allocate();
- if (iop[1] == NULL) {
- rtems_bsd_libio_iop_free(iop[0]);
- return rtems_bsd_error_to_status_and_errno(ENFILE);
- }
- error = kern_pipe(td, fildes, 0, NULL, NULL);
- if (error != 0) {
- goto out;
- }
- error = rtems_bsd_libio_iop_set_bsd_fd(
- td, fildes[0], iop[0], &rtems_bsd_sysgen_nodeops);
- if (error != 0) {
- goto out;
- }
- error = rtems_bsd_libio_iop_set_bsd_fd(
- td, fildes[1], iop[1], &rtems_bsd_sysgen_nodeops);
- if (error == 0) {
- fildes[0] = rtems_libio_iop_to_descriptor(iop[0]);
- fildes[1] = rtems_libio_iop_to_descriptor(iop[1]);
- if (RTEMS_BSD_SYSCALL_TRACE) {
- printf("bsd: sys: pipe: %d -> %d, %d -> %d\n",
- fildes[0],
- rtems_bsd_libio_iop_to_descriptor(iop[0]),
- fildes[1],
- rtems_bsd_libio_iop_to_descriptor(iop[1]));
- }
- return 0;
- }
-out:
- kern_close(td, rtems_bsd_libio_iop_to_descriptor(iop[0]));
- kern_close(td, rtems_bsd_libio_iop_to_descriptor(iop[1]));
- rtems_bsd_libio_iop_free(iop[0]);
- rtems_bsd_libio_iop_free(iop[1]);
- return rtems_bsd_error_to_status_and_errno(error);
-}
-
-int
poll(struct pollfd fds[], nfds_t nfds, int timeout)
{
struct thread *td = rtems_bsd_get_curthread_or_null();
diff --git a/testsuite/selectpollkqueue01/test_main.c b/testsuite/selectpollkqueue01/test_main.c
index 1c481517..fe114189 100755
--- a/testsuite/selectpollkqueue01/test_main.c
+++ b/testsuite/selectpollkqueue01/test_main.c
@@ -1096,156 +1096,6 @@ test_kqueue_user(test_context *ctx)
}
static void
-test_pipe_timeout(test_context *ctx)
-{
- struct pipe_poll_events
- {
- short event;
- int rv;
- };
- const struct pipe_poll_events events[] = {
- { POLLIN, 0 },
- { POLLPRI, 0 },
- { POLLOUT, 1 },
- { POLLRDNORM, 0 },
- { POLLWRNORM, 1 },
- { POLLRDBAND, 0 },
- { POLLWRBAND, 0 },
- { POLLINIGNEOF, 0 }
- };
-
- int timeout = 100;
- struct pollfd pfd;
- size_t i;
- int rv;
-
- puts("test pipe timeout");
-
- rv = pipe(ctx->pfd);
- assert(rv == 0);
-
- pfd.fd = ctx->pfd[1];
-
- for (i = 0; i < nitems(events); ++i) {
- int rv;
-
- pfd.events = events[i].event;
- pfd.revents = 0;
-
- rv = poll(&pfd, 1, timeout);
- assert(rv == events[i].rv);
- }
-}
-
-static void
-test_pipe_read(test_context *ctx)
-{
- int rfd = ctx->pfd[0];
- int wfd = ctx->pfd[1];
- struct pollfd pfd = {
- .fd = rfd,
- .events = POLLIN
- };
- int timeout = -1;
- int rv;
- ssize_t n;
-
- puts("test pipe read");
-
- assert(rfd >= 0);
- assert(wfd >= 0);
-
- ctx->wfd = wfd;
- ctx->wbuf = &msg[0];
- ctx->wn = sizeof(msg);
- send_events(ctx, EVENT_WRITE);
-
- set_non_blocking(rfd, 1);
-
- errno = 0;
- n = read(rfd, &ctx->buf[0], sizeof(ctx->buf));
- assert(n == -1);
- assert(errno == EAGAIN);
-
- rv = poll(&pfd, 1, timeout);
- assert(rv == 1);
- assert(pfd.revents == POLLIN);
-
- n = read(rfd, &ctx->buf[0], sizeof(ctx->buf));
- assert(n == (ssize_t) sizeof(msg));
- assert(memcmp(&msg[0], &ctx->buf[0], sizeof(msg)) == 0);
-}
-
-static void
-test_pipe_write(test_context *ctx)
-{
- int rfd = ctx->pfd[0];
- int wfd = ctx->pfd[1];
- struct pollfd pfd = {
- .fd = wfd,
- .events = POLLOUT
- };
- int timeout = -1;
- int rv;
- ssize_t n;
-
- puts("test pipe write");
-
- assert(rfd >= 0);
- assert(wfd >= 0);
-
- ctx->rfd = rfd;
- ctx->rbuf = &ctx->buf[0];
- ctx->rn = sizeof(ctx->buf);
- send_events(ctx, EVENT_READ);
-
- set_non_blocking(wfd, 1);
-
- do {
- errno = 0;
- n = write(wfd, &ctx->buf[0], sizeof(ctx->buf));
- if (n == -1) {
- assert(errno == EAGAIN);
- }
- } while (n > 0);
-
- rv = poll(&pfd, 1, timeout);
- assert(rv == 1);
- assert(pfd.revents == POLLOUT);
-}
-
-static void
-test_pipe_close(test_context *ctx)
-{
- int rfd = ctx->pfd[0];
- struct pollfd pfd = {
- .fd = rfd,
- .events = POLLIN
- };
- int timeout = -1;
- int rv;
-
- puts("test pipe close");
-
- assert(ctx->pfd[0] >= 0);
- assert(ctx->pfd[1] >= 0);
-
- send_events(ctx, EVENT_CLOSE_PIPE);
-
- set_non_blocking(rfd, 0);
-
- assert(ctx->pfd[0] >= 0);
- assert(ctx->pfd[1] >= 0);
-
- rv = poll(&pfd, 1, timeout);
- assert(rv == 1);
- assert(pfd.revents == (POLLIN | POLLHUP));
-
- assert(ctx->pfd[0] == -1);
- assert(ctx->pfd[1] == -1);
-}
-
-static void
test_main(void)
{
test_context *ctx = &test_instance;
@@ -1279,11 +1129,6 @@ test_main(void)
test_kqueue_close(ctx);
test_kqueue_user(ctx);
- test_pipe_timeout(ctx);
- test_pipe_read(ctx);
- test_pipe_write(ctx);
- test_pipe_close(ctx);
-
exit(0);
}