svn commit: r347132 - head/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Sat May 4 19:05:31 UTC 2019


Author: mjg
Date: Sat May  4 19:05:30 2019
New Revision: 347132
URL: https://svnweb.freebsd.org/changeset/base/347132

Log:
  sysv: get rid of fork/exit hooks if the code is compiled in
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/kern/sysv_ipc.c
  head/sys/kern/sysv_shm.c

Modified: head/sys/kern/sysv_ipc.c
==============================================================================
--- head/sys/kern/sysv_ipc.c	Sat May  4 19:04:17 2019	(r347131)
+++ head/sys/kern/sysv_ipc.c	Sat May  4 19:05:30 2019	(r347132)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/proc.h>
 #include <sys/ucred.h>
 
+#ifndef SYSVSHM
 void (*shmfork_hook)(struct proc *, struct proc *) = NULL;
 void (*shmexit_hook)(struct vmspace *) = NULL;
 
@@ -73,6 +74,7 @@ shmexit(struct vmspace *vm)
 		shmexit_hook(vm);
 	return;
 }
+#endif
 
 /*
  * Check for IPC permission.

Modified: head/sys/kern/sysv_shm.c
==============================================================================
--- head/sys/kern/sysv_shm.c	Sat May  4 19:04:17 2019	(r347131)
+++ head/sys/kern/sysv_shm.c	Sat May  4 19:05:30 2019	(r347132)
@@ -137,8 +137,10 @@ static void shmrealloc(void);
 static int shminit(void);
 static int sysvshm_modload(struct module *, int, void *);
 static int shmunload(void);
+#ifndef SYSVSHM
 static void shmexit_myhook(struct vmspace *vm);
 static void shmfork_myhook(struct proc *p1, struct proc *p2);
+#endif
 static int sysctl_shmsegs(SYSCTL_HANDLER_ARGS);
 static void shm_remove(struct shmid_kernel *, int);
 static struct prison *shm_find_prison(struct ucred *);
@@ -810,8 +812,13 @@ sys_shmget(struct thread *td, struct shmget_args *uap)
 	return (error);
 }
 
+#ifdef SYSVSHM
+void
+shmfork(struct proc *p1, struct proc *p2)
+#else
 static void
 shmfork_myhook(struct proc *p1, struct proc *p2)
+#endif
 {
 	struct shmmap_state *shmmap_s;
 	size_t size;
@@ -834,8 +841,13 @@ shmfork_myhook(struct proc *p1, struct proc *p2)
 	SYSVSHM_UNLOCK();
 }
 
+#ifdef SYSVSHM
+void
+shmexit(struct vmspace *vm)
+#else
 static void
 shmexit_myhook(struct vmspace *vm)
+#endif
 {
 	struct shmmap_state *base, *shm;
 	int i;
@@ -956,8 +968,10 @@ shminit(void)
 	shm_nused = 0;
 	shm_committed = 0;
 	sx_init(&sysvshmsx, "sysvshmsx");
+#ifndef SYSVSHM
 	shmexit_hook = &shmexit_myhook;
 	shmfork_hook = &shmfork_myhook;
+#endif
 
 	/* Set current prisons according to their allow.sysvipc. */
 	shm_prison_slot = osd_jail_register(NULL, methods);
@@ -1021,8 +1035,10 @@ shmunload(void)
 			vm_object_deallocate(shmsegs[i].object);
 	}
 	free(shmsegs, M_SHM);
+#ifndef SYSVSHM
 	shmexit_hook = NULL;
 	shmfork_hook = NULL;
+#endif
 	sx_destroy(&sysvshmsx);
 	return (0);
 }


More information about the svn-src-all mailing list