From 8287b6ffdf2cb631591decb17429701218122259 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 25 Feb 2014 01:01:09 +0100 Subject: libtrivfs: improve the mig mutator functions Previously, the mig mutator functions were in migsupport.c, preventing them from being inlined into the mig-generated server functions. Put them in mig-decls.h instead. Rename mutations.h to mig-mutate.h. This is the naming convention used for pflocal. * libtrivfs/fsmutations.h: Rename to mig-mutate.h, adopt imports. * libtrivfs/Makefile: Adopt accordingly. * libtrivfs/migsupport.c: Rename to mig-decls.h. * libtrivfs/trivfs.h: Move dynamic classes/buckets declarations to mig-decls.h, remove superfluous imports. * exec/execmutations.h: Fix import. * pfinet/mig-mutate.h: Likewise. * trans/Makefile: Likewise. --- libtrivfs/Makefile | 6 +-- libtrivfs/fsmutations.h | 33 --------------- libtrivfs/mig-decls.h | 105 ++++++++++++++++++++++++++++++++++++++++++++++++ libtrivfs/mig-mutate.h | 32 +++++++++++++++ libtrivfs/migsupport.c | 86 --------------------------------------- libtrivfs/trivfs.h | 44 +------------------- 6 files changed, 141 insertions(+), 165 deletions(-) delete mode 100644 libtrivfs/fsmutations.h create mode 100644 libtrivfs/mig-decls.h create mode 100644 libtrivfs/mig-mutate.h delete mode 100644 libtrivfs/migsupport.c (limited to 'libtrivfs') diff --git a/libtrivfs/Makefile b/libtrivfs/Makefile index 3e4c0393..921acbea 100644 --- a/libtrivfs/Makefile +++ b/libtrivfs/Makefile @@ -38,7 +38,7 @@ FSYSSRCS=fsys-getroot.c fsys-goaway.c fsys-stubs.c fsys-syncfs.c \ file-get-children.c file-get-source.c OTHERSRCS=demuxer.c protid-clean.c protid-dup.c cntl-create.c \ - cntl-clean.c migsupport.c times.c startup.c open.c \ + cntl-clean.c times.c startup.c open.c \ runtime-argp.c set-options.c append-args.c dyn-classes.c \ protid-classes.c cntl-classes.c @@ -49,7 +49,7 @@ MIGSTUBS=fsServer.o ioServer.o fsysServer.o fsys_replyUser.o libname = libtrivfs HURDLIBS = fshelp iohelp ports shouldbeinlibc OBJS= $(sort $(subst .c,.o,$(SRCS)) $(MIGSTUBS)) -MIGSFLAGS=-imacros $(srcdir)/fsmutations.h +MIGSFLAGS=-imacros $(srcdir)/mig-mutate.h MIGCOMSFLAGS = -prefix trivfs_ installhdrs := trivfs.h mig-sheader-prefix = trivfs_ @@ -59,4 +59,4 @@ endif include ../Makeconf -$(MIGSTUBS:%Server.o=%.sdefsi): $(srcdir)/fsmutations.h +$(MIGSTUBS:%Server.o=%.sdefsi): $(srcdir)/mig-mutate.h diff --git a/libtrivfs/fsmutations.h b/libtrivfs/fsmutations.h deleted file mode 100644 index d81e5a87..00000000 --- a/libtrivfs/fsmutations.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 1994,95,2002 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 - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Only CPP macro definitions should go in this file. */ - -#define REPLY_PORTS - -#define FILE_INTRAN trivfs_protid_t trivfs_begin_using_protid (file_t) -#define FILE_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t) - -#define IO_INTRAN trivfs_protid_t trivfs_begin_using_protid (io_t) -#define IO_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t) - -#define FSYS_INTRAN trivfs_control_t trivfs_begin_using_control (fsys_t) -#define FSYS_DESTRUCTOR trivfs_end_using_control (trivfs_control_t) - -#define FILE_IMPORTS import ; -#define IO_IMPORTS import ; -#define FSYS_IMPORTS import ; diff --git a/libtrivfs/mig-decls.h b/libtrivfs/mig-decls.h new file mode 100644 index 00000000..2baaee86 --- /dev/null +++ b/libtrivfs/mig-decls.h @@ -0,0 +1,105 @@ +/* + Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef __TRIVFS_MIG_DECLS_H__ +#define __TRIVFS_MIG_DECLS_H__ + +#include "priv.h" + +/* Vectors of dynamically allocated port classes/buckets. */ + +/* Protid port classes. */ +extern struct port_class **trivfs_dynamic_protid_port_classes; +extern size_t trivfs_num_dynamic_protid_port_classes; + +/* Control port classes. */ +extern struct port_class **trivfs_dynamic_control_port_classes; +extern size_t trivfs_num_dynamic_control_port_classes; + +/* Port buckets. */ +extern struct port_bucket **trivfs_dynamic_port_buckets; +extern size_t trivfs_num_dynamic_port_buckets; + +static inline struct trivfs_protid * __attribute__ ((unused)) +trivfs_begin_using_protid (mach_port_t port) +{ + if (trivfs_protid_nportclasses + trivfs_num_dynamic_protid_port_classes > 1) + { + struct port_info *pi = ports_lookup_port (0, port, 0); + int i; + + if (pi) + { + for (i = 0; i < trivfs_protid_nportclasses; i++) + if (pi->class == trivfs_protid_portclasses[i]) + return (struct trivfs_protid *) pi; + for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++) + if (pi->class == trivfs_dynamic_protid_port_classes[i]) + return (struct trivfs_protid *) pi; + ports_port_deref (pi); + } + + return 0; + } + else if (trivfs_protid_nportclasses == 1) + return ports_lookup_port (0, port, trivfs_protid_portclasses[0]); + else + return ports_lookup_port (0, port, trivfs_dynamic_protid_port_classes[0]); +} + +static inline void __attribute__ ((unused)) +trivfs_end_using_protid (struct trivfs_protid *cred) +{ + if (cred) + ports_port_deref (cred); +} + +static inline struct trivfs_control * __attribute__ ((unused)) +trivfs_begin_using_control (mach_port_t port) +{ + if (trivfs_cntl_nportclasses + trivfs_num_dynamic_control_port_classes > 1) + { + struct port_info *pi = ports_lookup_port (0, port, 0); + int i; + + if (pi) + { + for (i = 0; i < trivfs_cntl_nportclasses; i++) + if (pi->class == trivfs_cntl_portclasses[i]) + return (struct trivfs_control *) pi; + for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++) + if (pi->class == trivfs_dynamic_control_port_classes[i]) + return (struct trivfs_control *) pi; + ports_port_deref (pi); + } + + return 0; + } + else if (trivfs_cntl_nportclasses == 1) + return ports_lookup_port (0, port, trivfs_cntl_portclasses[0]); + else + return ports_lookup_port (0, port, trivfs_dynamic_control_port_classes[0]); +} + +static inline void __attribute__ ((unused)) +trivfs_end_using_control (struct trivfs_control *cred) +{ + if (cred) + ports_port_deref (cred); +} + +#endif /* __TRIVFS_MIG_DECLS_H__ */ diff --git a/libtrivfs/mig-mutate.h b/libtrivfs/mig-mutate.h new file mode 100644 index 00000000..fad5389a --- /dev/null +++ b/libtrivfs/mig-mutate.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 1994,95,2002 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 + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Only CPP macro definitions should go in this file. */ + +#define REPLY_PORTS + +#define FILE_INTRAN trivfs_protid_t trivfs_begin_using_protid (file_t) +#define FILE_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t) +#define FILE_IMPORTS import "mig-decls.h"; + +#define IO_INTRAN trivfs_protid_t trivfs_begin_using_protid (io_t) +#define IO_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t) +#define IO_IMPORTS import "mig-decls.h"; + +#define FSYS_INTRAN trivfs_control_t trivfs_begin_using_control (fsys_t) +#define FSYS_DESTRUCTOR trivfs_end_using_control (trivfs_control_t) +#define FSYS_IMPORTS import "mig-decls.h"; diff --git a/libtrivfs/migsupport.c b/libtrivfs/migsupport.c deleted file mode 100644 index b2d98e16..00000000 --- a/libtrivfs/migsupport.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "priv.h" - -struct trivfs_protid * -trivfs_begin_using_protid (mach_port_t port) -{ - if (trivfs_protid_nportclasses + trivfs_num_dynamic_protid_port_classes > 1) - { - struct port_info *pi = ports_lookup_port (0, port, 0); - int i; - - if (pi) - { - for (i = 0; i < trivfs_protid_nportclasses; i++) - if (pi->class == trivfs_protid_portclasses[i]) - return (struct trivfs_protid *) pi; - for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++) - if (pi->class == trivfs_dynamic_protid_port_classes[i]) - return (struct trivfs_protid *) pi; - ports_port_deref (pi); - } - - return 0; - } - else if (trivfs_protid_nportclasses == 1) - return ports_lookup_port (0, port, trivfs_protid_portclasses[0]); - else - return ports_lookup_port (0, port, trivfs_dynamic_protid_port_classes[0]); -} - -void -trivfs_end_using_protid (struct trivfs_protid *cred) -{ - if (cred) - ports_port_deref (cred); -} - -struct trivfs_control * -trivfs_begin_using_control (mach_port_t port) -{ - if (trivfs_cntl_nportclasses + trivfs_num_dynamic_control_port_classes > 1) - { - struct port_info *pi = ports_lookup_port (0, port, 0); - int i; - - if (pi) - { - for (i = 0; i < trivfs_cntl_nportclasses; i++) - if (pi->class == trivfs_cntl_portclasses[i]) - return (struct trivfs_control *) pi; - for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++) - if (pi->class == trivfs_dynamic_control_port_classes[i]) - return (struct trivfs_control *) pi; - ports_port_deref (pi); - } - - return 0; - } - else if (trivfs_cntl_nportclasses == 1) - return ports_lookup_port (0, port, trivfs_cntl_portclasses[0]); - else - return ports_lookup_port (0, port, trivfs_dynamic_control_port_classes[0]); -} - -void -trivfs_end_using_control (struct trivfs_control *cred) -{ - if (cred) - ports_port_deref (cred); -} diff --git a/libtrivfs/trivfs.h b/libtrivfs/trivfs.h index 306a4302..bb456ffa 100644 --- a/libtrivfs/trivfs.h +++ b/libtrivfs/trivfs.h @@ -37,11 +37,6 @@ struct trivfs_protid struct trivfs_peropen *po; }; -/* These can be used as `intran' and `destructor' functions for - a MiG port type, to have the stubs called with the protid pointer. */ -struct trivfs_protid *trivfs_begin_using_protid (mach_port_t); -void trivfs_end_using_protid (struct trivfs_protid *); - struct trivfs_peropen { void *hook; /* for user use */ @@ -62,11 +57,6 @@ struct trivfs_control void *hook; /* for user use */ }; -/* These can be used as `intran' and `destructor' functions for - a MiG port type, to have the stubs called with the control pointer. */ -struct trivfs_control *trivfs_begin_using_control (mach_port_t); -void trivfs_end_using_control (struct trivfs_control *); - /* The user must define these variables. */ extern int trivfs_fstype; @@ -267,41 +257,9 @@ error_t trivfs_add_port_bucket (struct port_bucket **bucket); /* Remove the previously added dynamic port bucket BUCKET, freeing it if it was allocated by trivfs_add_port_bucket. */ void trivfs_remove_port_bucket (struct port_bucket *bucket); - -/* This stuff is for the sake of MiG stubs and could be in a private - header. But it might be handy for users that override parts of the - library. Moreover, since the stub headers will use all the imports we - need for the stubs, we couldn't make the stub headers public without - making this public too. */ - +/* Type-aliases for mig. */ typedef struct trivfs_protid *trivfs_protid_t; typedef struct trivfs_control *trivfs_control_t; -struct trivfs_protid *_trivfs_begin_using_protid (mach_port_t); -void _trivfs_end_using_protid (struct trivfs_protid *); -struct trivfs_control *_trivfs_begin_using_control (mach_port_t); -void _trivfs_end_using_control (struct trivfs_control *); - -/* Vectors of dynamically allocated port classes/buckets. */ - -/* Protid port classes. */ -extern struct port_class **trivfs_dynamic_protid_port_classes; -extern size_t trivfs_num_dynamic_protid_port_classes; - -/* Control port classes. */ -extern struct port_class **trivfs_dynamic_control_port_classes; -extern size_t trivfs_num_dynamic_control_port_classes; - -/* Port buckets. */ -extern struct port_bucket **trivfs_dynamic_port_buckets; -extern size_t trivfs_num_dynamic_port_buckets; - -/* These are the MiG-generated headers that declare prototypes - for the server functions. */ -#include -#include -#include - - #endif /* __TRIVFS_H__ */ -- cgit v1.2.3