summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/sys/fcntl.h20
-rw-r--r--sys/sys/unistd.h4
-rw-r--r--sys/vm/vm_mmap.c10
3 files changed, 32 insertions, 2 deletions
diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h
index d5b29e6..6bbf156 100644
--- a/sys/sys/fcntl.h
+++ b/sys/sys/fcntl.h
@@ -106,12 +106,12 @@
/* bits to save after open */
#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
/* bits settable by fcntl(F_SETFL, ...) */
-#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
+#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM)
#endif
/*
* The O_* flags used to have only F* names, which were used in the kernel
- * and by fcntl. We retain the F* names for the kernel f_flags field
+ * and by fcntl. We retain the F* names for the kernel f_flag field
* and for backward compatibility for fcntl.
*/
#ifndef _POSIX_SOURCE
@@ -124,6 +124,22 @@
#endif
/*
+ * We are out of bits in f_flag (which is a short). However,
+ * the flag bits not set in FMASK are only meaningful in the
+ * initial open syscall. Those bits can thus be given a
+ * different meaning for fcntl(2).
+ */
+#ifndef _POSIX_SOURCE
+
+/*
+ * Set by shm_open(3) to get automatic MAP_ASYNC behavior
+ * for POSIX shared memory objects (which are otherwise
+ * implemented as plain files).
+ */
+#define FPOSIXSHM O_NOFOLLOW
+#endif
+
+/*
* Constants used for fcntl(2)
*/
diff --git a/sys/sys/unistd.h b/sys/sys/unistd.h
index 11e74f6..515c69f 100644
--- a/sys/sys/unistd.h
+++ b/sys/sys/unistd.h
@@ -160,6 +160,10 @@
#define _POSIX_MEMLOCK_RANGE
#endif
+/* ??? #define _POSIX_FSYNC 1 */
+#define _POSIX_MAPPED_FILES 1
+#define _POSIX_SHARED_MEMORY_OBJECTS 1
+
/* POSIX.1B sysconf options */
#define _SC_ASYNCHRONOUS_IO 28
#define _SC_MAPPED_FILES 29
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 53462f4..d617d0c 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -282,6 +282,16 @@ mmap(p, uap)
return (EBADF);
if (fp->f_type != DTYPE_VNODE)
return (EINVAL);
+ /*
+ * POSIX shared-memory objects are defined to have
+ * kernel persistence, and are not defined to support
+ * read(2)/write(2) -- or even open(2). Thus, we can
+ * use MAP_ASYNC to trade on-disk coherence for speed.
+ * The shm_open(3) library routine turns on the FPOSIXSHM
+ * flag to request this behavior.
+ */
+ if (fp->f_flag & FPOSIXSHM)
+ flags |= MAP_NOSYNC;
vp = (struct vnode *) fp->f_data;
if (vp->v_type != VREG && vp->v_type != VCHR)
return (EINVAL);
OpenPOWER on IntegriCloud