summaryrefslogtreecommitdiff
path: root/libpipe
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2012-03-25 22:13:55 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-03-25 22:33:49 +0200
commit69056411a354300a17d1e92027435c988508655d (patch)
tree0d3741400b400cef79c7bf52625adc8966f2207f /libpipe
parentf605070d37c741436b5f82745eae2a5c018e304d (diff)
Fix extern inline use
* ext2fs/Makefile (SRCS): Add xinl.c * libtreefs/Makefile (OTHERSRCS): Likewise. * term/Makefile (SRCS): Likewise. * ufs/Makefile (SRCS): Likewise. * hostmux/hostmux-xinl.c: Define HOSTMUX_DEFINE_EI instead of HOSTMUX_EI. * libdiskfs/extern-inline.c: Define DISKFS_DEFINE_EXTERN_INLINE instead of DISKFS_EXTERN_INLINE. * libftpconn/xinl.c: Define FTP_CONN_DEFINE_EI instead of FTP_CONN_EI. * libpipe/pipe-funcs.c: Define PIPE_DEFINE_EI instead of PIPE_EI. * libpipe/pq-funcs.c: Define PQ_DEFINE_EI instead of PQ_EI. * libshouldbeinlibc/idvec-funcs.c: Define IDVEC_DEFINE_EI instead of IDVEC_EI. * libshouldbeinlibc/maptime-funcs.c: Define MAPTIME_DEFINE_EI instead of MAPTIME_EI. * libshouldbeinlibc/ugids-xinl.c: Define UGIDS_DEFINE_EI instead of UGIDS_EI. * libstore/xinl.c: Define STORE_DEFINE_EI instead of STORE_EI. * libthreads/rwlock.c: Define RWLOCK_DEFINE_EI instead of RWLOCK_EI. * ext2fs/xinl.c: New file, define EXT2FS_DEFINE_EI and include "ext2fs.h" * libtreefs/xinl.c: New file, define TREEFS_DEFINE_EI and include "treefs.h" and "mig-decls.h". * term/xinl.c: New file, define TERM_DEFINE_EI and include "term.h". * ufs/xinl.c: New file, define UFS_DEFINE_EI and include "ufs.h" * ext2fs/ext2fs.h: Include <features.h>, define EXT2FS_EI to __extern_inline instead of "extern inline", define it to empty when EXT2FS_DEFINE_EI is defined. Always declare extern inline prototypes, and define extern inlines content only if __USE_EXTERN_INLINES or EXT2FS_DEFINE_EI is defined. * libdiskfs/diskfs.h: Likewise with DISKFS_EXTERN_INLINE and DISKFS_DEFINE_EXTERN_INLINE. * libftpconn/ftpconn.h: Likewise with FTP_CONN_EI and FTP_CONN_DEFINE_EI. * libftpconn/priv.h: Likewise. * libpipe/pipe.h: Likewise with PIPE_EI and PIPE_DEFINE_EI. * libpipe/pq.h: Likewise with PQ_EI and PQ_DEFINE_EI. * libshouldbeinlibc/idvec.h: Likewise with IDVEC_EI and IDVEC_DEFINE_EI. * libshouldbeinlibc/maptime.h: Likewise with MAPTIME_EI and MAPTIME_DEFINE_EI. * libshouldbeinlibc/ugids.h: Likewise with UGIDS_EI and UGIDS_DEFINE_EI. * libstore/store.h: Likewise with STORE_EI and STORE_DEFINE_EI. * libthreads/rwlock.h: Likewise with RWLOCK_EI and RWLOCK_DEFINE_EI. * term/term.h: Likewise with TERM_EI and TERM_DEFINE_EI. * ufs/ufs.h: Likewise with UFS_EI and UFS_DEFINE_EI. * libtreefs/treefs.h: Include <features.h>, define TREE_FS_EI to __extern_inline, or to empty when TREEFS_DEFINE_EI is defined. Use TREEFS_EI instead of "extern inline". * libtreefs/mig-decls.h: Use TREEFS_EI instead of "extern inline".
Diffstat (limited to 'libpipe')
-rw-r--r--libpipe/pipe-funcs.c2
-rw-r--r--libpipe/pipe.h50
-rw-r--r--libpipe/pq-funcs.c2
-rw-r--r--libpipe/pq.h43
4 files changed, 89 insertions, 8 deletions
diff --git a/libpipe/pipe-funcs.c b/libpipe/pipe-funcs.c
index 450180ee..79cda2a4 100644
--- a/libpipe/pipe-funcs.c
+++ b/libpipe/pipe-funcs.c
@@ -1,2 +1,2 @@
-#define PIPE_EI
+#define PIPE_DEFINE_EI
#include "pipe.h"
diff --git a/libpipe/pipe.h b/libpipe/pipe.h
index 701cc918..96432990 100644
--- a/libpipe/pipe.h
+++ b/libpipe/pipe.h
@@ -24,13 +24,16 @@
#define EWOULDBLOCK EAGAIN /* XXX */
#include <cthreads.h> /* For conditions & mutexes */
+#include <features.h>
-#include "pq.h"
-
-#ifndef PIPE_EI
-#define PIPE_EI extern inline
+#ifdef PIPE_DEFINE_EI
+#define PIPE_EI
+#else
+#define PIPE_EI __extern_inline
#endif
+#include "pq.h"
+
/* A description of a class of pipes and how to operate on them. */
struct pipe_class
@@ -107,6 +110,21 @@ struct pipe
/* Pipe flags. */
#define PIPE_BROKEN 0x1 /* This pipe isn't connected. */
+
+extern size_t pipe_readable (struct pipe *pipe, int data_only);
+
+extern int pipe_is_readable (struct pipe *pipe, int data_only);
+
+extern error_t pipe_wait_readable (struct pipe *pipe, int noblock, int data_only);
+
+extern error_t pipe_select_readable (struct pipe *pipe, int data_only);
+
+extern error_t pipe_wait_writable (struct pipe *pipe, int noblock);
+
+extern error_t pipe_select_writable (struct pipe *pipe);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PIPE_DEFINE_EI)
+
/* Returns the number of characters quickly readable from PIPE. If DATA_ONLY
is true, then `control' packets are ignored. */
PIPE_EI size_t
@@ -203,6 +221,8 @@ pipe_select_writable (struct pipe *pipe)
return 0;
}
+#endif /* Use extern inlines. */
+
/* Creates a new pipe of class CLASS and returns it in RESULT. */
error_t pipe_create (struct pipe_class *class, struct pipe **pipe);
@@ -223,6 +243,26 @@ void _pipe_no_readers (struct pipe *pipe);
should be locked. */
void _pipe_no_writers (struct pipe *pipe);
+extern void pipe_acquire_reader (struct pipe *pipe);
+
+extern void pipe_acquire_writer (struct pipe *pipe);
+
+extern void pipe_release_reader (struct pipe *pipe);
+
+extern void pipe_release_writer (struct pipe *pipe);
+
+extern void pipe_add_reader (struct pipe *pipe);
+
+extern void pipe_add_writer (struct pipe *pipe);
+
+extern void pipe_remove_reader (struct pipe *pipe);
+
+extern void pipe_remove_writer (struct pipe *pipe);
+
+extern void pipe_drain (struct pipe *pipe);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PIPE_DEFINE_EI)
+
/* Lock PIPE and increment its readers count. */
PIPE_EI void
pipe_acquire_reader (struct pipe *pipe)
@@ -304,6 +344,8 @@ pipe_drain (struct pipe *pipe)
pq_drain (pipe->queue);
}
+#endif /* Use extern inlines. */
+
/* Writes up to LEN bytes of DATA, to PIPE, which should be locked, and
returns the amount written in AMOUNT. If present, the information in
CONTROL & PORTS is written in a preceding control packet. If an error is
diff --git a/libpipe/pq-funcs.c b/libpipe/pq-funcs.c
index 2acecd08..57061419 100644
--- a/libpipe/pq-funcs.c
+++ b/libpipe/pq-funcs.c
@@ -1,2 +1,2 @@
-#define PQ_EI
+#define PQ_DEFINE_EI
#include "pq.h"
diff --git a/libpipe/pq.h b/libpipe/pq.h
index 2f8311ef..0fffe254 100644
--- a/libpipe/pq.h
+++ b/libpipe/pq.h
@@ -25,9 +25,12 @@
#include <stddef.h> /* for size_t */
#include <string.h>
#include <mach/mach.h>
+#include <features.h>
-#ifndef PQ_EI
-#define PQ_EI extern inline
+#ifdef PQ_DEFINE_EI
+#define PQ_EI
+#else
+#define PQ_EI __extern_inline
#endif
@@ -70,6 +73,10 @@ error_t packet_set_ports (struct packet *packet,
/* If PACKET has any ports, deallocates them. */
void packet_dealloc_ports (struct packet *packet);
+extern size_t packet_readable (struct packet *packet);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* Returns the number of bytes of data in PACKET. */
PQ_EI size_t
packet_readable (struct packet *packet)
@@ -77,6 +84,8 @@ packet_readable (struct packet *packet)
return packet->buf_end - packet->buf_start;
}
+#endif /* Use extern inlines. */
+
/* Append the bytes in DATA, of length DATA_LEN, to what's already in PACKET,
and return the amount appended in AMOUNT if that's not the null pointer. */
error_t packet_write (struct packet *packet,
@@ -94,6 +103,10 @@ error_t packet_read (struct packet *packet,
error_t packet_read_ports (struct packet *packet,
mach_port_t **ports, size_t *num_ports);
+extern void packet_read_source (struct packet *packet, void **source);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* Return the source addressd in PACKET in SOURCE, deallocating it from
PACKET. */
PQ_EI void
@@ -102,6 +115,8 @@ packet_read_source (struct packet *packet, void **source)
*source = packet->source;
packet->source = 0;
}
+
+#endif /* Use extern inlines. */
/* The packet size above which we start to do things differently to avoid
copying around data. */
@@ -125,6 +140,14 @@ int packet_extend (struct packet *packet, size_t new_len);
returned. */
error_t packet_realloc (struct packet *packet, size_t new_len);
+extern int packet_fit (struct packet *packet, size_t amount);
+
+extern error_t packet_ensure (struct packet *packet, size_t amount);
+
+extern int packet_ensure_efficiently (struct packet *packet, size_t amount);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* Try to make space in PACKET for AMOUNT more bytes without growing the
buffer, returning true if we could do it. */
PQ_EI int
@@ -189,6 +212,8 @@ packet_ensure_efficiently (struct packet *packet, size_t amount)
}
return 0;
}
+
+#endif /* Use extern inlines. */
struct pq
{
@@ -201,6 +226,10 @@ struct pq
the packet, or deallocated by calling pipe_dealloc_addr. */
struct packet *pq_queue (struct pq *pq, unsigned type, void *source);
+extern struct packet * pq_tail (struct pq *pq, unsigned type, void *source);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* 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. */
@@ -214,10 +243,18 @@ pq_tail (struct pq *pq, unsigned type, void *source)
return tail;
}
+#endif /* Use extern inlines. */
+
/* Remove the first packet (if any) in PQ, deallocating any resources it
holds. True is returned if a packet was found, false otherwise. */
int pq_dequeue (struct pq *pq);
+extern struct packet * pq_head (struct pq *pq, unsigned type, void *source);
+
+extern struct packet * pq_next (struct pq *pq, unsigned type, void *source);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PQ_DEFINE_EI)
+
/* Returns the next available packet in PQ, without removing it from the
queue, or NULL if there is none, or the next packet isn't appropriate.
A packet is inappropriate if SOURCE is non-NULL its source field doesn't
@@ -246,6 +283,8 @@ pq_next (struct pq *pq, unsigned type, void *source)
return pq_head (pq, type, source);
}
+#endif /* Use extern inlines. */
+
/* Dequeues all packets in PQ. */
void pq_drain (struct pq *pq);