Author: kib
Date: Mon May 20 16:31:45 2019
New Revision: 347995
URL: https://svnweb.freebsd.org/changeset/base/347995

Log:
  MFC r329348 (by brooks):
  Get rid of the requirement to include SysV IPC headers with _KERNEL
  defined in ipcrm by introducing _WANT_SYSVxxx_INTERNALS defines.
  
  MFC r329390 (by lwhsu):
  Follow r329348 in ipcs for getting rid of the requirement to include SysV IPC
  headers with _KERNEL.
  
  Sponsored by: Mellanox Technologies
  Approved by:  re (gjb)

Modified:
  stable/11/sys/sys/ipc.h
  stable/11/sys/sys/msg.h
  stable/11/sys/sys/sem.h
  stable/11/sys/sys/shm.h
  stable/11/usr.bin/ipcrm/ipcrm.c
  stable/11/usr.bin/ipcs/ipc.c
  stable/11/usr.bin/ipcs/ipc.h
  stable/11/usr.bin/ipcs/ipcs.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/sys/ipc.h
==============================================================================
--- stable/11/sys/sys/ipc.h     Mon May 20 16:23:35 2019        (r347994)
+++ stable/11/sys/sys/ipc.h     Mon May 20 16:31:45 2019        (r347995)
@@ -117,12 +117,14 @@ struct ipc_perm {
 #define        IPC_INFO        3       /* get info */
 #endif
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(_WANT_SYSVIPC_INTERNALS)
 /* Macros to convert between ipc ids and array indices or sequence ids */
 #define        IPCID_TO_IX(id)         ((id) & 0xffff)
 #define        IPCID_TO_SEQ(id)        (((id) >> 16) & 0xffff)
 #define        IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff))
+#endif
 
+#ifdef _KERNEL
 struct thread;
 struct proc;
 struct vmspace;

Modified: stable/11/sys/sys/msg.h
==============================================================================
--- stable/11/sys/sys/msg.h     Mon May 20 16:23:35 2019        (r347994)
+++ stable/11/sys/sys/msg.h     Mon May 20 16:31:45 2019        (r347995)
@@ -25,6 +25,9 @@
 
 #include <sys/cdefs.h>
 #include <sys/_types.h>
+#ifdef _WANT_SYSVMSG_INTERNALS
+#define        _WANT_SYSVIPC_INTERNALS
+#endif
 #include <sys/ipc.h>
 
 /*
@@ -116,7 +119,6 @@ struct mymsg {
 #endif
 
 #ifdef _KERNEL
-
 struct msg {
        struct  msg *msg_next;  /* next msg in the chain */
        long    msg_type;       /* type of this message */
@@ -126,7 +128,9 @@ struct msg {
        short   msg_spot;       /* location of start of msg in buffer */
        struct  label *label;   /* MAC Framework label */
 };
+#endif
 
+#if defined(_KERNEL) || defined(_WANT_SYSVMSG_INTERNALS)
 /*
  * Based on the configuration parameters described in an SVR2 (yes, two)
  * config(1m) man page.
@@ -145,7 +149,6 @@ struct msginfo {
                msgssz,         /* size of a message segment (see notes above) 
*/
                msgseg;         /* number of message segments */
 };
-extern struct msginfo  msginfo;
 
 /*
  * Kernel wrapper for the user-level structure.
@@ -162,10 +165,13 @@ struct msqid_kernel {
        struct  label *label;   /* MAC label */
        struct  ucred *cred;    /* creator's credentials */
 };
+#endif
 
-#endif /* _KERNEL */
+#ifdef _KERNEL
+extern struct msginfo  msginfo;
 
-#if !defined(_KERNEL) || defined(_WANT_MSG_PROTOTYPES)
+#else /* _KERNEL */
+
 __BEGIN_DECLS
 int msgctl(int, int, struct msqid_ds *);
 int msgget(key_t, int);
@@ -176,7 +182,6 @@ int msgsnd(int, const void *, size_t, int);
 int msgsys(int, ...);
 #endif
 __END_DECLS
-
-#endif /* !_KERNEL || _WANT_MSG_PROTOTYPES  */
+#endif /* !_KERNEL */
 
 #endif /* !_SYS_MSG_H_ */

