Changeset: 036b44dac309 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=036b44dac309
Added Files:
        monetdb5/mal/mal_embedded.c
        monetdb5/mal/mal_embedded.h
        monetdb5/mal/mal_signatures
Modified Files:
        monetdb5/mal/Makefile.ag
        monetdb5/mal/mal_session.c
Branch: mdbl-mal
Log Message:

First step in embedded MAL


diffs (153 lines):

diff --git a/monetdb5/mal/Makefile.ag b/monetdb5/mal/Makefile.ag
--- a/monetdb5/mal/Makefile.ag
+++ b/monetdb5/mal/Makefile.ag
@@ -47,7 +47,8 @@ lib_mal = {
                mal_stack.c mal_stack.h \
                mal_type.c mal_type.h \
                mal_utils.c mal_utils.h \
-               mal_private.h
+               mal_private.h \
+               mal_embedded.c mal_embedded.h mal_signatures
 }
 
 headers_h = {
@@ -68,7 +69,9 @@ headers_h = {
                mal_profiler.h \
                mal_resolve.h \
                mal_stack.h \
-               mal_type.h
+               mal_type.h \
+               mal_embedded.h \
+               mal_signatures
 }
 
 EXTRA_DIST_DIR = Tests
diff --git a/monetdb5/mal/mal_embedded.c b/monetdb5/mal/mal_embedded.c
new file mode 100644
--- /dev/null
+++ b/monetdb5/mal/mal_embedded.c
@@ -0,0 +1,60 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+ */
+
+/*
+ * (author) M.L. Kersten
+ * These routines assume that the signatures for all MAL files are defined as 
text in mal_embdded.h
+ * They are parsed upon system restart without access to their source files.
+ * This way the definitions are part of the library upon compilation.
+ */
+#include "monetdb_config.h"
+#include "mal_type.h"
+#include "mal_namespace.h"
+#include "mal_exception.h"
+#include "mal_private.h"
+#include "mal_embedded.h"
+
+static int embeddedinitialized = 0;
+
+/* The source for the MAL signatures */
+static struct{
+       str filename, source;
+} malSignatures[] = 
+{
+{ "welcome", "io.print(\"Load MAL signatures\");"},
+{ 0, 0}
+}
+;
+str
+malEmbeddedBoot(Client c)
+{
+       int i;
+
+       (void) c;
+       if( embeddedinitialized )
+               return MAL_SUCCEED;
+       for(i = 0; malSignatures[i].filename; i++){
+               fprintf(stderr, "Load the file %s\n", malSignatures[i].source);
+       }
+       embeddedinitialized = 1;
+       return MAL_SUCCEED;
+}
+
+str
+malEmbeddedStop(Client c)
+{
+       (void) c;
+       return MAL_SUCCEED;
+}
+
+str
+malEmbeddedRestart(Client c)
+{
+       (void) c;
+       return MAL_SUCCEED;
+}
diff --git a/monetdb5/mal/mal_embedded.h b/monetdb5/mal/mal_embedded.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/mal/mal_embedded.h
@@ -0,0 +1,26 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+ */
+
+#ifndef _MAL_EMBEDDED_H
+#define _MAL_EMBEDDED_H
+
+#include "monetdb_config.h"
+#include "mal_type.h"
+#include "mal_client.h"
+#include "mal_namespace.h"
+#include "mal_exception.h"
+#include "mal_import.h"
+#include "mal_private.h"
+
+/* #define MAL_EMBEDDED_DEBUG  */
+
+mal_export str malEmbeddedBoot(Client c);
+mal_export str malEmbeddedStop(Client c);
+mal_export str malEmbeddedRestart(Client c);
+
+#endif /*  _MAL_EMBEDDED_H*/
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -19,6 +19,7 @@
 #include "mal_builder.h"
 #include "mal_sabaoth.h"
 #include "mal_private.h"
+#include "mal_embedded.h"
 #include "gdk.h"       /* for opendir and friends */
 
 #ifdef HAVE_EMBEDDED
@@ -64,6 +65,7 @@ malBootstrap(void)
                fprintf(stderr,"#malBootstrap:Failed to create client thread");
                mal_exit();
        }
+       malEmbeddedBoot(c);
        s = malInclude(c, bootfile, 0);
        if (s != NULL) {
                fprintf(stderr, "!%s\n", s);
diff --git a/monetdb5/mal/mal_signatures b/monetdb5/mal/mal_signatures
new file mode 100644
--- /dev/null
+++ b/monetdb5/mal/mal_signatures
@@ -0,0 +1,9 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+ */
+
+{ "welcome", "io.print('Hello')"}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to