Debian Codegraph @

gcc/m2/pge-boot/Glibc.h

raw
1 /* do not edit automatically generated by mc from libc. */
2 /* libc.def provides an interface to the C library functions.
3
4 Copyright (C) 2001-2025 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <[email protected]>.
6
7 This file is part of GNU Modula-2.
8
9 GNU Modula-2 is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
13
14 GNU Modula-2 is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
22
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
27
28
29 #if !defined (_libc_H)
30 # define _libc_H
31
32 # ifdef __cplusplus
33 extern "C" {
34 # endif
35 #include <stdbool.h>
36 # if !defined (PROC_D)
37 # define PROC_D
38 typedef void (*PROC_t) (void);
39 typedef struct { PROC_t proc; } PROC;
40 # endif
41
42 #include <stdlib.h>
43 # include <sys/types.h>
44 # include "GSYSTEM.h"
45
46 # if defined (_libc_C)
47 # define EXTERN
48 # else
49 # define EXTERN extern
50 # endif
51
52 typedef long int libc_time_t;
53
54 typedef struct libc_tm_r libc_tm;
55
56 typedef struct libc_timeb_r libc_timeb;
57
58 typedef struct libc_exitP_p libc_exitP;
59
60 typedef libc_tm *libc_ptrToTM;
61
62 struct libc_tm_r {
63 int tm_sec;
64 int tm_min;
65 int tm_hour;
66 int tm_mday;
67 int tm_mon;
68 int tm_year;
69 int tm_wday;
70 int tm_yday;
71 int tm_isdst;
72 long int tm_gmtoff;
73 void *tm_zone;
74 };
75
76 struct libc_timeb_r {
77 libc_time_t time_;
78 short unsigned int millitm;
79 short unsigned int timezone;
80 short unsigned int dstflag;
81 };
82
83 typedef int (*libc_exitP_t) (void);
84 typedef libc_exitP_t libc_exitP_C;
85
86 struct libc_exitP_p { libc_exitP_t proc; };
87
88 EXTERN double libc_atof (void * nptr);
89 EXTERN int libc_atoi (void * nptr);
90 EXTERN ssize_t libc_atol (void * nptr);
91 EXTERN long int libc_atoll (void * nptr);
92 EXTERN double libc_strtod (void * nptr, void * endptr);
93 EXTERN float libc_strtof (void * nptr, void * endptr);
94 EXTERN long double libc_strtold (void * nptr, void * endptr);
95 EXTERN ssize_t libc_strtol (void * nptr, void * endptr, int base);
96 EXTERN long int libc_strtoll (void * nptr, void * endptr, int base);
97 EXTERN size_t libc_strtoul (void * nptr, void * endptr, int base);
98 EXTERN long unsigned int libc_strtoull (void * nptr, void * endptr, int base);
99 EXTERN ssize_t libc_write (int d, void * buf, size_t nbytes);
100 EXTERN ssize_t libc_read (int d, void * buf, size_t nbytes);
101 EXTERN int libc_system (void * a);
102
103 /*
104 abort - generate a fault
105
106 abort() first closes all open files if possible, then sends
107 an IOT signal to the process. This signal usually results
108 in termination with a core dump, which may be used for
109 debugging.
110
111 It is possible for abort() to return control if is caught or
112 ignored, in which case the value returned is that of the
113 kill(2V) system call.
114 */
115
116 EXTERN void libc_abort (void) __attribute__ ((noreturn));
117
118 /*
119 malloc - memory allocator.
120
121 void *malloc(size_t size);
122
123 malloc() returns a pointer to a block of at least size
124 bytes, which is appropriately aligned. If size is zero,
125 malloc() returns a non-NULL pointer, but this pointer should
126 not be dereferenced.
127 */
128
129 EXTERN void * libc_malloc (size_t size);
130
131 /*
132 free - memory deallocator.
133
134 free (void *ptr);
135
136 free() releases a previously allocated block. Its argument
137 is a pointer to a block previously allocated by malloc,
138 calloc, realloc, malloc, or memalign.
139 */
140
141 EXTERN void libc_free (void * ptr);
142 EXTERN void * libc_realloc (void * ptr, size_t size);
143
144 /*
145 isatty - does this descriptor refer to a terminal.
146 */
147
148 EXTERN int libc_isatty (int fd);
149
150 /*
151 exit - returns control to the invoking process. Result, r, is
152 returned.
153 */
154
155 EXTERN void libc_exit (int r) __attribute__ ((noreturn));
156
157 /*
158 getenv - returns the C string for the equivalent C environment
159 variable.
160 */
161
162 EXTERN void * libc_getenv (void * s);
163
164 /*
165 putenv - change or add an environment variable.
166 */
167
168 EXTERN int libc_putenv (void * s);
169
170 /*
171 getpid - returns the UNIX process identification number.
172 */
173
174 EXTERN int libc_getpid (void);
175
176 /*
177 dup - duplicates the file descriptor, d.
178 */
179
180 EXTERN int libc_dup (int d);
181
182 /*
183 close - closes the file descriptor, d.
184 */
185
186 EXTERN int libc_close (int d);
187
188 /*
189 open - open the file, filename with flag and mode.
190 */
191
192 EXTERN int libc_open (void * filename, int oflag, int mode);
193
194 /*
195 creat - creates a new file
196 */
197
198 EXTERN int libc_creat (void * filename, unsigned int mode);
199
200 /*
201 lseek - calls unix lseek:
202
203 off_t lseek(int fildes, off_t offset, int whence);
204 */
205
206 EXTERN off_t libc_lseek (int fd, off_t offset, int whence);
207
208 /*
209 perror - writes errno and string. (ARRAY OF CHAR is translated onto ADDRESS).
210 */
211
212 EXTERN void libc_perror (const char *string_, unsigned int _string_high);
213
214 /*
215 readv - reads an io vector of bytes.
216 */
217
218 EXTERN int libc_readv (int fd, void * v, int n);
219
220 /*
221 writev - writes an io vector of bytes.
222 */
223
224 EXTERN int libc_writev (int fd, void * v, int n);
225
226 /*
227 getcwd - copies the absolute pathname of the
228 current working directory to the array pointed to by buf,
229 which is of length size.
230
231 If the current absolute path name would require a buffer
232 longer than size elements, NULL is returned, and errno is
233 set to ERANGE; an application should check for this error,
234 and allocate a larger buffer if necessary.
235 */
236
237 EXTERN void * libc_getcwd (void * buf, size_t size);
238
239 /*
240 chown - The owner of the file specified by path or by fd is
241 changed. Only the super-user may change the owner of a
242 file. The owner of a file may change the group of the
243 file to any group of which that owner is a member. The
244 super-user may change the group arbitrarily.
245
246 If the owner or group is specified as -1, then that ID is
247 not changed.
248
249 On success, zero is returned. On error, -1 is returned,
250 and errno is set appropriately.
251 */
252
253 EXTERN int libc_chown (void * filename, int uid, int gid);
254
255 /*
256 strlen - returns the length of string, a.
257 */
258
259 EXTERN size_t libc_strlen (void * a);
260
261 /*
262 strcpy - copies string, src, into, dest.
263 It returns dest.
264 */
265
266 EXTERN void * libc_strcpy (void * dest, void * src);
267
268 /*
269 strncpy - copies string, src, into, dest, copying at most, n, bytes.
270 It returns dest.
271 */
272
273 EXTERN void * libc_strncpy (void * dest, void * src, unsigned int n);
274
275 /*
276 unlink - removes file and returns 0 if successful.
277 */
278
279 EXTERN int libc_unlink (void * file);
280
281 /*
282 memcpy - copy memory area
283
284 SYNOPSIS
285
286 #include <string.h>
287
288 void *memcpy(void *dest, const void *src, size_t n);
289 It returns dest.
290 */
291
292 EXTERN void * libc_memcpy (void * dest, void * src, size_t size);
293
294 /*
295 memset - fill memory with a constant byte
296
297 SYNOPSIS
298
299 #include <string.h>
300
301 void *memset(void *s, int c, size_t n);
302 It returns s.
303 */
304
305 EXTERN void * libc_memset (void * s, int c, size_t size);
306
307 /*
308 memmove - copy memory areas which may overlap
309
310 SYNOPSIS
311
312 #include <string.h>
313
314 void *memmove(void *dest, const void *src, size_t n);
315 It returns dest.
316 */
317
318 EXTERN void * libc_memmove (void * dest, void * src, size_t size);
319 EXTERN int libc_printf (const char *format_, unsigned int _format_high, ...);
320 EXTERN int libc_snprintf (void * dest, size_t size, const char *format_, unsigned int _format_high, ...);
321
322 /*
323 setenv - sets environment variable, name, to value.
324 It will overwrite an existing value if, overwrite,
325 is true. It returns 0 on success and -1 for an error.
326 */
327
328 EXTERN int libc_setenv (void * name, void * value, int overwrite);
329
330 /*
331 srand - initialize the random number seed.
332 */
333
334 EXTERN void libc_srand (int seed);
335
336 /*
337 rand - return a random integer.
338 */
339
340 EXTERN int libc_rand (void);
341
342 /*
343 time - returns a pointer to the time_t value. If, a,
344 is not NIL then the libc value is copied into
345 memory at address, a.
346 */
347
348 EXTERN libc_time_t libc_time (void * a);
349
350 /*
351 localtime - returns a pointer to the libc copy of the tm
352 structure.
353 */
354
355 EXTERN void * libc_localtime (libc_time_t *t);
356
357 /*
358 ftime - return date and time.
359 */
360
361 EXTERN int libc_ftime (libc_timeb *t);
362
363 /*
364 shutdown - shutdown a socket, s.
365 if how = 0, then no more reads are allowed.
366 if how = 1, then no more writes are allowed.
367 if how = 2, then mo more reads or writes are allowed.
368 */
369
370 EXTERN int libc_shutdown (int s, int how);
371
372 /*
373 rename - change the name or location of a file
374 */
375
376 EXTERN int libc_rename (void * oldpath, void * newpath);
377
378 /*
379 setjmp - returns 0 if returning directly, and non-zero
380 when returning from longjmp using the saved
381 context.
382 */
383
384 EXTERN int libc_setjmp (void * env);
385
386 /*
387 longjmp - restores the environment saved by the last call
388 of setjmp with the corresponding env argument.
389 After longjmp is completed, program execution
390 continues as if the corresponding call of setjmp
391 had just returned the value val. The value of
392 val must not be zero.
393 */
394
395 EXTERN void libc_longjmp (void * env, int val);
396
397 /*
398 atexit - execute, proc, when the function exit is called.
399 */
400
401 EXTERN int libc_atexit (libc_exitP_C proc);
402
403 /*
404 ttyname - returns a pointer to a string determining the ttyname.
405 */
406
407 EXTERN void * libc_ttyname (int filedes);
408
409 /*
410 sleep - calling thread sleeps for seconds.
411 */
412
413 EXTERN unsigned int libc_sleep (unsigned int seconds);
414
415 /*
416 execv - execute a file.
417 */
418
419 EXTERN int libc_execv (void * pathname, void * argv);
420 # ifdef __cplusplus
421 }
422 # endif
423
424 # undef EXTERN
425 #endif