pike.git / src / modules / _Stdio / buffer.cmod

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:26:   #include "module_support.h"   #include "bitvector.h"      #ifdef HAVE_ARPA_INET_H   #include <arpa/inet.h>   #endif      #undef MP_INT   #include <gmp.h>    + #define READ_CHUNKSIZE 4096 + #define WRITE_CHUNKSIZE 4096 +    #define DEFAULT_CMOD_STORAGE static   DECLARATIONS      struct sysmem {    unsigned char *p;    size_t size;   };      static struct program *buffer_error_program;   
pike.git/src/modules/_Stdio/buffer.cmod:955:    if (!nbytes) RETURN 0;    }       if( _once )    once = _once->u.integer;       if( (fd = get_storage( f, file_program )) )    {    while( 1 )    { -  unsigned char *ptr = io_add_space( io, 4096, 0 ); +  unsigned char *ptr = io_add_space( io, READ_CHUNKSIZE, 0 );    int res;    -  res = fd_read( fd->box.fd, ptr, MINIMUM(4096,nbytes) ); +  res = fd_read( fd->box.fd, ptr, MINIMUM(READ_CHUNKSIZE, nbytes) );       if( res == -1 && errno == EINTR )    continue;       if( res <= 0 )    break;       nbytes -= res;    io->len += res;    bread += res; -  if( res != 4096 || once || !nbytes ) +  if( res != READ_CHUNKSIZE || once || !nbytes )    break;    }    io_set_events( io, fd, PIKE_BIT_FD_READ_OOB, PIKE_FD_READ );    }    else    {    /* some other object. Just call read */    while( nbytes )    { -  push_int( MINIMUM(4096,nbytes) ); +  push_int( MINIMUM(READ_CHUNKSIZE, nbytes) );    safe_apply( f, "read", 1 );    if( TYPEOF(Pike_sp[-1]) != PIKE_T_STRING || Pike_sp[-1].u.string->len == 0 )    break;    if( Pike_sp[-1].u.string->size_shift )    Pike_error("Can not handle non-8bit data\n");    io_append( io, Pike_sp[-1].u.string->str, Pike_sp[-1].u.string->len );    nbytes -= Pike_sp[-1].u.string->len;    pop_stack();    }    }
pike.git/src/modules/_Stdio/buffer.cmod:1102:    struct program *prog = f->u.object->prog;    struct reference *ref = PTR_FROM_INT(prog, write_fun_num);    struct inherit *inh = INHERIT_FROM_PTR(prog, ref);       if( (inh->prog == file_program) &&    (ref->identifier_offset == fd_write_identifier_offset) ) {    struct my_file *fd =    get_inherit_storage( f->u.object, ref->inherit_offset );    while( sz > written )    { -  ptrdiff_t rd = MINIMUM(sz-written,4096); +  ptrdiff_t rd = MINIMUM(sz-written, WRITE_CHUNKSIZE);    unsigned char *ptr = io_read_pointer( io );    ptrdiff_t res;    res = fd_write( fd->box.fd, ptr, rd );    if( res == -1 && errno == EINTR )    continue;    if( res <= 0 ) {    fd->my_errno = errno;    if (!written) written = -1;    break;    }
pike.git/src/modules/_Stdio/buffer.cmod:1124:    written += res;    io_set_events( io, fd, PIKE_BIT_FD_WRITE_OOB, PIKE_FD_WRITE);    }    RETURN written;    }    }       /* Some other object or function. Just call it. */    while( sz > written )    { -  size_t rd = MINIMUM(sz-written,4096); +  size_t rd = MINIMUM(sz-written, WRITE_CHUNKSIZE);    ptrdiff_t wr = io_call_write( io, f, rd );    if( wr <= 0 )    {    if (!written) written = -1;    break;    }    written += wr; -  if( wr < 4096 ) +  if( wr < WRITE_CHUNKSIZE )    break;    }    RETURN written;    }       /*! @decl int(-1..) try_output()    *!    *! Try to write some data from the buffer to the file    *! registered with @[__fd_set_output()].    *!