diff options
34 files changed, 354 insertions, 80 deletions
diff --git a/ext2fs/Makefile b/ext2fs/Makefile index e0419d46..e83aab26 100644 --- a/ext2fs/Makefile +++ b/ext2fs/Makefile @@ -21,7 +21,7 @@ makemode := server target = ext2fs SRCS = balloc.c dir.c ext2fs.c getblk.c hyper.c ialloc.c \ - inode.c pager.c pokel.c truncate.c storeinfo.c msg.c + inode.c pager.c pokel.c truncate.c storeinfo.c msg.c xinl.c OBJS = $(SRCS:.c=.o) LCLHDRS = ext2fs.h ext2_fs.h ext2_fs_i.h bitmap.c HURDLIBS = diskfs pager iohelp fshelp store threads ports ihash shouldbeinlibc diff --git a/ext2fs/ext2fs.h b/ext2fs/ext2fs.h index 1d490861..2ad4a9df 100644 --- a/ext2fs/ext2fs.h +++ b/ext2fs/ext2fs.h @@ -101,8 +101,11 @@ void pokel_flush (struct pokel *pokel); /* Transfer all regions from FROM to POKEL, which must have the same pager. */ void pokel_inherit (struct pokel *pokel, struct pokel *from); -#ifndef EXT2FS_EI -#define EXT2FS_EI extern inline +#include <features.h> +#ifdef EXT2FS_DEFINE_EI +#define EXT2FS_EI +#else +#define EXT2FS_EI __extern_inline #endif /* ---------------------------------------------------------------- */ @@ -110,6 +113,11 @@ void pokel_inherit (struct pokel *pokel, struct pokel *from); #include <stdint.h> +extern int test_bit (unsigned num, char *bitmap); + +extern int set_bit (unsigned num, char *bitmap); + +#if defined(__USE_EXTERN_INLINES) || defined(EXT2FS_DEFINE_EI) /* Returns TRUE if bit NUM is set in BITMAP. */ EXT2FS_EI int test_bit (unsigned num, char *bitmap) @@ -138,6 +146,7 @@ clear_bit (unsigned num, char *bitmap) const uint_fast32_t mask = 1 << (num & 31); return (*bw & mask) ? (*bw &= ~mask, mask) : 0; } +#endif /* Use extern inlines. */ /* ---------------------------------------------------------------- */ @@ -294,6 +303,9 @@ struct ext2_group_desc *group_desc_image; #define inode_group_num(inum) (((inum) - 1) / sblock->s_inodes_per_group) +extern struct ext2_inode *dino (ino_t inum); + +#if defined(__USE_EXTERN_INLINES) || defined(EXT2FS_DEFINE_EI) /* Convert an inode number to the dinode on disk. */ EXT2FS_EI struct ext2_inode * dino (ino_t inum) @@ -305,6 +317,7 @@ dino (ino_t inum) block_t block = bg->bg_inode_table + (group_inum / inodes_per_block); return ((struct ext2_inode *)bptr(block)) + group_inum % inodes_per_block; } +#endif /* Use extern inlines. */ /* ---------------------------------------------------------------- */ /* inode.c */ @@ -333,6 +346,14 @@ struct pokel global_pokel; char *modified_global_blocks; spin_lock_t modified_global_blocks_lock; +extern int global_block_modified (block_t block); +extern void record_global_poke (void *ptr); +extern void sync_global_ptr (void *bptr, int wait); +extern void record_indir_poke (struct node *node, void *ptr); +extern void sync_global (int wait); +extern void alloc_sync (struct node *np); + +#if defined(__USE_EXTERN_INLINES) || defined(EXT2FS_DEFINE_EI) /* Marks the global block BLOCK as being modified, and returns true if we think it may have been clean before (but we may not be sure). Note that this isn't enough to cause the block to be synced; you must call @@ -401,6 +422,7 @@ alloc_sync (struct node *np) diskfs_set_hypermetadata (1, 0); } } +#endif /* Use extern inlines. */ /* ---------------------------------------------------------------- */ /* getblk.c */ diff --git a/ext2fs/xinl.c b/ext2fs/xinl.c new file mode 100644 index 00000000..9f37e166 --- /dev/null +++ b/ext2fs/xinl.c @@ -0,0 +1,2 @@ +#define EXT2FS_DEFINE_EI +#include "ext2fs.h" diff --git a/hostmux/hostmux-xinl.c b/hostmux/hostmux-xinl.c index e8ab1493..4e11968e 100644 --- a/hostmux/hostmux-xinl.c +++ b/hostmux/hostmux-xinl.c @@ -18,7 +18,5 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ -#define HOSTMUX_EI -#undef __OPTIMIZE__ -#define __OPTIMIZE__ 1 +#define HOSTMUX_DEFINE_EI #include "hostmux.h" diff --git a/hostmux/hostmux.h b/hostmux/hostmux.h index 10170002..98ef04ac 100644 --- a/hostmux/hostmux.h +++ b/hostmux/hostmux.h @@ -24,6 +24,13 @@ #include <hurd/netfs.h> #include <rwlock.h> #include <maptime.h> +#include <features.h> + +#ifdef HOSTMUX_DEFINE_EI +#define HOSTMUX_EI +#else +#define HOSTMUX_EI __extern_inline +#endif /* Handy source of time. */ volatile struct mapped_time_value *hostmux_maptime; @@ -85,8 +92,4 @@ struct netnode struct hostmux_name *name; }; -#ifndef HOSTMUX_EI -# define HOSTMUX_EI extern inline -#endif - #endif /* __HOSTMUX_H__ */ diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h index 9a61964c..2051e41d 100644 --- a/libdiskfs/diskfs.h +++ b/libdiskfs/diskfs.h @@ -27,9 +27,12 @@ #include <hurd/fshelp.h> #include <hurd/iohelp.h> #include <idvec.h> +#include <features.h> -#ifndef DISKFS_EXTERN_INLINE -#define DISKFS_EXTERN_INLINE extern inline +#ifdef DISKFS_DEFINE_EXTERN_INLINE +#define DISKFS_EXTERN_INLINE +#else +#define DISKFS_EXTERN_INLINE __extern_inline #endif /* Each user port referring to a file points to one of these @@ -781,6 +784,12 @@ error_t diskfs_start_protid (struct peropen *po, struct protid **cred); the user to install is USER. */ void diskfs_finish_protid (struct protid *cred, struct iouser *user); +extern struct protid * diskfs_begin_using_protid_port (file_t port); + +extern void diskfs_end_using_protid_port (struct protid *cred); + +#if defined(__USE_EXTERN_INLINES) || defined(DISKFS_DEFINE_EXTERN_INLINE) + /* Called by MiG to translate ports into struct protid *. fsmutations.h arranges for this to happen for the io and fs interfaces. */ @@ -800,6 +809,8 @@ diskfs_end_using_protid_port (struct protid *cred) ports_port_deref (cred); } +#endif /* Use extern inlines. */ + /* Called when a protid CRED has no more references. (Because references\ to protids are maintained by the port management library, this is installed in the clean routines list.) The ports library will diff --git a/libdiskfs/extern-inline.c b/libdiskfs/extern-inline.c index 0abcc4cc..43de88d6 100644 --- a/libdiskfs/extern-inline.c +++ b/libdiskfs/extern-inline.c @@ -15,6 +15,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 DISKFS_DEFINE_EXTERN_INLINE #include "diskfs.h" diff --git a/libftpconn/ftpconn.h b/libftpconn/ftpconn.h index 558ff8f9..6bff5918 100644 --- a/libftpconn/ftpconn.h +++ b/libftpconn/ftpconn.h @@ -26,6 +26,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/stat.h> +#include <features.h> #define __need_error_t #include <errno.h> @@ -35,8 +36,10 @@ typedef int error_t; #define __error_t_defined #endif -#ifndef FTP_CONN_EI -# define FTP_CONN_EI extern inline +#ifdef FTP_CONN_DEFINE_EI +#define FTP_CONN_EI +#else +#define FTP_CONN_EI __extern_inline #endif struct ftp_conn; @@ -242,6 +245,9 @@ error_t ftp_conn_open (struct ftp_conn *conn); void ftp_conn_close (struct ftp_conn *conn); +extern error_t ftp_conn_validate_syshooks (struct ftp_conn *conn); + +#if defined(__USE_EXTERN_INLINES) || defined(FTP_CONN_DEFINE_EI) /* Makes sure that CONN's syshooks are set according to the remote system type. */ FTP_CONN_EI error_t @@ -253,6 +259,7 @@ ftp_conn_validate_syshooks (struct ftp_conn *conn) /* Opening the connection should set the syshooks. */ return ftp_conn_open (conn); } +#endif /* Use extern inlines. */ /* Create a new ftp connection as specified by PARAMS, and return it in CONN; HOOKS contains customization hooks used by the connection. Neither PARAMS diff --git a/libftpconn/priv.h b/libftpconn/priv.h index fb4dae50..570ea290 100644 --- a/libftpconn/priv.h +++ b/libftpconn/priv.h @@ -21,8 +21,12 @@ #ifndef __FTPCONN_PRIV_H__ #define __FTPCONN_PRIV_H__ -#ifndef FTP_CONN_EI -# define FTP_CONN_EI extern inline +#include <features.h> + +#ifdef FTP_CONN_DEFINE_EI +#define FTP_CONN_EI +#else +#define FTP_CONN_EI __extern_inline #endif /* Ftp reply codes. */ @@ -61,6 +65,9 @@ #define REPLY_IS_TRANSIENT(rep) ((rep) >= 400 && (rep) < 500) #define REPLY_IS_FAILURE(rep) ((rep) >= 500 && (rep) < 600) +extern error_t unexpected_reply (struct ftp_conn *conn, int reply, const char *reply_txt, + const error_t *poss_errs); +#if defined(__USE_EXTERN_INLINES) || defined(FTP_CONN_DEFINE_EI) FTP_CONN_EI error_t unexpected_reply (struct ftp_conn *conn, int reply, const char *reply_txt, const error_t *poss_errs) @@ -79,6 +86,7 @@ unexpected_reply (struct ftp_conn *conn, int reply, const char *reply_txt, else return EGRATUITOUS; } +#endif /* Use extern inlines. */ /* Error codes we think may result from file operations we do. */ extern const error_t ftp_conn_poss_file_errs[]; diff --git a/libftpconn/xinl.c b/libftpconn/xinl.c index a975b80d..72b7fdcf 100644 --- a/libftpconn/xinl.c +++ b/libftpconn/xinl.c @@ -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 FTP_CONN_DEFINE_EI #include <ftpconn.h> #include "priv.h" 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); diff --git a/libshouldbeinlibc/idvec-funcs.c b/libshouldbeinlibc/idvec-funcs.c index 1bc6d85f..3bb0318d 100644 --- a/libshouldbeinlibc/idvec-funcs.c +++ b/libshouldbeinlibc/idvec-funcs.c @@ -1,2 +1,2 @@ -#define IDVEC_EI +#define IDVEC_DEFINE_EI #include "idvec.h" diff --git a/libshouldbeinlibc/idvec.h b/libshouldbeinlibc/idvec.h index 3c70a5d7..abbc273e 100644 --- a/libshouldbeinlibc/idvec.h +++ b/libshouldbeinlibc/idvec.h @@ -24,9 +24,12 @@ #include <hurd/hurd_types.h> #include <errno.h> #include <string.h> +#include <features.h> -#ifndef IDVEC_EI -#define IDVEC_EI extern inline +#ifdef IDVEC_DEFINE_EI +#define IDVEC_EI +#else +#define IDVEC_EI __extern_inline #endif struct idvec @@ -50,6 +53,14 @@ void idvec_free_wrapper (struct idvec *idvec); /* Free IDVEC and any storage associated with it. */ void idvec_free (struct idvec *idvec); +extern void idvec_clear (struct idvec *idvec); + +extern int idvec_is_empty (const struct idvec *idvec); + +extern int idvec_equal (const struct idvec *idvec1, const struct idvec *idvec2); + +#if defined(__USE_EXTERN_INLINES) || defined(IDVEC_DEFINE_EI) + /* Mark IDVEC as not containing any ids. */ IDVEC_EI void idvec_clear (struct idvec *idvec) @@ -74,6 +85,8 @@ idvec_equal (const struct idvec *idvec1, const struct idvec *idvec2) || memcmp (idvec1->ids, idvec2->ids, num * sizeof *idvec1->ids) == 0); } +#endif /* Use extern inlines. */ + /* Ensure that IDVEC has enough spaced allocated to hold NUM ids, thus ensuring that any subsequent ids added won't return a memory allocation error unless it would result in more ids that NUM. ENOMEM is returned if @@ -87,6 +100,10 @@ error_t idvec_grow (struct idvec *idvec, unsigned inc); /* Returns true if IDVEC contains ID, at or after position POS. */ int idvec_tail_contains (const struct idvec *idvec, unsigned pos, uid_t id); +extern int idvec_contains (const struct idvec *idvec, uid_t id); + +#if defined(__USE_EXTERN_INLINES) || defined(IDVEC_DEFINE_EI) + /* Returns true if IDVEC contains ID. */ IDVEC_EI int idvec_contains (const struct idvec *idvec, uid_t id) @@ -94,6 +111,8 @@ idvec_contains (const struct idvec *idvec, uid_t id) return idvec_tail_contains (idvec, 0, id); } +#endif /* Use extern inlines. */ + /* Insert ID into IDVEC at position POS, returning ENOMEM if there wasn't enough memory, or 0. */ error_t idvec_insert (struct idvec *idvec, unsigned pos, uid_t id); diff --git a/libshouldbeinlibc/maptime-funcs.c b/libshouldbeinlibc/maptime-funcs.c index eeac3b3e..080e3ae6 100644 --- a/libshouldbeinlibc/maptime-funcs.c +++ b/libshouldbeinlibc/maptime-funcs.c @@ -1,4 +1,4 @@ -#define MAPTIME_EI +#define MAPTIME_DEFINE_EI #include <errno.h> #include <sys/types.h> #include <sys/time.h> diff --git a/libshouldbeinlibc/maptime.h b/libshouldbeinlibc/maptime.h index ac97b411..947ad640 100644 --- a/libshouldbeinlibc/maptime.h +++ b/libshouldbeinlibc/maptime.h @@ -21,13 +21,16 @@ #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> +#include <features.h> + +#ifdef MAPTIME_DEFINE_EI +#define MAPTIME_EI +#else +#define MAPTIME_EI __extern_inline +#endif /* Return the mach mapped time page in MTIME. If USE_MACH_DEV is false, then the hurd time device DEV_NAME, or "/dev/time" if DEV_NAME is 0, is @@ -37,6 +40,10 @@ error_t maptime_map (int use_mach_dev, char *dev_name, volatile struct mapped_time_value **mtime); +extern void maptime_read (volatile struct mapped_time_value *mtime, struct timeval *tv); + +#if defined(__USE_EXTERN_INLINES) || defined(MAPTIME_DEFINE_EI) + /* Read the current time from MTIME into TV. This should be very fast. */ MAPTIME_EI void maptime_read (volatile struct mapped_time_value *mtime, struct timeval *tv) @@ -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..107de8b9 100644 --- a/libshouldbeinlibc/ugids-xinl.c +++ b/libshouldbeinlibc/ugids-xinl.c @@ -19,7 +19,5 @@ 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 UGIDS_DEFINE_EI #include "ugids.h" diff --git a/libshouldbeinlibc/ugids.h b/libshouldbeinlibc/ugids.h index 8440b608..10e7a242 100644 --- a/libshouldbeinlibc/ugids.h +++ b/libshouldbeinlibc/ugids.h @@ -23,9 +23,12 @@ #include <stdlib.h> /* For inline function stuff. */ #include <idvec.h> +#include <features.h> -#ifndef UGIDS_EI -#define UGIDS_EI extern inline +#ifdef UGIDS_DEFINE_EI +#define UGIDS_EI +#else +#define UGIDS_EI __extern_inline #endif /* A structure holding a set of the common various types of ids. */ @@ -47,6 +50,16 @@ struct ugids /* Return a new ugids structure, or 0 if an allocation error occurs. */ struct ugids *make_ugids (); +extern void ugids_fini (struct ugids *ugids); + +extern void ugids_free (struct ugids *ugids); + +extern int ugids_is_empty (const struct ugids *ugids); + +extern int ugids_equal (const struct ugids *ugids1, const struct ugids *ugids2); + +#if defined(__USE_EXTERN_INLINES) || defined(UGIDS_DEFINE_EI) + /* Free all resources used by UGIDS except UGIDS itself. */ UGIDS_EI void ugids_fini (struct ugids *ugids) @@ -93,6 +106,8 @@ ugids_equal (const struct ugids *ugids1, const struct ugids *ugids2) && idvec_equal (&ugids1->imp_avail_gids, &ugids2->imp_avail_gids); } +#endif /* Use extern inlines. */ + /* Add all ids in NEW to UGIDS. */ error_t ugids_merge (struct ugids *ugids, const struct ugids *new); diff --git a/libstore/store.h b/libstore/store.h index fd250448..ae334a1d 100644 --- a/libstore/store.h +++ b/libstore/store.h @@ -33,11 +33,13 @@ #include <mach.h> #include <device/device.h> #include <hurd/hurd_types.h> +#include <features.h> -#ifndef STORE_EI -#define STORE_EI extern inline +#ifdef STORE_DEFINE_EI +#define STORE_EI +#else +#define STORE_EI __extern_inline #endif - /* Type for addresses inside the store. */ typedef off64_t store_offset_t; @@ -270,6 +272,10 @@ error_t store_set_child_flags (struct store *store, int flags); STORE's flags. */ error_t store_clear_child_flags (struct store *store, int flags); +extern int store_is_securely_returnable (struct store *store, int open_flags); + +#if defined(__USE_EXTERN_INLINES) || defined(STORE_DEFINE_EI) + /* 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 @@ -283,6 +289,8 @@ store_is_securely_returnable (struct store *store, int open_flags) || (flags & STORE_HARD_READONLY))); } +#endif /* Use extern inlines. */ + /* Fills in the values of the various fields in STORE that are derivable from the set of runs & the block size. */ void _store_derive (struct store *store); diff --git a/libstore/xinl.c b/libstore/xinl.c index a603d621..90242212 100644 --- a/libstore/xinl.c +++ b/libstore/xinl.c @@ -1,2 +1,2 @@ -#define STORE_EI +#define STORE_DEFINE_EI #include "store.h" diff --git a/libthreads/rwlock.c b/libthreads/rwlock.c index 93533a97..ae6a7c48 100644 --- a/libthreads/rwlock.c +++ b/libthreads/rwlock.c @@ -1,2 +1,2 @@ -#define RWLOCK_EI +#define RWLOCK_DEFINE_EI #include "rwlock.h" diff --git a/libthreads/rwlock.h b/libthreads/rwlock.h index 1a61eeea..44d9a35d 100644 --- a/libthreads/rwlock.h +++ b/libthreads/rwlock.h @@ -21,6 +21,13 @@ #include <cthreads.h> #include <assert.h> +#include <features.h> + +#ifdef RWLOCK_DEFINE_EI +#define RWLOCK_EI +#else +#define RWLOCK_EI __extern_inline +#endif struct rwlock { @@ -31,9 +38,17 @@ struct rwlock int readers_waiting; }; -#ifndef RWLOCK_EI -#define RWLOCK_EI extern inline -#endif +extern void rwlock_reader_lock (struct rwlock *lock); + +extern void rwlock_writer_lock (struct rwlock *lock); + +extern void rwlock_reader_unlock (struct rwlock *lock); + +extern void rwlock_writer_unlock (struct rwlock *lock); + +extern void rwlock_init (struct rwlock *lock); + +#if defined(__USE_EXTERN_INLINES) || defined(RWLOCK_DEFINE_EI) /* Get a reader lock on reader-writer lock LOCK for disknode DN */ RWLOCK_EI void @@ -104,6 +119,8 @@ rwlock_init (struct rwlock *lock) lock->writers_waiting = 0; } +#endif /* Use extern inlines. */ + #define RWLOCK_INITIALIZER \ { MUTEX_INITIALIZER, CONDITION_INITIALIZER, 0, 0, 0 } diff --git a/libtreefs/Makefile b/libtreefs/Makefile index 89d95e9b..3cdc30c9 100644 --- a/libtreefs/Makefile +++ b/libtreefs/Makefile @@ -25,12 +25,12 @@ installhdrs = treefs.h S_SRCS = s-file.c s-dir.c s-io.c s-fsys.c OTHERSRCS = defhooks.c dir-hooks.c dir-lookup.c fsys-getroot.c fsys-hooks.c \ fsys-startup.c hooks.c mdir.c nlist.c node-hooks.c rights.c \ - trans-help.c trans-start.c + trans-help.c trans-start.c xinl.c SRCS = $(OTHERSRCS) $(S_SRCS) LCLHDRS = treefs.h fs-mutate.h MIGSTUBS = fsServer.o ioServer.o fsysServer.o -OBJS = $(sort $(subst .c,.o,$(SRCS)) $(MIGSTUBS) +OBJS = $(sort $(SRCS:.c=.o)) $(MIGSTUBS) MIGSFLAGS = -imacros fs-mutate.h MIGCOMSFLAGS = -prefix treefs_ diff --git a/libtreefs/mig-decls.h b/libtreefs/mig-decls.h index 0d051e9c..e17f6196 100644 --- a/libtreefs/mig-decls.h +++ b/libtreefs/mig-decls.h @@ -25,7 +25,11 @@ /* For mig */ typedef struct treefs_handle *treefs_handle_t; -extern inline +extern treefs_handle_t treefs_begin_using_handle_port(mach_port_t port); +extern void treefs_end_using_handle_port (treefs_handle_t handle); + +#if defined(__USE_EXTERN_INLINES) || defined(TREEFS_DEFINE_EI) +TREEFS_EI treefs_handle_t treefs_begin_using_handle_port(mach_port_t port) { return @@ -33,9 +37,10 @@ treefs_handle_t treefs_begin_using_handle_port(mach_port_t port) ports_lookup_port (0, port, treefs_fsys_port_class); } -extern inline void +TREEFS_EI void treefs_end_using_handle_port (treefs_handle_t handle) { if (handle != NULL) ports_port_deref (&handle->pi); } +#endif /* Use extern inlines. */ diff --git a/libtreefs/treefs.h b/libtreefs/treefs.h index 0ad528d8..d8f30e4e 100644 --- a/libtreefs/treefs.h +++ b/libtreefs/treefs.h @@ -26,6 +26,7 @@ #include <errno.h> #include <cthreads.h> #include <assert.h> +#include <features.h> #include <sys/stat.h> @@ -36,6 +37,12 @@ /* Include the hook calling macros and non-rpc hook definitions (to get those, include "trees-s-hooks.h"). */ #include "treefs-hooks.h" + +#ifdef TREEFS_DEFINE_EI +#define TREEFS_EI +#else +#define TREEFS_EI __extern_inline +#endif /* ---------------------------------------------------------------- */ @@ -237,10 +244,18 @@ void treefs_hooks_set (treefs_hook_vector_t hooks, extern spin_lock_t treefs_node_refcnt_lock; +extern void treefs_node_ref (struct treefs_node *node); +extern void treefs_node_release (struct treefs_node *node); +extern void treefs_node_unref (struct treefs_node *node); +extern void treefs_node_ref_weak (struct treefs_node *node); +extern void treefs_node_release_weak (struct treefs_node *node); +extern void treefs_node_unref_weak (struct treefs_node *node); + +#if defined(__USE_EXTERN_INLINES) || defined(TREEFS_DEFINE_EI) /* Add a hard reference to a node. If there were no hard references previously, then the node cannot be locked (because you must hold a hard reference to hold the lock). */ -extern inline void +TREEFS_EI void treefs_node_ref (struct treefs_node *node) { int new_ref; @@ -259,7 +274,7 @@ treefs_node_ref (struct treefs_node *node) /* Unlock node NODE and release a hard reference; if this is the last hard reference and there are no links to the file then request weak references to be dropped. */ -extern inline void +TREEFS_EI void treefs_node_release (struct treefs_node *node) { int tried_drop_weak_refs = 0; @@ -306,7 +321,7 @@ treefs_node_release (struct treefs_node *node) hard reference in order to hold the lock). If this is the last hard reference and there are no links, then request weak references to be dropped. */ -extern inline void +TREEFS_EI void treefs_node_unref (struct treefs_node *node) { int tried_drop_weak_refs = 0; @@ -346,7 +361,7 @@ treefs_node_unref (struct treefs_node *node) } /* Add a weak reference to a node. */ -extern inline void +TREEFS_EI void treefs_node_ref_weak (struct treefs_node *node) { spin_lock (&treefs_node_refcnt_lock); @@ -355,7 +370,7 @@ treefs_node_ref_weak (struct treefs_node *node) } /* Unlock node NODE and release a weak reference */ -extern inline void +TREEFS_EI void treefs_node_release_weak (struct treefs_node *node) { spin_lock (&treefs_node_refcnt_lock); @@ -373,7 +388,7 @@ treefs_node_release_weak (struct treefs_node *node) /* Release a weak reference on NODE. If NODE is locked by anyone, then this cannot be the last reference (because you must hold a hard reference in order to hold the lock). */ -extern inline void +TREEFS_EI void treefs_node_unref_weak (struct treefs_node *node) { spin_lock (&treefs_node_refcnt_lock); @@ -387,6 +402,7 @@ treefs_node_unref_weak (struct treefs_node *node) else spin_unlock (&treefs_node_refcnt_lock); } +#endif /* Use extern inlines. */ /* ---------------------------------------------------------------- */ @@ -408,8 +424,12 @@ treefs_node_create_right (struct treefs_node *node, int flags, /* ---------------------------------------------------------------- */ /* Auth functions; copied from diskfs. */ +extern int treefs_auth_has_uid (struct treefs_auth *auth, uid_t uid); +extern int treefs_auth_in_group (struct treefs_auth *auth, gid_t gid); + +#if defined(__USE_EXTERN_INLINES) || defined(TREEFS_DEFINE_EI) /* Return nonzero iff the user identified by AUTH has uid UID. */ -extern inline int +TREEFS_EI int treefs_auth_has_uid (struct treefs_auth *auth, uid_t uid) { int i; @@ -420,7 +440,7 @@ treefs_auth_has_uid (struct treefs_auth *auth, uid_t uid) } /* Return nonzero iff the user identified by AUTH has group GID. */ -extern inline int +TREEFS_EI int treefs_auth_in_group (struct treefs_auth *auth, gid_t gid) { int i; @@ -429,6 +449,7 @@ treefs_auth_in_group (struct treefs_auth *auth, gid_t gid) return 1; return 0; } +#endif /* Use extern inlines. */ /* ---------------------------------------------------------------- */ /* Helper routines for dealing with translators. */ diff --git a/libtreefs/xinl.c b/libtreefs/xinl.c new file mode 100644 index 00000000..fe83e5a3 --- /dev/null +++ b/libtreefs/xinl.c @@ -0,0 +1,3 @@ +#define TREEFS_DEFINE_EI +#include "treefs.h" +#include "mig-decls.h" diff --git a/term/Makefile b/term/Makefile index 8b287f36..e13763a1 100644 --- a/term/Makefile +++ b/term/Makefile @@ -22,7 +22,7 @@ dir := term makemode := server target = term -SRCS = devio.c munge.c users.c main.c ptyio.c hurdio.c +SRCS = devio.c munge.c users.c main.c ptyio.c hurdio.c xinl.c LCLHDRS = term.h DIST_FILES = ourmsg.defs diff --git a/term/term.h b/term/term.h index 8448d78e..81d0efee 100644 --- a/term/term.h +++ b/term/term.h @@ -25,8 +25,15 @@ #include <sys/types.h> #include <sys/mman.h> #include <fcntl.h> +#include <features.h> #include <hurd/hurd_types.h> +#ifdef TERM_DEFINE_EI +#define TERM_EI +#else +#define TERM_EI __extern_inline +#endif + #undef MDMBUF #undef ECHO #undef TOSTOP @@ -184,34 +191,49 @@ struct queue struct queue *create_queue (int size, int lowat, int hiwat); +extern int qsize (struct queue *q); +extern int qavail (struct queue *q); +extern void clear_queue (struct queue *q); +extern quoted_char dequeue_quote (struct queue *q); +extern char dequeue (struct queue *q); +extern void enqueue_internal (struct queue **qp, quoted_char c); +extern void enqueue (struct queue **qp, char c); +extern void enqueue_quote (struct queue **qp, char c); +extern char unquote_char (quoted_char c); +extern int char_quoted_p (quoted_char c); +extern short queue_erase (struct queue *q); + +#if defined(__USE_EXTERN_INLINES) || defined(TERM_DEFINE_EI) /* Return the number of characters in Q. */ -extern inline int +TERM_EI int qsize (struct queue *q) { return q->ce - q->cs; } /* Return nonzero if characters can be added to Q. */ -extern inline int +TERM_EI int qavail (struct queue *q) { return !q->susp; } /* Flush all the characters from Q. */ -extern inline void +TERM_EI void clear_queue (struct queue *q) { q->susp = 0; q->cs = q->ce = q->array; condition_broadcast (q->wait); } +#endif /* Use extern inlines. */ /* Should be below, but inlines need it. */ void call_asyncs (int dir); +#if defined(__USE_EXTERN_INLINES) || defined(TERM_DEFINE_EI) /* Return the next character off Q; leave the quoting bit on. */ -extern inline quoted_char +TERM_EI quoted_char dequeue_quote (struct queue *q) { int beep = 0; @@ -234,16 +256,18 @@ dequeue_quote (struct queue *q) } /* Return the next character off Q. */ -extern inline char +TERM_EI char dequeue (struct queue *q) { return dequeue_quote (q) & ~QUEUE_QUOTE_MARK; } +#endif /* Use extern inlines. */ struct queue *reallocate_queue (struct queue *); +#if defined(__USE_EXTERN_INLINES) || defined(TERM_DEFINE_EI) /* Add C to *QP. */ -extern inline void +TERM_EI void enqueue_internal (struct queue **qp, quoted_char c) { struct queue *q = *qp; @@ -265,28 +289,28 @@ enqueue_internal (struct queue **qp, quoted_char c) } /* Add C to *QP. */ -extern inline void +TERM_EI void enqueue (struct queue **qp, char c) { enqueue_internal (qp, c); } /* Add C to *QP, marking it with a quote. */ -extern inline void +TERM_EI void enqueue_quote (struct queue **qp, char c) { enqueue_internal (qp, c | QUEUE_QUOTE_MARK); } /* Return the unquoted version of a quoted_char. */ -extern inline char +TERM_EI char unquote_char (quoted_char c) { return c & ~QUEUE_QUOTE_MARK; } /* Tell if a quoted_char is actually quoted. */ -extern inline int +TERM_EI int char_quoted_p (quoted_char c) { return c & QUEUE_QUOTE_MARK; @@ -294,7 +318,7 @@ char_quoted_p (quoted_char c) /* Remove the most recently enqueue character from Q; leaving the quote mark on. */ -extern inline short +TERM_EI short queue_erase (struct queue *q) { short answer; @@ -313,6 +337,7 @@ queue_erase (struct queue *q) condition_broadcast (q->wait); return answer; } +#endif /* Use extern inlines. */ /* Functions devio is supposed to call */ diff --git a/term/xinl.c b/term/xinl.c new file mode 100644 index 00000000..3695faa5 --- /dev/null +++ b/term/xinl.c @@ -0,0 +1,2 @@ +#define TERM_DEFINE_EI +#include "term.h" diff --git a/ufs/Makefile b/ufs/Makefile index 02cf38ba..cf5c40d7 100644 --- a/ufs/Makefile +++ b/ufs/Makefile @@ -21,7 +21,7 @@ makemode := server target = ufs SRCS = alloc.c consts.c dir.c hyper.c inode.c main.c pager.c \ - sizes.c subr.c tables.c bmap.c pokeloc.c + sizes.c subr.c tables.c bmap.c pokeloc.c xinl.c LCLHDRS = ufs.h fs.h dinode.h dir.h OBJS = $(SRCS:.c=.o) @@ -25,9 +25,16 @@ #include <hurd/diskfs.h> #include <sys/mman.h> #include <assert.h> +#include <features.h> #include "fs.h" #include "dinode.h" +#ifdef UFS_DEFINE_EI +#define UFS_EI +#else +#define UFS_EI __extern_inline +#endif + /* Define this if memory objects should not be cached by the kernel. Normally, don't define it, but defining it causes a much greater rate of paging requests, which may be helpful in catching bugs. */ @@ -150,8 +157,18 @@ unsigned log2_dev_blocks_per_dev_bsize; /* Functions for looking inside disk_image */ +extern struct dinode * dino (ino_t inum); +extern daddr_t * indir_block (daddr_t bno); +extern struct cg * cg_locate (int ncg); +extern void sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait); +extern void sync_dinode (int inum, int wait); +extern short swab_short (short arg); +extern long swab_long (long arg); +extern long long swab_long_long (long long arg); + +#if defined(__USE_EXTERN_INLINES) || defined(UFS_DEFINE_EI) /* Convert an inode number to the dinode on disk. */ -extern inline struct dinode * +UFS_EI struct dinode * dino (ino_t inum) { return (struct dinode *) @@ -161,28 +178,28 @@ dino (ino_t inum) } /* Convert a indirect block number to a daddr_t table. */ -extern inline daddr_t * +UFS_EI daddr_t * indir_block (daddr_t bno) { return (daddr_t *) (disk_image + fsaddr (sblock, bno)); } /* Convert a cg number to the cylinder group. */ -extern inline struct cg * +UFS_EI struct cg * cg_locate (int ncg) { return (struct cg *) (disk_image + fsaddr (sblock, cgtod (sblock, ncg))); } /* Sync part of the disk */ -extern inline void +UFS_EI void sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait) { pager_sync_some (diskfs_disk_pager, fsaddr (sblock, blkno), nbytes, wait); } /* Sync an disk inode */ -extern inline void +UFS_EI void sync_dinode (int inum, int wait) { sync_disk_blocks (ino_to_fsba (sblock, inum), sblock->fs_fsize, wait); @@ -190,26 +207,27 @@ sync_dinode (int inum, int wait) /* Functions for byte swapping */ -extern inline short +UFS_EI short swab_short (short arg) { return (((arg & 0xff) << 8) | ((arg & 0xff00) >> 8)); } -extern inline long +UFS_EI long swab_long (long arg) { return (((long) swab_short (arg & 0xffff) << 16) | swab_short ((arg & 0xffff0000) >> 16)); } -extern inline long long +UFS_EI long long swab_long_long (long long arg) { return (((long long) swab_long (arg & 0xffffffff) << 32) | swab_long ((arg & 0xffffffff00000000LL) >> 32)); } +#endif /* Use extern inlines. */ /* Return ENTRY, after byteswapping it if necessary */ #define read_disk_entry(entry) \ diff --git a/ufs/xinl.c b/ufs/xinl.c new file mode 100644 index 00000000..7994a1f7 --- /dev/null +++ b/ufs/xinl.c @@ -0,0 +1,2 @@ +#define UFS_DEFINE_EI +#include "ufs.h" |