1 /**********************************************************************/
5 /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
7 /* Copyright 1996 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file */
11 /* ../../LICENSE-INRIA. */
13 /**********************************************************************/
15 /* Buffered input/output */
20 #ifndef IO_BUFFER_SIZE
21 #define IO_BUFFER_SIZE 4096
24 typedef long file_offset;
27 int fd; /* Unix file descriptor */
28 file_offset offset; /* Absolute position of fd in the file */
29 char * end; /* Physical end of the buffer */
30 char * curr; /* Current position in the buffer */
31 char * max; /* Logical end of the buffer (for input) */
32 void * mutex; /* Placeholder for mutex (for systhreads) */
33 struct channel * next; /* Linear chaining of channels (flush_all) */
34 int revealed; /* For Cash only */
35 int old_revealed; /* For Cash only */
36 int refcount; /* For flush_all and for Cash */
37 char buff[IO_BUFFER_SIZE]; /* The buffer itself */
40 /* For an output channel:
41 [offset] is the absolute position of the beginning of the buffer [buff].
43 [offset] is the absolute position of the logical end of the buffer, [max].
46 /* Functions and macros that can be called from C. Take arguments of
47 type struct channel *. No locking is performed. */
49 /* Extract a struct channel * from the heap object representing it */
51 #define Channel(v) (*((struct channel **) (Data_custom_val(v))))