a68g.h

You can download the current version of Algol 68 Genie and its documentation here.

   1 //! @file a68g.h
   2 //! @author J. Marcel van der Veer
   3 //!
   4 //! @section Copyright
   5 //!
   6 //! This file is part of Algol68G - an Algol 68 compiler-interpreter.
   7 //! Copyright 2001-2023 J. Marcel van der Veer .
   8 //!
   9 //! @section License
  10 //!
  11 //! This program is free software; you can redistribute it and/or modify it 
  12 //! under the terms of the GNU General Public License as published by the 
  13 //! Free Software Foundation; either version 3 of the License, or 
  14 //! (at your option) any later version.
  15 //!
  16 //! This program is distributed in the hope that it will be useful, but 
  17 //! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  18 //! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 
  19 //! more details. You should have received a copy of the GNU General Public 
  20 //! License along with this program. If not, see .
  21 
  22 //! @section Synopsis
  23 //!
  24 //! Master include file.
  25 
  26 #if ! defined (__A68G_H__)
  27 #define __A68G_H__
  28 
  29 // Debugging switch, only useful during development.
  30 #undef A68_DEBUG
  31 
  32 // Early typedef
  33 #define unt unsigned
  34 
  35 // Configuration
  36 
  37 #include "a68g-platform.h"
  38 #include "a68g-includes.h"
  39 
  40 // Build switches depending on platform.
  41 
  42 #if ((defined (BUILD_LINUX) || defined (BUILD_BSD)) && defined (HAVE_GCC) && defined (HAVE_DL))
  43 #  define BUILD_A68_COMPILER
  44 #else
  45 // Untested, so disabled.
  46 #  undef BUILD_A68_COMPILER
  47 #endif
  48 
  49 #if defined (BUILD_LINUX)
  50 #  define BUILD_UNIX
  51 #elif defined (BUILD_BSD)
  52 #  define BUILD_UNIX
  53 #elif defined (BUILD_CYGWIN)
  54 #  define BUILD_UNIX
  55 #elif defined (BUILD_HAIKU)
  56 #  define BUILD_UNIX
  57 #endif
  58 
  59 // REAL_T should be a REAL*8 for external libs.
  60 typedef double REAL_T; 
  61 
  62 #if (A68_LEVEL >= 3)
  63 #  include 
  64 #endif
  65 
  66 // Can we access the internet?
  67 #if defined (BUILD_WIN32)
  68 #  undef BUILD_HTTP
  69 #else
  70 #  if (defined (HAVE_NETDB_H) && defined (HAVE_NETINET_IN_H) && defined (HAVE_SYS_SOCKET_H))
  71 #    if (defined (BUILD_LINUX) || defined (BUILD_BSD) || defined (BUILD_HAIKU))
  72 #      define BUILD_HTTP
  73 #    endif
  74 #  endif
  75 #endif
  76 
  77 // Compatibility.
  78 
  79 #if ! defined (O_BINARY)
  80 #  define O_BINARY 0x0000
  81 #endif
  82 
  83 // Forward type definitions.
  84 
  85 typedef struct NODE_T NODE_T;
  86 typedef unt STATUS_MASK_T, BOOL_T;
  87 
  88 // Decide the internal representation of A68 modes.
  89 
  90 #include "a68g-stddef.h"
  91 
  92 #define ALIGNED __attribute__((aligned (sizeof (A68_ALIGN_T))))
  93 
  94 #if (A68_LEVEL >= 3)
  95 #  include "a68g-level-3.h"
  96 #else // Vintage Algol 68 Genie (versions 1 and 2).
  97 #  include "a68g-generic.h"
  98 #endif
  99 
 100 #define MP_REAL_RADIX ((MP_REAL_T) MP_RADIX)
 101 
 102 #if defined (BUILD_WIN32)
 103 typedef unt __off_t;
 104 #  if defined (__MSVCRT__) && defined (_environ)
 105 #    undef _environ
 106 #  endif
 107 #endif
 108 
 109 #define A68_ALIGN(s) ((int) ((s) % A68_ALIGNMENT) == 0 ? (s) : ((s) - (s) % A68_ALIGNMENT + A68_ALIGNMENT))
 110 #define A68_ALIGNMENT ((int) (sizeof (A68_ALIGN_T)))
 111 
 112 #include "a68g-defines.h"
 113 #include "a68g-stack.h"
 114 #include "a68g-masks.h"
 115 #include "a68g-enums.h"
 116 #include "a68g-types.h"
 117 #include "a68g-nil.h"
 118 #include "a68g-diagnostics.h"
 119 #include "a68g-common.h"
 120 #include "a68g-lib.h"
 121 
 122 // Global declarations
 123 
 124 extern BOOL_T a68_mkstemp (char *, int, mode_t);
 125 extern BYTE_T *get_fixed_heap_space (size_t);
 126 extern BYTE_T *get_heap_space (size_t);
 127 extern BYTE_T *get_temp_heap_space (size_t);
 128 extern char *a68_basename (char *);
 129 extern char *a68_dirname (char *);
 130 extern char *a68_relpath (char *, char *, char *);
 131 extern char *ctrl_char (int);
 132 extern char *moid_to_string (MOID_T *, int, NODE_T *);
 133 extern char *new_fixed_string (char *);
 134 extern char *new_string (char *, ...);
 135 extern char *new_temp_string (char *);
 136 extern char *non_terminal_string (char *, int);
 137 extern char *read_string_from_tty (char *);
 138 extern char *standard_environ_proc_name (GPROC);
 139 extern int get_row_size (A68_TUPLE *, int);
 140 extern int moid_digits (MOID_T *);
 141 extern int moid_size (MOID_T *);
 142 extern int (snprintf) (char *, size_t, const char *, ...); // Prevent macro substitution on Darwin.
 143 extern void *a68_alloc (size_t, const char *, int);
 144 extern void a68_exit (int);
 145 extern void a68_free (void *);
 146 extern void a68_getty (int *, int *);
 147 extern void *a68_memmove (void *, void *, size_t);
 148 extern void abend (char *, char *, char *, int);
 149 extern void announce_phase (char *);
 150 extern void apropos (FILE_T, char *, char *);
 151 extern void bufcat (char *, char *, int);
 152 extern void bufcpy (char *, char *, int);
 153 extern void default_mem_sizes (int);
 154 extern void discard_heap (void);
 155 extern void free_file_entries (void);
 156 extern void free_syntax_tree (NODE_T *);
 157 extern void get_stack_size (void);
 158 extern void indenter (MODULE_T *);
 159 extern void init_curses (void);
 160 extern void init_file_entries (void);
 161 extern void init_file_entry (int);
 162 extern void init_heap (void);
 163 extern void init_rng (unt);
 164 extern void init_tty (void);
 165 extern void install_signal_handlers (void);
 166 extern void online_help (FILE_T);
 167 extern void state_version (FILE_T);
 168 
 169 // Below from R mathlib
 170 
 171 extern void GetRNGstate(void);
 172 extern void PutRNGstate(void);
 173 extern REAL_T a68_unif_rand(void);
 174 extern REAL_T R_unif_index(REAL_T);
 175 
 176 #endif