diff --git a/build-aux/configure-lib.sh b/build-aux/configure-lib.sh index 0f09d489..609dcaff 100644 --- a/build-aux/configure-lib.sh +++ b/build-aux/configure-lib.sh @@ -439,6 +439,7 @@ src/core.c src/display.c src/eval-apply.c src/gc.c +src/globals.c src/hash.c src/lib.c src/math.c diff --git a/include/mes/mes.h b/include/mes/mes.h index 90abe592..9ef6491e 100644 --- a/include/mes/mes.h +++ b/include/mes/mes.h @@ -54,59 +54,59 @@ struct scm }; /* mes */ -char *g_datadir; -int g_debug; -char *g_buf; -int g_continuations; -struct scm *g_symbols; -struct scm *g_symbol_max; -int g_mini; +extern char *g_datadir; +extern int g_debug; +extern char *g_buf; +extern int g_continuations; +extern struct scm *g_symbols; +extern struct scm *g_symbol_max; +extern int g_mini; /* a/env */ -struct scm *R0; +extern struct scm *R0; /* param 1 */ -struct scm *R1; +extern struct scm *R1; /* save 2 */ -struct scm *R2; +extern struct scm *R2; /* continuation */ -struct scm *R3; +extern struct scm *R3; /* current-module */ -struct scm *M0; +extern struct scm *M0; /* macro */ -struct scm *g_macros; -struct scm *g_ports; +extern struct scm *g_macros; +extern struct scm *g_ports; /* gc */ -size_t ARENA_SIZE; -size_t MAX_ARENA_SIZE; -size_t STACK_SIZE; -size_t JAM_SIZE; -size_t GC_SAFETY; -size_t MAX_STRING; -char *g_arena; -struct scm *cell_arena; -struct scm *cell_zero; +extern size_t ARENA_SIZE; +extern size_t MAX_ARENA_SIZE; +extern size_t STACK_SIZE; +extern size_t JAM_SIZE; +extern size_t GC_SAFETY; +extern size_t MAX_STRING; +extern char *g_arena; +extern struct scm *cell_arena; +extern struct scm *cell_zero; -struct scm *g_free; -struct scm *g_symbol; +extern struct scm *g_free; +extern struct scm *g_symbol; -struct scm **g_stack_array; -struct scm *g_cells; -struct scm *g_news; -long g_stack; -size_t gc_count; -struct timespec *gc_start_time; -struct timespec *gc_end_time; -size_t gc_time; +extern struct scm **g_stack_array; +extern struct scm *g_cells; +extern struct scm *g_news; +extern long g_stack; +extern size_t gc_count; +extern struct timespec *gc_start_time; +extern struct timespec *gc_end_time; +extern size_t gc_time; -char **__execl_c_argv; -char *__open_boot_buf; -char *__open_boot_file_name; -char *__setenv_buf; -char *__reader_read_char_buf; -struct timespec *g_start_time; -struct timeval *__gettimeofday_time; -struct timespec *__get_internal_run_time_ts; +extern char **__execl_c_argv; +extern char *__open_boot_buf; +extern char *__open_boot_file_name; +extern char *__setenv_buf; +extern char *__reader_read_char_buf; +extern struct timespec *g_start_time; +extern struct timeval *__gettimeofday_time; +extern struct timespec *__get_internal_run_time_ts; struct scm *cast_charp_to_scmp (char const *i); struct scm **cast_charp_to_scmpp (char const *i); diff --git a/include/mes/symbols.h b/include/mes/symbols.h index ec185bdc..490fa1e2 100644 --- a/include/mes/symbols.h +++ b/include/mes/symbols.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -21,121 +21,121 @@ #ifndef __MES_SYMBOLS_H #define __MES_SYMBOLS_H -struct scm *cell_nil; -struct scm *cell_f; -struct scm *cell_t; -struct scm *cell_dot; -struct scm *cell_arrow; -struct scm *cell_undefined; -struct scm *cell_unspecified; -struct scm *cell_closure; -struct scm *cell_circular; +extern struct scm *cell_nil; +extern struct scm *cell_f; +extern struct scm *cell_t; +extern struct scm *cell_dot; +extern struct scm *cell_arrow; +extern struct scm *cell_undefined; +extern struct scm *cell_unspecified; +extern struct scm *cell_closure; +extern struct scm *cell_circular; -struct scm *cell_vm_apply; -struct scm *cell_vm_apply2; -struct scm *cell_vm_begin; -struct scm *cell_vm_begin_eval; -struct scm *cell_vm_begin_expand; -struct scm *cell_vm_begin_expand_eval; -struct scm *cell_vm_begin_expand_macro; -struct scm *cell_vm_begin_expand_primitive_load; -struct scm *cell_vm_begin_primitive_load; -struct scm *cell_vm_begin_read_input_file; -struct scm *cell_vm_call_with_current_continuation2; -struct scm *cell_vm_call_with_values2; -struct scm *cell_vm_eval; -struct scm *cell_vm_eval2; -struct scm *cell_vm_eval_check_func; -struct scm *cell_vm_eval_define; -struct scm *cell_vm_eval_macro_expand_eval; -struct scm *cell_vm_eval_macro_expand_expand; -struct scm *cell_vm_eval_pmatch_car; -struct scm *cell_vm_eval_pmatch_cdr; -struct scm *cell_vm_eval_set_x; -struct scm *cell_vm_evlis; -struct scm *cell_vm_evlis2; -struct scm *cell_vm_evlis3; -struct scm *cell_vm_if; -struct scm *cell_vm_if_expr; -struct scm *cell_vm_macro_expand; -struct scm *cell_vm_macro_expand_car; -struct scm *cell_vm_macro_expand_cdr; -struct scm *cell_vm_macro_expand_define; -struct scm *cell_vm_macro_expand_define_macro; -struct scm *cell_vm_macro_expand_lambda; -struct scm *cell_vm_macro_expand_set_x; -struct scm *cell_vm_return; +extern struct scm *cell_vm_apply; +extern struct scm *cell_vm_apply2; +extern struct scm *cell_vm_begin; +extern struct scm *cell_vm_begin_eval; +extern struct scm *cell_vm_begin_expand; +extern struct scm *cell_vm_begin_expand_eval; +extern struct scm *cell_vm_begin_expand_macro; +extern struct scm *cell_vm_begin_expand_primitive_load; +extern struct scm *cell_vm_begin_primitive_load; +extern struct scm *cell_vm_begin_read_input_file; +extern struct scm *cell_vm_call_with_current_continuation2; +extern struct scm *cell_vm_call_with_values2; +extern struct scm *cell_vm_eval; +extern struct scm *cell_vm_eval2; +extern struct scm *cell_vm_eval_check_func; +extern struct scm *cell_vm_eval_define; +extern struct scm *cell_vm_eval_macro_expand_eval; +extern struct scm *cell_vm_eval_macro_expand_expand; +extern struct scm *cell_vm_eval_pmatch_car; +extern struct scm *cell_vm_eval_pmatch_cdr; +extern struct scm *cell_vm_eval_set_x; +extern struct scm *cell_vm_evlis; +extern struct scm *cell_vm_evlis2; +extern struct scm *cell_vm_evlis3; +extern struct scm *cell_vm_if; +extern struct scm *cell_vm_if_expr; +extern struct scm *cell_vm_macro_expand; +extern struct scm *cell_vm_macro_expand_car; +extern struct scm *cell_vm_macro_expand_cdr; +extern struct scm *cell_vm_macro_expand_define; +extern struct scm *cell_vm_macro_expand_define_macro; +extern struct scm *cell_vm_macro_expand_lambda; +extern struct scm *cell_vm_macro_expand_set_x; +extern struct scm *cell_vm_return; -struct scm *cell_symbol_lambda; -struct scm *cell_symbol_begin; -struct scm *cell_symbol_if; -struct scm *cell_symbol_quote; -struct scm *cell_symbol_define; -struct scm *cell_symbol_define_macro; -struct scm *cell_symbol_quasiquote; -struct scm *cell_symbol_unquote; -struct scm *cell_symbol_unquote_splicing; -struct scm *cell_symbol_syntax; -struct scm *cell_symbol_quasisyntax; -struct scm *cell_symbol_unsyntax; -struct scm *cell_symbol_unsyntax_splicing; -struct scm *cell_symbol_set_x; -struct scm *cell_symbol_sc_expand; -struct scm *cell_symbol_macro_expand; -struct scm *cell_symbol_portable_macro_expand; -struct scm *cell_symbol_sc_expander_alist; -struct scm *cell_symbol_call_with_values; -struct scm *cell_symbol_call_with_current_continuation; -struct scm *cell_symbol_boot_module; -struct scm *cell_symbol_current_module; -struct scm *cell_symbol_primitive_load; -struct scm *cell_symbol_car; -struct scm *cell_symbol_cdr; -struct scm *cell_symbol_not_a_number; -struct scm *cell_symbol_not_a_pair; -struct scm *cell_symbol_system_error; -struct scm *cell_symbol_throw; -struct scm *cell_symbol_unbound_variable; -struct scm *cell_symbol_wrong_number_of_args; -struct scm *cell_symbol_wrong_type_arg; -struct scm *cell_symbol_buckets; -struct scm *cell_symbol_builtin; -struct scm *cell_symbol_frame; -struct scm *cell_symbol_hashq_table; -struct scm *cell_symbol_module; -struct scm *cell_symbol_procedure; -struct scm *cell_symbol_record_type; -struct scm *cell_symbol_size; -struct scm *cell_symbol_stack; -struct scm *cell_symbol_argv; -struct scm *cell_symbol_mes_datadir; -struct scm *cell_symbol_mes_version; -struct scm *cell_symbol_internal_time_units_per_second; -struct scm *cell_symbol_compiler; -struct scm *cell_symbol_arch; -struct scm *cell_symbol_pmatch_car; -struct scm *cell_symbol_pmatch_cdr; -struct scm *cell_type_bytes; -struct scm *cell_type_char; -struct scm *cell_type_closure; -struct scm *cell_type_continuation; -struct scm *cell_type_function; -struct scm *cell_type_keyword; -struct scm *cell_type_macro; -struct scm *cell_type_number; -struct scm *cell_type_pair; -struct scm *cell_type_port; -struct scm *cell_type_ref; -struct scm *cell_type_special; -struct scm *cell_type_string; -struct scm *cell_type_struct; -struct scm *cell_type_symbol; -struct scm *cell_type_values; -struct scm *cell_type_variable; -struct scm *cell_type_vector; -struct scm *cell_type_broken_heart; -struct scm *cell_symbol_program; -struct scm *cell_symbol_test; +extern struct scm *cell_symbol_lambda; +extern struct scm *cell_symbol_begin; +extern struct scm *cell_symbol_if; +extern struct scm *cell_symbol_quote; +extern struct scm *cell_symbol_define; +extern struct scm *cell_symbol_define_macro; +extern struct scm *cell_symbol_quasiquote; +extern struct scm *cell_symbol_unquote; +extern struct scm *cell_symbol_unquote_splicing; +extern struct scm *cell_symbol_syntax; +extern struct scm *cell_symbol_quasisyntax; +extern struct scm *cell_symbol_unsyntax; +extern struct scm *cell_symbol_unsyntax_splicing; +extern struct scm *cell_symbol_set_x; +extern struct scm *cell_symbol_sc_expand; +extern struct scm *cell_symbol_macro_expand; +extern struct scm *cell_symbol_portable_macro_expand; +extern struct scm *cell_symbol_sc_expander_alist; +extern struct scm *cell_symbol_call_with_values; +extern struct scm *cell_symbol_call_with_current_continuation; +extern struct scm *cell_symbol_boot_module; +extern struct scm *cell_symbol_current_module; +extern struct scm *cell_symbol_primitive_load; +extern struct scm *cell_symbol_car; +extern struct scm *cell_symbol_cdr; +extern struct scm *cell_symbol_not_a_number; +extern struct scm *cell_symbol_not_a_pair; +extern struct scm *cell_symbol_system_error; +extern struct scm *cell_symbol_throw; +extern struct scm *cell_symbol_unbound_variable; +extern struct scm *cell_symbol_wrong_number_of_args; +extern struct scm *cell_symbol_wrong_type_arg; +extern struct scm *cell_symbol_buckets; +extern struct scm *cell_symbol_builtin; +extern struct scm *cell_symbol_frame; +extern struct scm *cell_symbol_hashq_table; +extern struct scm *cell_symbol_module; +extern struct scm *cell_symbol_procedure; +extern struct scm *cell_symbol_record_type; +extern struct scm *cell_symbol_size; +extern struct scm *cell_symbol_stack; +extern struct scm *cell_symbol_argv; +extern struct scm *cell_symbol_mes_datadir; +extern struct scm *cell_symbol_mes_version; +extern struct scm *cell_symbol_internal_time_units_per_second; +extern struct scm *cell_symbol_compiler; +extern struct scm *cell_symbol_arch; +extern struct scm *cell_symbol_pmatch_car; +extern struct scm *cell_symbol_pmatch_cdr; +extern struct scm *cell_type_bytes; +extern struct scm *cell_type_char; +extern struct scm *cell_type_closure; +extern struct scm *cell_type_continuation; +extern struct scm *cell_type_function; +extern struct scm *cell_type_keyword; +extern struct scm *cell_type_macro; +extern struct scm *cell_type_number; +extern struct scm *cell_type_pair; +extern struct scm *cell_type_port; +extern struct scm *cell_type_ref; +extern struct scm *cell_type_special; +extern struct scm *cell_type_string; +extern struct scm *cell_type_struct; +extern struct scm *cell_type_symbol; +extern struct scm *cell_type_values; +extern struct scm *cell_type_variable; +extern struct scm *cell_type_vector; +extern struct scm *cell_type_broken_heart; +extern struct scm *cell_symbol_program; +extern struct scm *cell_symbol_test; // CONSTANT SYMBOL_MAX 114 #define SYMBOL_MAX 114 diff --git a/src/globals.c b/src/globals.c new file mode 100644 index 00000000..43c255f3 --- /dev/null +++ b/src/globals.c @@ -0,0 +1,25 @@ +/* + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2021 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes 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 of the License, or (at + * your option) any later version. + * + * GNU Mes 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. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include + +#define extern +#include +#include diff --git a/src/symbol.c b/src/symbol.c index 1b6850f5..11dc9311 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -33,8 +33,6 @@ // CONSTANT M2_CELL_SIZE 12 #endif -struct scm *g_symbol; - struct scm * init_symbol (struct scm *x, long type, char const *name) {