From owner-svn-src-all@freebsd.org Tue Jul 26 17:23:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 744E0BA52A9; Tue, 26 Jul 2016 17:23:50 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 395BF17B7; Tue, 26 Jul 2016 17:23:50 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6QHNnxM080079; Tue, 26 Jul 2016 17:23:49 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6QHNnhm080076; Tue, 26 Jul 2016 17:23:49 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201607261723.u6QHNnhm080076@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Tue, 26 Jul 2016 17:23:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303340 - in head/sys: compat/freebsd32 kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2016 17:23:50 -0000 Author: ed Date: Tue Jul 26 17:23:49 2016 New Revision: 303340 URL: https://svnweb.freebsd.org/changeset/base/303340 Log: Add shmatt_t. It looks like our "struct shmid_ds::shm_nattch" deviates from the standard in the sense that it is a signed integer, whereas POSIX requires that it is unsigned, having a special type shmatt_t. Patch up our native and 32-bit copies to use a new shmatt_t that is an unsigned integer. As it's unsigned, we can relax the comparisons that are performed on it. Leave the Linux, iBCS2, etc. copies of the structure alone. Reviewed by: ngie Differential Revision: https://reviews.freebsd.org/D6655 Modified: head/sys/compat/freebsd32/freebsd32_ipc.h head/sys/kern/sysv_shm.c head/sys/sys/shm.h Modified: head/sys/compat/freebsd32/freebsd32_ipc.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_ipc.h Tue Jul 26 16:40:03 2016 (r303339) +++ head/sys/compat/freebsd32/freebsd32_ipc.h Tue Jul 26 17:23:49 2016 (r303340) @@ -72,7 +72,7 @@ struct shmid_ds32 { int32_t shm_segsz; pid_t shm_lpid; pid_t shm_cpid; - int shm_nattch; + unsigned int shm_nattch; int32_t shm_atime; int32_t shm_dtime; int32_t shm_ctime; Modified: head/sys/kern/sysv_shm.c ============================================================================== --- head/sys/kern/sysv_shm.c Tue Jul 26 16:40:03 2016 (r303339) +++ head/sys/kern/sysv_shm.c Tue Jul 26 17:23:49 2016 (r303340) @@ -275,7 +275,7 @@ shm_delete_mapping(struct vmspace *vm, s return (EINVAL); shmmap_s->shmid = -1; shmseg->u.shm_dtime = time_second; - if ((--shmseg->u.shm_nattch <= 0) && + if (--shmseg->u.shm_nattch == 0 && (shmseg->u.shm_perm.mode & SHMSEG_REMOVED)) { shm_deallocate_segment(shmseg); shm_last_free = segnum; @@ -289,7 +289,7 @@ shm_remove(struct shmid_kernel *shmseg, shmseg->u.shm_perm.key = IPC_PRIVATE; shmseg->u.shm_perm.mode |= SHMSEG_REMOVED; - if (shmseg->u.shm_nattch <= 0) { + if (shmseg->u.shm_nattch == 0) { shm_deallocate_segment(shmseg); shm_last_free = segnum; } Modified: head/sys/sys/shm.h ============================================================================== --- head/sys/sys/shm.h Tue Jul 26 16:40:03 2016 (r303339) +++ head/sys/sys/shm.h Tue Jul 26 17:23:49 2016 (r303340) @@ -92,12 +92,14 @@ struct shmid_ds_old { }; #endif +typedef unsigned int shmatt_t; + struct shmid_ds { struct ipc_perm shm_perm; /* operation permission structure */ size_t shm_segsz; /* size of segment in bytes */ pid_t shm_lpid; /* process ID of last shared memory op */ pid_t shm_cpid; /* process ID of creator */ - int shm_nattch; /* number of current attaches */ + shmatt_t shm_nattch; /* number of current attaches */ time_t shm_atime; /* time of last shmat() */ time_t shm_dtime; /* time of last shmdt() */ time_t shm_ctime; /* time of last change by shmctl() */