On Sat, Apr 24, 2010 at 08:52:25PM -0700, Philip Guenther wrote:
On Sat, Apr 24, 2010 at 1:33 PM, Brad b...@comstyle.com wrote:
...
I have updated the diff with your suggestions.
Close: I think the #include of sys/cdefs.h needs to be moved up in
sys/mman.h so that the __BSD_VISIBLE test actually works. Otherwise,
looks good to me.
How about this?
Index: sys/sys/mman.h
===
RCS file: /cvs/src/sys/sys/mman.h,v
retrieving revision 1.18
diff -u -p -r1.18 mman.h
--- sys/sys/mman.h 21 Jul 2003 22:52:19 - 1.18
+++ sys/sys/mman.h 25 Apr 2010 15:24:06 -
@@ -32,6 +32,10 @@
* @(#)mman.h 8.1 (Berkeley) 6/2/93
*/
+#ifndef _KERNEL
+#include sys/cdefs.h
+#endif
+
/*
* Protections are chosen from these bits, or-ed together
*/
@@ -72,15 +76,28 @@
#defineMAP_FLAGMASK0x17f7
/*
- * Advice to madvise
+ * POSIX memory advisory values.
+ * Note: keep consistent with the original defintions below.
*/
-#defineMADV_NORMAL 0 /* no further special treatment */
-#defineMADV_RANDOM 1 /* expect random page references */
-#defineMADV_SEQUENTIAL 2 /* expect sequential page references */
-#defineMADV_WILLNEED 3 /* will need these pages */
-#defineMADV_DONTNEED 4 /* dont need these pages */
-#defineMADV_SPACEAVAIL 5 /* insure that resources are reserved */
-#defineMADV_FREE 6 /* pages are empty, free them */
+#definePOSIX_MADV_NORMAL 0 /* no further special treatment
*/
+#definePOSIX_MADV_RANDOM 1 /* expect random page
references */
+#definePOSIX_MADV_SEQUENTIAL 2 /* expect sequential page
references */
+#definePOSIX_MADV_WILLNEED 3 /* will need these pages */
+#definePOSIX_MADV_DONTNEED 4 /* don't need these pages */
+
+#if __BSD_VISIBLE
+/*
+ * Original advice values, equivalent to POSIX defintions,
+ * and few implementation-specific ones.
+ */
+#defineMADV_NORMAL POSIX_MADV_NORMAL
+#defineMADV_RANDOM POSIX_MADV_RANDOM
+#defineMADV_SEQUENTIAL POSIX_MADV_SEQUENTIAL
+#defineMADV_WILLNEED POSIX_MADV_WILLNEED
+#defineMADV_DONTNEED POSIX_MADV_DONTNEED
+#defineMADV_SPACEAVAIL 5 /* insure that resources are
reserved */
+#defineMADV_FREE 6 /* pages are empty, free them */
+#endif
/*
* Flags to minherit
@@ -105,8 +122,17 @@
#defineMCL_FUTURE 0x02/* lock all pages mapped in the future
*/
#ifndef _KERNEL
+#include sys/_types.h
-#include sys/cdefs.h
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+
+#ifndef _OFF_T_DEFINED_
+#define _OFF_T_DEFINED_
+typedef __off_toff_t;
+#endif
__BEGIN_DECLS
/* Some of these int's should probably be size_t's */
@@ -118,10 +144,13 @@ int mlock(const void *, size_t);
intmunlock(const void *, size_t);
intmlockall(int);
intmunlockall(void);
+#if __BSD_VISIBLE
intmadvise(void *, size_t, int);
intmincore(void *, size_t, char *);
intminherit(void *, size_t, int);
void * mquery(void *, size_t, int, int, int, off_t);
+#endif
+intposix_madvise(void *, size_t, int);
__END_DECLS
#endif /* !_KERNEL */
Index: lib/libc/shlib_version
===
RCS file: /cvs/src/lib/libc/shlib_version,v
retrieving revision 1.121
diff -u -p -r1.121 shlib_version
@@ -1,4 +1,4 @@
major=53
-minor=1
+minor=2
# note: If changes were made to include/thread_private.h or if system
# calls were added/changed then libpthread must also be updated.
Index: lib/libc/sys/Makefile.inc
===
RCS file: /cvs/src/lib/libc/sys/Makefile.inc,v
retrieving revision 1.89
diff -u -p -r1.89 Makefile.inc
--- lib/libc/sys/Makefile.inc 3 Feb 2010 20:49:00 - 1.89
+++ lib/libc/sys/Makefile.inc 20 Apr 2010 00:35:43 -
@@ -23,6 +23,9 @@ DPSRCS+= Lint_Ovfork.c Lint_brk.c Lint_e
Lint_setjmp.c Lint_longjmp.c \
Lint_sigsetjmp.c Lint_siglongjmp.c
+# glue to offer userland wrappers for some syscalls
+SRCS+= posix_madvise.c
+
# glue to provide compatibility between GCC 1.X and 2.X and for compat
# with old syscall interfaces.
SRCS+= ftruncate.c lseek.c mquery.c mmap.c ptrace.c semctl.c truncate.c \
@@ -264,6 +267,7 @@ MLINKS+=gettimeofday.2 settimeofday.2
MLINKS+=getuid.2 geteuid.2
MLINKS+=kqueue.2 kevent.2 kqueue.2 EV_SET.2
MLINKS+=intro.2 errno.2
+MLINKS+=madvise.2 posix_madvise.2
MLINKS+=mlock.2 munlock.2
MLINKS+=mlockall.2 munlockall.2
MLINKS+=mount.2 unmount.2
Index: lib/libc/sys/madvise.2
===
RCS file: /cvs/src/lib/libc/sys/madvise.2,v