boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

lib-mini.h (2419B)


      1 /* -*-comment-start: "//";comment-end:""-*-
      2  * GNU Mes --- Maxwell Equations of Software
      3  * Copyright © 2016,2017,2018,2020,2022,2023,2025 Janneke Nieuwenhuizen <janneke@gnu.org>
      4  *
      5  * This file is part of GNU Mes.
      6  *
      7  * GNU Mes is free software; you can redistribute it and/or modify it
      8  * under the terms of the GNU General Public License as published by
      9  * the Free Software Foundation; either version 3 of the License, or (at
     10  * your option) any later version.
     11  *
     12  * GNU Mes is distributed in the hope that it will be useful, but
     13  * 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.
     16  *
     17  * You should have received a copy of the GNU General Public License
     18  * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
     19  */
     20 
     21 #ifndef __MES_LIB_MINI_H
     22 #define __MES_LIB_MINI_H
     23 
     24 #if HAVE_CONFIG_H
     25 #include <mes/config.h>
     26 #endif
     27 
     28 #ifndef STDIN
     29 #define STDIN 0
     30 #endif
     31 
     32 #ifndef STDOUT
     33 #define STDOUT 1
     34 #endif
     35 
     36 #ifndef STDERR
     37 #define STDERR 2
     38 #endif
     39 
     40 /* M2-Planet does not support pointer arithmetic.  Explicitly compensate
     41    for that by multiplying with M2_PTR_SIZE when using (char)
     42    pointers. */
     43 #if __M2__
     44 #define M2_PTR_SIZE sizeof (void*)
     45 #else
     46 #define M2_PTR_SIZE 1
     47 #endif
     48 
     49 extern char **environ;
     50 extern int __stdin;
     51 extern int __stdout;
     52 extern int __stderr;
     53 
     54 void __init_io ();
     55 int eputs (char const *s);
     56 int puts (char const *s);
     57 int oputs (char const *s);
     58 
     59 #if SYSTEM_LIBC
     60 
     61 #include <stdlib.h>
     62 #include <sys/types.h>
     63 #include <unistd.h>
     64 
     65 #else //!SYSTEM_LIBC
     66 
     67 #ifndef _SIZE_T
     68 #define _SIZE_T
     69 #ifndef __SIZE_T
     70 #define __SIZE_T
     71 #ifndef __MES_SIZE_T
     72 #define __MES_SIZE_T
     73 #undef size_t
     74 #if __M2__
     75 typedef unsigned size_t;
     76 #else
     77 typedef unsigned long size_t;
     78 #endif
     79 #endif
     80 #endif
     81 #endif
     82 
     83 #ifndef _SSIZE_T
     84 #define _SSIZE_T
     85 #ifndef __SSIZE_T
     86 #define __SSIZE_T
     87 #ifndef __MES_SSIZE_T
     88 #define __MES_SSIZE_T
     89 #undef ssize_t
     90 #if __i386__
     91 typedef int ssize_t;
     92 #else
     93 typedef long ssize_t;
     94 #endif
     95 #endif
     96 #endif
     97 #endif
     98 
     99 #ifndef __MES_ERRNO_T
    100 #define __MES_ERRNO_T 1
    101 typedef int error_t;
    102 extern int errno;
    103 #endif // !__MES_ERRNO_T
    104 
    105 #if !__M2__
    106 extern void (*__call_at_exit) (void);
    107 #endif
    108 
    109 void _exit (int status);
    110 void exit (int status);
    111 size_t strlen (char const *s);
    112 ssize_t _write ();
    113 ssize_t write (int filedes, void const *buffer, size_t size);
    114 #endif // !SYSTEM_LIBC
    115 
    116 #endif //__MES_LIB_MINI_H