summaryrefslogtreecommitdiff
path: root/libpipe
diff options
context:
space:
mode:
Diffstat (limited to 'libpipe')
-rw-r--r--libpipe/ChangeLog13
-rw-r--r--libpipe/pipe.c57
-rw-r--r--libpipe/pq.c30
3 files changed, 58 insertions, 42 deletions
diff --git a/libpipe/ChangeLog b/libpipe/ChangeLog
index 6f286f16..c95d471f 100644
--- a/libpipe/ChangeLog
+++ b/libpipe/ChangeLog
@@ -1,3 +1,10 @@
+1998-10-20 Roland McGrath <roland@baalperazim.frob.com>
+
+ * pq.c (free_packets): Add braces to silence gcc warning.
+ (packet_realloc): Likewise.
+ * pipe.c (pipe_send): Likewise.
+ (pipe_recv): Likewise.
+
Mon Oct 21 21:58:03 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* pipe.h: Add extern inline protection.
@@ -38,7 +45,7 @@ Sat Jan 13 13:56:13 1996 Miles Bader <miles@gnu.ai.mit.edu>
(packet_new_size): New declaration.
* pq.c (packet_size_adjust): Function removed.
(packet_new_size): New function.
-
+
* pq.c (packet_read): Re-arrange to be slightly less confusing.
Reverse start-past-buf-beginning test that may have leaked memory.
@@ -96,7 +103,7 @@ Tue Aug 29 14:37:49 1995 Miles Bader <miles@geech.gnu.ai.mit.edu>
* pipe.c (pipe_send): Use condition_broadcast, not condition_signal.
* pipe.h (pipe_select): New function.
-
+
* pipe.h (struct pipe): Remove interrupt_seq_num field.
(pipe_wait): Use hurd_condition_wait to detect interrupts instead
of previous ad-hoc mechanism.
@@ -144,6 +151,6 @@ Mon Jul 31 14:50:00 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu>
Fri Jul 28 23:03:27 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu>
- * pipe.h (stream_pipe_class, dgram_pipe_class, seqpack_pipe_class):
+ * pipe.h (stream_pipe_class, dgram_pipe_class, seqpack_pipe_class):
Make these declarations extern so they don't fuck up initialization.
(seqpacket_pipe_class): Renamed to `seqpack_pipe_class'.
diff --git a/libpipe/pipe.c b/libpipe/pipe.c
index 7f36e5f8..914816bc 100644
--- a/libpipe/pipe.c
+++ b/libpipe/pipe.c
@@ -1,6 +1,6 @@
/* Generic one-way pipes
- Copyright (C) 1995 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1998 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -66,7 +66,7 @@ pipe_create (struct pipe_class *class, struct pipe **pipe)
condition_init (&new->pending_write_selects);
mutex_init (&new->lock);
- pq_create (&new->queue);
+ pq_create (&new->queue);
if (! pipe_is_connless (new))
new->flags |= PIPE_BROKEN;
@@ -76,7 +76,7 @@ pipe_create (struct pipe_class *class, struct pipe **pipe)
}
/* Free PIPE and any resources it holds. */
-void
+void
pipe_free (struct pipe *pipe)
{
pq_free (pipe->queue);
@@ -149,7 +149,7 @@ void _pipe_no_writers (struct pipe *pipe)
this function (unlike most pipe functions). */
error_t
pipe_pair_select (struct pipe *rpipe, struct pipe *wpipe,
- int *select_type, int data_only)
+ int *select_type, int data_only)
{
error_t err = 0;
@@ -214,7 +214,7 @@ pipe_pair_select (struct pipe *rpipe, struct pipe *wpipe,
! ((wpipe->flags & PIPE_BROKEN)
|| pipe_readable (wpipe, 1) < wlimit);
}
-
+
if (!err)
{
if (rpipe_blocked)
@@ -260,10 +260,12 @@ pipe_send (struct pipe *pipe, int noblock, void *source,
{
size_t left = pipe->write_limit - pipe_readable (pipe, 1);
if (left < data_len)
- if (data_len <= pipe->write_atomic)
- return EWOULDBLOCK;
- else
- data_len = left;
+ {
+ if (data_len <= pipe->write_atomic)
+ return EWOULDBLOCK;
+ else
+ data_len = left;
+ }
}
if (control_len > 0 || num_ports > 0)
@@ -294,7 +296,7 @@ pipe_send (struct pipe *pipe, int noblock, void *source,
if (!err)
{
timestamp (&pipe->write_time);
-
+
/* And wakeup anyone that might be interested in it. */
condition_broadcast (&pipe->pending_reads);
mutex_unlock (&pipe->lock);
@@ -373,26 +375,29 @@ pipe_recv (struct pipe *pipe, int noblock, unsigned *flags, void **source,
}
if (!err)
- if (packet)
- /* Read some data (PACKET must be a data packet at this point). */
- {
- int dq = 1; /* True if we should dequeue this packet. */
-
- if (source)
- packet_read_source (packet, source);
-
- err = (*pipe->class->read)(packet, &dq, flags, data, data_len, amount);
- if (dq)
- pq_dequeue (pq);
- }
- else
- /* Return EOF. */
- *data_len = 0;
+ {
+ if (packet)
+ /* Read some data (PACKET must be a data packet at this point). */
+ {
+ int dq = 1; /* True if we should dequeue this packet. */
+
+ if (source)
+ packet_read_source (packet, source);
+
+ err = (*pipe->class->read)(packet, &dq, flags,
+ data, data_len, amount);
+ if (dq)
+ pq_dequeue (pq);
+ }
+ else
+ /* Return EOF. */
+ *data_len = 0;
+ }
if (!err && packet)
{
timestamp (&pipe->read_time);
-
+
/* And wakeup anyone that might be interested in it. */
condition_broadcast (&pipe->pending_writes);
mutex_unlock (&pipe->lock);
diff --git a/libpipe/pq.c b/libpipe/pq.c
index c48f90bd..9f8ab7ed 100644
--- a/libpipe/pq.c
+++ b/libpipe/pq.c
@@ -1,6 +1,6 @@
/* Packet queues
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -52,11 +52,13 @@ free_packets (struct packet *head)
if (head->ports)
free (head->ports);
if (head->buf_len > 0)
- if (head->buf_vm_alloced)
- vm_deallocate (mach_task_self (),
- (vm_address_t)head->buf, head->buf_len);
- else
- free (head->buf);
+ {
+ if (head->buf_vm_alloced)
+ vm_deallocate (mach_task_self (),
+ (vm_address_t)head->buf, head->buf_len);
+ else
+ free (head->buf);
+ }
free (head);
free_packets (next);
}
@@ -203,7 +205,7 @@ packet_extend (struct packet *packet, size_t new_len)
packet->buf_start = new_buf + (packet->buf_start - old_buf);
packet->buf_end = new_buf + (packet->buf_end - old_buf);
}
-
+
packet->buf_len = new_len;
return 1;
@@ -249,10 +251,12 @@ packet_realloc (struct packet *packet, size_t new_len)
/* And get rid of the old buffer. */
if (old_len > 0)
- if (packet->buf_vm_alloced)
- vm_deallocate (mach_task_self (), (vm_address_t)old_buf, old_len);
- else
- free (old_buf);
+ {
+ if (packet->buf_vm_alloced)
+ vm_deallocate (mach_task_self (), (vm_address_t)old_buf, old_len);
+ else
+ free (old_buf);
+ }
packet->buf = new_buf;
packet->buf_len = new_len;
@@ -267,7 +271,7 @@ packet_realloc (struct packet *packet, size_t new_len)
/* ---------------------------------------------------------------- */
/* If PACKET has any ports, deallocates them. */
-void
+void
packet_dealloc_ports (struct packet *packet)
{
unsigned i;
@@ -322,7 +326,7 @@ packet_read_ports (struct packet *packet,
/* Append the bytes in DATA, of length DATA_LEN, to what's already in PACKET,
and return the amount appended in AMOUNT. */
-error_t
+error_t
packet_write (struct packet *packet,
char *data, size_t data_len, size_t *amount)
{