diff options
| author | Garrett Wollman <wollman@FreeBSD.org> | 2000-04-22 15:22:31 +0000 |
|---|---|---|
| committer | Garrett Wollman <wollman@FreeBSD.org> | 2000-04-22 15:22:31 +0000 |
| commit | aa543039b57a46e0087df4a4dec3586071ae6120 (patch) | |
| tree | bf6ed85570f850a184fd25e49ef2b68222430aca | |
| parent | b39b38ecd0f0fdec3130c626f0a33967b07b7f2c (diff) | |
Notes
| -rw-r--r-- | sys/sys/fcntl.h | 20 | ||||
| -rw-r--r-- | sys/sys/unistd.h | 4 | ||||
| -rw-r--r-- | sys/vm/vm_mmap.c | 10 |
3 files changed, 32 insertions, 2 deletions
diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index d5b29e656f23..6bbf156ebe60 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 11e74f623feb..515c69f14090 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 53462f4bccf4..d617d0c2d3ba 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); |
