summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@gnu.org>2009-06-23 00:27:28 +0200
committerThomas Schwinge <tschwinge@gnu.org>2009-06-24 14:46:14 +0200
commit2753b921ca2d486e023de8f8d10b606e25ad1387 (patch)
tree9f030fde5ab2b53044346f67ed79dd9d201d3cd2
parentc6c9d7a69dea26e04bba7010582e7bcd612e710c (diff)
[__USE_EXTERN_INLINES]: Use glibc's __extern_inline machinery.
* libdiskfs/diskfs.h: Apply inline optimization only #ifdef __USE_EXTERN_INLINES. Use __extern_inline instead of extern inline. * libftpconn/ftpconn.h: Likewise. * libpipe/pipe.h: Likewise. * libpipe/pq.h: Likewise. * libshouldbeinlibc/idvec.h: Likewise. * libshouldbeinlibc/maptime.h: Likewise. * libshouldbeinlibc/ugids.h: Likewise. * libstore/store.h: Likewise. * libthreads/rwlock.h: Likewise. * libdiskfs/extern-inline.c: Adapt to these changes. * libftpconn/xinl.c: Likewise. And don't #include "priv.h". * libpipe/pipe-funcs.c: Likewise. * libpipe/pq-funcs.c: Likewise. * libshouldbeinlibc/idvec-funcs.c: Likewise. * libshouldbeinlibc/maptime-funcs.c: Likewise. And remove superfluous includes. * libshouldbeinlibc/ugids-xinl.c: Likewise. * libstore/xinl.c: Likewise. * libthreads/rwlock.c: Likewise.
-rw-r--r--libdiskfs/diskfs.h41
-rw-r--r--libdiskfs/extern-inline.c7
-rw-r--r--libftpconn/ftpconn.h37
-rw-r--r--libftpconn/xinl.c8
-rw-r--r--libpipe/pipe-funcs.c3
-rw-r--r--libpipe/pipe.h306
-rw-r--r--libpipe/pq-funcs.c3
-rw-r--r--libpipe/pq.h148
-rw-r--r--libshouldbeinlibc/idvec-funcs.c3
-rw-r--r--libshouldbeinlibc/idvec.h73
-rw-r--r--libshouldbeinlibc/maptime-funcs.c6
-rw-r--r--libshouldbeinlibc/maptime.h21
-rw-r--r--libshouldbeinlibc/ugids-xinl.c7
-rw-r--r--libshouldbeinlibc/ugids.h101
-rw-r--r--libstore/store.h42
-rw-r--r--libstore/xinl.c3
-rw-r--r--libthreads/rwlock.c3
-rw-r--r--libthreads/rwlock.h50
18 files changed, 505 insertions, 357 deletions
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 9a61964c..bb139fc2 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -28,10 +28,6 @@
#include <hurd/iohelp.h>
#include <idvec.h>
-#ifndef DISKFS_EXTERN_INLINE
-#define DISKFS_EXTERN_INLINE extern inline
-#endif
-
/* Each user port referring to a file points to one of these
(with the aid of the ports library). */
struct protid
@@ -784,21 +780,12 @@ void diskfs_finish_protid (struct protid *cred, struct iouser *user);
/* Called by MiG to translate ports into struct protid *.
fsmutations.h arranges for this to happen for the io and
fs interfaces. */
-DISKFS_EXTERN_INLINE struct protid *
-diskfs_begin_using_protid_port (file_t port)
-{
- return ports_lookup_port (diskfs_port_bucket, port, diskfs_protid_class);
-}
+struct protid *diskfs_begin_using_protid_port (file_t port);
/* Called by MiG after server routines have been run; this
balances begin_using_protid_port, and is arranged for the io
and fs interfaces by fsmutations.h. */
-DISKFS_EXTERN_INLINE void
-diskfs_end_using_protid_port (struct protid *cred)
-{
- if (cred)
- ports_port_deref (cred);
-}
+void diskfs_end_using_protid_port (struct protid *cred);
/* Called when a protid CRED has no more references. (Because references\
to protids are maintained by the port management library, this is
@@ -978,5 +965,29 @@ struct store *diskfs_init_main (struct argp *startup_argp,
/* Make errors go somewhere reasonable. */
void diskfs_console_stdio ();
+
+/* Inlining optimizations. */
+
+#include <features.h>
+
+#ifdef __USE_EXTERN_INLINES
+# ifndef DISKFS_H_EXTERN_INLINE
+# define DISKFS_H_EXTERN_INLINE __extern_inline
+# endif
+
+DISKFS_H_EXTERN_INLINE struct protid *
+diskfs_begin_using_protid_port (file_t port)
+{
+ return ports_lookup_port (diskfs_port_bucket, port, diskfs_protid_class);
+}
+
+DISKFS_H_EXTERN_INLINE void
+diskfs_end_using_protid_port (struct protid *cred)
+{
+ if (cred)
+ ports_port_deref (cred);
+}
+
+#endif /* __USE_EXTERN_INLINES */
#endif /* hurd/diskfs.h */
diff --git a/libdiskfs/extern-inline.c b/libdiskfs/extern-inline.c
index 0abcc4cc..efcb7b6c 100644
--- a/libdiskfs/extern-inline.c
+++ b/libdiskfs/extern-inline.c
@@ -1,5 +1,6 @@
/* Run time callable functions for extern inlines.
- Copyright (C) 2001 Free Software Foundation, Inc.
+
+ Copyright (C) 2001, 2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -15,6 +16,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#define DISKFS_EXTERN_INLINE
-
+#define __USE_EXTERN_INLINES
+#define DISKFS_H_EXTERN_INLINE
#include "diskfs.h"
diff --git a/libftpconn/ftpconn.h b/libftpconn/ftpconn.h
index e445130e..f18aa784 100644
--- a/libftpconn/ftpconn.h
+++ b/libftpconn/ftpconn.h
@@ -1,6 +1,6 @@
/* Manage an ftp connection
- Copyright (C) 1997,2001,02 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2001, 2002, 2009 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.org>
@@ -35,10 +35,6 @@ typedef int error_t;
#define __error_t_defined
#endif
-#ifndef FTP_CONN_EI
-# define FTP_CONN_EI extern inline
-#endif
-
struct ftp_conn;
struct ftp_conn_params;
struct ftp_conn_stat;
@@ -244,15 +240,7 @@ void ftp_conn_close (struct ftp_conn *conn);
/* Makes sure that CONN's syshooks are set according to the remote system
type. */
-FTP_CONN_EI error_t
-ftp_conn_validate_syshooks (struct ftp_conn *conn)
-{
- if (conn->syshooks_valid)
- return 0;
- else
- /* Opening the connection should set the syshooks. */
- return ftp_conn_open (conn);
-}
+error_t ftp_conn_validate_syshooks (struct ftp_conn *conn);
/* Create a new ftp connection as specified by PARAMS, and return it in CONN;
HOOKS contains customization hooks used by the connection. Neither PARAMS
@@ -383,5 +371,26 @@ error_t ftp_conn_append_name (struct ftp_conn *conn,
newly malloced copy of COMPOSITE in BASE. */
error_t ftp_conn_basename (struct ftp_conn *conn,
const char *composite, char **base);
+
+/* Inlining optimizations. */
+
+#include <features.h>
+
+#ifdef __USE_EXTERN_INLINES
+# ifndef FTPCONN_H_EXTERN_INLINE
+# define FTPCONN_H_EXTERN_INLINE __extern_inline
+# endif
+
+FTPCONN_H_EXTERN_INLINE error_t
+ftp_conn_validate_syshooks (struct ftp_conn *conn)
+{
+ if (conn->syshooks_valid)
+ return 0;
+ else
+ /* Opening the connection should set the syshooks. */
+ return ftp_conn_open (conn);
+}
+
+#endif /* __USE_EXTERN_INLINES */
#endif /* __FTPCONN_H__ */
diff --git a/libftpconn/xinl.c b/libftpconn/xinl.c
index a975b80d..c2d119f9 100644
--- a/libftpconn/xinl.c
+++ b/libftpconn/xinl.c
@@ -1,6 +1,6 @@
-/* Real definitions for extern inline functions in priv.h
+/* Real definitions for extern inline functions in ftpconn.h.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2009 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -19,6 +19,6 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#define FTP_CONN_EI
+#define __USE_EXTERN_INLINES
+#define FTPCONN_H_EXTERN_INLINE
#include <ftpconn.h>
-#include "priv.h"
diff --git a/libpipe/pipe-funcs.c b/libpipe/pipe-funcs.c
index 450180ee..5a21a84b 100644
--- a/libpipe/pipe-funcs.c
+++ b/libpipe/pipe-funcs.c
@@ -1,2 +1,3 @@
-#define PIPE_EI
+#define __USE_EXTERN_INLINES
+#define PIPE_H_EXTERN_INLINE
#include "pipe.h"
diff --git a/libpipe/pipe.h b/libpipe/pipe.h
index d6c5ae8f..6cda4f32 100644
--- a/libpipe/pipe.h
+++ b/libpipe/pipe.h
@@ -1,6 +1,6 @@
/* Generic one-way pipes
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 2009 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -26,11 +26,6 @@
#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
@@ -109,99 +104,35 @@ struct pipe
/* Returns the number of characters quickly readable from PIPE. If DATA_ONLY
is true, then `control' packets are ignored. */
-PIPE_EI size_t
-pipe_readable (struct pipe *pipe, int data_only)
-{
- size_t readable = 0;
- struct pq *pq = pipe->queue;
- struct packet *packet = pq_head (pq, PACKET_TYPE_ANY, NULL);
- while (packet)
- {
- if (packet->type == PACKET_TYPE_DATA)
- readable += packet_readable (packet);
- packet = packet->next;
- }
- return readable;
-}
+size_t pipe_readable (struct pipe *pipe, int data_only);
/* Returns true if there's any data available in PIPE. If DATA_ONLY is true,
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. */
-PIPE_EI int
-pipe_is_readable (struct pipe *pipe, int data_only)
-{
- struct pq *pq = pipe->queue;
- struct packet *packet = pq_head (pq, PACKET_TYPE_ANY, NULL);
- if (data_only)
- while (packet && packet->type == PACKET_TYPE_CONTROL)
- packet = packet->next;
- return (packet != NULL);
-}
+int pipe_is_readable (struct pipe *pipe, int data_only);
/* Waits for PIPE to be readable, or an error to occurr. If NOBLOCK is true,
this operation will return EWOULDBLOCK instead of blocking when no data is
immediately available. If DATA_ONLY is true, then `control' packets are
ignored. */
-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))
- {
- if (noblock)
- return EWOULDBLOCK;
- if (hurd_condition_wait (&pipe->pending_reads, &pipe->lock))
- return EINTR;
- }
- return 0;
-}
+error_t pipe_wait_readable (struct pipe *pipe, int noblock, int data_only);
/* Waits for PIPE to be readable, or an error to occurr. This call 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. */
-PIPE_EI error_t
-pipe_select_readable (struct pipe *pipe, int data_only)
-{
- while (! pipe_is_readable (pipe, data_only) && ! (pipe->flags & PIPE_BROKEN))
- if (hurd_condition_wait (&pipe->pending_read_selects, &pipe->lock))
- return EINTR;
- return 0;
-}
+error_t 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. */
-PIPE_EI error_t
-pipe_wait_writable (struct pipe *pipe, int noblock)
-{
- size_t limit = pipe->write_limit;
- if (pipe->flags & PIPE_BROKEN)
- return EPIPE;
- while (pipe_readable (pipe, 1) >= limit)
- {
- if (noblock)
- return EWOULDBLOCK;
- if (hurd_condition_wait (&pipe->pending_writes, &pipe->lock))
- return EINTR;
- if (pipe->flags & PIPE_BROKEN)
- return EPIPE;
- }
- return 0;
-}
+error_t 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. */
-PIPE_EI error_t
-pipe_select_writable (struct pipe *pipe)
-{
- size_t limit = pipe->write_limit;
- while (! (pipe->flags & PIPE_BROKEN) && pipe_readable (pipe, 1) >= limit)
- if (hurd_condition_wait (&pipe->pending_writes, &pipe->lock))
- return EINTR;
- return 0;
-}
+error_t pipe_select_writable (struct pipe *pipe);
/* Creates a new pipe of class CLASS and returns it in RESULT. */
error_t pipe_create (struct pipe_class *class, struct pipe **pipe);
@@ -224,85 +155,35 @@ void _pipe_no_readers (struct pipe *pipe);
void _pipe_no_writers (struct pipe *pipe);
/* Lock PIPE and increment its readers count. */
-PIPE_EI void
-pipe_acquire_reader (struct pipe *pipe)
-{
- mutex_lock (&pipe->lock);
- if (pipe->readers++ == 0)
- _pipe_first_reader (pipe);
-}
+void pipe_acquire_reader (struct pipe *pipe);
/* Lock PIPE and increment its writers count. */
-PIPE_EI void
-pipe_acquire_writer (struct pipe *pipe)
-{
- mutex_lock (&pipe->lock);
- if (pipe->writers++ == 0)
- _pipe_first_writer (pipe);
-}
+void 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. */
-PIPE_EI void
-pipe_release_reader (struct pipe *pipe)
-{
- if (--pipe->readers == 0)
- _pipe_no_readers (pipe);
- else
- mutex_unlock (&pipe->lock);
-}
+void 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. */
-PIPE_EI void
-pipe_release_writer (struct pipe *pipe)
-{
- if (--pipe->writers == 0)
- _pipe_no_writers (pipe);
- else
- mutex_unlock (&pipe->lock);
-}
+void pipe_release_writer (struct pipe *pipe);
/* Increment PIPE's reader count. PIPE should be unlocked. */
-PIPE_EI void
-pipe_add_reader (struct pipe *pipe)
-{
- pipe_acquire_reader (pipe);
- mutex_unlock (&pipe->lock);
-}
+void pipe_add_reader (struct pipe *pipe);
/* Increment PIPE's writer count. PIPE should be unlocked. */
-PIPE_EI void
-pipe_add_writer (struct pipe *pipe)
-{
- pipe_acquire_writer (pipe);
- mutex_unlock (&pipe->lock);
-}
+void 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. */
-PIPE_EI void
-pipe_remove_reader (struct pipe *pipe)
-{
- mutex_lock (&pipe->lock);
- pipe_release_reader (pipe);
-}
+void 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. */
-PIPE_EI void
-pipe_remove_writer (struct pipe *pipe)
-{
- mutex_lock (&pipe->lock);
- pipe_release_writer (pipe);
-}
+void pipe_remove_writer (struct pipe *pipe);
/* Empty out PIPE of any data. PIPE should be locked. */
-PIPE_EI void
-pipe_drain (struct pipe *pipe)
-{
- pq_drain (pipe->queue);
-}
+void pipe_drain (struct pipe *pipe);
/* 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
@@ -377,5 +258,160 @@ error_t pipe_pair_select (struct pipe *rpipe, struct pipe *wpipe,
function taking a non-NULL source address and deallocating it. It
defaults to calling ports_port_deref. */
void pipe_dealloc_addr (void *addr);
+
+/* Inlining optimizations. */
+
+#include <features.h>
+
+#ifdef __USE_EXTERN_INLINES
+# ifndef PIPE_H_EXTERN_INLINE
+# define PIPE_H_EXTERN_INLINE __extern_inline
+# endif
+
+PIPE_H_EXTERN_INLINE size_t
+pipe_readable (struct pipe *pipe, int data_only)
+{
+ size_t readable = 0;
+ struct pq *pq = pipe->queue;
+ struct packet *packet = pq_head (pq, PACKET_TYPE_ANY, NULL);
+ while (packet)
+ {
+ if (packet->type == PACKET_TYPE_DATA)
+ readable += packet_readable (packet);
+ packet = packet->next;
+ }
+ return readable;
+}
+
+PIPE_H_EXTERN_INLINE int
+pipe_is_readable (struct pipe *pipe, int data_only)
+{
+ struct pq *pq = pipe->queue;
+ struct packet *packet = pq_head (pq, PACKET_TYPE_ANY, NULL);
+ if (data_only)
+ while (packet && packet->type == PACKET_TYPE_CONTROL)
+ packet = packet->next;
+ return (packet != NULL);
+}
+
+PIPE_H_EXTERN_INLINE error_t
+pipe_wait_readable (struct pipe *pipe, int noblock, int data_only)
+{
+ while (! pipe_is_readable (pipe, data_only) && ! (pipe->flags & PIPE_BROKEN))
+ {
+ if (noblock)
+ return EWOULDBLOCK;
+ if (hurd_condition_wait (&pipe->pending_reads, &pipe->lock))
+ return EINTR;
+ }
+ return 0;
+}
+
+PIPE_H_EXTERN_INLINE error_t
+pipe_select_readable (struct pipe *pipe, int data_only)
+{
+ while (! pipe_is_readable (pipe, data_only) && ! (pipe->flags & PIPE_BROKEN))
+ if (hurd_condition_wait (&pipe->pending_read_selects, &pipe->lock))
+ return EINTR;
+ return 0;
+}
+
+PIPE_H_EXTERN_INLINE error_t
+pipe_wait_writable (struct pipe *pipe, int noblock)
+{
+ size_t limit = pipe->write_limit;
+ if (pipe->flags & PIPE_BROKEN)
+ return EPIPE;
+ while (pipe_readable (pipe, 1) >= limit)
+ {
+ if (noblock)
+ return EWOULDBLOCK;
+ if (hurd_condition_wait (&pipe->pending_writes, &pipe->lock))
+ return EINTR;
+ if (pipe->flags & PIPE_BROKEN)
+ return EPIPE;
+ }
+ return 0;
+}
+
+PIPE_H_EXTERN_INLINE error_t
+pipe_select_writable (struct pipe *pipe)
+{
+ size_t limit = pipe->write_limit;
+ while (! (pipe->flags & PIPE_BROKEN) && pipe_readable (pipe, 1) >= limit)
+ if (hurd_condition_wait (&pipe->pending_writes, &pipe->lock))
+ return EINTR;
+ return 0;
+}
+
+PIPE_H_EXTERN_INLINE void
+pipe_acquire_reader (struct pipe *pipe)
+{
+ mutex_lock (&pipe->lock);
+ if (pipe->readers++ == 0)
+ _pipe_first_reader (pipe);
+}
+
+PIPE_H_EXTERN_INLINE void
+pipe_acquire_writer (struct pipe *pipe)
+{
+ mutex_lock (&pipe->lock);
+ if (pipe->writers++ == 0)
+ _pipe_first_writer (pipe);
+}
+
+PIPE_H_EXTERN_INLINE void
+pipe_release_reader (struct pipe *pipe)
+{
+ if (--pipe->readers == 0)
+ _pipe_no_readers (pipe);
+ else
+ mutex_unlock (&pipe->lock);
+}
+
+PIPE_H_EXTERN_INLINE void
+pipe_release_writer (struct pipe *pipe)
+{
+ if (--pipe->writers == 0)
+ _pipe_no_writers (pipe);
+ else
+ mutex_unlock (&pipe->lock);
+}
+
+PIPE_H_EXTERN_INLINE void
+pipe_add_reader (struct pipe *pipe)
+{
+ pipe_acquire_reader (pipe);
+ mutex_unlock (&pipe->lock);
+}
+
+PIPE_H_EXTERN_INLINE void
+pipe_add_writer (struct pipe *pipe)
+{
+ pipe_acquire_writer (pipe);
+ mutex_unlock (&pipe->lock);
+}
+
+PIPE_H_EXTERN_INLINE void
+pipe_remove_reader (struct pipe *pipe)
+{
+ mutex_lock (&pipe->lock);
+ pipe_release_reader (pipe);
+}
+
+PIPE_H_EXTERN_INLINE void
+pipe_remove_writer (struct pipe *pipe)
+{
+ mutex_lock (&pipe->lock);
+ pipe_release_writer (pipe);
+}
+
+PIPE_H_EXTERN_INLINE void
+pipe_drain (struct pipe *pipe)
+{
+ pq_drain (pipe->queue);
+}
+
+#endif /* __USE_EXTERN_INLINES */
#endif /* __PIPE_H__ */
diff --git a/libpipe/pq-funcs.c b/libpipe/pq-funcs.c
index 2acecd08..fabe466d 100644
--- a/libpipe/pq-funcs.c
+++ b/libpipe/pq-funcs.c
@@ -1,2 +1,3 @@
-#define PQ_EI
+#define __USE_EXTERN_INLINES
+#define PQ_H_EXTERN_INLINE
#include "pq.h"
diff --git a/libpipe/pq.h b/libpipe/pq.h
index 3a26aa80..2ff8c326 100644
--- a/libpipe/pq.h
+++ b/libpipe/pq.h
@@ -1,6 +1,6 @@
/* Packet queues
- Copyright (C) 1995, 1996, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 2006, 2009 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -25,11 +25,6 @@
#include <stddef.h> /* for size_t */
#include <string.h>
#include <mach/mach.h>
-
-#ifndef PQ_EI
-#define PQ_EI extern inline
-#endif
-
struct packet
{
@@ -71,11 +66,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. */
-PQ_EI size_t
-packet_readable (struct packet *packet)
-{
- return packet->buf_end - packet->buf_start;
-}
+size_t packet_readable (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 if that's not the null pointer. */
@@ -96,12 +87,7 @@ error_t packet_read_ports (struct packet *packet,
/* Return the source addressd in PACKET in SOURCE, deallocating it from
PACKET. */
-PQ_EI void
-packet_read_source (struct packet *packet, void **source)
-{
- *source = packet->source;
- packet->source = 0;
-}
+void packet_read_source (struct packet *packet, void **source);
/* The packet size above which we start to do things differently to avoid
copying around data. */
@@ -127,7 +113,82 @@ 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. */
-PQ_EI int
+int 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. */
+error_t packet_ensure (struct packet *packet, size_t amount);
+
+/* Make sure that PACKET has room for at least AMOUNT more bytes, *only* if
+ 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. */
+int packet_ensure_efficiently (struct packet *packet, size_t amount);
+
+struct pq
+{
+ struct packet *head, *tail; /* Packet queue */
+ struct packet *free; /* Free packets */
+};
+
+/* Pushes a new packet of type TYPE and source SOURCE, and returns it, or
+ NULL if there was an allocation error. SOURCE is returned to readers of
+ the packet, or deallocated by calling pipe_dealloc_addr. */
+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. */
+struct packet *pq_tail (struct pq *pq, unsigned type, void *source);
+
+/* 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);
+
+/* 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 appropiate.
+ 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. */
+struct packet *pq_head (struct pq *pq, unsigned type, void *source);
+
+/* The same as pq_head, but first discards the head of the queue. */
+struct packet *pq_next (struct pq *pq, unsigned type, void *source);
+
+/* Dequeues all packets in PQ. */
+void pq_drain (struct pq *pq);
+
+/* Create a new packet queue, returning it in PQ. The only possible error is
+ ENOMEM. */
+error_t pq_create (struct pq **pq);
+
+/* Frees PQ and any resources it holds, including deallocating any ports in
+ packets left in the queue. */
+void pq_free (struct pq *pq);
+
+/* Inlining optimizations. */
+
+#include <features.h>
+
+#ifdef __USE_EXTERN_INLINES
+# ifndef PQ_H_EXTERN_INLINE
+# define PQ_H_EXTERN_INLINE __extern_inline
+# endif
+
+PQ_H_EXTERN_INLINE size_t
+packet_readable (struct packet *packet)
+{
+ return packet->buf_end - packet->buf_start;
+}
+
+PQ_H_EXTERN_INLINE void
+packet_read_source (struct packet *packet, void **source)
+{
+ *source = packet->source;
+ packet->source = 0;
+}
+
+PQ_H_EXTERN_INLINE int
packet_fit (struct packet *packet, size_t amount)
{
char *buf = packet->buf, *end = packet->buf_end;
@@ -157,9 +218,7 @@ packet_fit (struct packet *packet, size_t amount)
return 1;
}
-/* Make sure that PACKET has room for at least AMOUNT more bytes, or return
- the reason why not. */
-PQ_EI error_t
+PQ_H_EXTERN_INLINE error_t
packet_ensure (struct packet *packet, size_t amount)
{
if (! packet_fit (packet, amount))
@@ -172,11 +231,7 @@ packet_ensure (struct packet *packet, size_t amount)
return 0;
}
-/* Make sure that PACKET has room for at least AMOUNT more bytes, *only* if
- 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. */
-PQ_EI int
+PQ_H_EXTERN_INLINE int
packet_ensure_efficiently (struct packet *packet, size_t amount)
{
if (! packet_fit (packet, amount))
@@ -189,22 +244,8 @@ packet_ensure_efficiently (struct packet *packet, size_t amount)
}
return 0;
}
-
-struct pq
-{
- struct packet *head, *tail; /* Packet queue */
- struct packet *free; /* Free packets */
-};
-/* Pushes a new packet of type TYPE and source SOURCE, and returns it, or
- NULL if there was an allocation error. SOURCE is returned to readers of
- the packet, or deallocated by calling pipe_dealloc_addr. */
-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. */
-PQ_EI struct packet *
+PQ_H_EXTERN_INLINE struct packet *
pq_tail (struct pq *pq, unsigned type, void *source)
{
struct packet *tail = pq->tail;
@@ -214,16 +255,7 @@ pq_tail (struct pq *pq, unsigned type, void *source)
return tail;
}
-/* 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);
-
-/* 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 appropiate.
- 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. */
-PQ_EI struct packet *
+PQ_H_EXTERN_INLINE struct packet *
pq_head (struct pq *pq, unsigned type, void *source)
{
struct packet *head = pq->head;
@@ -236,8 +268,7 @@ pq_head (struct pq *pq, unsigned type, void *source)
return head;
}
-/* The same as pq_head, but first discards the head of the queue. */
-PQ_EI struct packet *
+PQ_H_EXTERN_INLINE struct packet *
pq_next (struct pq *pq, unsigned type, void *source)
{
if (!pq->head)
@@ -246,15 +277,6 @@ pq_next (struct pq *pq, unsigned type, void *source)
return pq_head (pq, type, source);
}
-/* Dequeues all packets in PQ. */
-void pq_drain (struct pq *pq);
-
-/* Create a new packet queue, returning it in PQ. The only possible error is
- ENOMEM. */
-error_t pq_create (struct pq **pq);
-
-/* Frees PQ and any resources it holds, including deallocating any ports in
- packets left in the queue. */
-void pq_free (struct pq *pq);
+#endif /* __USE_EXTERN_INLINES */
#endif /* __PQ_H__ */
diff --git a/libshouldbeinlibc/idvec-funcs.c b/libshouldbeinlibc/idvec-funcs.c
index 1bc6d85f..b7bb2788 100644
--- a/libshouldbeinlibc/idvec-funcs.c
+++ b/libshouldbeinlibc/idvec-funcs.c
@@ -1,2 +1,3 @@
-#define IDVEC_EI
+#define __USE_EXTERN_INLINES
+#define IDVEC_H_EXTERN_INLINE
#include "idvec.h"
diff --git a/libshouldbeinlibc/idvec.h b/libshouldbeinlibc/idvec.h
index 41441259..9538e970 100644
--- a/libshouldbeinlibc/idvec.h
+++ b/libshouldbeinlibc/idvec.h
@@ -1,6 +1,8 @@
/* Routines for vectors of uids/gids
- Copyright (C) 1995,96,97,99,2001 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1999, 2001, 2009 Free Software Foundation,
+ Inc.
+
Written by Miles Bader <miles@gnu.org>
This program is free software; you can redistribute it and/or
@@ -25,10 +27,6 @@
#include <errno.h>
#include <string.h>
-#ifndef IDVEC_EI
-#define IDVEC_EI extern inline
-#endif
-
struct idvec
{
uid_t *ids;
@@ -51,28 +49,13 @@ void idvec_free_wrapper (struct idvec *idvec);
void idvec_free (struct idvec *idvec);
/* Mark IDVEC as not containing any ids. */
-IDVEC_EI void
-idvec_clear (struct idvec *idvec)
-{
- idvec->num = 0;
-}
+void idvec_clear (struct idvec *idvec);
/* Returns true if IDVEC contains no ids. */
-IDVEC_EI int
-idvec_is_empty (const struct idvec *idvec)
-{
- return idvec->num == 0;
-}
+int idvec_is_empty (const struct idvec *idvec);
/* Return true if IDVEC1 has contents identical to IDVEC2. */
-IDVEC_EI int
-idvec_equal (const struct idvec *idvec1, const struct idvec *idvec2)
-{
- size_t num = idvec1->num;
- return idvec2->num == num
- && (num == 0
- || memcmp (idvec1->ids, idvec2->ids, num * sizeof *idvec1->ids) == 0);
-}
+int idvec_equal (const struct idvec *idvec1, const struct idvec *idvec2);
/* Ensure that IDVEC has enough spaced allocated to hold NUM ids, thus
ensuring that any subsequent ids added won't return a memory allocation
@@ -88,11 +71,7 @@ error_t idvec_grow (struct idvec *idvec, unsigned inc);
int idvec_tail_contains (const struct idvec *idvec, unsigned pos, uid_t id);
/* Returns true if IDVEC contains ID. */
-IDVEC_EI int
-idvec_contains (const struct idvec *idvec, uid_t id)
-{
- return idvec_tail_contains (idvec, 0, id);
-}
+int idvec_contains (const struct idvec *idvec, uid_t id);
/* Insert ID into IDVEC at position POS, returning ENOMEM if there wasn't
enough memory, or 0. */
@@ -214,5 +193,43 @@ char *idvec_uids_rep (const struct idvec *idvec,
char *idvec_gids_rep (const struct idvec *idvec,
int show_values, int show_names,
const char *sep);
+
+/* Inlining optimizations. */
+
+#include <features.h>
+
+#ifdef __USE_EXTERN_INLINES
+# ifndef IDVEC_H_EXTERN_INLINE
+# define IDVEC_H_EXTERN_INLINE __extern_inline
+# endif
+
+IDVEC_H_EXTERN_INLINE void
+idvec_clear (struct idvec *idvec)
+{
+ idvec->num = 0;
+}
+
+IDVEC_H_EXTERN_INLINE int
+idvec_is_empty (const struct idvec *idvec)
+{
+ return idvec->num == 0;
+}
+
+IDVEC_H_EXTERN_INLINE int
+idvec_equal (const struct idvec *idvec1, const struct idvec *idvec2)
+{
+ size_t num = idvec1->num;
+ return idvec2->num == num
+ && (num == 0
+ || memcmp (idvec1->ids, idvec2->ids, num * sizeof *idvec1->ids) == 0);
+}
+
+IDVEC_H_EXTERN_INLINE int
+idvec_contains (const struct idvec *idvec, uid_t id)
+{
+ return idvec_tail_contains (idvec, 0, id);
+}
+
+#endif /* __USE_EXTERN_INLINES */
#endif /* __IDVEC_H__ */
diff --git a/libshouldbeinlibc/maptime-funcs.c b/libshouldbeinlibc/maptime-funcs.c
index eeac3b3e..cb5cfe87 100644
--- a/libshouldbeinlibc/maptime-funcs.c
+++ b/libshouldbeinlibc/maptime-funcs.c
@@ -1,5 +1,3 @@
-#define MAPTIME_EI
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/time.h>
+#define __USE_EXTERN_INLINES
+#define MAPTIME_H_EXTERN_INLINE
#include "maptime.h"
diff --git a/libshouldbeinlibc/maptime.h b/libshouldbeinlibc/maptime.h
index ac97b411..c2a34783 100644
--- a/libshouldbeinlibc/maptime.h
+++ b/libshouldbeinlibc/maptime.h
@@ -1,6 +1,6 @@
/* Support for mach's mapped time
- Copyright (C) 1996, 1997, 2000, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 2000, 2007, 2009 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.org>
@@ -21,10 +21,6 @@
#ifndef __MAPTIME_H__
#define __MAPTIME_H__
-#ifndef MAPTIME_EI
-#define MAPTIME_EI extern inline
-#endif
-
#include <mach/time_value.h>
#include <sys/time.h>
#include <errno.h>
@@ -38,7 +34,18 @@ error_t maptime_map (int use_mach_dev, char *dev_name,
volatile struct mapped_time_value **mtime);
/* Read the current time from MTIME into TV. This should be very fast. */
-MAPTIME_EI void
+void maptime_read (volatile struct mapped_time_value *mtime, struct timeval *tv);
+
+/* Inlining optimizations. */
+
+#include <features.h>
+
+#ifdef __USE_EXTERN_INLINES
+# ifndef MAPTIME_H_EXTERN_INLINE
+# define MAPTIME_H_EXTERN_INLINE __extern_inline
+# endif
+
+MAPTIME_H_EXTERN_INLINE void
maptime_read (volatile struct mapped_time_value *mtime, struct timeval *tv)
{
do
@@ -49,4 +56,6 @@ maptime_read (volatile struct mapped_time_value *mtime, struct timeval *tv)
while (tv->tv_sec != mtime->check_seconds);
}
+#endif /* __USE_EXTERN_INLINES */
+
#endif /* __MAPTIME_H__ */
diff --git a/libshouldbeinlibc/ugids-xinl.c b/libshouldbeinlibc/ugids-xinl.c
index 26df93cc..3fb4d20a 100644
--- a/libshouldbeinlibc/ugids-xinl.c
+++ b/libshouldbeinlibc/ugids-xinl.c
@@ -1,6 +1,6 @@
/* Real definitions for extern inline functions in ugids.h
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2009 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -19,7 +19,6 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#define UGIDS_EI
-#undef __OPTIMIZE__
-#define __OPTIMIZE__ 1
+#define __USE_EXTERN_INLINES
+#define UGIDS_H_EXTERN_INLINE
#include "ugids.h"
diff --git a/libshouldbeinlibc/ugids.h b/libshouldbeinlibc/ugids.h
index 8440b608..97f95071 100644
--- a/libshouldbeinlibc/ugids.h
+++ b/libshouldbeinlibc/ugids.h
@@ -1,6 +1,6 @@
/* Uid/gid parsing/frobbing
- Copyright (C) 1997,2001 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2001, 2009 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.org>
@@ -24,10 +24,6 @@
#include <stdlib.h> /* For inline function stuff. */
#include <idvec.h>
-#ifndef UGIDS_EI
-#define UGIDS_EI extern inline
-#endif
-
/* A structure holding a set of the common various types of ids. */
struct ugids
{
@@ -48,50 +44,16 @@ struct ugids
struct ugids *make_ugids ();
/* Free all resources used by UGIDS except UGIDS itself. */
-UGIDS_EI void
-ugids_fini (struct ugids *ugids)
-{
- idvec_fini (&ugids->eff_uids);
- idvec_fini (&ugids->eff_gids);
- idvec_fini (&ugids->avail_uids);
- idvec_fini (&ugids->avail_gids);
- idvec_fini (&ugids->imp_eff_gids);
- idvec_fini (&ugids->imp_avail_gids);
-}
+void ugids_fini (struct ugids *ugids);
/* Free all resources used by UGIDS. */
-UGIDS_EI void
-ugids_free (struct ugids *ugids)
-{
- ugids_fini (ugids);
- free (ugids);
-}
+void ugids_free (struct ugids *ugids);
/* Return true if UGIDS contains no ids. */
-UGIDS_EI int
-ugids_is_empty (const struct ugids *ugids)
-{
- /* We needn't test the imp_*_gids vectors because they are subsets of the
- corresponding *_gids vectors. */
- return
- idvec_is_empty (&ugids->eff_uids)
- && idvec_is_empty (&ugids->eff_gids)
- && idvec_is_empty (&ugids->avail_uids)
- && idvec_is_empty (&ugids->avail_gids);
-}
+int ugids_is_empty (const struct ugids *ugids);
/* Free all resources used by UGIDS except UGIDS itself. */
-UGIDS_EI int
-ugids_equal (const struct ugids *ugids1, const struct ugids *ugids2)
-{
- return
- idvec_equal (&ugids1->eff_uids, &ugids2->eff_uids)
- && idvec_equal (&ugids1->eff_gids, &ugids2->eff_gids)
- && idvec_equal (&ugids1->avail_uids, &ugids2->avail_uids)
- && idvec_equal (&ugids1->avail_gids, &ugids2->avail_gids)
- && idvec_equal (&ugids1->imp_eff_gids, &ugids2->imp_eff_gids)
- && idvec_equal (&ugids1->imp_avail_gids, &ugids2->imp_avail_gids);
-}
+int ugids_equal (const struct ugids *ugids1, const struct ugids *ugids2);
/* Add all ids in NEW to UGIDS. */
error_t ugids_merge (struct ugids *ugids, const struct ugids *new);
@@ -210,5 +172,58 @@ struct ugids_argp_params
/* A parser for selecting a set of ugids. */
extern struct argp ugids_argp;
+
+/* Inlining optimizations. */
+
+#include <features.h>
+
+#ifdef __USE_EXTERN_INLINES
+# ifndef UGIDS_H_EXTERN_INLINE
+# define UGIDS_H_EXTERN_INLINE __extern_inline
+# endif
+
+UGIDS_H_EXTERN_INLINE void
+ugids_fini (struct ugids *ugids)
+{
+ idvec_fini (&ugids->eff_uids);
+ idvec_fini (&ugids->eff_gids);
+ idvec_fini (&ugids->avail_uids);
+ idvec_fini (&ugids->avail_gids);
+ idvec_fini (&ugids->imp_eff_gids);
+ idvec_fini (&ugids->imp_avail_gids);
+}
+
+UGIDS_H_EXTERN_INLINE void
+ugids_free (struct ugids *ugids)
+{
+ ugids_fini (ugids);
+ free (ugids);
+}
+
+UGIDS_H_EXTERN_INLINE int
+ugids_is_empty (const struct ugids *ugids)
+{
+ /* We needn't test the imp_*_gids vectors because they are subsets of the
+ corresponding *_gids vectors. */
+ return
+ idvec_is_empty (&ugids->eff_uids)
+ && idvec_is_empty (&ugids->eff_gids)
+ && idvec_is_empty (&ugids->avail_uids)
+ && idvec_is_empty (&ugids->avail_gids);
+}
+
+UGIDS_H_EXTERN_INLINE int
+ugids_equal (const struct ugids *ugids1, const struct ugids *ugids2)
+{
+ return
+ idvec_equal (&ugids1->eff_uids, &ugids2->eff_uids)
+ && idvec_equal (&ugids1->eff_gids, &ugids2->eff_gids)
+ && idvec_equal (&ugids1->avail_uids, &ugids2->avail_uids)
+ && idvec_equal (&ugids1->avail_gids, &ugids2->avail_gids)
+ && idvec_equal (&ugids1->imp_eff_gids, &ugids2->imp_eff_gids)
+ && idvec_equal (&ugids1->imp_avail_gids, &ugids2->imp_avail_gids);
+}
+
+#endif /* __USE_EXTERN_INLINES */
#endif /* __UGIDS_H__ */
diff --git a/libstore/store.h b/libstore/store.h
index 5b48504c..1b2be7c4 100644
--- a/libstore/store.h
+++ b/libstore/store.h
@@ -1,7 +1,10 @@
/* Store I/O
- Copyright (C) 1995,96,97,98,99,2001,02,04,05 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005, 2009
+ Free Software Foundation, Inc.
+
Written by Miles Bader <miles@gnu.org>
+
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or
@@ -33,11 +36,6 @@
#include <mach.h>
#include <device/device.h>
#include <hurd/hurd_types.h>
-
-#ifndef STORE_EI
-#define STORE_EI extern inline
-#endif
-
/* Type for addresses inside the store. */
typedef off64_t store_offset_t;
@@ -272,16 +270,7 @@ error_t store_clear_child_flags (struct store *store, int flags);
/* Returns true if STORE can safely be returned to a user who has accessed it
via a node using OPEN_FLAGS, without compromising security. */
-STORE_EI int
-store_is_securely_returnable (struct store *store, int open_flags)
-{
- int flags = store->flags;
- return
- (flags & (STORE_INNOCUOUS | STORE_INACTIVE))
- || ((flags & STORE_ENFORCED)
- && (((open_flags & O_ACCMODE) == O_RDWR)
- || (flags & STORE_HARD_READONLY)));
-}
+int store_is_securely_returnable (struct store *store, int open_flags);
/* Fills in the values of the various fields in STORE that are derivable from
the set of runs & the block size. */
@@ -787,6 +776,27 @@ error_t store_parsed_append_args (const struct store_parsed *parsed,
/* Make a string describing PARSED, and return it in malloced storage in
NAME. */
error_t store_parsed_name (const struct store_parsed *parsed, char **name);
+
+/* Inlining optimizations. */
+
+#include <features.h>
+
+#ifdef __USE_EXTERN_INLINES
+# ifndef STORE_H_EXTERN_INLINE
+# define STORE_H_EXTERN_INLINE __extern_inline
+# endif
+
+STORE_H_EXTERN_INLINE int
+store_is_securely_returnable (struct store *store, int open_flags)
+{
+ int flags = store->flags;
+ return
+ (flags & (STORE_INNOCUOUS | STORE_INACTIVE))
+ || ((flags & STORE_ENFORCED)
+ && (((open_flags & O_ACCMODE) == O_RDWR)
+ || (flags & STORE_HARD_READONLY)));
+}
+#endif /* __USE_EXTERN_INLINES */
#endif /* __STORE_H__ */
diff --git a/libstore/xinl.c b/libstore/xinl.c
index a603d621..00f32c2b 100644
--- a/libstore/xinl.c
+++ b/libstore/xinl.c
@@ -1,2 +1,3 @@
-#define STORE_EI
+#define __USE_EXTERN_INLINES
+#define STORE_H_EXTERN_INLINE
#include "store.h"
diff --git a/libthreads/rwlock.c b/libthreads/rwlock.c
index 93533a97..15811377 100644
--- a/libthreads/rwlock.c
+++ b/libthreads/rwlock.c
@@ -1,2 +1,3 @@
-#define RWLOCK_EI
+#define __USE_EXTERN_INLINES
+#define RWLOCK_H_EXTERN_INLINE
#include "rwlock.h"
diff --git a/libthreads/rwlock.h b/libthreads/rwlock.h
index 1a61eeea..b90b929c 100644
--- a/libthreads/rwlock.h
+++ b/libthreads/rwlock.h
@@ -1,6 +1,6 @@
/* Simple reader/writer locks.
- Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 1996, 2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -31,12 +31,34 @@ struct rwlock
int readers_waiting;
};
-#ifndef RWLOCK_EI
-#define RWLOCK_EI extern inline
-#endif
-
/* Get a reader lock on reader-writer lock LOCK for disknode DN */
-RWLOCK_EI void
+void rwlock_reader_lock (struct rwlock *lock);
+
+/* Get a writer lock on reader-writer lock LOCK for disknode DN */
+void rwlock_writer_lock (struct rwlock *lock);
+
+/* Release a reader lock on reader-writer lock LOCK for disknode DN */
+void rwlock_reader_unlock (struct rwlock *lock);
+
+/* Release a writer lock on reader-writer lock LOCK for disknode DN */
+void rwlock_writer_unlock (struct rwlock *lock);
+
+/* Initialize reader-writer lock LOCK */
+void rwlock_init (struct rwlock *lock);
+
+#define RWLOCK_INITIALIZER \
+ { MUTEX_INITIALIZER, CONDITION_INITIALIZER, 0, 0, 0 }
+
+/* Inlining optimizations. */
+
+#include <features.h>
+
+#ifdef __USE_EXTERN_INLINES
+# ifndef RWLOCK_H_EXTERN_INLINE
+# define RWLOCK_H_EXTERN_INLINE __extern_inline
+# endif
+
+RWLOCK_H_EXTERN_INLINE void
rwlock_reader_lock (struct rwlock *lock)
{
mutex_lock (&lock->master);
@@ -52,8 +74,7 @@ rwlock_reader_lock (struct rwlock *lock)
mutex_unlock (&lock->master);
}
-/* Get a writer lock on reader-writer lock LOCK for disknode DN */
-RWLOCK_EI void
+RWLOCK_H_EXTERN_INLINE void
rwlock_writer_lock (struct rwlock *lock)
{
mutex_lock (&lock->master);
@@ -69,8 +90,7 @@ rwlock_writer_lock (struct rwlock *lock)
mutex_unlock (&lock->master);
}
-/* Release a reader lock on reader-writer lock LOCK for disknode DN */
-RWLOCK_EI void
+RWLOCK_H_EXTERN_INLINE void
rwlock_reader_unlock (struct rwlock *lock)
{
mutex_lock (&lock->master);
@@ -81,8 +101,7 @@ rwlock_reader_unlock (struct rwlock *lock)
mutex_unlock (&lock->master);
}
-/* Release a writer lock on reader-writer lock LOCK for disknode DN */
-RWLOCK_EI void
+RWLOCK_H_EXTERN_INLINE void
rwlock_writer_unlock (struct rwlock *lock)
{
mutex_lock (&lock->master);
@@ -93,8 +112,7 @@ rwlock_writer_unlock (struct rwlock *lock)
mutex_unlock (&lock->master);
}
-/* Initialize reader-writer lock LOCK */
-RWLOCK_EI void
+RWLOCK_H_EXTERN_INLINE void
rwlock_init (struct rwlock *lock)
{
mutex_init (&lock->master);
@@ -104,8 +122,6 @@ rwlock_init (struct rwlock *lock)
lock->writers_waiting = 0;
}
-#define RWLOCK_INITIALIZER \
- { MUTEX_INITIALIZER, CONDITION_INITIALIZER, 0, 0, 0 }
-
+#endif /* __USE_EXTERN_INLINES */
#endif /* rwlock.h */