svn commit: r194744 - in stable/4/lib/libc: . gen
John Baldwin
jhb at FreeBSD.org
Tue Jun 23 17:44:56 UTC 2009
Author: jhb
Date: Tue Jun 23 17:44:55 2009
New Revision: 194744
URL: http://svn.freebsd.org/changeset/base/194744
Log:
MF7: 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.
Modified:
stable/4/lib/libc/ (props changed)
stable/4/lib/libc/gen/posixshm.c
Modified: stable/4/lib/libc/gen/posixshm.c
==============================================================================
--- stable/4/lib/libc/gen/posixshm.c Tue Jun 23 17:42:06 2009 (r194743)
+++ stable/4/lib/libc/gen/posixshm.c Tue Jun 23 17:44:55 2009 (r194744)
@@ -37,12 +37,34 @@
#include <errno.h>
#include <unistd.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);
@@ -65,5 +87,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-other
mailing list