Module Name: src
Committed By: dholland
Date: Sun Apr 24 19:48:30 UTC 2016
Modified Files:
src/distrib/sets/lists/comp: mi
src/include: semaphore.h
src/sys/kern: uipc_sem.c
src/sys/sys: Makefile
Added Files:
src/sys/sys: semaphore.h
Log Message:
Define SEM_VALUE_MAX in only one place.
Adding a whole extra header file just for this is not the optimal
solution... but stuffing it in with anything else exposes things that
otherwise wouldn't be.
Nothing in userland should use <sys/semaphore.h> directly, and if some
foolish third-party software should decide to do so anyway in spite of
the instructions to the contrary I will ruthlessly break it later when
the big kernel includes cleanup finally happens.
Reported by Kamil Rytarowski, and, as it turns out, also by Klaus
Heinz in 2008.
To generate a diff of this commit:
cvs rdiff -u -r1.2031 -r1.2032 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.4 -r1.5 src/include/semaphore.h
cvs rdiff -u -r1.44 -r1.45 src/sys/kern/uipc_sem.c
cvs rdiff -u -r1.158 -r1.159 src/sys/sys/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/sys/semaphore.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2031 src/distrib/sets/lists/comp/mi:1.2032
--- src/distrib/sets/lists/comp/mi:1.2031 Sat Apr 23 23:28:13 2016
+++ src/distrib/sets/lists/comp/mi Sun Apr 24 19:48:30 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2031 2016/04/23 23:28:13 christos Exp $
+# $NetBSD: mi,v 1.2032 2016/04/24 19:48:30 dholland Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -2918,6 +2918,7 @@
./usr/include/sys/select.h comp-c-include
./usr/include/sys/selinfo.h comp-c-include
./usr/include/sys/sem.h comp-c-include
+./usr/include/sys/semaphore.h comp-c-include
./usr/include/sys/sha1.h comp-c-include
./usr/include/sys/sha2.h comp-c-include
./usr/include/sys/shm.h comp-c-include
Index: src/include/semaphore.h
diff -u src/include/semaphore.h:1.4 src/include/semaphore.h:1.5
--- src/include/semaphore.h:1.4 Thu Mar 8 21:59:28 2012
+++ src/include/semaphore.h Sun Apr 24 19:48:29 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: semaphore.h,v 1.4 2012/03/08 21:59:28 joerg Exp $ */
+/* $NetBSD: semaphore.h,v 1.5 2016/04/24 19:48:29 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -38,8 +38,8 @@ struct _sem_st;
typedef struct _sem_st *sem_t;
#define SEM_FAILED ((sem_t *)0)
-#define SEM_VALUE_MAX (~0U)
+#include <sys/semaphore.h> /* some kernel-only bits */
#include <sys/time.h>
__BEGIN_DECLS
Index: src/sys/kern/uipc_sem.c
diff -u src/sys/kern/uipc_sem.c:1.44 src/sys/kern/uipc_sem.c:1.45
--- src/sys/kern/uipc_sem.c:1.44 Mon Nov 9 01:55:03 2015
+++ src/sys/kern/uipc_sem.c Sun Apr 24 19:48:29 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_sem.c,v 1.44 2015/11/09 01:55:03 pgoyette Exp $ */
+/* $NetBSD: uipc_sem.c,v 1.45 2016/04/24 19:48:29 dholland Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.44 2015/11/09 01:55:03 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.45 2016/04/24 19:48:29 dholland Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -77,6 +77,7 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v
#include <sys/kauth.h>
#include <sys/module.h>
#include <sys/mount.h>
+#include <sys/semaphore.h>
#include <sys/syscall.h>
#include <sys/syscallargs.h>
#include <sys/syscallvar.h>
@@ -85,7 +86,6 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v
MODULE(MODULE_CLASS_MISC, ksem, NULL);
#define SEM_MAX_NAMELEN 14
-#define SEM_VALUE_MAX (~0U)
#define KS_UNLINKED 0x01
Index: src/sys/sys/Makefile
diff -u src/sys/sys/Makefile:1.158 src/sys/sys/Makefile:1.159
--- src/sys/sys/Makefile:1.158 Sat Apr 2 20:38:40 2016
+++ src/sys/sys/Makefile Sun Apr 24 19:48:29 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.158 2016/04/02 20:38:40 christos Exp $
+# $NetBSD: Makefile,v 1.159 2016/04/24 19:48:29 dholland Exp $
.include <bsd.own.mk>
@@ -34,8 +34,8 @@ INCS= acct.h agpio.h aio.h ansi.h aout_m
queue.h quota.h quotactl.h \
ras.h rbtree.h reboot.h radioio.h resource.h resourcevar.h rmd160.h \
rnd.h rndio.h rwlock.h \
- scanio.h sched.h scsiio.h sdt.h select.h selinfo.h sem.h sha1.h \
- sha2.h shm.h siginfo.h signal.h signalvar.h sigtypes.h \
+ scanio.h sched.h scsiio.h sdt.h select.h selinfo.h sem.h semaphore.h \
+ sha1.h sha2.h shm.h siginfo.h signal.h signalvar.h sigtypes.h \
sleepq.h socket.h \
socketvar.h sockio.h spawn.h specificdata.h stat.h \
statvfs.h syscall.h syscallargs.h sysctl.h stdarg.h stdbool.h \
Added files:
Index: src/sys/sys/semaphore.h
diff -u /dev/null src/sys/sys/semaphore.h:1.1
--- /dev/null Sun Apr 24 19:48:30 2016
+++ src/sys/sys/semaphore.h Sun Apr 24 19:48:29 2016
@@ -0,0 +1,44 @@
+/* $NetBSD: semaphore.h,v 1.1 2016/04/24 19:48:29 dholland Exp $ */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This file is NOT a public interface. From userland you should
+ * include <semaphore.h>.
+ */
+
+#ifndef _SYS_SEMAPHORE_H_
+#define _SYS_SEMAPHORE_H_
+
+/* POSIX 1003.1b semaphores */
+
+#define SEM_VALUE_MAX (~0U)
+
+#endif /* !_SYS_SEMAPHORE_H_ */