Changeset: a1c8eda2276f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a1c8eda2276f
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk_posix.c
        gdk/gdk_private.h
        gdk/gdk_system.c
        gdk/gdk_system.h
        gdk/gdk_utils.c
        gdk/gdk_utils.h
        monetdb5/mal/mal.c
        monetdb5/mal/mal.h
        monetdb5/mal/mal_linker.c
        monetdb5/mal/mal_linker.h
        tools/mserver/mserver5.c
        tools/mserver/shutdowntest.c
Branch: port-monetdblite
Log Message:

Merging MonetDB and MonetDBLite codebases.

Steps done so far:
- Allow the mal linker to accept libmonetdb5 library located in a pre-defined 
location.
- Apapt mal_init and GDKinit for MonetDB and MonetDBLite environments. In the 
later, monet_options is not present.

Still yet to be done:
- MonetDBLite initialization process.
- Compilation setup.
- Stdio output.
- GDKfatal and GDKerror behavior.


diffs (truncated from 852 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -2376,7 +2376,7 @@ void mal_dataflow_reset(void) __attribut
 MT_Lock mal_delayLock;
 void mal_exit(void);
 void mal_factory_reset(void) __attribute__((__visibility__("hidden")));
-int mal_init(void);
+str mal_init(const char* library_path);
 void mal_instruction_reset(void);
 void mal_linker_reset(void) __attribute__((__visibility__("hidden")));
 void mal_module_reset(void) __attribute__((__visibility__("hidden")));
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -704,8 +704,12 @@ MT_path_absolute(const char *pathname)
 void *
 mdlopen(const char *library, int mode)
 {
+#ifndef HAVE_EMBEDDED
        (void) library;
        return dlopen(NULL, mode);
+#else
+       return dlopen(library, mode);
+#endif
 }
 
 #else /* WIN32 native */
@@ -995,14 +999,14 @@ reduce_dir_name(const char *src, char *d
 
 #undef _stat64
 int
-win_stat(const char *pathname, struct _stat64 *st)
+win_stat(const char *pathname, struct stat *st)
 {
        char buf[128], *p = reduce_dir_name(pathname, buf, sizeof(buf));
        int ret;
 
        if (p == NULL)
                return -1;
-       ret = _stat64(p, st);
+       ret = _stat64(p, (struct _stat64*) st);
        if (p != buf)
                free(p);
        return ret;
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -160,6 +160,8 @@ void BBPdump(void)          /* never called: for
 __hidden gdk_return GDKssort(void *restrict h, void *restrict t, const void 
*restrict base, size_t n, int hs, int ts, int tpe)
        __attribute__((__warn_unused_result__))
        __attribute__((__visibility__("hidden")));
+__hidden void gdk_system_init(void)
+       __attribute__((__visibility__("hidden")));
 __hidden void gdk_system_reset(void)
        __attribute__((__visibility__("hidden")));
 __hidden gdk_return GDKunlink(int farmid, const char *dir, const char *nme, 
const char *extension)
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -168,6 +168,15 @@ static CRITICAL_SECTION winthread_cs;
 static bool winthread_cs_init = false;
 
 void
+gdk_system_init(void)
+{
+       if (!winthread_cs_init) {
+               InitializeCriticalSection(&winthread_cs);
+               winthread_cs_init = true;
+       }
+}
+
+void
 gdk_system_reset(void)
 {
        winthread_cs_init = false;
@@ -268,13 +277,6 @@ MT_create_thread(MT_Id *t, void (*f) (vo
        if (w == NULL)
                return -1;
 
-       if (!winthread_cs_init) {
-               /* we only get here before any threads are created,
-                * and this is the only time that winthread_cs_init is
-                * ever changed */
-               InitializeCriticalSection(&winthread_cs);
-               winthread_cs_init = true;
-       }
        join_threads();
        w->func = f;
        w->arg = arg;
@@ -307,6 +309,7 @@ MT_exiting_thread(void)
 void
 MT_exit_thread(int s)
 {
+#ifndef HAVE_EMBEDDED
        if (winthread_cs_init) {
                MT_exiting_thread();
                ExitThread(s);
@@ -314,6 +317,9 @@ MT_exit_thread(int s)
                /* no threads started yet, so this is a global exit */
                MT_global_exit(s);
        }
+#else
+       (void) s;
+#endif
 }
 
 int
@@ -642,10 +648,14 @@ MT_exiting_thread(void)
 void
 MT_exit_thread(int s)
 {
+#ifndef HAVE_EMBEDDED
        int st = s;
 
        MT_exiting_thread();
        pthread_exit(&st);
+#else
+       (void) s;
+#endif
 }
 
 int
@@ -667,7 +677,7 @@ MT_join_thread(MT_Id t)
 int
 MT_kill_thread(MT_Id t)
 {
-#ifdef HAVE_PTHREAD_KILL
+#if defined(HAVE_PTHREAD_KILL) && !defined(HAVE_EMBEDDED)
        pthread_t id;
 #ifdef PTW32
        id.p = (void *) (t - 1);
@@ -731,7 +741,11 @@ pthread_sema_down(pthread_sema_t *s)
 void
 MT_global_exit(int s)
 {
+#ifndef HAVE_EMBEDDED
        exit(s);
+#else
+       (void) s;
+#endif
 }
 
 MT_Id
@@ -789,3 +803,14 @@ MT_check_nr_cores(void)
 
        return ncpus;
 }
+
+int
+MT_check_endianness(void)
+{
+       int num = 1;
+       if(*(char *)&num == 1) {
+               return HOST_LITTLE_ENDIAN;
+       } else {
+               return HOST_BIG_ENDIAN;
+       }
+}
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -384,4 +384,8 @@ typedef struct {
 
 gdk_export int MT_check_nr_cores(void);
 
+#define HOST_LITTLE_ENDIAN 1
+#define HOST_BIG_ENDIAN 2
+gdk_export int MT_check_endianness(void);
+
 #endif /*_GDK_SYSTEM_H_*/
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -78,15 +78,15 @@ static int
 GDKenvironment(const char *dbpath)
 {
        if (dbpath == 0) {
-               fprintf(stderr, "!GDKenvironment: database name missing.\n");
+               mnstr_printf(GDKerr, "!GDKenvironment: database name 
missing.\n");
                return 0;
        }
        if (strlen(dbpath) >= FILENAME_MAX) {
-               fprintf(stderr, "!GDKenvironment: database name too long.\n");
+               mnstr_printf(GDKerr, "!GDKenvironment: database name too 
long.\n");
                return 0;
        }
        if (!MT_path_absolute(dbpath)) {
-               fprintf(stderr, "!GDKenvironment: directory not an absolute 
path: %s.\n", dbpath);
+               mnstr_printf(GDKerr, "!GDKenvironment: directory not an 
absolute path: %s.\n", dbpath);
                return 0;
        }
        return 1;
@@ -211,6 +211,7 @@ GDKlog(FILE *lockFile, const char *forma
        fflush(lockFile);
 }
 
+#ifndef HAVE_EMBEDDED
 /*
  * @+ Interrupt handling
  * The current version simply catches signals and prints a warning.
@@ -269,6 +270,7 @@ BATSIGinit(void)
        return 0;
 }
 #endif /* NATIVE_WIN32 */
+#endif /* HAVE_EMBEDDED */
 
 /* memory thresholds; these values some "sane" constants only, really
  * set in GDKinit() */
@@ -420,7 +422,7 @@ MT_init(void)
 
 #define CATNAP         50      /* time to sleep in ms for catnaps */
 
-static int THRinit(void);
+static int THRinit(bool silent);
 static void GDKlockHome(int farmid);
 
 #ifndef STATIC_CODE_ANALYSIS
@@ -429,15 +431,10 @@ static MT_Lock mallocsuccesslock MT_LOCK
 #endif
 #endif
 
-bool
-GDKinit(opt *set, int setlen)
+static bool
+GDKInitInternal(char* dbpath, bool silent)
 {
-       char *dbpath = mo_find_option(set, setlen, "gdk_dbpath");
-       char *p;
-       opt *n;
-       int i, nlen = 0;
-       int farmid;
-       char buf[16];
+       int i, farmid;
 
        /* some sanity checks (should also find if symbols are not defined) */
        static_assert(sizeof(char) == SIZEOF_CHAR, "error in configure: bad 
value for SIZEOF_CHAR");
@@ -451,7 +448,8 @@ GDKinit(opt *set, int setlen)
        static_assert(sizeof(oid) == SIZEOF_OID, "error in configure: bad value 
for SIZEOF_OID");
        static_assert(sizeof(void *) == SIZEOF_VOID_P, "error in configure: bad 
value for SIZEOF_VOID_P");
        static_assert(sizeof(size_t) == SIZEOF_SIZE_T, "error in configure: bad 
value for SIZEOF_SIZE_T");
-       static_assert(SIZEOF_OID == SIZEOF_INT || SIZEOF_OID == SIZEOF_LNG, 
"SIZEOF_OID should be equal to SIZEOF_INT or SIZEOF_LNG");
+       static_assert(SIZEOF_OID == SIZEOF_INT || SIZEOF_OID == SIZEOF_LNG,
+                                 "SIZEOF_OID should be equal to SIZEOF_INT or 
SIZEOF_LNG");
 
 #ifdef NEED_MT_LOCK_INIT
        MT_lock_init(&MT_system_lock,"MT_system_lock");
@@ -478,14 +476,15 @@ GDKinit(opt *set, int setlen)
        if (!GDKinmemory() && !GDKenvironment(dbpath))
                return 0;
 
-       if ((p = mo_find_option(set, setlen, "gdk_debug")))
-               GDKdebug = strtol(p, NULL, 10);
-
        if (mnstr_init() < 0)
                return 0;
+#if !defined(HAVE_PTHREAD_H) && defined(WIN32)
+       gdk_system_init();
+#endif
        MT_init_posix();
-       if (THRinit() < 0)
+       if (THRinit(silent) < 0)
                return 0;
+#ifndef HAVE_EMBEDDED
 #ifndef NATIVE_WIN32
        if (BATSIGinit() < 0)
                return 0;
@@ -497,6 +496,7 @@ GDKinit(opt *set, int setlen)
        _set_error_mode(_OUT_TO_STDERR);
 #endif
 #endif
+#endif
        MT_init();
        BBP_dirty = true;
 
@@ -508,7 +508,7 @@ GDKinit(opt *set, int setlen)
                        int j;
                        for (j = 0; j < farmid; j++) {
                                if (BBPfarms[j].dirname != NULL &&
-                                   strcmp(BBPfarms[farmid].dirname, 
BBPfarms[j].dirname) == 0) {
+                                       strcmp(BBPfarms[farmid].dirname, 
BBPfarms[j].dirname) == 0) {
                                        skip = 1;
                                        break;
                                }
@@ -528,55 +528,6 @@ GDKinit(opt *set, int setlen)
                        GDK_mmap_minsize_persistent = 
GDK_mmap_minsize_transient;
        }
 
-       n = (opt *) malloc(setlen * sizeof(opt));
-       if (n == NULL)
-               GDKfatal("GDKinit: malloc failed\n");
-       for (i = 0; i < setlen; i++) {
-               int done = 0;
-               int j;
-
-               for (j = 0; j < nlen; j++) {
-                       if (strcmp(n[j].name, set[i].name) == 0) {
-                               if (n[j].kind < set[i].kind) {
-                                       n[j] = set[i];
-                               }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to