gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] gawk branch, feature/pma2, updated. gawk-4.1.0-4741-g92011908


From: Arnold Robbins
Subject: [SCM] gawk branch, feature/pma2, updated. gawk-4.1.0-4741-g92011908
Date: Fri, 10 Jun 2022 03:31:37 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, feature/pma2 has been updated
       via  920119080d877186165506ba819a548a5ea4ae85 (commit)
      from  36ba3cb86acd0cf8b70d78391ef0b77279b57b7c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=920119080d877186165506ba819a548a5ea4ae85

commit 920119080d877186165506ba819a548a5ea4ae85
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Fri Jun 10 10:29:53 2022 +0300

    Attempt pma symbol table integration. Works in pass through mode.

diff --git a/ChangeLog b/ChangeLog
index 2938960e..85b5819f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,13 @@
-2022-06-02         Arnold D. Robbins     <arnold@skeeve.com>
+2022-06-10         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * awk.h (using_persistent_malloc): Declare new variable
+       * main.c (main): Check for error from pma_init. Set
+       using_persistent_malloc.
+       * symbol.c (init_symbol_table): Check using_persistent_malloc
+       appropriately.
+       * NEWS: Updated.
+
+2022-06-09         Arnold D. Robbins     <arnold@skeeve.com>
 
        * custom.h: Deal with use/non-use of persistent malloc.
        * main.c (main): Bracket mtrace call in #ifndef. Call pma_init()
diff --git a/NEWS b/NEWS
index 89807bd4..447a4bc8 100644
--- a/NEWS
+++ b/NEWS
@@ -44,6 +44,11 @@ for saving / restoring all of gawk's variables and arrays.
 Wherever possible, details were replaced with references to the online
 copy of the manual.
 
+9. Gawk now supports Terrence Kelley's "persistent malloc" (pma),
+allowing gawk to preserve the contents of its variables and arrays
+between runs. THIS IS AN EXPERIMENTAL FEATURE!  For more information,
+see the manual.
+
 Changes from 5.1.1 to 5.1.2
 ---------------------------
 
diff --git a/awk.h b/awk.h
index 732aec04..f89b0866 100644
--- a/awk.h
+++ b/awk.h
@@ -1197,6 +1197,7 @@ extern enum do_flag_values {
 extern bool do_optimize;
 extern int use_lc_numeric;
 extern int exit_val;
+extern bool using_persistent_malloc;
 
 #ifdef NO_LINT
 #define do_lint 0
diff --git a/doc/ChangeLog b/doc/ChangeLog
index eee7808f..8bfd132c 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2022-06-10         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * gawk.1: Document GAWK_PERSIST_FILE.
+
 2022-06-06         Andrew J. Schorr      <aschorr@telemetry-investments.com>
 
        * gawktexi.in (Array Functions): Add new function destroy_array.
diff --git a/doc/gawk.1 b/doc/gawk.1
index 98bdff8a..6593e5b3 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -13,7 +13,7 @@
 .              if \w'\(rq' .ds rq "\(rq
 .      \}
 .\}
-.TH GAWK 1 "May 03 2022" "Free Software Foundation" "Utility Commands"
+.TH GAWK 1 "Jun 09 2022" "Free Software Foundation" "Utility Commands"
 .SH NAME
 gawk \- pattern scanning and processing language
 .SH SYNOPSIS
@@ -2289,6 +2289,13 @@ and
 options.
 .PP
 The
+.B GAWK_PERSIST_FILE
+environment variable, if present, specifies a file to use as
+the backing store for persistent memory.
+.IR "This is an experimental feature" .
+See \*(EP for the details.
+.PP
+The
 .B GAWK_READ_TIMEOUT
 environment variable can be used to specify a timeout
 in milliseconds for reading input from a terminal, pipe
diff --git a/main.c b/main.c
index 78bb7110..3c136bfa 100644
--- a/main.c
+++ b/main.c
@@ -147,6 +147,7 @@ static void parse_args(int argc, char **argv);
 static void set_locale_stuff(void);
 static bool stopped_early = false;
 
+bool using_persistent_malloc = false;
 enum do_flag_values do_flags = DO_FLAG_NONE;
 bool do_itrace = false;                        /* provide simple instruction 
trace */
 bool do_optimize = true;               /* apply default optimizations */
@@ -231,7 +232,11 @@ for PMA */
        const char *initial_locale;
 #endif
 
-       pma_init(1, persist_file);
+       if (pma_init(1, persist_file) < 0) {
+               fatal(_("persistent memory allocator failed to initialize"));
+       }
+
+       using_persistent_malloc = (persist_file != NULL);
 
        /* do these checks early */
        if (getenv("TIDYMEM") != NULL)
diff --git a/symbol.c b/symbol.c
index 78b29bba..9b158f6e 100644
--- a/symbol.c
+++ b/symbol.c
@@ -55,9 +55,18 @@ static bool installing_specials = false;
 void
 init_symbol_table()
 {
-       getnode(global_table);
-       memset(global_table, '\0', sizeof(NODE));
-       null_array(global_table);
+       NODE *pma_root_node = NULL;
+
+       if (using_persistent_malloc) {
+               pma_root_node = (NODE *) pma_get_root();
+               if (pma_root_node != NULL) {
+                       global_table = pma_root_node;
+               }
+       } else {
+               getnode(global_table);
+               memset(global_table, '\0', sizeof(NODE));
+               null_array(global_table);
+       }
 
        getnode(param_table);
        memset(param_table, '\0', sizeof(NODE));
@@ -66,8 +75,15 @@ init_symbol_table()
        installing_specials = true;
        func_table = install_symbol(estrdup("FUNCTAB", 7), Node_var_array);
 
-       symbol_table = install_symbol(estrdup("SYMTAB", 6), Node_var_array);
+       if (using_persistent_malloc && pma_root_node != NULL) {
+               symbol_table = lookup("SYMTAB");
+       } else
+               symbol_table = install_symbol(estrdup("SYMTAB", 6), 
Node_var_array);
+
        installing_specials = false;
+
+       if (using_persistent_malloc && pma_root_node == 0)
+               pma_set_root(global_table);
 }
 
 /*

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog     | 11 ++++++++++-
 NEWS          |  5 +++++
 awk.h         |  1 +
 doc/ChangeLog |  4 ++++
 doc/gawk.1    |  9 ++++++++-
 main.c        |  7 ++++++-
 symbol.c      | 24 ++++++++++++++++++++----
 7 files changed, 54 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]