svn commit: r194040 - stable/7/lib/libc/gen
John Baldwin
jhb at FreeBSD.org
Thu Jun 11 21:37:25 UTC 2009
Author: jhb
Date: Thu Jun 11 21:37:23 2009
New Revision: 194040
URL: http://svn.freebsd.org/changeset/base/194040
Log:
If the running kernel has support for shm_open() and shm_unlink() as
system calls (i.e. 8.0+), then invoke the system calls instead of using
open/fcntl/unlink. This is a direct commit instead of an MFC since libc
in 8.0 always uses the system calls directly.
MFC after: 1 week
Modified:
stable/7/lib/libc/gen/posixshm.c
Modified: stable/7/lib/libc/gen/posixshm.c
==============================================================================
--- stable/7/lib/libc/gen/posixshm.c Thu Jun 11 21:32:26 2009 (r194039)
+++ stable/7/lib/libc/gen/posixshm.c Thu Jun 11 21:37:23 2009 (r194040)
@@ -40,12 +40,34 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include "un-namespace.h"
+static int _shm_in_kernel = -1;
+
+/* Wrappers for POSIX SHM system calls in newer kernels. */
+static __inline int
+_shm_open(const char *path, int flags, mode_t mode)
+{
+
+ return (syscall(482, path, flags, mode));
+}
+
+static __inline int
+_shm_unlink(const char *path)
+{
+
+ return (syscall(483, path));
+}
+
int
shm_open(const char *path, int flags, mode_t mode)
{
int fd;
struct stat stab;
+ if (_shm_in_kernel == -1)
+ _shm_in_kernel = feature_present("posix_shm");
+ if (_shm_in_kernel == 1)
+ return (_shm_open(path, flags, mode));
+
if ((flags & O_ACCMODE) == O_WRONLY)
return (EINVAL);
@@ -68,5 +90,11 @@ shm_open(const char *path, int flags, mo
int
shm_unlink(const char *path)
{
+
+ if (_shm_in_kernel == -1)
+ _shm_in_kernel = feature_present("posix_shm");
+ if (_shm_in_kernel == 1)
+ return (_shm_unlink(path));
+
return (unlink(path));
}
More information about the svn-src-stable-7
mailing list