summaryrefslogtreecommitdiffstats
path: root/sys/kern/sysv_shm.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1995-10-21 19:50:00 +0000
committerbde <bde@FreeBSD.org>1995-10-21 19:50:00 +0000
commit2f3f635ee848c555dd74d424053ca0722cbe8d77 (patch)
treed76c7dacc8e15aed67fd05370a96749d0af845fc /sys/kern/sysv_shm.c
parent24b513df484222b79b96be40e5765dd94d41b0de (diff)
downloadFreeBSD-src-2f3f635ee848c555dd74d424053ca0722cbe8d77.zip
FreeBSD-src-2f3f635ee848c555dd74d424053ca0722cbe8d77.tar.gz
Start including <sys/sysproto.h> to get the correct args structs and
prototypes for all syscalls. The args structs are still declared in comments as in VOP implementation functions. I don't like the duplication for this, but several more layers of changes are required to get it right. First we need to catch up with 4.4lite2, which uses macros to handle struct padding. Then we need to catch up with NetBSD, which passes the args correctly (as void *). Then we need to handle varargs functions and struct padding better. I think all the details can be hidden in machine-generated functions so that the args structs and verbose macros to reference them don't have to appear in the core sources. Add prototypes. Add bogus casts to hide the evil type puns exposed by the previous steps. &uap[1] was used to get at the args after the first. This worked because only the first arg in *uap was declared. This broke when the machine- genenerated args struct declared all the args (actually it declares extra args in some cases and depends on the user stack having some accessible junk after the last arg, not to mention the user args being on the stack. It isn't possible to declare a correct args struct for a varargs syscall). The msgsys(), semsys() and shmsys() syscall interfaces are BAD because they multiplex several syscalls that have different types of args. There was no reason to duplicate this sysv braindamage but now we're stuck with it. NetBSD has reimplemented the syscalls properly as separate syscalls #220-231. Declare static functions as static in both their prototype and their implementation (the latter is optional, and this misfeature was used). Remove gratuitous #includes. Continue cleaning up new init stuff.
Diffstat (limited to 'sys/kern/sysv_shm.c')
-rw-r--r--sys/kern/sysv_shm.c53
1 files changed, 36 insertions, 17 deletions
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index ffbad31..a396ea3 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -1,4 +1,4 @@
-/* $Id: sysv_shm.c,v 1.8 1995/08/30 00:33:02 bde Exp $ */
+/* $Id: sysv_shm.c,v 1.9 1995/09/09 18:10:09 davidg Exp $ */
/* $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $ */
/*
@@ -31,29 +31,44 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/sysproto.h>
#include <sys/kernel.h>
#include <sys/shm.h>
#include <sys/proc.h>
-#include <sys/uio.h>
-#include <sys/time.h>
#include <sys/malloc.h>
#include <sys/mman.h>
-#include <sys/systm.h>
#include <sys/stat.h>
+#include <sys/sysent.h>
#include <vm/vm.h>
#include <vm/vm_map.h>
-#include <vm/vm_map.h>
#include <vm/vm_kern.h>
+struct shmat_args;
+extern int shmat __P((struct proc *p, struct shmat_args *uap, int *retval));
+struct shmctl_args;
+extern int shmctl __P((struct proc *p, struct shmctl_args *uap, int *retval));
+struct shmdt_args;
+extern int shmdt __P((struct proc *p, struct shmdt_args *uap, int *retval));
+struct shmget_args;
+extern int shmget __P((struct proc *p, struct shmget_args *uap, int *retval));
+
static void shminit __P((void *));
SYSINIT(sysv_shm, SI_SUB_SYSV_SHM, SI_ORDER_FIRST, shminit, NULL)
-int oshmctl();
-int shmat(), shmctl(), shmdt(), shmget();
-int (*shmcalls[])() = { shmat, oshmctl, shmdt, shmget, shmctl };
+struct oshmctl_args;
+int oshmctl __P((struct proc *p, struct oshmctl_args *uap, int *retval));
+static int shmget_allocate_segment __P((struct proc *p, struct shmget_args *uap, int mode, int *retval));
+static int shmget_existing __P((struct proc *p, struct shmget_args *uap, int mode, int segnum, int *retval));
+
+/* XXX casting to (sy_call_t *) is bogus, as usual. */
+sy_call_t *shmcalls[] = {
+ (sy_call_t *)shmat, (sy_call_t *)oshmctl,
+ (sy_call_t *)shmdt, (sy_call_t *)shmget,
+ (sy_call_t *)shmctl
+};
#define SHMSEG_FREE 0x0200
#define SHMSEG_REMOVED 0x0400
@@ -296,7 +311,8 @@ oshmctl(p, uap, retval)
return error;
break;
default:
- return shmctl(p, uap, retval);
+ /* XXX casting to (sy_call_t *) is bogus, as usual. */
+ return ((sy_call_t *)shmctl)(p, uap, retval);
}
return 0;
#else
@@ -507,19 +523,22 @@ shmget(p, uap, retval)
return shmget_allocate_segment(p, uap, mode, retval);
}
-struct shmsys_args {
- u_int which;
-};
int
shmsys(p, uap, retval)
struct proc *p;
- struct shmsys_args *uap;
+ /* XXX actually varargs. */
+ struct shmsys_args /* {
+ u_int which;
+ int a2;
+ int a3;
+ int a4;
+ } */ *uap;
int *retval;
{
if (uap->which >= sizeof(shmcalls)/sizeof(shmcalls[0]))
return EINVAL;
- return ((*shmcalls[uap->which])(p, &uap[1], retval));
+ return ((*shmcalls[uap->which])(p, &uap->a2, retval));
}
void
@@ -556,8 +575,8 @@ shmexit(p)
}
void
-shminit(udata)
- void *udata;
+shminit(dummy)
+ void *dummy;
{
int i;
vm_offset_t garbage1, garbage2;
OpenPOWER on IntegriCloud