Modified: stable/11/sys/sys/sem.h
==============================================================================
--- stable/11/sys/sys/sem.h     Mon May 20 16:23:35 2019        (r347994)
+++ stable/11/sys/sys/sem.h     Mon May 20 16:31:45 2019        (r347995)
@@ -10,6 +10,9 @@
 #ifndef _SYS_SEM_H_
 #define _SYS_SEM_H_
 
+#ifdef _WANT_SYSVSEM_INTERNALS
+#define        _WANT_SYSVIPC_INTERNALS
+#endif
 #include <sys/ipc.h>
 
 #ifndef _PID_T_DECLARED
@@ -101,8 +104,7 @@ union semun {
 #define SEM_A          IPC_W   /* alter permission */
 #define SEM_R          IPC_R   /* read permission */
 
-#ifdef _KERNEL
-
+#if defined(_KERNEL) || defined(_WANT_SYSVSEM_INTERNALS)
 /*
  * semaphore info struct
  */
@@ -117,7 +119,6 @@ struct seminfo {
                semvmx,         /* semaphore maximum value */
                semaem;         /* adjust on exit max value */
 };
-extern struct seminfo  seminfo;
 
 /*
  * Kernel wrapper for the user-level structure
@@ -131,15 +132,17 @@ struct semid_kernel {
 /* internal "mode" bits */
 #define        SEM_ALLOC       01000   /* semaphore is allocated */
 #define        SEM_DEST        02000   /* semaphore will be destroyed on last 
detach */
+#endif
 
+#ifdef _KERNEL
+extern struct seminfo  seminfo;
 /*
  * Process sem_undo vectors at proc exit.
  */
 void   semexit(struct proc *p);
 
-#endif /* _KERNEL */
+#else /* !_KERNEL */
 
-#if !defined(_KERNEL) || defined(_WANT_SEM_PROTOTYPES)
 __BEGIN_DECLS
 #if __BSD_VISIBLE
 int semsys(int, ...);
@@ -149,6 +152,6 @@ int semget(key_t, int, int);
 int semop(int, struct sembuf *, size_t);
 __END_DECLS
 
-#endif /* !_KERNEL || _WANT_SEM_PROTOTYPES */
+#endif /* !_KERNEL */
 
 #endif /* !_SYS_SEM_H_ */

Modified: stable/11/sys/sys/shm.h
==============================================================================
--- stable/11/sys/sys/shm.h     Mon May 20 16:23:35 2019        (r347994)
+++ stable/11/sys/sys/shm.h     Mon May 20 16:31:45 2019        (r347995)
@@ -40,6 +40,9 @@
 #define _SYS_SHM_H_
 
 #include <sys/cdefs.h>
+#ifdef _WANT_SYSVSHM_INTERNALS
+#define        _WANT_SYSVIPC_INTERNALS
+#endif
 #include <sys/ipc.h>
 #include <sys/_types.h>
 
@@ -104,9 +107,7 @@ struct shmid_ds {
        time_t          shm_ctime;      /* time of last change by shmctl() */
 };
 
-#ifdef _KERNEL
-#include <vm/vm.h>
-
+#if defined(_KERNEL) || defined(_WANT_SYSVSHM_INTERNALS)
 /*
  * System 5 style catch-all structure for shared memory constants that
  * might be of interest to user programs.  Do we really want/need this?
@@ -119,19 +120,20 @@ struct shminfo {
        u_long  shmall;         /* max amount of shared memory (pages) */
 };
 
+struct vm_object;
+
 /* 
  * Add a kernel wrapper to the shmid_ds struct so that private info (like the
  * MAC label) can be added to it, without changing the user interface.
  */
 struct shmid_kernel {
        struct shmid_ds u;
-       vm_object_t object;
+       struct vm_object *object;
        struct label *label;    /* MAC label */
        struct ucred *cred;     /* creator's credendials */
 };
+#endif
 
