aboutsummaryrefslogtreecommitdiff
path: root/gcc/m2/pge-boot/Glibc.h
blob: daa0a1c66ad8ac369722c9151174a560a6b23949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
/* do not edit automatically generated by mc from libc.  */
/* libc.def provides an interface to the C library functions.

Copyright (C) 2001-2023 Free Software Foundation, Inc.
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.

This file is part of GNU Modula-2.

GNU Modula-2 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GNU Modula-2 is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.

You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
<http://www.gnu.org/licenses/>.  */


#if !defined (_libc_H)
#   define _libc_H

#include "config.h"
#include "system.h"
#   ifdef __cplusplus
extern "C" {
#   endif
#   if !defined (PROC_D)
#      define PROC_D
       typedef void (*PROC_t) (void);
       typedef struct { PROC_t proc; } PROC;
#   endif

#   include "GSYSTEM.h"

#   if defined (_libc_C)
#      define EXTERN
#   else
#      define EXTERN extern
#   endif

typedef long int libc_time_t;

typedef struct libc_tm_r libc_tm;

typedef struct libc_timeb_r libc_timeb;

typedef struct libc_exitP_p libc_exitP;

typedef libc_tm *libc_ptrToTM;

struct libc_tm_r {
                   int tm_sec;
                   int tm_min;
                   int tm_hour;
                   int tm_mday;
                   int tm_mon;
                   int tm_year;
                   int tm_wday;
                   int tm_yday;
                   int tm_isdst;
                   long int tm_gmtoff;
                   void *tm_zone;
                 };

struct libc_timeb_r {
                      libc_time_t time_;
                      short unsigned int millitm;
                      short unsigned int timezone;
                      short unsigned int dstflag;
                    };

typedef int (*libc_exitP_t) (void);
typedef libc_exitP_t libc_exitP_C;

struct libc_exitP_p { libc_exitP_t proc; };

EXTERN ssize_t libc_write (int d, void * buf, size_t nbytes);
EXTERN ssize_t libc_read (int d, void * buf, size_t nbytes);
EXTERN int libc_system (void * a);

/*
     abort - generate a fault

     abort() first closes all open files if possible, then sends
     an IOT signal to the process.  This signal usually results
     in termination with a core dump, which may be used for
     debugging.

     It is possible for abort() to return control if is caught or
     ignored, in which case the value returned is that of the
     kill(2V) system call.
*/

EXTERN void libc_abort (void) __attribute__ ((noreturn));

/*
     malloc - memory allocator.

     void *malloc(size_t size);

     malloc() returns a pointer to a block of at least size
     bytes, which is appropriately aligned.  If size is zero,
     malloc() returns a non-NULL pointer, but this pointer should
     not be dereferenced.
*/

EXTERN void * libc_malloc (size_t size);

/*
     free - memory deallocator.

     free (void *ptr);

     free() releases a previously allocated block.  Its argument
     is a pointer to a block previously allocated by malloc,
     calloc, realloc, malloc, or memalign.
*/

EXTERN void libc_free (void * ptr);
EXTERN void * libc_realloc (void * ptr, size_t size);

/*
   isatty - does this descriptor refer to a terminal.
*/

EXTERN int libc_isatty (int fd);

/*
   exit - returns control to the invoking process. Result, r, is
          returned.
*/

EXTERN void libc_exit (int r) __attribute__ ((noreturn));

/*
   getenv - returns the C string for the equivalent C environment
            variable.
*/

EXTERN void * libc_getenv (void * s);

/*
   putenv - change or add an environment variable.
*/

EXTERN int libc_putenv (void * s);

/*
   getpid - returns the UNIX process identification number.
*/

EXTERN int libc_getpid (void);

/*
   dup - duplicates the file descriptor, d.
*/

EXTERN int libc_dup (int d);

/*
   close - closes the file descriptor, d.
*/

EXTERN int libc_close (int d);

/*
   open - open the file, filename with flag and mode.
*/

EXTERN int libc_open (void * filename, int oflag, ...);

/*
   creat - creates a new file
*/

EXTERN int libc_creat (void * filename, unsigned int mode);

/*
   lseek - calls unix lseek:

           off_t lseek(int fildes, off_t offset, int whence);
*/

EXTERN long int libc_lseek (int fd, long int offset, int whence);

/*
   perror - writes errno and string. (ARRAY OF CHAR is translated onto ADDRESS).
*/

EXTERN void libc_perror (const char *string_, unsigned int _string_high);

/*
   readv - reads an io vector of bytes.
*/

EXTERN int libc_readv (int fd, void * v, int n);

/*
   writev - writes an io vector of bytes.
*/

EXTERN int libc_writev (int fd, void * v, int n);

/*
   getcwd - copies the absolute pathname of the
            current working directory to the array pointed to by buf,
            which is of length size.

            If the current absolute path name would require a buffer
            longer than size elements, NULL is returned, and errno is
            set to ERANGE; an application should check for this error,
            and allocate a larger buffer if necessary.
*/

EXTERN void * libc_getcwd (void * buf, size_t size);

/*
   chown - The  owner  of  the  file  specified  by  path or by fd is
           changed.  Only the super-user may change the  owner  of  a
           file.   The  owner  of  a file may change the group of the
           file to any group of which that owner is  a  member.   The
           super-user may change the group arbitrarily.

           If  the owner or group is specified as -1, then that ID is
           not changed.

           On success, zero is returned.  On error, -1  is  returned,
           and errno is set appropriately.
*/

EXTERN int libc_chown (void * filename, int uid, int gid);

/*
   strlen - returns the length of string, a.
*/

EXTERN size_t libc_strlen (void * a);

/*
   strcpy - copies string, src, into, dest.
            It returns dest.
*/

EXTERN void * libc_strcpy (void * dest, void * src);

/*
   strncpy - copies string, src, into, dest, copying at most, n, bytes.
             It returns dest.
*/

EXTERN void * libc_strncpy (void * dest, void * src, unsigned int n);

/*
   unlink - removes file and returns 0 if successful.
*/

EXTERN int libc_unlink (void * file);

/*
   memcpy - copy memory area

   SYNOPSIS

   #include <string.h>

   void *memcpy(void *dest, const void *src, size_t n);
   It returns dest.
*/

EXTERN void * libc_memcpy (void * dest, void * src, size_t size);

/*
   memset - fill memory with a constant byte

   SYNOPSIS

   #include <string.h>

   void *memset(void *s, int c, size_t n);
   It returns s.
*/

EXTERN void * libc_memset (void * s, int c, size_t size);

/*
   memmove - copy memory areas which may overlap

   SYNOPSIS

   #include <string.h>

   void *memmove(void *dest, const void *src, size_t n);
   It returns dest.
*/

EXTERN void * libc_memmove (void * dest, void * src, size_t size);
EXTERN int libc_printf (const char *format_, unsigned int _format_high, ...);

/*
   setenv - sets environment variable, name, to value.
            It will overwrite an existing value if, overwrite,
            is true.  It returns 0 on success and -1 for an error.
*/

EXTERN int libc_setenv (void * name, void * value, int overwrite);

/*
   srand - initialize the random number seed.
*/

EXTERN void libc_srand (int seed);

/*
   rand - return a random integer.
*/

EXTERN int libc_rand (void);

/*
   time - returns a pointer to the time_t value. If, a,
          is not NIL then the libc value is copied into
          memory at address, a.
*/

EXTERN libc_time_t libc_time (void * a);

/*
   localtime - returns a pointer to the libc copy of the tm
               structure.
*/

EXTERN void * libc_localtime (libc_time_t *t);

/*
   ftime - return date and time.
*/

EXTERN int libc_ftime (libc_timeb *t);

/*
   shutdown - shutdown a socket, s.
              if how = 0, then no more reads are allowed.
              if how = 1, then no more writes are allowed.
              if how = 2, then mo more reads or writes are allowed.
*/

EXTERN int libc_shutdown (int s, int how);

/*
   rename - change the name or location of a file
*/

EXTERN int libc_rename (void * oldpath, void * newpath);

/*
   setjmp - returns 0 if returning directly, and non-zero
            when returning from longjmp using the saved
            context.
*/

EXTERN int libc_setjmp (void * env);

/*
   longjmp - restores the environment saved by the last call
             of setjmp with the corresponding env argument.
             After longjmp is completed, program execution
             continues as if the corresponding call of setjmp
             had just returned the value val.  The value of
             val must not be zero.
*/

EXTERN void libc_longjmp (void * env, int val);

/*
   atexit - execute, proc, when the function exit is called.
*/

EXTERN int libc_atexit (libc_exitP_C proc);

/*
   ttyname - returns a pointer to a string determining the ttyname.
*/

EXTERN void * libc_ttyname (int filedes);

/*
   sleep - calling thread sleeps for seconds.
*/

EXTERN unsigned int libc_sleep (unsigned int seconds);

/*
   execv - execute a file.
*/

EXTERN int libc_execv (void * pathname, void * argv);
#   ifdef __cplusplus
}
#   endif

#   undef EXTERN
#endif