io.c File Reference

#include "config.h"
#include "headers.h"
#include "error.h"
#include "fd.h"
#include "io.h"

Include dependency graph for io.c:

Go to the source code of this file.

Defines

#define PAGESIZE   _SC_PAGE_SIZE
#define USED_MEMALIGN

Functions

int ioInit (void)
 Initialize I/O state data.
static void sig_int (int signo)
 A signal handler for control-C.
int ioBegin (void)
 Prepare I/O.
int ioEnd (void)
 Shut down I/O.
void ioCheck (void)
 Check to see if I/O is ready.
int ioRead (void)
 Read input.
int ioWrite (void)
 Write data.
int ioIsDone (void)
 Check to see if we're done copying input to output.

Variables

IO io
 I/O state data.


Define Documentation

#define PAGESIZE   _SC_PAGE_SIZE

Definition at line 65 of file io.c.

Referenced by ioBegin().

#define USED_MEMALIGN


Function Documentation

int ioBegin ( void   ) 

Prepare I/O.

Returns:
0 for success, non-zero for failure.

If memalign() or posix_memalign() is available, then allocate memory on a page boundary. If sysconf() is available, find out what the page size is for this machine, otherwise assume that a page is 8192 bytes.

Allocate memory for the ring buffer.

Incorporating patch provided by Doncho N. Gunchev Closes bug: [ 1158420 ] glibc detects invalid free on exit (Fedora Core 3)

If we have signal(), then set up a signal handler to catch control-C's.

Prepare the I/O file descriptors.

Definition at line 82 of file io.c.

References _io::buffer, _io::buffer_size, DEFAULT_PAGE_SIZE, fdBegin(), _io::in, io, _io::out, PAGESIZE, print_error(), and sig_int().

Referenced by main().

Here is the call graph for this function:

void ioCheck ( void   ) 

Check to see if I/O is ready.

Wait for up to io.timeout milliseconds for a change in I/O state.

Check to see if I/O is ready.

Set the I/O ready flags in I/O state data.

Definition at line 164 of file io.c.

References _io::buffer_size, _io::buffer_used, _io::in, _io::in_ready, io, _io::out, _io::out_ready, print_error(), and _io::timeout.

Referenced by main().

Here is the call graph for this function:

int ioEnd ( void   ) 

Shut down I/O.

Returns:
0 for success. (This function does not fail.)

Free the I/O buffer.

Return the file descriptors to their previous state.

Definition at line 151 of file io.c.

References _io::buffer, _io::buffer_used, fdEnd(), _io::in, io, and _io::out.

Referenced by main().

Here is the call graph for this function:

int ioInit ( void   ) 

Initialize I/O state data.

Returns:
0 for success. (This function does not fail.)

Initlalize the input file path to null.

Initialize the input file descriptor to standard input.

Initialize the output file descriptor to standard output.

Set the initial end-of-file flags to false (or zero).

Initialize the ring buffer.

Initialize the byte-counters.

Initialize the I/O timeout to 1 millisecond.

Initialize the current time and the throttle counts.

Initialize the default block size to 512 bytes.

Definition at line 14 of file io.c.

References _io::block_size, _io::buffer, _io::buffer_head, _io::buffer_size, _io::buffer_used, _io::continue_size, _io::current_time, DEFAULT_BUFFER_SIZE, _io::eof_in, _io::eof_out, _io::in, _io::in_path, io, _io::last_read, _io::last_write, MAX_UINT64, _io::out, _io::throttle, _io::throttle_count, _io::timeout, _io::total_read, _io::total_size, _io::total_size_known, and _io::total_write.

Referenced by main(), test1(), test10(), test100(), test101(), test102(), test103(), test104(), test105(), test106(), test107(), test108(), test109(), test11(), test110(), test111(), test112(), test113(), test114(), test115(), test116(), test117(), test118(), test119(), test12(), test120(), test121(), test122(), test123(), test124(), test125(), test126(), test127(), test128(), test129(), test13(), test130(), test131(), test132(), test133(), test134(), test135(), test136(), test137(), test138(), test139(), test14(), test140(), test141(), test142(), test15(), test16(), test17(), test18(), test19(), test2(), test20(), test21(), test22(), test23(), test24(), test25(), test26(), test27(), test28(), test29(), test3(), test30(), test31(), test32(), test33(), test34(), test35(), test36(), test37(), test38(), test39(), test4(), test40(), test41(), test42(), test43(), test44(), test45(), test46(), test47(), test48(), test49(), test5(), test50(), test51(), test52(), test53(), test54(), test55(), test56(), test57(), test58(), test59(), test6(), test60(), test61(), test62(), test63(), test64(), test65(), test66(), test67(), test68(), test69(), test7(), test70(), test71(), test72(), test73(), test74(), test75(), test76(), test77(), test78(), test79(), test8(), test80(), test81(), test82(), test83(), test84(), test85(), test86(), test87(), test88(), test89(), test9(), test90(), test91(), test92(), test93(), test94(), test95(), test96(), test97(), test98(), and test99().

