1 /* Implement runtime actions for CHILL.
2 Copyright (C) 1992,1993 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License. */
36 /* predefined associations, accesses, and text for stdin, stdout, stderr */
38 #define STDIO_TEXT_LENGTH 1024
39 #define STDIN_TEXT_LENGTH STDIO_TEXT_LENGTH
41 static Access_Mode stdin_access
;
44 #define STDIN_FILENO 0
48 Association_Mode stdin_association
=
50 IO_EXISTING
| IO_READABLE
| IO_SEQUENCIBLE
| IO_ISASSOCIATED
,
59 static Access_Mode stdin_access
=
62 STDIN_TEXT_LENGTH
+ 2,
72 VARYING_STRING(STDIN_TEXT_LENGTH
) stdin_text_record
;
74 Text_Mode chill_stdin
=
77 (VarString
*)&stdin_text_record
,
83 #define STDOUT_TEXT_LENGTH STDIO_TEXT_LENGTH
85 #define STDOUT_FILENO 1
88 static Access_Mode stdout_access
;
91 Association_Mode stdout_association
=
93 IO_EXISTING
| IO_WRITEABLE
| IO_SEQUENCIBLE
| IO_ISASSOCIATED
,
102 static Access_Mode stdout_access
=
105 STDOUT_TEXT_LENGTH
+ 2,
115 VARYING_STRING(STDOUT_TEXT_LENGTH
) stdout_text_record
;
117 Text_Mode chill_stdout
=
120 (VarString
*)&stdout_text_record
,
126 #define STDERR_TEXT_LENGTH STDIO_TEXT_LENGTH
127 #ifndef STDERR_FILENO
128 #define STDERR_FILENO 2
131 static Access_Mode stderr_access
;
134 Association_Mode stderr_association
=
136 IO_EXISTING
| IO_WRITEABLE
| IO_SEQUENCIBLE
| IO_ISASSOCIATED
,
145 static Access_Mode stderr_access
=
148 STDERR_TEXT_LENGTH
+ 2,
158 VARYING_STRING(STDIN_TEXT_LENGTH
) stderr_text_record
;
160 Text_Mode chill_stderr
=
163 (VarString
*)&stderr_text_record
,
169 * function __xmalloc_
172 * size number of bytes to allocate
178 * This is the general allocation routine for libchill
186 void *tmp
= malloc (size
);
190 fprintf (stderr
, "ChillLib: Out of heap space.\n");
198 newstring (char *str
)
200 char *tmp
= __xmalloc_ (strlen (str
) + 1);
205 static void setup_stdinout (void) __attribute__((constructor
));
210 /* allocate the names */
211 stdin_association
.pathname
= newstring ("stdin");
212 stdout_association
.pathname
= newstring ("stdout");
213 stderr_association
.pathname
= newstring ("stderr");
215 /* stdin needs a readbuffer */
216 stdin_association
.bufptr
= __xmalloc_ (sizeof (readbuf_t
));
217 memset (stdin_association
.bufptr
, 0, sizeof (readbuf_t
));