From: Stefano Zacchiroli Date: Fri, 29 Nov 2002 11:26:13 +0000 (+0000) Subject: - slices of io.h from ocaml source tree to retrieve file descriptor X-Git-Tag: V_0_0_6~37 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=154e67890197ca44b5d323f48e30822c3f6703b9;p=helm.git - slices of io.h from ocaml source tree to retrieve file descriptor from channel structures --- diff --git a/helm/DEVEL/gdome_xslt/ocaml/gdome_xslt/ocaml-io.h b/helm/DEVEL/gdome_xslt/ocaml/gdome_xslt/ocaml-io.h new file mode 100644 index 000000000..6ce9493c8 --- /dev/null +++ b/helm/DEVEL/gdome_xslt/ocaml/gdome_xslt/ocaml-io.h @@ -0,0 +1,54 @@ +/**********************************************************************/ +/* */ +/* Objective Caml */ +/* */ +/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ +/* */ +/* Copyright 1996 Institut National de Recherche en Informatique et */ +/* en Automatique. All rights reserved. This file is distributed */ +/* under the terms of the GNU Library General Public License, with */ +/* the special exception on linking described in file */ +/* ../../LICENSE-INRIA. */ +/* */ +/**********************************************************************/ + +/* Buffered input/output */ + +#ifndef __IO_H__ +#define __IO_H__ + +#ifndef IO_BUFFER_SIZE +#define IO_BUFFER_SIZE 4096 +#endif + +typedef long file_offset; + +struct channel { + int fd; /* Unix file descriptor */ + file_offset offset; /* Absolute position of fd in the file */ + char * end; /* Physical end of the buffer */ + char * curr; /* Current position in the buffer */ + char * max; /* Logical end of the buffer (for input) */ + void * mutex; /* Placeholder for mutex (for systhreads) */ + struct channel * next; /* Linear chaining of channels (flush_all) */ + int revealed; /* For Cash only */ + int old_revealed; /* For Cash only */ + int refcount; /* For flush_all and for Cash */ + char buff[IO_BUFFER_SIZE]; /* The buffer itself */ +}; + +/* For an output channel: + [offset] is the absolute position of the beginning of the buffer [buff]. + For an input channel: + [offset] is the absolute position of the logical end of the buffer, [max]. +*/ + +/* Functions and macros that can be called from C. Take arguments of + type struct channel *. No locking is performed. */ + +/* Extract a struct channel * from the heap object representing it */ + +#define Channel(v) (*((struct channel **) (Data_custom_val(v)))) + +#endif /* __IO_H__ */ +