[PATCH] fadvise(2) system call

Ed Schouten ed at 80386.nl
Mon Oct 31 22:16:28 UTC 2011


Hi John,

* John Baldwin <jhb at freebsd.org>, 20111031 22:17:
> I also really do think that posix_*() truly is far uglier to read.  In the 
> worst case, imagine something like this:
> 
> 	char *cp;
> 
> 	cp = posix_malloc(posix_strlen(some_string) + 1);
> 	posix_strcpy(cp, s);
> 	posix_printf("%s\n", cp);
> 
> *blech*

I do agree it's ugly, but at least it's standardized. The fact is that
it's easier to explain to someone "this code doesn't build on $NONBSD,
because $NONBSD lacks POSIX conformance" than saying "this code doesn't
build on $NONBSD because it uses BSD-specific crap". As I mentioned
previously, there is no fadvise() on Linux. There's no gain in
compatibility by implementing it -- it's just syntactic sugar.

Maybe we can find a compromise. My main objection is that the current
patch adds some redundancy that will stay part of our ABI. Also, having
two different symbols makes debugging a bit harder, because you must not
forget to place multiple breakpoints, maybe even preload multiple
symbols.

What if we implement everything using the POSIX naming scheme, but put
this in <fcntl.h>:

> #if _BSD_SOURCE
> #define	FADV_NORMAL	POSIX_FADV_NORMAL
> #define	...
>
> static inline int
> fadvise(int _fd, off_t _offset, off_t _len, int _advice)
> {
>
> 	return (fadvise(_fd, _offset, _len, _advice));
> }
> #endif

That way userspace code still has the liberty of using the shorthand
notation, without being a burden on the ABI.

But please, don't let me stop you from committing your work as is. I'm
happy either way. :-)

-- 
 Ed Schouten <ed at 80386.nl>
 WWW: http://80386.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20111031/08bd517e/attachment.pgp


More information about the freebsd-arch mailing list