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