On Mar 2, 2012, at 11:10 AM, Craig A. Berry wrote: > > On Mar 2, 2012, at 9:15 AM, Nicholas Clark wrote: > >> On Thu, Mar 01, 2012 at 05:17:27PM -0600, Craig A. Berry wrote: >>> >>> On Mar 1, 2012, at 12:30 PM, Nicholas Clark wrote: >>>> >>>> Specifically, the code is emulated on "everything else", but intended to >>>> do something real and useful on VMS: >>>> >>>> #ifdef VMS >>>> /* VMS wants read instead of fread, because fread doesn't respect */ >>>> /* RMS record boundaries. This is not necessarily a good thing to be */ >>>> /* doing, but we've got no other real choice - except avoid stdio >>>> as implementation - perhaps write a :vms layer ? >>>> */ >>>> fd = PerlIO_fileno(fp); >>>> if (fd != -1) { >>>> bytesread = PerlLIO_read(fd, buffer, recsize); >>>> } >>>> else /* in-memory file from PerlIO::Scalar */ >>>> #endif >>> >>> I don't think this code is as meaningful as it used to be since unix I/O is >>> the bottom layer for PerlIO now. Which means that PerlLIO_read and >>> PerlIO_read (differing only by the "L") are really the same thing, i.e., >>> both boil down to read(). I guess we can't simplify this code until and >>> unless using stdio as the bottom layer is truly deprecated and expunged. >> >> I don't think you're correct on that one. read() is not stdio. It's (at least >> on Unix) a syscall. fread() is stdio, and loops on read() until it gets >> enough >> octets. > > Yes, I know read() is not stdio and that fread() is. That was my point. > Unless I'm really missing something, there is no fread() involved anymore > since unix is the bottom PerlIO layer.
Sigh. This was only about half right. It's true that there is no fread() involved anymore, and read() sits at the bottom in all cases, but PerlIO_read, as we currently do on non-VMS, does buffering, whereas PerlLIO_read (which in the non-threads case is actually just a macro defined as read) does not. On non-VMS the call stack when using $/ = \N looks like: read syscall PerlIOUnix_read Perl_PerlIO_read (unix layer) PerlIOBuf_fill Perl_PerlIO_fill PerlIOBase_read PerlIOBuf_read Perl_PerlIO_read (perlio layer) S_sv_gets_read_record Perl_sv_gets Perl_do_readline Perl_pp_readline Perl_runops_debug S_run_body perl_run whereas on VMS, the call stack looks like: read syscall, aka PerlLIO_read S_sv_gets_read_record Perl_sv_gets Perl_do_readline Perl_pp_readline Perl_runops_debug S_run_body perl_run ________________________________________ Craig A. Berry mailto:craigbe...@mac.com "... getting out of a sonnet is much more difficult than getting in." Brad Leithauser