int ioIsDone ( void   ) 

Check to see if we're done copying input to output.

Returns:
1 if done, 0 otherwise.

Definition at line 340 of file io.c.

References _io::buffer_used, _io::eof_in, _io::eof_out, and io.

Referenced by main().

int ioRead ( void   ) 

Read input.

Returns:
0 for success, non-zero for failure.

If we've reached out throttle count for this second, return.

If there is nothing to read yet, return.

If we've reached the end of input, return.

If the buffer is full, return.

Calculate the location and size of the free space in the buffer.

If the free space in the buffer is greater than the number of bytes left to be read in this second, throttle the input.

If using iovec I/O, set up vec[] with the proper information and then read using iovec I/O.

Check for end of file.

Check for an error.

Update I/O byte counters.

Definition at line 197 of file io.c.

References _io::buffer, _io::buffer_head, _io::buffer_size, _io::buffer_used, _io::current_time, _io::eof_in, _io::in, _io::in_ready, io, _io::last_read, _io::throttle, _io::throttle_count, and _io::total_read.

Referenced by main().

int ioWrite ( void   ) 

Write data.

Returns:
0 for success, non-zero for failure.

If output is not ready, return.

If using iovec I/O, set up vec[] with the correct information and then write.

Check for end of file.

Check for an error.

Update the I/O byte counters.

Definition at line 280 of file io.c.

References _io::buffer, _io::buffer_head, _io::buffer_size, _io::buffer_used, _io::eof_out, io, _io::last_write, _io::out, _io::out_ready, and _io::total_write.

Referenced by main().

static void sig_int ( int  signo  )  [static]

A signal handler for control-C.

Parameters:
signo The signal number.

Return I/O streams to a default state before exiting.

Definition at line 54 of file io.c.

References fdEnd(), _io::in, io, and _io::out.

Referenced by ioBegin().

Here is the call graph for this function:


Variable Documentation

IO io

I/O state data.

Definition at line 9 of file io.c.

Referenced by calculateCountDisplay(), calculatePercentComplete(), calculateThroughputDisplay(), displayEnd(), displayPrint(), displayTwiddle(), ioBegin(), ioCheck(), ioEnd(), ioInit(), ioIsDone(), ioRead(), ioWrite(), parse_args(), parse_block_size_value(), parse_buffer_size_value(), parse_completed_value(), parse_infile_value(), parse_num(), parse_outfile_value(), parse_size_value(), parse_throttle_value(), parse_timeout_value(), sig_int(), test10(), test100(), test101(), test102(), test103(), test104(), test105(), test106(), test107(), test108(), test109(), test11(), test110(), test111(), test112(), test113(), test114(), test115(), test116(), test117(), test118(), test119(), test12(), test120(), test121(), test122(), test123(), test124(), test125(), test126(), test127(), test128(), test129(), test13(), test130(), test131(), test132(), test133(), test134(), test135(), test136(), test137(), test138(), test139(), test14(), test140(), test141(), test142(), test15(), test16(), test17(), test18(), test19(), test20(), test21(), test22(), test23(), test24(), test25(), test26(), test27(), test28(), test29(), test3(), test30(), test31(), test32(), test33(), test34(), test35(), test36(), test37(), test38(), test39(), test4(), test40(), test41(), test42(), test43(), test44(), test45(), test46(), test47(), test48(), test49(), test5(), test50(), test51(), test52(), test53(), test54(), test55(), test56(), test57(), test58(), test59(), test6(), test60(), test61(), test62(), test63(), test64(), test65(), test66(), test67(), test68(), test69(), test7(), test70(), test71(), test72(), test73(), test74(), test75(), test76(), test77(), test78(), test79(), test8(), test80(), test81(), test82(), test83(), test84(), test85(), test86(), test87(), test88(), test89(), test9(), test90(), test91(), test92(), test93(), test94(), test95(), test96(), test97(), test98(), and test99().


Generated on Thu Jun 28 09:13:25 2007 for bar by  doxygen 1.5.1