Author: brooks
Date: Fri Mar  2 22:10:48 2018
New Revision: 330297
URL: https://svnweb.freebsd.org/changeset/base/330297

Log:
  Rename kernel-only members of semid_ds and msgid_ds.
  
  This deliberately breaks the API in preperation for future syscall
  revisions which will remove these nonstandard members.
  
  In an exp-run a single port (devel/qemu-user-static) was found to
  use them which it did becuase it emulates system calls.  This has
  been fixed in the ports tree.
  
  PR:           224443 (exp-run)
  Reviewed by:  kib, jhb (previous version)
  Exp-run by:   antoine
  Sponsored by: DARPA, AFRP
  Differential Revision:        https://reviews.freebsd.org/D14490

Modified:
  head/lib/libc/sys/msgctl.2
  head/lib/libc/sys/semctl.2
  head/sys/compat/freebsd32/freebsd32_ipc.h
  head/sys/i386/ibcs2/ibcs2_ipc.c
  head/sys/kern/sysv_msg.c
  head/sys/kern/sysv_sem.c
  head/sys/sys/msg.h
  head/sys/sys/sem.h

Modified: head/lib/libc/sys/msgctl.2
==============================================================================
--- head/lib/libc/sys/msgctl.2  Fri Mar  2 21:50:02 2018        (r330296)
+++ head/lib/libc/sys/msgctl.2  Fri Mar  2 22:10:48 2018        (r330297)
@@ -63,8 +63,8 @@ and contains (amongst others) the following members:
 .Bd -literal
 struct msqid_ds {
        struct  ipc_perm msg_perm;      /* msg queue permission bits */
-       struct  msg *msg_first; /* first message in the queue */
-       struct  msg *msg_last;  /* last message in the queue */
+       struct  msg *__msg_first;       /* kernel data, don't use */
+       struct  msg *__msg_last;        /* kernel data, don't use */
        msglen_t msg_cbytes;    /* number of bytes in use on the queue */
        msgqnum_t msg_qnum;     /* number of msgs in the queue */
        msglen_t msg_qbytes;    /* max # of bytes on the queue */

Modified: head/lib/libc/sys/semctl.2
==============================================================================
--- head/lib/libc/sys/semctl.2  Fri Mar  2 21:50:02 2018        (r330296)
+++ head/lib/libc/sys/semctl.2  Fri Mar  2 22:10:48 2018        (r330297)
@@ -145,7 +145,7 @@ is defined as follows:
 .Bd -literal
 struct semid_ds {
         struct  ipc_perm sem_perm;      /* operation permission struct */
-        struct  sem *sem_base;  /* pointer to first semaphore in set */
+        struct  sem *__sem_base;  /* kernel data, don't use */
         u_short sem_nsems;      /* number of sems in set */
         time_t  sem_otime;      /* last operation time */
         time_t  sem_ctime;      /* last change time */

Modified: head/sys/compat/freebsd32/freebsd32_ipc.h
==============================================================================
--- head/sys/compat/freebsd32/freebsd32_ipc.h   Fri Mar  2 21:50:02 2018        
(r330296)
+++ head/sys/compat/freebsd32/freebsd32_ipc.h   Fri Mar  2 22:10:48 2018        
(r330297)
@@ -43,7 +43,7 @@ struct ipc_perm32 {
 
 struct semid_ds32 {
        struct ipc_perm32 sem_perm;
-       uint32_t        sem_base;
+       uint32_t        __sem_base;
        unsigned short  sem_nsems;
        int32_t         sem_otime;
        int32_t         sem_ctime;
@@ -69,8 +69,8 @@ union semun32 {
 
 struct msqid_ds32 {
        struct ipc_perm32 msg_perm;
-       uint32_t        msg_first;
-       uint32_t        msg_last;
+       uint32_t        __msg_first;
+       uint32_t        __msg_last;
        uint32_t        msg_cbytes;
        uint32_t        msg_qnum;
        uint32_t        msg_qbytes;
@@ -143,7 +143,7 @@ struct ipc_perm32_old {
 
 struct semid_ds32_old {
        struct ipc_perm32_old sem_perm;
-       uint32_t        sem_base;
+       uint32_t        __sem_base;
        unsigned short  sem_nsems;
        int32_t         sem_otime;
        int32_t         sem_pad1;
@@ -154,8 +154,8 @@ struct semid_ds32_old {
 
 struct msqid_ds32_old {
        struct ipc_perm32_old msg_perm;
-       uint32_t        msg_first;
-       uint32_t        msg_last;
+       uint32_t        __msg_first;
+       uint32_t        __msg_last;
        uint32_t        msg_cbytes;
        uint32_t        msg_qnum;
        uint32_t        msg_qbytes;

Modified: head/sys/i386/ibcs2/ibcs2_ipc.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_ipc.c     Fri Mar  2 21:50:02 2018        
(r330296)
+++ head/sys/i386/ibcs2/ibcs2_ipc.c     Fri Mar  2 22:10:48 2018        
(r330297)
@@ -73,9 +73,8 @@ cvt_msqid2imsqid(bp, ibp)
 struct msqid_ds *bp;
 struct ibcs2_msqid_ds *ibp;
 {
+       memset(ibp, 0, sizeof(*ibp));
        cvt_perm2iperm(&bp->msg_perm, &ibp->msg_perm);
-       ibp->msg_first = bp->msg_first;
-       ibp->msg_last = bp->msg_last;
        ibp->msg_cbytes = (u_short)bp->msg_cbytes;
        ibp->msg_qnum = (u_short)bp->msg_qnum;
        ibp->msg_qbytes = (u_short)bp->msg_qbytes;
@@ -93,8 +92,6 @@ struct ibcs2_msqid_ds *ibp;
 struct msqid_ds *bp;
 {
        cvt_iperm2perm(&ibp->msg_perm, &bp->msg_perm);
-       bp->msg_first = ibp->msg_first;
-       bp->msg_last = ibp->msg_last;
        bp->msg_cbytes = ibp->msg_cbytes;
        bp->msg_qnum = ibp->msg_qnum;
        bp->msg_qbytes = ibp->msg_qbytes;
@@ -283,8 +280,8 @@ cvt_semid2isemid(bp, ibp)
 struct semid_ds *bp;
 struct ibcs2_semid_ds *ibp;
 {
+       memset(ibp, 0, sizeof(*ibp);
        cvt_perm2iperm(&bp->sem_perm, &ibp->sem_perm);
-       ibp->sem_base = (struct ibcs2_sem *)bp->sem_base;
        ibp->sem_nsems = bp->sem_nsems;
        ibp->sem_otime = bp->sem_otime;
        ibp->sem_ctime = bp->sem_ctime;
@@ -297,7 +294,6 @@ struct ibcs2_semid_ds *ibp;
 struct semid_ds *bp;
 {
        cvt_iperm2perm(&ibp->sem_perm, &bp->sem_perm);
-       bp->sem_base = (struct sem *)ibp->sem_base;
        bp->sem_nsems = ibp->sem_nsems;
        bp->sem_otime = ibp->sem_otime;
        bp->sem_ctime = ibp->sem_ctime;

Modified: head/sys/kern/sysv_msg.c
==============================================================================
--- head/sys/kern/sysv_msg.c    Fri Mar  2 21:50:02 2018        (r330296)
+++ head/sys/kern/sysv_msg.c    Fri Mar  2 22:10:48 2018        (r330297)
@@ -425,7 +425,7 @@ msq_remove(struct msqid_kernel *msqkptr)
        msqkptr->cred = NULL;
 
        /* Free the message headers */
-       msghdr = msqkptr->u.msg_first;
+       msghdr = msqkptr->u.__msg_first;
        while (msghdr != NULL) {
                struct msg *msghdr_tmp;
 
@@ -573,7 +573,7 @@ kern_msgctl(td, msqid, cmd, msqbuf)
                 * thread cannot free a certain msghdr.  The msq will get
                 * into an inconsistent state.
                 */
-               for (msghdr = msqkptr->u.msg_first; msghdr != NULL;
+               for (msghdr = msqkptr->u.__msg_first; msghdr != NULL;
                    msghdr = msghdr->msg_next) {
                        error = mac_sysvmsq_check_msgrmid(td->td_ucred, msghdr);
                        if (error != 0)
@@ -731,8 +731,8 @@ sys_msgget(struct thread *td, struct msgget_args *uap)
                msqkptr->cred = crhold(cred);
                /* Make sure that the returned msqid is unique */
                msqkptr->u.msg_perm.seq = (msqkptr->u.msg_perm.seq + 1) & 
0x7fff;
-               msqkptr->u.msg_first = NULL;
-               msqkptr->u.msg_last = NULL;
+               msqkptr->u.__msg_first = NULL;
+               msqkptr->u.__msg_last = NULL;
                msqkptr->u.msg_cbytes = 0;
                msqkptr->u.msg_qnum = 0;
                msqkptr->u.msg_qbytes = msginfo.msgmnb;
@@ -1079,14 +1079,14 @@ kern_msgsnd(struct thread *td, int msqid, const void *
        /*
         * Put the message into the queue
         */
-       if (msqkptr->u.msg_first == NULL) {
-               msqkptr->u.msg_first = msghdr;
-               msqkptr->u.msg_last = msghdr;
+       if (msqkptr->u.__msg_first == NULL) {
+               msqkptr->u.__msg_first = msghdr;
+               msqkptr->u.__msg_last = msghdr;
        } else {
-               msqkptr->u.msg_last->msg_next = msghdr;
-               msqkptr->u.msg_last = msghdr;
+               msqkptr->u.__msg_last->msg_next = msghdr;
+               msqkptr->u.__msg_last = msghdr;
        }
-       msqkptr->u.msg_last->msg_next = NULL;
+       msqkptr->u.__msg_last->msg_next = NULL;
 
        msqkptr->u.msg_cbytes += msghdr->msg_ts;
        msqkptr->u.msg_qnum++;
@@ -1194,7 +1194,7 @@ kern_msgrcv(struct thread *td, int msqid, void *msgp, 
        msghdr = NULL;
        while (msghdr == NULL) {
                if (msgtyp == 0) {
-                       msghdr = msqkptr->u.msg_first;
+                       msghdr = msqkptr->u.__msg_first;
                        if (msghdr != NULL) {
                                if (msgsz < msghdr->msg_ts &&
                                    (msgflg & MSG_NOERROR) == 0) {
@@ -1210,12 +1210,13 @@ kern_msgrcv(struct thread *td, int msqid, void *msgp, 
                                if (error != 0)
                                        goto done2;
 #endif
-                               if (msqkptr->u.msg_first == 
msqkptr->u.msg_last) {
-                                       msqkptr->u.msg_first = NULL;
-                                       msqkptr->u.msg_last = NULL;
+                               if (msqkptr->u.__msg_first ==
+                                   msqkptr->u.__msg_last) {
+                                       msqkptr->u.__msg_first = NULL;
+                                       msqkptr->u.__msg_last = NULL;
                                } else {
-                                       msqkptr->u.msg_first = msghdr->msg_next;
-                                       if (msqkptr->u.msg_first == NULL)
+                                       msqkptr->u.__msg_first = 
msghdr->msg_next;
+                                       if (msqkptr->u.__msg_first == NULL)
                                                panic("msg_first/last screwed 
up #1");
                                }
                        }
@@ -1224,7 +1225,7 @@ kern_msgrcv(struct thread *td, int msqid, void *msgp, 
                        struct msg **prev;
 
                        previous = NULL;
-                       prev = &(msqkptr->u.msg_first);
+                       prev = &(msqkptr->u.__msg_first);
                        while ((msghdr = *prev) != NULL) {
                                /*
                                 * Is this message's type an exact match or is
@@ -1256,20 +1257,20 @@ kern_msgrcv(struct thread *td, int msqid, void *msgp, 
                                                goto done2;
 #endif
                                        *prev = msghdr->msg_next;
-                                       if (msghdr == msqkptr->u.msg_last) {
+                                       if (msghdr == msqkptr->u.__msg_last) {
                                                if (previous == NULL) {
                                                        if (prev !=
-                                                           
&msqkptr->u.msg_first)
-                                                               
panic("msg_first/last screwed up #2");
-                                                       msqkptr->u.msg_first =
+                                                           
&msqkptr->u.__msg_first)
+                                                               
panic("__msg_first/last screwed up #2");
+                                                       msqkptr->u.__msg_first =
                                                            NULL;
-                                                       msqkptr->u.msg_last =
+                                                       msqkptr->u.__msg_last =
                                                            NULL;
                                                } else {
                                                        if (prev ==
-                                                           
&msqkptr->u.msg_first)
-                                                               
panic("msg_first/last screwed up #3");
-                                                       msqkptr->u.msg_last =
+                                                           
&msqkptr->u.__msg_first)
+                                                               
panic("__msg_first/last screwed up #3");
+                                                       msqkptr->u.__msg_last =
                                                            previous;
                                                }
                                        }
@@ -1461,8 +1462,8 @@ sysctl_msqids(SYSCTL_HANDLER_ARGS)
 #endif
                {
                        /* Don't leak kernel pointers */
-                       tmsqk.u.msg_first = NULL;
-                       tmsqk.u.msg_last = NULL;
+                       tmsqk.u.__msg_first = NULL;
+                       tmsqk.u.__msg_last = NULL;
                        tmsqk.label = NULL;
                        tmsqk.cred = NULL;
                        /*
@@ -1713,8 +1714,8 @@ freebsd7_freebsd32_msgctl(struct thread *td,
                if (error)
                        return (error);
                freebsd32_ipcperm_old_in(&msqbuf32.msg_perm, &msqbuf.msg_perm);
-               PTRIN_CP(msqbuf32, msqbuf, msg_first);
-               PTRIN_CP(msqbuf32, msqbuf, msg_last);
+               PTRIN_CP(msqbuf32, msqbuf, __msg_first);
+               PTRIN_CP(msqbuf32, msqbuf, __msg_last);
                CP(msqbuf32, msqbuf, msg_cbytes);
                CP(msqbuf32, msqbuf, msg_qnum);
                CP(msqbuf32, msqbuf, msg_qbytes);
@@ -1730,8 +1731,8 @@ freebsd7_freebsd32_msgctl(struct thread *td,
        if (uap->cmd == IPC_STAT) {
                bzero(&msqbuf32, sizeof(msqbuf32));
                freebsd32_ipcperm_old_out(&msqbuf.msg_perm, &msqbuf32.msg_perm);
-               PTROUT_CP(msqbuf, msqbuf32, msg_first);
-               PTROUT_CP(msqbuf, msqbuf32, msg_last);
+               PTROUT_CP(msqbuf, msqbuf32, __msg_first);
+               PTROUT_CP(msqbuf, msqbuf32, __msg_last);
                CP(msqbuf, msqbuf32, msg_cbytes);
                CP(msqbuf, msqbuf32, msg_qnum);
                CP(msqbuf, msqbuf32, msg_qbytes);
@@ -1758,8 +1759,8 @@ freebsd32_msgctl(struct thread *td, struct freebsd32_m
                if (error)
                        return (error);
                freebsd32_ipcperm_in(&msqbuf32.msg_perm, &msqbuf.msg_perm);
-               PTRIN_CP(msqbuf32, msqbuf, msg_first);
-               PTRIN_CP(msqbuf32, msqbuf, msg_last);
+               PTRIN_CP(msqbuf32, msqbuf, __msg_first);
+               PTRIN_CP(msqbuf32, msqbuf, __msg_last);
                CP(msqbuf32, msqbuf, msg_cbytes);
                CP(msqbuf32, msqbuf, msg_qnum);
                CP(msqbuf32, msqbuf, msg_qbytes);
@@ -1774,8 +1775,8 @@ freebsd32_msgctl(struct thread *td, struct freebsd32_m
                return (error);
        if (uap->cmd == IPC_STAT) {
                freebsd32_ipcperm_out(&msqbuf.msg_perm, &msqbuf32.msg_perm);
-               PTROUT_CP(msqbuf, msqbuf32, msg_first);
-               PTROUT_CP(msqbuf, msqbuf32, msg_last);
+               PTROUT_CP(msqbuf, msqbuf32, __msg_first);
+               PTROUT_CP(msqbuf, msqbuf32, __msg_last);
                CP(msqbuf, msqbuf32, msg_cbytes);
                CP(msqbuf, msqbuf32, msg_qnum);
                CP(msqbuf, msqbuf32, msg_qbytes);
@@ -1883,8 +1884,8 @@ freebsd7_msgctl(struct thread *td, struct freebsd7_msg
                if (error)
                        return (error);
                ipcperm_old2new(&msqold.msg_perm, &msqbuf.msg_perm);
-               CP(msqold, msqbuf, msg_first);
-               CP(msqold, msqbuf, msg_last);
+               CP(msqold, msqbuf, __msg_first);
+               CP(msqold, msqbuf, __msg_last);
                CP(msqold, msqbuf, msg_cbytes);
                CP(msqold, msqbuf, msg_qnum);
                CP(msqold, msqbuf, msg_qbytes);
@@ -1900,8 +1901,8 @@ freebsd7_msgctl(struct thread *td, struct freebsd7_msg
        if (uap->cmd == IPC_STAT) {
                bzero(&msqold, sizeof(msqold));
                ipcperm_new2old(&msqbuf.msg_perm, &msqold.msg_perm);
-               CP(msqbuf, msqold, msg_first);
-               CP(msqbuf, msqold, msg_last);
+               CP(msqbuf, msqold, __msg_first);
+               CP(msqbuf, msqold, __msg_last);
                CP(msqbuf, msqold, msg_cbytes);
                CP(msqbuf, msqold, msg_qnum);
                CP(msqbuf, msqold, msg_qbytes);

Modified: head/sys/kern/sysv_sem.c
==============================================================================
--- head/sys/kern/sysv_sem.c    Fri Mar  2 21:50:02 2018        (r330296)
+++ head/sys/kern/sysv_sem.c    Fri Mar  2 22:10:48 2018        (r330297)
@@ -287,7 +287,7 @@ seminit(void)
        semu = malloc(seminfo.semmnu * seminfo.semusz, M_SEM, M_WAITOK);
 
        for (i = 0; i < seminfo.semmni; i++) {
-               sema[i].u.sem_base = 0;
+               sema[i].u.__sem_base = 0;
                sema[i].u.sem_perm.mode = 0;
                sema[i].u.sem_perm.seq = 0;
 #ifdef MAC
@@ -576,15 +576,15 @@ sem_remove(int semidx, struct ucred *cred)
        wakeup(semakptr);
        for (i = 0; i < seminfo.semmni; i++) {
                if ((sema[i].u.sem_perm.mode & SEM_ALLOC) &&
-                   sema[i].u.sem_base > semakptr->u.sem_base)
+                   sema[i].u.__sem_base > semakptr->u.__sem_base)
                        mtx_lock_flags(&sema_mtx[i], LOP_DUPOK);
        }
-       for (i = semakptr->u.sem_base - sem; i < semtot; i++)
+       for (i = semakptr->u.__sem_base - sem; i < semtot; i++)
                sem[i] = sem[i + semakptr->u.sem_nsems];
        for (i = 0; i < seminfo.semmni; i++) {
                if ((sema[i].u.sem_perm.mode & SEM_ALLOC) &&
-                   sema[i].u.sem_base > semakptr->u.sem_base) {
-                       sema[i].u.sem_base -= semakptr->u.sem_nsems;
+                   sema[i].u.__sem_base > semakptr->u.__sem_base) {
+                       sema[i].u.__sem_base -= semakptr->u.sem_nsems;
                        mtx_unlock(&sema_mtx[i]);
                }
        }
@@ -802,7 +802,7 @@ kern_semctl(struct thread *td, int semid, int semnum, 
                        error = EINVAL;
                        goto done2;
                }
-               *rval = semakptr->u.sem_base[semnum].semncnt;
+               *rval = semakptr->u.__sem_base[semnum].semncnt;
                break;
 
        case GETPID:
@@ -814,7 +814,7 @@ kern_semctl(struct thread *td, int semid, int semnum, 
                        error = EINVAL;
                        goto done2;
                }
-               *rval = semakptr->u.sem_base[semnum].sempid;
+               *rval = semakptr->u.__sem_base[semnum].sempid;
                break;
 
        case GETVAL:
@@ -826,7 +826,7 @@ kern_semctl(struct thread *td, int semid, int semnum, 
                        error = EINVAL;
                        goto done2;
                }
-               *rval = semakptr->u.sem_base[semnum].semval;
+               *rval = semakptr->u.__sem_base[semnum].semval;
                break;
 
        case GETALL:
@@ -860,7 +860,7 @@ kern_semctl(struct thread *td, int semid, int semnum, 
                if ((error = ipcperm(td, &semakptr->u.sem_perm, IPC_R)))
                        goto done2;
                for (i = 0; i < semakptr->u.sem_nsems; i++)
-                       array[i] = semakptr->u.sem_base[i].semval;
+                       array[i] = semakptr->u.__sem_base[i].semval;
                mtx_unlock(sema_mtxp);
                error = copyout(array, arg->array, count * sizeof(*array));
                mtx_lock(sema_mtxp);
@@ -875,7 +875,7 @@ kern_semctl(struct thread *td, int semid, int semnum, 
                        error = EINVAL;
                        goto done2;
                }
-               *rval = semakptr->u.sem_base[semnum].semzcnt;
+               *rval = semakptr->u.__sem_base[semnum].semzcnt;
                break;
 
        case SETVAL:
@@ -891,7 +891,7 @@ kern_semctl(struct thread *td, int semid, int semnum, 
                        error = ERANGE;
                        goto done2;
                }
-               semakptr->u.sem_base[semnum].semval = arg->val;
+               semakptr->u.__sem_base[semnum].semval = arg->val;
                SEMUNDO_LOCK();
                semundo_clear(semidx, semnum);
                SEMUNDO_UNLOCK();
@@ -921,7 +921,7 @@ kern_semctl(struct thread *td, int semid, int semnum, 
                                error = ERANGE;
                                break;
                        }
-                       semakptr->u.sem_base[i].semval = usval;
+                       semakptr->u.__sem_base[i].semval = usval;
                }
                SEMUNDO_LOCK();
                semundo_clear(semidx, -1);
@@ -1052,16 +1052,16 @@ sys_semget(struct thread *td, struct semget_args *uap)
                sema[semid].u.sem_nsems = nsems;
                sema[semid].u.sem_otime = 0;
                sema[semid].u.sem_ctime = time_second;
-               sema[semid].u.sem_base = &sem[semtot];
+               sema[semid].u.__sem_base = &sem[semtot];
                semtot += nsems;
-               bzero(sema[semid].u.sem_base,
-                   sizeof(sema[semid].u.sem_base[0])*nsems);
+               bzero(sema[semid].u.__sem_base,
+                   sizeof(sema[semid].u.__sem_base[0])*nsems);
 #ifdef MAC
                mac_sysvsem_create(cred, &sema[semid]);
 #endif
                mtx_unlock(&sema_mtx[semid]);
                DPRINTF(("sembase = %p, next = %p\n",
-                   sema[semid].u.sem_base, &sem[semtot]));
+                   sema[semid].u.__sem_base, &sem[semtot]));
        } else {
                DPRINTF(("didn't find it and wasn't asked to create it\n"));
                error = ENOENT;
@@ -1204,12 +1204,12 @@ sys_semop(struct thread *td, struct semop_args *uap)
 
                for (i = 0; i < nsops; i++) {
                        sopptr = &sops[i];
-                       semptr = &semakptr->u.sem_base[sopptr->sem_num];
+                       semptr = &semakptr->u.__sem_base[sopptr->sem_num];
 
                        DPRINTF((
-                           "semop:  semakptr=%p, sem_base=%p, "
+                           "semop:  semakptr=%p, __sem_base=%p, "
                            "semptr=%p, sem[%d]=%d : op=%d, flag=%s\n",
-                           semakptr, semakptr->u.sem_base, semptr,
+                           semakptr, semakptr->u.__sem_base, semptr,
                            sopptr->sem_num, semptr->semval, sopptr->sem_op,
                            (sopptr->sem_flg & IPC_NOWAIT) ?
                            "nowait" : "wait"));
@@ -1251,7 +1251,7 @@ sys_semop(struct thread *td, struct semop_args *uap)
                 */
                DPRINTF(("semop:  rollback 0 through %d\n", i-1));
                for (j = 0; j < i; j++)
-                       semakptr->u.sem_base[sops[j].sem_num].semval -=
+                       semakptr->u.__sem_base[sops[j].sem_num].semval -=
                            sops[j].sem_op;
 
                /* If we detected an error, return it */
@@ -1290,10 +1290,10 @@ sys_semop(struct thread *td, struct semop_args *uap)
 
                /*
                 * Renew the semaphore's pointer after wakeup since
-                * during msleep sem_base may have been modified and semptr
+                * during msleep __sem_base may have been modified and semptr
                 * is not valid any more
                 */
-               semptr = &semakptr->u.sem_base[sopptr->sem_num];
+               semptr = &semakptr->u.__sem_base[sopptr->sem_num];
 
                /*
                 * The semaphore is still alive.  Readjust the count of
@@ -1362,7 +1362,7 @@ done:
                        }
 
                        for (j = 0; j < nsops; j++)
-                               semakptr->u.sem_base[sops[j].sem_num].semval -=
+                               semakptr->u.__sem_base[sops[j].sem_num].semval 
-=
                                    sops[j].sem_op;
 
                        DPRINTF(("error = %d from semundo_adjust\n", error));
@@ -1375,7 +1375,7 @@ done:
        /* We're definitely done - set the sempid's and time */
        for (i = 0; i < nsops; i++) {
                sopptr = &sops[i];
-               semptr = &semakptr->u.sem_base[sopptr->sem_num];
+               semptr = &semakptr->u.__sem_base[sopptr->sem_num];
                semptr->sempid = td->td_proc->p_pid;
        }
        semakptr->u.sem_otime = time_second;
@@ -1458,13 +1458,13 @@ semexit_myhook(void *arg, struct proc *p)
                            suptr->un_proc, suptr->un_ent[ix].un_id,
                            suptr->un_ent[ix].un_num,
                            suptr->un_ent[ix].un_adjval,
-                           semakptr->u.sem_base[semnum].semval));
+                           semakptr->u.__sem_base[semnum].semval));
 
-                       if (adjval < 0 && semakptr->u.sem_base[semnum].semval <
+                       if (adjval < 0 && semakptr->u.__sem_base[semnum].semval 
<
                            -adjval)
-                               semakptr->u.sem_base[semnum].semval = 0;
+                               semakptr->u.__sem_base[semnum].semval = 0;
                        else
-                               semakptr->u.sem_base[semnum].semval += adjval;
+                               semakptr->u.__sem_base[semnum].semval += adjval;
 
                        wakeup(semakptr);
                        DPRINTF(("semexit:  back from wakeup\n"));
@@ -1514,7 +1514,7 @@ sysctl_sema(SYSCTL_HANDLER_ARGS)
                        bzero(&tsemak32, sizeof(tsemak32));
                        freebsd32_ipcperm_out(&tsemak.u.sem_perm,
                            &tsemak32.u.sem_perm);
-                       /* Don't copy u.sem_base */
+                       /* Don't copy u.__sem_base */
                        CP(tsemak, tsemak32, u.sem_nsems);
                        CP(tsemak, tsemak32, u.sem_otime);
                        CP(tsemak, tsemak32, u.sem_ctime);
@@ -1524,7 +1524,7 @@ sysctl_sema(SYSCTL_HANDLER_ARGS)
                } else
 #endif
                {
-                       tsemak.u.sem_base = NULL;
+                       tsemak.u.__sem_base = NULL;
                        tsemak.label = NULL;
                        tsemak.cred = NULL;
                        outaddr = &tsemak;
@@ -1791,7 +1791,7 @@ freebsd7___semctl(struct thread *td, struct freebsd7__
                if (error)
                        return (error);
                ipcperm_old2new(&dsold.sem_perm, &dsbuf.sem_perm);
-               CP(dsold, dsbuf, sem_base);
+               CP(dsold, dsbuf, __sem_base);
                CP(dsold, dsbuf, sem_nsems);
                CP(dsold, dsbuf, sem_otime);
                CP(dsold, dsbuf, sem_ctime);
@@ -1816,7 +1816,7 @@ freebsd7___semctl(struct thread *td, struct freebsd7__
        case IPC_STAT:
                bzero(&dsold, sizeof(dsold));
                ipcperm_new2old(&dsbuf.sem_perm, &dsold.sem_perm);
-               CP(dsbuf, dsold, sem_base);
+               CP(dsbuf, dsold, __sem_base);
                CP(dsbuf, dsold, sem_nsems);
                CP(dsbuf, dsold, sem_otime);
                CP(dsbuf, dsold, sem_ctime);
@@ -1888,7 +1888,7 @@ freebsd7_freebsd32_semctl(struct thread *td,
                if (error)
                        return (error);
                freebsd32_ipcperm_old_in(&dsbuf32.sem_perm, &dsbuf.sem_perm);
-               PTRIN_CP(dsbuf32, dsbuf, sem_base);
+               PTRIN_CP(dsbuf32, dsbuf, __sem_base);
                CP(dsbuf32, dsbuf, sem_nsems);
                CP(dsbuf32, dsbuf, sem_otime);
                CP(dsbuf32, dsbuf, sem_ctime);
@@ -1913,7 +1913,7 @@ freebsd7_freebsd32_semctl(struct thread *td,
        case IPC_STAT:
                bzero(&dsbuf32, sizeof(dsbuf32));
                freebsd32_ipcperm_old_out(&dsbuf.sem_perm, &dsbuf32.sem_perm);
-               PTROUT_CP(dsbuf, dsbuf32, sem_base);
+               PTROUT_CP(dsbuf, dsbuf32, __sem_base);
                CP(dsbuf, dsbuf32, sem_nsems);
                CP(dsbuf, dsbuf32, sem_otime);
                CP(dsbuf, dsbuf32, sem_ctime);
@@ -1960,7 +1960,7 @@ freebsd32_semctl(struct thread *td, struct freebsd32_s
                if (error)
                        return (error);
                freebsd32_ipcperm_in(&dsbuf32.sem_perm, &dsbuf.sem_perm);
-               PTRIN_CP(dsbuf32, dsbuf, sem_base);
+               PTRIN_CP(dsbuf32, dsbuf, __sem_base);
                CP(dsbuf32, dsbuf, sem_nsems);
                CP(dsbuf32, dsbuf, sem_otime);
                CP(dsbuf32, dsbuf, sem_ctime);
@@ -1985,7 +1985,7 @@ freebsd32_semctl(struct thread *td, struct freebsd32_s
        case IPC_STAT:
                bzero(&dsbuf32, sizeof(dsbuf32));
                freebsd32_ipcperm_out(&dsbuf.sem_perm, &dsbuf32.sem_perm);
-               PTROUT_CP(dsbuf, dsbuf32, sem_base);
+               PTROUT_CP(dsbuf, dsbuf32, __sem_base);
                CP(dsbuf, dsbuf32, sem_nsems);
                CP(dsbuf, dsbuf32, sem_otime);
                CP(dsbuf, dsbuf32, sem_ctime);

Modified: head/sys/sys/msg.h
==============================================================================
--- head/sys/sys/msg.h  Fri Mar  2 21:50:02 2018        (r330296)
+++ head/sys/sys/msg.h  Fri Mar  2 22:10:48 2018        (r330297)
@@ -64,8 +64,8 @@ typedef       __time_t        time_t;
     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
 struct msqid_ds_old {
        struct  ipc_perm_old msg_perm;  /* msg queue permission bits */
-       struct  msg *msg_first; /* first message in the queue */
-       struct  msg *msg_last;  /* last message in the queue */
+       struct  msg *__msg_first;       /* first message in the queue */
+       struct  msg *__msg_last;        /* last message in the queue */
        msglen_t msg_cbytes;    /* number of bytes in use on the queue */
        msgqnum_t msg_qnum;     /* number of msgs in the queue */
        msglen_t msg_qbytes;    /* max # of bytes on the queue */
@@ -89,8 +89,8 @@ struct msqid_ds_old {
 
 struct msqid_ds {
        struct  ipc_perm msg_perm;      /* msg queue permission bits */
-       struct  msg *msg_first; /* first message in the queue */
-       struct  msg *msg_last;  /* last message in the queue */
+       struct  msg *__msg_first;       /* first message in the queue */
+       struct  msg *__msg_last;        /* last message in the queue */
        msglen_t msg_cbytes;    /* number of bytes in use on the queue */
        msgqnum_t msg_qnum;     /* number of msgs in the queue */
        msglen_t msg_qbytes;    /* max # of bytes on the queue */

Modified: head/sys/sys/sem.h
==============================================================================
--- head/sys/sys/sem.h  Fri Mar  2 21:50:02 2018        (r330296)
+++ head/sys/sys/sem.h  Fri Mar  2 22:10:48 2018        (r330297)
@@ -34,7 +34,7 @@ typedef       __time_t        time_t;
     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
 struct semid_ds_old {
        struct ipc_perm_old sem_perm;   /* operation permission struct */
-       struct sem      *sem_base;      /* pointer to first semaphore in set */
+       struct sem      *__sem_base;    /* pointer to first semaphore in set */
        unsigned short  sem_nsems;      /* number of sems in set */
        time_t          sem_otime;      /* last operation time */
        long            sem_pad1;       /* SVABI/386 says I need this here */
@@ -48,7 +48,7 @@ struct semid_ds_old {
 
 struct semid_ds {
        struct ipc_perm sem_perm;       /* operation permission struct */
-       struct sem      *sem_base;      /* pointer to first semaphore in set */
+       struct sem      *__sem_base;    /* pointer to first semaphore in set */
        unsigned short  sem_nsems;      /* number of sems in set */
        time_t          sem_otime;      /* last operation time */
        time_t          sem_ctime;      /* last change time */
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to