a68g.h
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-2025 J. Marcel van der Veer [algol68g@xs4all.nl].
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 [http://www.gnu.org/licenses/].
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
31 #if defined (A68G_DEBUG)
32 #undef A68G_DEBUG
33 #endif
34
35 #include "a68g-platform.h"
36
37 // Build switches depending on platform.
38
39 #if ((defined (BUILD_LINUX) || defined (BUILD_BSD)) && defined (HAVE_DL))
40 #define BUILD_A68G_COMPILER
41 #else
42 #undef BUILD_A68G_COMPILER
43 #endif
44
45 #if defined (BUILD_WINDOWS)
46 #if defined (__MSVCRT__) && defined (_environ)
47 #undef _environ
48 #endif
49 #endif
50
51 // Includes, defines and typedefs, in sequence.
52
53 #define unt unsigned
54
55 #include "a68g-includes.h"
56
57 typedef double REAL_T; // REAL_T should be a REAL*8 for external libs.
58 typedef struct NODE_T NODE_T;
59 typedef unt STATUS_MASK_T, BOOL_T;
60
61 // Internal representation of A68 modes.
62
63 #include "a68g-stddef.h"
64
65 #define ALIGNED __attribute__((aligned (sizeof (A68G_ALIGN_T))))
66 #define A68G_ALIGN(s) ((s) % A68G_ALIGNMENT) == 0 ? (s) : ((s) - (s) % A68G_ALIGNMENT + A68G_ALIGNMENT)
67 #define A68G_ALIGNMENT (sizeof (A68G_ALIGN_T))
68 #define SIZE_ALIGNED(p) (A68G_ALIGN (sizeof (p)))
69
70 #if (A68G_LEVEL >= 3)
71 #include "a68g-level-3.h"
72 #else // Vintage Algol 68 Genie (versions 1 and 2).
73 #include "a68g-generic.h"
74 #endif
75
76 #include "a68g-defines.h"
77 #include "a68g-stack.h"
78 #include "a68g-masks.h"
79 #include "a68g-enums.h"
80 #include "a68g-types.h"
81 #include "a68g-nil.h"
82 #include "a68g-diagnostics.h"
83 #include "a68g-common.h"
84 #include "a68g-lib.h"
85 #include "a68g-mach.h"
86
87 // Global definitions
88
89 #define MP_REAL_RADIX ((MP_REAL_T) MP_RADIX)
90
91 #if defined (BUILD_LINUX) && defined (__off_t_defined) // See fcntl.h
92 typedef __off_t a68g_off_t;
93 #else // Reasonable default
94 typedef ssize_t a68g_off_t;
95 #endif
96
97 #if ! defined (O_BINARY)
98 #define O_BINARY 0x0000
99 #endif
100
101 // Global declarations
102
103 BOOL_T a68g_mkstemp (char *, int, mode_t);
104 BYTE_T *get_fixed_heap_space (size_t);
105 BYTE_T *get_heap_space (size_t);
106 BYTE_T *get_temp_heap_space (size_t);
107 char *a68g_basename (char *);
108 char *a68g_dirname (char *);
109 char *a68g_relpath (char *, char *, char *);
110 char *ctrl_char (int);
111 char *moid_to_string (MOID_T *, int, NODE_T *);
112 char *new_fixed_string (char *);
113 char *new_string (char *, ...);
114 char *new_temp_string (char *);
115 char *non_terminal_string (char *, int);
116 char *read_string_from_tty (char *);
117 char *standard_environ_proc_name (GPROC);
118 int a68g_bufprt (char *, size_t, const char *, ...);
119 int a68g_usleep (unsigned);
120 int moid_digits (MOID_T *);
121 size_t get_row_size (A68G_TUPLE *, int);
122 size_t moid_size (MOID_T *);
123 unsigned a68g_alarm (unsigned);
124 void *a68g_alloc (size_t, const char *, int);
125 void a68g_bufcat (char *, char *, size_t);
126 void a68g_bufcpy (char *, char *, size_t);
127 void *a68g_bufset (void *, int, size_t);
128 void a68g_exit (int);
129 void a68g_free (void *);
130 void a68g_getty (int *, int *);
131 void a68g_rm (char *);
132 void abend (char *, char *, char *);
133 void announce_phase (char *);
134 void apropos (FILE_T, char *, char *);
135 void default_mem_sizes (INT_T, LINE_T *, char *);
136 void discard_heap (void);
137 void free_file_entries (void);
138 void free_syntax_tree (NODE_T *);
139 void get_C_stack_size (void);
140 void indenter (MODULE_T *);
141 void init_curses (void);
142 void init_file_entries (void);
143 void init_file_entry (int);
144 void init_heap (void);
145 void init_rng (unt);
146 void init_tty (void);
147 void install_signal_handlers (void);
148 void online_help (FILE_T);
149 void state_version (FILE_T);
150 void storage_limit (size_t);
151
152 // Below from R mathlib
153
154 void GetRNGstate (void);
155 void PutRNGstate (void);
156 REAL_T a68g_unif_rand (void);
157 REAL_T a68g_gauss_rand (void);
158 REAL_T R_unif_index (REAL_T);
159
160 #endif
© 2002-2025 J.M. van der Veer (jmvdveer@xs4all.nl)
|