diff options
author | Thomas Bushnell <thomas@gnu.org> | 1996-10-24 19:27:14 +0000 |
---|---|---|
committer | Thomas Bushnell <thomas@gnu.org> | 1996-10-24 19:27:14 +0000 |
commit | 46b6fea942cd4840f5510cd06629e8c91fb55c11 (patch) | |
tree | 6124bcca09a2d369b8e35e3d244797a9663ecee6 /libpipe | |
parent | 3e94c51b0ade0767cf807dad1052e2e927ecc535 (diff) |
Mon Oct 21 21:58:03 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* pipe.h: Add extern inline protection.
* pq.h: Likewise.
* pipe-funcs.c, pq-funcs.c: New files.
* Makefile (SRCS): Add pipe-funcs.c and pq-funcs.c.
Diffstat (limited to 'libpipe')
-rw-r--r-- | libpipe/ChangeLog | 7 | ||||
-rw-r--r-- | libpipe/Makefile | 2 | ||||
-rw-r--r-- | libpipe/pipe-funcs.c | 2 | ||||
-rw-r--r-- | libpipe/pipe.h | 35 | ||||
-rw-r--r-- | libpipe/pq-funcs.c | 2 | ||||
-rw-r--r-- | libpipe/pq.h | 23 |
6 files changed, 46 insertions, 25 deletions
diff --git a/libpipe/ChangeLog b/libpipe/ChangeLog index a87e0bd0..6f286f16 100644 --- a/libpipe/ChangeLog +++ b/libpipe/ChangeLog @@ -1,3 +1,10 @@ +Mon Oct 21 21:58:03 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * pipe.h: Add extern inline protection. + * pq.h: Likewise. + * pipe-funcs.c, pq-funcs.c: New files. + * Makefile (SRCS): Add pipe-funcs.c and pq-funcs.c. + Thu Sep 12 16:24:41 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> * Makefile (HURDLIBS): New variable. diff --git a/libpipe/Makefile b/libpipe/Makefile index bb864dd4..b64166a6 100644 --- a/libpipe/Makefile +++ b/libpipe/Makefile @@ -22,7 +22,7 @@ makemode := library libname = libpipe installhdrs = pipe.h pq.h -SRCS = pq.c dgram.c pipe.c stream.c seqpack.c addr.c +SRCS = pq.c dgram.c pipe.c stream.c seqpack.c addr.c pq-funcs.c pipe-funcs.c LCLHDRS = pipe.h pq.h OBJS = $(SRCS:.c=.o) diff --git a/libpipe/pipe-funcs.c b/libpipe/pipe-funcs.c new file mode 100644 index 00000000..450180ee --- /dev/null +++ b/libpipe/pipe-funcs.c @@ -0,0 +1,2 @@ +#define PIPE_EI +#include "pipe.h" diff --git a/libpipe/pipe.h b/libpipe/pipe.h index cc765dc6..d6c5ae8f 100644 --- a/libpipe/pipe.h +++ b/libpipe/pipe.h @@ -26,6 +26,11 @@ #include <cthreads.h> /* For conditions & mutexes */ #include "pq.h" + +#ifndef PIPE_EI +#define PIPE_EI extern inline +#endif + /* A description of a class of pipes and how to operate on them. */ struct pipe_class @@ -104,7 +109,7 @@ struct pipe /* Returns the number of characters quickly readable from PIPE. If DATA_ONLY is true, then `control' packets are ignored. */ -extern inline size_t +PIPE_EI size_t pipe_readable (struct pipe *pipe, int data_only) { size_t readable = 0; @@ -123,7 +128,7 @@ pipe_readable (struct pipe *pipe, int data_only) then `control' packets are ignored. Note that this is different than (pipe_readable (PIPE) > 0) in the case where a control packet containing only ports is present. */ -extern inline int +PIPE_EI int pipe_is_readable (struct pipe *pipe, int data_only) { struct pq *pq = pipe->queue; @@ -138,7 +143,7 @@ pipe_is_readable (struct pipe *pipe, int data_only) this operation will return EWOULDBLOCK instead of blocking when no data is immediately available. If DATA_ONLY is true, then `control' packets are ignored. */ -extern inline error_t +PIPE_EI error_t pipe_wait_readable (struct pipe *pipe, int noblock, int data_only) { while (! pipe_is_readable (pipe, data_only) && ! (pipe->flags & PIPE_BROKEN)) @@ -155,7 +160,7 @@ pipe_wait_readable (struct pipe *pipe, int noblock, int data_only) returns once threads waiting using pipe_wait_readable have been woken and given a chance to read, and if there is still data available thereafter. If DATA_ONLY is true, then `control' packets are ignored. */ -extern inline error_t +PIPE_EI error_t pipe_select_readable (struct pipe *pipe, int data_only) { while (! pipe_is_readable (pipe, data_only) && ! (pipe->flags & PIPE_BROKEN)) @@ -167,7 +172,7 @@ pipe_select_readable (struct pipe *pipe, int data_only) /* Block until data can be written to PIPE. If NOBLOCK is true, then EWOULDBLOCK is returned instead of blocking if this can't be done immediately. */ -extern inline error_t +PIPE_EI error_t pipe_wait_writable (struct pipe *pipe, int noblock) { size_t limit = pipe->write_limit; @@ -188,7 +193,7 @@ pipe_wait_writable (struct pipe *pipe, int noblock) /* Block until some data can be written to PIPE. This call only returns once threads waiting using pipe_wait_writable have been woken and given a chance to write, and if there is still space available thereafter. */ -extern inline error_t +PIPE_EI error_t pipe_select_writable (struct pipe *pipe) { size_t limit = pipe->write_limit; @@ -219,7 +224,7 @@ void _pipe_no_readers (struct pipe *pipe); void _pipe_no_writers (struct pipe *pipe); /* Lock PIPE and increment its readers count. */ -extern inline void +PIPE_EI void pipe_acquire_reader (struct pipe *pipe) { mutex_lock (&pipe->lock); @@ -228,7 +233,7 @@ pipe_acquire_reader (struct pipe *pipe) } /* Lock PIPE and increment its writers count. */ -extern inline void +PIPE_EI void pipe_acquire_writer (struct pipe *pipe) { mutex_lock (&pipe->lock); @@ -238,7 +243,7 @@ pipe_acquire_writer (struct pipe *pipe) /* Decrement PIPE's (which should be locked) reader count and unlock it. If there are no more refs to PIPE, it will be destroyed. */ -extern inline void +PIPE_EI void pipe_release_reader (struct pipe *pipe) { if (--pipe->readers == 0) @@ -249,7 +254,7 @@ pipe_release_reader (struct pipe *pipe) /* Decrement PIPE's (which should be locked) writer count and unlock it. If there are no more refs to PIPE, it will be destroyed. */ -extern inline void +PIPE_EI void pipe_release_writer (struct pipe *pipe) { if (--pipe->writers == 0) @@ -259,7 +264,7 @@ pipe_release_writer (struct pipe *pipe) } /* Increment PIPE's reader count. PIPE should be unlocked. */ -extern inline void +PIPE_EI void pipe_add_reader (struct pipe *pipe) { pipe_acquire_reader (pipe); @@ -267,7 +272,7 @@ pipe_add_reader (struct pipe *pipe) } /* Increment PIPE's writer count. PIPE should be unlocked. */ -extern inline void +PIPE_EI void pipe_add_writer (struct pipe *pipe) { pipe_acquire_writer (pipe); @@ -276,7 +281,7 @@ pipe_add_writer (struct pipe *pipe) /* Decrement PIPE's (which should be unlocked) reader count and unlock it. If there are no more refs to PIPE, it will be destroyed. */ -extern inline void +PIPE_EI void pipe_remove_reader (struct pipe *pipe) { mutex_lock (&pipe->lock); @@ -285,7 +290,7 @@ pipe_remove_reader (struct pipe *pipe) /* Decrement PIPE's (which should be unlocked) writer count and unlock it. If there are no more refs to PIPE, it will be destroyed. */ -extern inline void +PIPE_EI void pipe_remove_writer (struct pipe *pipe) { mutex_lock (&pipe->lock); @@ -293,7 +298,7 @@ pipe_remove_writer (struct pipe *pipe) } /* Empty out PIPE of any data. PIPE should be locked. */ -extern inline void +PIPE_EI void pipe_drain (struct pipe *pipe) { pq_drain (pipe->queue); diff --git a/libpipe/pq-funcs.c b/libpipe/pq-funcs.c new file mode 100644 index 00000000..2acecd08 --- /dev/null +++ b/libpipe/pq-funcs.c @@ -0,0 +1,2 @@ +#define PQ_EI +#include "pq.h" diff --git a/libpipe/pq.h b/libpipe/pq.h index abd193f8..b98c8b19 100644 --- a/libpipe/pq.h +++ b/libpipe/pq.h @@ -1,6 +1,6 @@ /* Packet queues - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -25,6 +25,11 @@ #include <stddef.h> /* for size_t */ #include <string.h> #include <mach/mach.h> + +#ifndef PQ_EI +#define PQ_EI extern inline +#endif + struct packet { @@ -66,7 +71,7 @@ error_t packet_set_ports (struct packet *packet, void packet_dealloc_ports (struct packet *packet); /* Returns the number of bytes of data in PACKET. */ -extern inline size_t +PQ_EI size_t packet_readable (struct packet *packet) { return packet->buf_end - packet->buf_start; @@ -91,7 +96,7 @@ error_t packet_read_ports (struct packet *packet, /* Return the source addressd in PACKET in SOURCE, deallocating it from PACKET. */ -extern inline void +PQ_EI void packet_read_source (struct packet *packet, void **source) { *source = packet->source; @@ -122,7 +127,7 @@ error_t packet_realloc (struct packet *packet, size_t new_len); /* Try to make space in PACKET for AMOUNT more bytes without growing the buffer, returning true if we could do it. */ -extern inline int +PQ_EI int packet_fit (struct packet *packet, size_t amount) { char *buf = packet->buf, *end = packet->buf_end; @@ -154,7 +159,7 @@ packet_fit (struct packet *packet, size_t amount) /* Make sure that PACKET has room for at least AMOUNT more bytes, or return the reason why not. */ -extern inline error_t +PQ_EI error_t packet_ensure (struct packet *packet, size_t amount) { if (! packet_fit (packet, amount)) @@ -171,7 +176,7 @@ packet_ensure (struct packet *packet, size_t amount) it can be done efficiently, e.g., the packet can be grown in place, rather than moving the contents (or there is little enough data so that copying it is OK). True is returned if room was made, false otherwise. */ -extern inline int +PQ_EI int packet_ensure_efficiently (struct packet *packet, size_t amount) { if (! packet_fit (packet, amount)) @@ -199,7 +204,7 @@ struct packet *pq_queue (struct pq *pq, unsigned type, void *source); /* Returns the tail of the packet queue PQ, which may mean pushing a new packet if TYPE and SOURCE do not match the current tail, or this is the first packet. */ -extern inline struct packet * +PQ_EI struct packet * pq_tail (struct pq *pq, unsigned type, void *source) { struct packet *tail = pq->tail; @@ -218,7 +223,7 @@ int pq_dequeue (struct pq *pq); A packet is inappropiate if SOURCE is non-NULL its source field doesn't match it, or TYPE is non-NULL and the packet's type field doesn't match it. */ -extern inline struct packet * +PQ_EI struct packet * pq_head (struct pq *pq, unsigned type, void *source) { struct packet *head = pq->head; @@ -232,7 +237,7 @@ pq_head (struct pq *pq, unsigned type, void *source) } /* The same as pq_head, but first discards the head of the queue. */ -extern inline struct packet * +PQ_EI struct packet * pq_next (struct pq *pq, unsigned type, void *source) { if (!pq->head) |