Author: jhb
Date: Tue Jun 23 17:19:50 2009
New Revision: 194740
URL: http://svn.freebsd.org/changeset/base/194740

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/6/lib/libc/   (props changed)
  stable/6/lib/libc/gen/posixshm.c

Modified: stable/6/lib/libc/gen/posixshm.c
==============================================================================
--- stable/6/lib/libc/gen/posixshm.c    Tue Jun 23 17:03:45 2009        
(r194739)
+++ stable/6/lib/libc/gen/posixshm.c    Tue Jun 23 17:19:50 2009        
(r194740)
@@ -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));
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to