From 1c8d4bbe1849bcdcc2f85e7f4f049e8077209ac5 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 4 Jul 2007 23:27:38 +0000 Subject: Change the C wrappers for mmap/lseek/pread/pwrite/truncate/ftruncate to call the pad-less versions of the corresponding syscalls if the running kernel supports it. Check kern.osreldate once per program and cache the result to select the appropriate syscall. This maintains userland compatability with kernel.old's from quite a while back. Approved by: re (kensmith) --- lib/libc/sys/ftruncate.c | 6 +++++- lib/libc/sys/lseek.c | 7 ++++++- lib/libc/sys/mmap.c | 8 ++++++-- lib/libc/sys/pread.c | 7 ++++++- lib/libc/sys/pwrite.c | 6 +++++- lib/libc/sys/truncate.c | 7 +++++-- 6 files changed, 33 insertions(+), 8 deletions(-) (limited to 'lib/libc/sys') diff --git a/lib/libc/sys/ftruncate.c b/lib/libc/sys/ftruncate.c index fcd2ef8..78b5a36 100644 --- a/lib/libc/sys/ftruncate.c +++ b/lib/libc/sys/ftruncate.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include "libc_private.h" /* * This function provides 64-bit offset padding that @@ -47,5 +48,8 @@ ftruncate(fd, length) off_t length; { - return(__syscall((quad_t)SYS_ftruncate, fd, 0, length)); + if (__getosreldate() >= 700051) + return(__sys_ftruncate(fd, length)); + else + return(__sys_freebsd6_ftruncate(fd, 0, length)); } diff --git a/lib/libc/sys/lseek.c b/lib/libc/sys/lseek.c index 8613678..a086be1 100644 --- a/lib/libc/sys/lseek.c +++ b/lib/libc/sys/lseek.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include "libc_private.h" /* * This function provides 64-bit offset padding that @@ -47,5 +48,9 @@ lseek(fd, offset, whence) off_t offset; int whence; { - return(__syscall((quad_t)SYS_lseek, fd, 0, offset, whence)); + + if (__getosreldate() >= 700051) + return(__sys_lseek(fd, offset, whence)); + else + return(__sys_freebsd6_lseek(fd, 0, offset, whence)); } diff --git a/lib/libc/sys/mmap.c b/lib/libc/sys/mmap.c index 8b22147..cfdb944 100644 --- a/lib/libc/sys/mmap.c +++ b/lib/libc/sys/mmap.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include "libc_private.h" /* * This function provides 64-bit offset padding that @@ -52,6 +53,9 @@ mmap(addr, len, prot, flags, fd, offset) off_t offset; { - return ((void *)(intptr_t)__syscall((quad_t)SYS_mmap, addr, len, prot, - flags, fd, 0, offset)); + if (__getosreldate() >= 700051) + return (__sys_mmap(addr, len, prot, flags, fd, offset)); + else + + return (__sys_freebsd6_mmap(addr, len, prot, flags, fd, 0, offset)); } diff --git a/lib/libc/sys/pread.c b/lib/libc/sys/pread.c index 1d2fee6..7566566 100644 --- a/lib/libc/sys/pread.c +++ b/lib/libc/sys/pread.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include "libc_private.h" /* * This function provides 64-bit offset padding that @@ -48,5 +49,9 @@ pread(fd, buf, nbyte, offset) size_t nbyte; off_t offset; { - return ((ssize_t)__syscall((quad_t)SYS_pread, fd, buf, nbyte, 0, offset)); + + if (__getosreldate() >= 700051) + return (__sys_pread(fd, buf, nbyte, offset)); + else + return (__sys_freebsd6_pread(fd, buf, nbyte, 0, offset)); } diff --git a/lib/libc/sys/pwrite.c b/lib/libc/sys/pwrite.c index ebbb1ec..d17ed29 100644 --- a/lib/libc/sys/pwrite.c +++ b/lib/libc/sys/pwrite.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include "libc_private.h" /* * This function provides 64-bit offset padding that @@ -48,5 +49,8 @@ pwrite(fd, buf, nbyte, offset) size_t nbyte; off_t offset; { - return ((ssize_t)__syscall((quad_t)SYS_pwrite, fd, buf, nbyte, 0, offset)); + if (__getosreldate() >= 700051) + return (__sys_pwrite(fd, buf, nbyte, offset)); + else + return (__sys_freebsd6_pwrite(fd, buf, nbyte, 0, offset)); } diff --git a/lib/libc/sys/truncate.c b/lib/libc/sys/truncate.c index e26f3f5..375c9d9 100644 --- a/lib/libc/sys/truncate.c +++ b/lib/libc/sys/truncate.c @@ -35,8 +35,8 @@ __FBSDID("$FreeBSD$"); #include #include - #include +#include "libc_private.h" /* * This function provides 64-bit offset padding that @@ -48,5 +48,8 @@ truncate(path, length) off_t length; { - return(__syscall((quad_t)SYS_truncate, path, 0, length)); + if (__getosreldate() >= 700051) + return(__sys_truncate(path, length)); + else + return(__sys_freebsd6_truncate(path, 0, length)); } -- cgit v1.1