From: Sascha Wildner Date: Wed, 28 Jan 2015 19:11:20 +0000 (+0100) Subject: : Some cleanup. X-Git-Tag: v4.2.0rc~976 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/c39183f979f1674bd77419a1537c62be31ea0129 : Some cleanup. * Handle _P1003_1B_VISIBLE and _POSIX_SOURCE checks with __POSIX_VISIBLE. * Separate BSD specific defines/prototypes better. --- diff --git a/sys/sys/mman.h b/sys/sys/mman.h index 4ba4f57df9..25dc99d6b8 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -37,9 +37,6 @@ #ifndef _SYS_MMAN_H_ #define _SYS_MMAN_H_ -#ifndef _SYS__POSIX_H_ -#include -#endif #ifndef _SYS_TYPES_H_ #include #endif @@ -47,12 +44,14 @@ #include #endif +#if __BSD_VISIBLE /* * Inheritance for minherit() */ #define INHERIT_SHARE 0 #define INHERIT_COPY 1 #define INHERIT_NONE 2 +#endif /* * Protections are chosen from these bits, or-ed together @@ -68,12 +67,15 @@ */ #define MAP_SHARED 0x0001 /* share changes */ #define MAP_PRIVATE 0x0002 /* changes are private */ +#if __BSD_VISIBLE #define MAP_COPY MAP_PRIVATE /* Obsolete */ +#endif /* * Other flags */ #define MAP_FIXED 0x0010 /* map addr must be exactly as requested */ +#if __BSD_VISIBLE #define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ #define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ #define MAP_INHERIT 0x0080 /* region is retained after exec */ @@ -82,14 +84,29 @@ #define MAP_STACK 0x0400 /* region grows down, like a stack */ #define MAP_NOSYNC 0x0800 /* page to but do not sync underlying file */ -#ifdef _P1003_1B_VISIBLE +/* + * Mapping type + */ +#define MAP_FILE 0x0000 /* map from file (default) */ +#define MAP_ANON 0x1000 /* allocated from memory, swap space */ +#define MAP_ANONYMOUS MAP_ANON /* alias for compatibility */ +#define MAP_VPAGETABLE 0x2000 /* manage with virtualized page table */ + +/* + * Extended flags + */ +#define MAP_TRYFIXED 0x00010000 /* attempt hint address, even within heap */ +#define MAP_NOCORE 0x00020000 /* dont include these pages in a coredump */ +#define MAP_SIZEALIGN 0x00040000 /* size is also an alignment requirement */ +#endif /* __BSD_VISIBLE */ + +#if __POSIX_VISIBLE >= 199309 /* * Process memory locking */ #define MCL_CURRENT 0x0001 /* Lock only current memory */ #define MCL_FUTURE 0x0002 /* Lock all future memory as well */ - -#endif /* _P1003_1B_VISIBLE */ +#endif /* __POSIX_VISIBLE >= 199309 */ /* * Error return from mmap() @@ -103,30 +120,21 @@ #define MS_ASYNC 0x0001 /* return immediately */ #define MS_INVALIDATE 0x0002 /* invalidate all cached data */ - -/* - * Mapping type - */ -#define MAP_FILE 0x0000 /* map from file (default) */ -#define MAP_ANON 0x1000 /* allocated from memory, swap space */ -#define MAP_ANONYMOUS MAP_ANON /* alias for compatibility */ -#define MAP_VPAGETABLE 0x2000 /* manage with virtualized page table */ - -/* - * Extended flags - */ -#define MAP_TRYFIXED 0x00010000 /* attempt hint address, even within heap */ -#define MAP_NOCORE 0x00020000 /* dont include these pages in a coredump */ -#define MAP_SIZEALIGN 0x00040000 /* size is also an alignment requirement */ - /* * Advice to madvise */ -#define MADV_NORMAL 0 /* no further special treatment */ -#define MADV_RANDOM 1 /* expect random page references */ -#define MADV_SEQUENTIAL 2 /* expect sequential page references */ -#define MADV_WILLNEED 3 /* will need these pages */ -#define MADV_DONTNEED 4 /* dont need these pages */ +#define _MADV_NORMAL 0 /* no further special treatment */ +#define _MADV_RANDOM 1 /* expect random page references */ +#define _MADV_SEQUENTIAL 2 /* expect sequential page references */ +#define _MADV_WILLNEED 3 /* will need these pages */ +#define _MADV_DONTNEED 4 /* dont need these pages */ + +#if __BSD_VISIBLE +#define MADV_NORMAL _MADV_NORMAL +#define MADV_RANDOM _MADV_RANDOM +#define MADV_SEQUENTIAL _MADV_SEQUENTIAL +#define MADV_WILLNEED _MADV_WILLNEED +#define MADV_DONTNEED _MADV_DONTNEED #define MADV_FREE 5 /* dont need these pages, and junk contents */ #define MADV_NOSYNC 6 /* try to avoid flushes to physical media */ #define MADV_AUTOSYNC 7 /* revert to default flushing strategy */ @@ -134,18 +142,20 @@ #define MADV_CORE 9 /* revert to including pages in a core file */ #define MADV_INVAL 10 /* virt page tables have changed, inval pmap */ #define MADV_SETMAP 11 /* set page table directory page for map */ +#endif /* * Advice to posix_madvise() */ #if __POSIX_VISIBLE >= 200112 -#define POSIX_MADV_NORMAL MADV_NORMAL -#define POSIX_MADV_RANDOM MADV_RANDOM -#define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL -#define POSIX_MADV_WILLNEED MADV_WILLNEED -#define POSIX_MADV_DONTNEED MADV_DONTNEED +#define POSIX_MADV_NORMAL _MADV_NORMAL +#define POSIX_MADV_RANDOM _MADV_RANDOM +#define POSIX_MADV_SEQUENTIAL _MADV_SEQUENTIAL +#define POSIX_MADV_WILLNEED _MADV_WILLNEED +#define POSIX_MADV_DONTNEED _MADV_DONTNEED #endif +#if __BSD_VISIBLE /* * mcontrol() must be used for these functions instead of madvise() */ @@ -161,14 +171,15 @@ #define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */ #define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */ #define MINCORE_SUPER 0x20 /* Page is a "super" page */ +#endif __BEGIN_DECLS -#ifdef _P1003_1B_VISIBLE +#if __POSIX_VISIBLE >= 199309 int mlockall(int); int munlockall(void); int shm_open(const char *, int, mode_t); int shm_unlink(const char *); -#endif /* _P1003_1B_VISIBLE */ +#endif /* __POSIX_VISIBLE >= 199309 */ int mlock(const void *, size_t); #ifndef _MMAP_DECLARED #define _MMAP_DECLARED @@ -181,7 +192,7 @@ int munmap(void *, size_t); #if __POSIX_VISIBLE >= 200112 int posix_madvise(void *, size_t, int); #endif -#ifndef _POSIX_SOURCE +#if __BSD_VISIBLE int madvise(void *, size_t, int); int mcontrol(void *, size_t, int, off_t); int mincore(const void *, size_t, char *); diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 29d0ed7369..7e47102f9f 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -1031,7 +1031,6 @@ sys_mlock(struct mlock_args *uap) int sys_mlockall(struct mlockall_args *uap) { -#ifdef _P1003_1B_VISIBLE struct thread *td = curthread; struct proc *p = td->td_proc; vm_map_t map = &p->p_vmspace->vm_map; @@ -1063,9 +1062,6 @@ sys_mlockall(struct mlockall_args *uap) vm_map_unlock(map); return (rc); -#else /* !_P1003_1B_VISIBLE */ - return (ENOSYS); -#endif /* _P1003_1B_VISIBLE */ } /*