1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- I N T E R F A C E S . C _ S T R E A M S --
11 -- Copyright (C) 1996-2001 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
34 ------------------------------------------------------------------------------
36 -- This is the default version which just calls the C versions directly
37 -- Note: the reason that we provide for specialization here is that on
38 -- some systems, notably VMS, we may need to worry about buffering.
40 with Unchecked_Conversion;
42 package body Interfaces.C_Streams is
61 pragma Import (C, C_fread, "fread");
64 return C_fread (buffer, size, count, stream);
85 pragma Import (C, C_fread, "fread");
87 type Byte_Buffer is array (0 .. size_t'Last / 2 - 1) of Unsigned_8;
88 -- This should really be 0 .. size_t'last, but there is a problem
89 -- in gigi in handling such types (introduced in GCC 3 Sep 2001)
90 -- since the size in bytes of this array overflows ???
92 type Acc_Bytes is access all Byte_Buffer;
94 function To_Acc_Bytes is new Unchecked_Conversion (voids, Acc_Bytes);
98 (To_Acc_Bytes (buffer) (index * size)'Address, size, count, stream);
118 pragma Import (C, C_fwrite, "fwrite");
121 return C_fwrite (buffer, size, count, stream);
141 pragma Import (C, C_setvbuf, "setvbuf");
144 return C_setvbuf (stream, buffer, mode, size);
147 end Interfaces.C_Streams;