Date: Mon, 9 Jul 2007 12:39:26 -0700 From: Alfred Perlstein <alfred@freebsd.org> To: Peter Wemm <peter@FreeBSD.org> Cc: Perforce Change Reviews <perforce@freebsd.org> Subject: Re: PERFORCE change 122592 for review Message-ID: <20070709193926.GF45894@elvis.mu.org> In-Reply-To: <200706302226.l5UMQXfP002249@repoman.freebsd.org> References: <200706302226.l5UMQXfP002249@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Peter, why not have libc obtain this at startup and cache it? Otherwise these syscalls will incur an additional sysctl per call, right? -Alfred * Peter Wemm <peter@FreeBSD.org> [070630 15:26] wrote: > http://perforce.freebsd.org/chv.cgi?CH=122592 > > Change 122592 by peter@peter_overcee on 2007/06/30 22:25:38 > > Use getosreldate() to test for __new_* syscalls. > > Affected files ... > > .. //depot/projects/hammer/lib/libc/sys/ftruncate.c#3 edit > .. //depot/projects/hammer/lib/libc/sys/lseek.c#3 edit > .. //depot/projects/hammer/lib/libc/sys/mmap.c#4 edit > .. //depot/projects/hammer/lib/libc/sys/pread.c#3 edit > .. //depot/projects/hammer/lib/libc/sys/pwrite.c#3 edit > .. //depot/projects/hammer/lib/libc/sys/truncate.c#3 edit > > Differences ... > > ==== //depot/projects/hammer/lib/libc/sys/ftruncate.c#3 (text+ko) ==== > > @@ -36,6 +36,7 @@ > #include <sys/types.h> > #include <sys/syscall.h> > #include <unistd.h> > +#include <osreldate.h> > > /* > * This function provides 64-bit offset padding that > @@ -47,5 +48,8 @@ > off_t length; > { > > - return(__syscall((quad_t)SYS_ftruncate, fd, 0, length)); > + if (getosreldate() >= 700049) > + return(__new_ftruncate(fd, length)); > + else > + return(__syscall((quad_t)SYS_ftruncate, fd, 0, length)); > } > > ==== //depot/projects/hammer/lib/libc/sys/lseek.c#3 (text+ko) ==== > > @@ -36,6 +36,7 @@ > #include <sys/types.h> > #include <sys/syscall.h> > #include <unistd.h> > +#include <osreldate.h> > > /* > * This function provides 64-bit offset padding that > @@ -47,5 +48,9 @@ > off_t offset; > int whence; > { > - return(__syscall((quad_t)SYS_lseek, fd, 0, offset, whence)); > + > + if (getosreldate() >= 700049) > + return(__new_lseek(fd, offset, whence)); > + else > + return(__syscall((quad_t)SYS_lseek, fd, 0, offset, whence)); > } > > ==== //depot/projects/hammer/lib/libc/sys/mmap.c#4 (text+ko) ==== > > @@ -37,6 +37,7 @@ > #include <sys/mman.h> > #include <sys/syscall.h> > #include <unistd.h> > +#include <osreldate.h> > > /* > * This function provides 64-bit offset padding that > @@ -52,6 +53,10 @@ > off_t offset; > { > > - return ((void *)(intptr_t)__syscall((quad_t)SYS_mmap, addr, len, prot, > - flags, fd, 0, offset)); > + if (getosreldate() >= 700049) > + return (__new_mmap(addr, len, prot, flags, fd, offset)); > + else > + > + return ((void *)(intptr_t)__syscall((quad_t)SYS_mmap, addr, len, prot, > + flags, fd, 0, offset)); > } > > ==== //depot/projects/hammer/lib/libc/sys/pread.c#3 (text+ko) ==== > > @@ -36,6 +36,7 @@ > #include <sys/types.h> > #include <sys/syscall.h> > #include <unistd.h> > +#include <osreldate.h> > > /* > * This function provides 64-bit offset padding that > @@ -48,5 +49,9 @@ > size_t nbyte; > off_t offset; > { > - return ((ssize_t)__syscall((quad_t)SYS_pread, fd, buf, nbyte, 0, offset)); > + > + if (getosreldate() >= 700049) > + return (__new_pread(fd, buf, nbyte, offset)); > + else > + return ((ssize_t)__syscall((quad_t)SYS_pread, fd, buf, nbyte, 0, offset)); > } > > ==== //depot/projects/hammer/lib/libc/sys/pwrite.c#3 (text+ko) ==== > > @@ -36,6 +36,7 @@ > #include <sys/types.h> > #include <sys/syscall.h> > #include <unistd.h> > +#include <osreldate.h> > > /* > * This function provides 64-bit offset padding that > @@ -48,5 +49,8 @@ > size_t nbyte; > off_t offset; > { > - return ((ssize_t)__syscall((quad_t)SYS_pwrite, fd, buf, nbyte, 0, offset)); > + if (getosreldate() >= 700049) > + return (__new_pwrite(fd, buf, nbyte, offset)); > + else > + return ((ssize_t)__syscall((quad_t)SYS_pwrite, fd, buf, nbyte, 0, offset)); > } > > ==== //depot/projects/hammer/lib/libc/sys/truncate.c#3 (text+ko) ==== > > @@ -35,8 +35,8 @@ > > #include <sys/types.h> > #include <sys/syscall.h> > - > #include <unistd.h> > +#include <osreldate.h> > > /* > * This function provides 64-bit offset padding that > @@ -48,5 +48,8 @@ > off_t length; > { > > - return(__syscall((quad_t)SYS_truncate, path, 0, length)); > + if (getosreldate() >= 700049) > + return(__new_truncate(path, length)); > + else > + return(__syscall((quad_t)SYS_truncate, path, 0, length)); > } -- - Alfred Perlstein
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070709193926.GF45894>