Add x prefix to v850e case for handling --with-cpu=v850e.
[official-gcc.git] / gcc / ada / i-cstrea.adb
blob4755f95de30ff7fe5035cea295533056a5b09665
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- I N T E R F A C E S . C _ S T R E A M S --
6 -- --
7 -- B o d y --
8 -- --
9 -- --
10 -- Copyright (C) 1996-2001 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
29 -- --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
32 -- --
33 ------------------------------------------------------------------------------
35 -- This is the default version which just calls the C versions directly
36 -- Note: the reason that we provide for specialization here is that on
37 -- some systems, notably VMS, we may need to worry about buffering.
39 with Unchecked_Conversion;
41 package body Interfaces.C_Streams is
43 ------------
44 -- fread --
45 ------------
47 function fread
48 (buffer : voids;
49 size : size_t;
50 count : size_t;
51 stream : FILEs)
52 return size_t
54 function C_fread
55 (buffer : voids;
56 size : size_t;
57 count : size_t;
58 stream : FILEs)
59 return size_t;
60 pragma Import (C, C_fread, "fread");
62 begin
63 return C_fread (buffer, size, count, stream);
64 end fread;
66 ------------
67 -- fread --
68 ------------
70 function fread
71 (buffer : voids;
72 index : size_t;
73 size : size_t;
74 count : size_t;
75 stream : FILEs)
76 return size_t
78 function C_fread
79 (buffer : voids;
80 size : size_t;
81 count : size_t;
82 stream : FILEs)
83 return size_t;
84 pragma Import (C, C_fread, "fread");
86 type Byte_Buffer is array (0 .. size_t'Last / 2 - 1) of Unsigned_8;
87 -- This should really be 0 .. size_t'last, but there is a problem
88 -- in gigi in handling such types (introduced in GCC 3 Sep 2001)
89 -- since the size in bytes of this array overflows ???
91 type Acc_Bytes is access all Byte_Buffer;
93 function To_Acc_Bytes is new Unchecked_Conversion (voids, Acc_Bytes);
95 begin
96 return C_fread
97 (To_Acc_Bytes (buffer) (index * size)'Address, size, count, stream);
98 end fread;
100 ------------
101 -- fwrite --
102 ------------
104 function fwrite
105 (buffer : voids;
106 size : size_t;
107 count : size_t;
108 stream : FILEs)
109 return size_t
111 function C_fwrite
112 (buffer : voids;
113 size : size_t;
114 count : size_t;
115 stream : FILEs)
116 return size_t;
117 pragma Import (C, C_fwrite, "fwrite");
119 begin
120 return C_fwrite (buffer, size, count, stream);
121 end fwrite;
123 -------------
124 -- setvbuf --
125 -------------
127 function setvbuf
128 (stream : FILEs;
129 buffer : chars;
130 mode : int;
131 size : size_t)
132 return int
134 function C_setvbuf
135 (stream : FILEs;
136 buffer : chars;
137 mode : int;
138 size : size_t)
139 return int;
140 pragma Import (C, C_setvbuf, "setvbuf");
142 begin
143 return C_setvbuf (stream, buffer, mode, size);
144 end setvbuf;
146 end Interfaces.C_Streams;