-extern struct shminfo  shminfo;
-
 struct shm_info {
        int used_ids;
        unsigned long shm_tot;
@@ -141,15 +143,17 @@ struct shm_info {
        unsigned long swap_successes;
 };
 
-struct thread;
+#ifdef _KERNEL
 struct proc;
 struct vmspace;
 
+extern struct shminfo  shminfo;
+
 void   shmexit(struct vmspace *);
 void   shmfork(struct proc *, struct proc *);
-#endif /* _KERNEL */
 
-#if !defined(_KERNEL) || defined(_WANT_SHM_PROTOTYPES)
+#else /* !_KERNEL */
+
 #include <sys/cdefs.h>
 
 #ifndef _SIZE_T_DECLARED
@@ -167,6 +171,6 @@ int shmctl(int, int, struct shmid_ds *);
 int shmdt(const void *);
 __END_DECLS
 
-#endif /* _KERNEL || _WANT_SHM_PROTOTYPES */
+#endif /* _KERNEL */
 
 #endif /* !_SYS_SHM_H_ */

Modified: stable/11/usr.bin/ipcrm/ipcrm.c
==============================================================================
--- stable/11/usr.bin/ipcrm/ipcrm.c     Mon May 20 16:23:35 2019        
(r347994)
+++ stable/11/usr.bin/ipcrm/ipcrm.c     Mon May 20 16:31:45 2019        
(r347995)
@@ -36,14 +36,12 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#define _WANT_MSG_PROTOTYPES
-#define _WANT_SEM_PROTOTYPES
-#define _WANT_SHM_PROTOTYPES
-#define _KERNEL
+#define        _WANT_SYSVMSG_INTERNALS
+#include <sys/msg.h>
+#define        _WANT_SYSVSEM_INTERNALS
 #include <sys/sem.h>
+#define        _WANT_SYSVSHM_INTERNALS
 #include <sys/shm.h>
-#include <sys/msg.h>
-#undef _KERNEL
 
 #include <ctype.h>
 #include <err.h>

Modified: stable/11/usr.bin/ipcs/ipc.c
==============================================================================
--- stable/11/usr.bin/ipcs/ipc.c        Mon May 20 16:23:35 2019        
(r347994)
+++ stable/11/usr.bin/ipcs/ipc.c        Mon May 20 16:31:45 2019        
(r347995)
@@ -35,11 +35,12 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
 #include <sys/sysctl.h>
-#define _KERNEL
+#define        _WANT_SYSVMSG_INTERNALS
+#include <sys/msg.h>
+#define        _WANT_SYSVSEM_INTERNALS
 #include <sys/sem.h>
+#define        _WANT_SYSVSHM_INTERNALS
 #include <sys/shm.h>
-#include <sys/msg.h>
-#undef _KERNEL
 
 #include <assert.h>
 #include <err.h>

Modified: stable/11/usr.bin/ipcs/ipc.h
==============================================================================
--- stable/11/usr.bin/ipcs/ipc.h        Mon May 20 16:23:35 2019        
(r347994)
+++ stable/11/usr.bin/ipcs/ipc.h        Mon May 20 16:31:45 2019        
(r347995)
@@ -68,3 +68,6 @@ extern kvm_t *kd;
 extern struct semid_kernel     *sema;
 extern struct msqid_kernel     *msqids;
 extern struct shmid_kernel     *shmsegs;
+extern struct seminfo           seminfo;
+extern struct msginfo           msginfo;
+extern struct shminfo           shminfo;

Modified: stable/11/usr.bin/ipcs/ipcs.c
==============================================================================
--- stable/11/usr.bin/ipcs/ipcs.c       Mon May 20 16:23:35 2019        
(r347994)
+++ stable/11/usr.bin/ipcs/ipcs.c       Mon May 20 16:31:45 2019        
(r347995)
@@ -32,11 +32,12 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/proc.h>
-#define _KERNEL
+#define        _WANT_SYSVMSG_INTERNALS
+#include <sys/msg.h>
+#define        _WANT_SYSVSEM_INTERNALS
 #include <sys/sem.h>
+#define        _WANT_SYSVSHM_INTERNALS
 #include <sys/shm.h>
-#include <sys/msg.h>
-#undef _KERNEL
 
 #include <err.h>
 #include <fcntl.h>
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to