about summary refs log tree commit diff
path: root/src/conf
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-03-10 21:34:19 -0500
committerRich Felker <dalias@aerifal.cx>2011-03-10 21:34:19 -0500
commit81af503610761a69476a3adbe8341fa8b6d078aa (patch)
tree87d40059752e8c9db136c3b53f25bc4f1a3a103d /src/conf
parent5fcebcde6aeba6ae4a339790beba5331fbcd3b6e (diff)
downloadmusl-81af503610761a69476a3adbe8341fa8b6d078aa.tar.gz
musl-81af503610761a69476a3adbe8341fa8b6d078aa.tar.xz
musl-81af503610761a69476a3adbe8341fa8b6d078aa.zip
fix sem_open and sem_close to obey posix semantics
multiple opens of the same named semaphore must return the same
pointer, and only the last close can unmap it. thus the ugly global
state keeping track of mappings. the maximum number of distinct named
semaphores that can be opened is limited sufficiently small that the
linear searches take trivial time, especially compared to the syscall
overhead of these functions.
Diffstat (limited to 'src/conf')
-rw-r--r--src/conf/sysconf.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c
index cdaeb2a6..a660257d 100644
--- a/src/conf/sysconf.c
+++ b/src/conf/sysconf.c
@@ -40,8 +40,8 @@ long sysconf(int name)
 		[_SC_VERSION] = VER,
 		[_SC_PAGE_SIZE] = PAGE_SIZE,
 		[_SC_RTSIG_MAX] = 63, /* ?? */
-		[_SC_SEM_NSEMS_MAX] = _POSIX_SEM_NSEMS_MAX,
-		[_SC_SEM_VALUE_MAX] = _POSIX_SEM_VALUE_MAX,
+		[_SC_SEM_NSEMS_MAX] = SEM_NSEMS_MAX,
+		[_SC_SEM_VALUE_MAX] = OFLOW,
 		[_SC_SIGQUEUE_MAX] = -1,
 		[_SC_TIMER_MAX] = -1,
 		[_SC_BC_BASE_MAX] = _POSIX2_BC_BASE_MAX,
@@ -215,8 +215,8 @@ long sysconf(int name)
 	} else if (values[name] == VER) {
 		return _POSIX_VERSION;
 	} else if (values[name] == OFLOW) {
-		return ARG_MAX;
-	} else {
-		return values[name];
+		if (name == _SC_ARG_MAX) return ARG_MAX;
+		if (name == _SC_SEM_VALUE_MAX) return SEM_VALUE_MAX;
 	}
+	return values[name];
 }