]> gcc.gnu.org Git - gcc.git/blame - gcc/m2/mc-boot-ch/GSelective.c
Year date changes for Modula-2 source tree.
[gcc.git] / gcc / m2 / mc-boot-ch / GSelective.c
CommitLineData
7401123f
GM
1/* GSelective.c provides access to select for Modula-2.
2
3d864fce 3Copyright (C) 2016-2022 Free Software Foundation, Inc.
7401123f
GM
4Contributed by Gaius Mulley <gaius@glam.ac.uk>.
5
6This file is part of GNU Modula-2.
7
8GNU Modula-2 is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 3, or (at your option)
11any later version.
12
13GNU Modula-2 is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with GNU Modula-2; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
21
22/* implementation module in C. */
23
24#include "config.h"
25#include "system.h"
26#include "ansidecl.h"
27
28#include "gm2-libs-host.h"
29
30/* PROCEDURE Select (nooffds: CARDINAL; readfds, writefds, exceptfds:
31SetOfFd; timeout: Timeval) : INTEGER ; */
32
33#if defined(HAVE_SELECT)
34int
35Selective_Select (int nooffds, fd_set *readfds, fd_set *writefds,
36 fd_set *exceptfds, struct timeval *timeout)
37{
38 return select (nooffds, readfds, writefds, exceptfds, timeout);
39}
40#else
41int
42Selective_Select (int nooffds, void *readfds, void *writefds, void *exceptfds,
43 void *timeout)
44{
45 return 0;
46}
47#endif
48
49/* PROCEDURE InitTime (sec, usec) : Timeval ; */
50
51#if defined(HAVE_SELECT)
52struct timeval *
53Selective_InitTime (unsigned int sec, unsigned int usec)
54{
55 struct timeval *t = (struct timeval *)malloc (sizeof (struct timeval));
56
57 t->tv_sec = (long int)sec;
58 t->tv_usec = (long int)usec;
59 return t;
60}
61
62void
63Selective_GetTime (struct timeval *t, unsigned int *sec, unsigned int *usec)
64{
65 *sec = (unsigned int)t->tv_sec;
66 *usec = (unsigned int)t->tv_usec;
67}
68
69void
70Selective_SetTime (struct timeval *t, unsigned int sec, unsigned int usec)
71{
72 t->tv_sec = sec;
73 t->tv_usec = usec;
74}
75
76/* PROCEDURE KillTime (t: Timeval) : Timeval ; */
77
78struct timeval *
79Selective_KillTime (struct timeval *t)
80{
81 free (t);
82 return NULL;
83}
84
85/* PROCEDURE InitSet () : SetOfFd ; */
86
87fd_set *
88Selective_InitSet (void)
89{
90 fd_set *s = (fd_set *)malloc (sizeof (fd_set));
91
92 return s;
93}
94
95/* PROCEDURE KillSet (s: SetOfFd) : SetOfFd ; */
96
97fd_set *
98Selective_KillSet (fd_set *s)
99{
100 free (s);
101 return NULL;
102}
103
104/* PROCEDURE FdZero (s: SetOfFd) ; */
105
106void
107Selective_FdZero (fd_set *s)
108{
109 FD_ZERO (s);
110}
111
112/* PROCEDURE Fd_Set (fd: INTEGER; SetOfFd) ; */
113
114void
115Selective_FdSet (int fd, fd_set *s)
116{
117 FD_SET (fd, s);
118}
119
120/* PROCEDURE FdClr (fd: INTEGER; SetOfFd) ; */
121
122void
123Selective_FdClr (int fd, fd_set *s)
124{
125 FD_CLR (fd, s);
126}
127
128/* PROCEDURE FdIsSet (fd: INTEGER; SetOfFd) : BOOLEAN ; */
129
130int
131Selective_FdIsSet (int fd, fd_set *s)
132{
133 return FD_ISSET (fd, s);
134}
135
136/* GetTimeOfDay - fills in a record, Timeval, filled in with the
137current system time in seconds and microseconds. It returns zero
138(see man 3p gettimeofday) */
139
140int
141Selective_GetTimeOfDay (struct timeval *t)
142{
143 return gettimeofday (t, NULL);
144}
145#else
146
147void *
148Selective_InitTime (unsigned int sec, unsigned int usec)
149{
150 return NULL;
151}
152
153void *
154Selective_KillTime (void *t)
155{
156 return NULL;
157}
158
159void
160Selective_GetTime (struct timeval *t, unsigned int *sec, unsigned int *usec)
161{
162}
163
164void
165Selective_SetTime (struct timeval *t, unsigned int sec, unsigned int usec)
166{
167}
168
169fd_set *
170Selective_InitSet (void)
171{
172 return NULL;
173}
174
175void
176Selective_FdZero (void *s)
177{
178}
179
180void
181Selective_FdSet (int fd, void *s)
182{
183}
184
185void
186Selective_FdClr (int fd, void *s)
187{
188}
189
190int
191Selective_FdIsSet (int fd, void *s)
192{
193 return 0;
194}
195
196int
197Selective_GetTimeOfDay (struct timeval *t)
198{
199 return -1;
200}
201#endif
202
203/* PROCEDURE MaxFdsPlusOne (a, b: File) : File ; */
204
205int
206Selective_MaxFdsPlusOne (int a, int b)
207{
208 if (a > b)
209 return a + 1;
210 else
211 return b + 1;
212}
213
214/* PROCEDURE WriteCharRaw (fd: INTEGER; ch: CHAR) ; */
215
216void
217Selective_WriteCharRaw (int fd, char ch)
218{
219 write (fd, &ch, 1);
220}
221
222/* PROCEDURE ReadCharRaw (fd: INTEGER) : CHAR ; */
223
224char
225Selective_ReadCharRaw (int fd)
226{
227 char ch;
228
229 read (fd, &ch, 1);
230 return ch;
231}
232
233void
234_M2_Selective_init ()
235{
236}
237
238void
239_M2_Selective_finish ()
240{
241}
This page took 0.072761 seconds and 5 git commands to generate.