diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2009-06-11 21:37:23 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2009-06-11 21:37:23 +0000 |
| commit | ae66536ebdd69f1e8cd443c780da96d902724d5c (patch) | |
| tree | 873a8c7df7f870e35b9dc51f510347e53a2d5abe /lib/libc | |
| parent | 6b324b023e2429180cb83ee00f4b99a8c16d65c3 (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/gen/posixshm.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/libc/gen/posixshm.c b/lib/libc/gen/posixshm.c index 05fc1c9bf403..21246e2a2c1c 100644 --- a/lib/libc/gen/posixshm.c +++ b/lib/libc/gen/posixshm.c @@ -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, mode_t mode) 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)); } |
