[PATCH rtems-libbsd] rtemsbsd/syscalls: Remove pipe()

chrisj at rtems.org chrisj at rtems.org
Thu Sep 23 05:43:27 UTC 2021


From: Chris Johns <chrisj at rtems.org>

- This call is provided by RTEMS and that is preferred

Closes #4518
---
 rtemsbsd/rtems/rtems-bsd-syscall-api.c   |  52 --------
 testsuite/selectpollkqueue01/test_main.c | 155 -----------------------
 2 files changed, 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
@@ -441,58 +441,6 @@ listen(int socket, int backlog)
 	return rtems_bsd_error_to_status_and_errno(error);
 }
 
-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)
 {
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
@@ -1095,156 +1095,6 @@ test_kqueue_user(test_context *ctx)
 	assert(rv == 0);
 }
 
-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)
 {
@@ -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);
 }
 
-- 
2.24.1



More information about the devel mailing list