Changeset: dd298a028f55 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dd298a028f55
Modified Files:
        CMakeLists.txt
        clients/mapiclient/eventparser.c
        clients/mapiclient/mclient.c
        clients/mapiclient/msqldump.c
        clients/mapilib/mapi.c
        clients/odbc/driver/ODBCConvert.c
        common/stream/stream.c
        common/utils/msabaoth.c
        gdk/gdk_posix.h
        gdk/gdk_utils.c
        geom/monetdb5/geom.c
        monetdb5/modules/kernel/alarm.c
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/mal_mapi.c
        monetdb_config.h.in
        tools/merovingian/daemon/client.c
        tools/merovingian/daemon/connections.c
        tools/merovingian/daemon/controlrunner.c
        tools/merovingian/daemon/proxy.c
        tools/merovingian/utils/control.c
Branch: cmake-fun
Log Message:

Further cleanup:

- Compilation fixes on Windows.
- Removed unecessary tests for POSIX functions available in all supported 
non-Windows platforms.


diffs (truncated from 747 to 300 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -165,7 +165,7 @@ function(MT_addCompilerFlag REGEX_EXPRES
 endfunction()
 
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ${CMAKE_C_COMPILER_ID} 
STREQUAL "Intel")
-       add_definitions(-D_GNU_SOURCE -D_XOPEN_SOURCE)
+       add_definitions(-D_GNU_SOURCE -D_XOPEN_SOURCE) # required for GNU 
extensions
        set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} 
-D_GNU_SOURCE -D_XOPEN_SOURCE") # required for tests
 endif()
 if(${CMAKE_C_COMPILER_ID} STREQUAL "Intel")
@@ -478,7 +478,6 @@ include(FindExtraLibraries)
 # Header files
 check_include_file("libintl.h" HAVE_LIBINTL_H) # Some Linux distributions 
don't have it
 check_include_file("pthread.h" HAVE_PTHREAD_H) # Distinguish between posix 
thread and win32 thread libraries
-check_include_file("sys/mman.h" HAVE_SYS_MMAN_H) # TODO check this
 
 # C types existence
 cmake_push_check_state()
@@ -516,22 +515,13 @@ cmake_pop_check_state()
 
 # Non portable functions
 check_symbol_exists("accept4" "sys/types.h;sys/socket.h" HAVE_ACCEPT4) # Some 
libc versions on Linux distributions don't have it
-check_symbol_exists("asctime_r" "time.h" HAVE_ASCTIME_R)
-check_symbol_exists("asctime_s" "time.h" HAVE_ASCTIME_S)
-check_symbol_exists("ctime_r" "time.h" HAVE_CTIME_R)
-check_symbol_exists("ctime_s" "time.h" HAVE_CTIME_S)
 check_symbol_exists("fallocate" "fcntl.h" HAVE_FALLOCATE) # Linux specific, in 
the future, it might be ported to other platforms
-check_symbol_exists("fcntl" "unistd.h;fcntl.h" HAVE_FCNTL) # Windows has the 
fcntl.h header, but not the function
-check_symbol_exists("localtime_r" "time.h" HAVE_LOCALTIME_R)
-check_symbol_exists("localtime_s" "time.h" HAVE_LOCALTIME_S)
-check_symbol_exists("madvise" "sys/mman.h" HAVE_MADVISE) # TODO check this
+check_symbol_exists("madvise" "sys/mman.h" HAVE_MADVISE) # The Linux kernel 
can be compiled without madvise
 check_symbol_exists("mremap" "sys/mman.h" HAVE_MREMAP) # Linux specific, in 
the future, it might be ported to other platforms
 check_symbol_exists("pipe2" "fcntl.h;unistd.h" HAVE_PIPE2) # Some libc 
versions on Linux distributions don't have it
 check_symbol_exists("posix_fallocate" "fcntl.h" HAVE_POSIX_FALLOCATE) # Some 
POSIX systems don't have it
-check_symbol_exists("posix_madvise" "sys/mman.h" HAVE_POSIX_MADVISE) # TODO 
check this
+check_symbol_exists("posix_madvise" "sys/mman.h" HAVE_POSIX_MADVISE) # The 
Linux kernel can be compiled without madvise, and posix_madvise is implemented 
using madvise
 check_symbol_exists("semtimedop" "sys/types.h;sys/ipc.h;sys/sem.h" 
HAVE_SEMTIMEDOP) # Some libc versions on Linux distributions don't have it
-check_symbol_exists("strtok_r" "string.h" HAVE_STRTOK_R)
-check_symbol_exists("strtok_s" "string.h" HAVE_STRTOK_S)
 
 if(${ENABLE_GDK} STREQUAL "NO")
        if(${ENABLE_MONETDB5} STREQUAL "YES")
diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c
--- a/clients/mapiclient/eventparser.c
+++ b/clients/mapiclient/eventparser.c
@@ -220,12 +220,10 @@ keyvalueparser(char *txt, EventRecord *e
                }
 
                sec = atol(val);
-#if defined(HAVE_LOCALTIME_R)
-               (void)localtime_r(&sec, &curr_time);
-#elif defined(HAVE_LOCALTIME_S)
+#ifdef NATIVE_WIN32
                (void)localtime_s(&curr_time, &sec);
 #else
-               curr_time = *localtime(&sec);
+               (void)localtime_r(&sec, &curr_time);
 #endif
                ev->time = malloc(DATETIME_CHAR_LENGTH*sizeof(char));
                snprintf(ev->time, DATETIME_CHAR_LENGTH, "%d/%02d/%02d 
%02d:%02d:%02d.%s",
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -158,7 +158,7 @@ gettime(void)
 {
        /* Return the time in milliseconds since an epoch.  The epoch
           is roughly the time this program started. */
-#ifdef _MSC_VER
+#ifdef NATIVE_WIN32
        static LARGE_INTEGER freq, start;       /* automatically initialized to 
0 */
        LARGE_INTEGER ctr;
 
@@ -170,7 +170,6 @@ gettime(void)
                QueryPerformanceCounter(&ctr);
                return (timertype) (((ctr.QuadPart - start.QuadPart) * 1000000) 
/ freq.QuadPart);
        }
-#elif defined(NATIVE_WIN32) //let the ftime code stay
        {
                static struct timeb tbbase;     /* automatically initialized to 
0 */
                struct timeb tb;
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -194,12 +194,10 @@ main(int argc, char **argv)
                time_t t = time(0);
                char *p;
 
-#if defined(HAVE_CTIME_R)
-               ctime_r(&t, buf);
-#elif defined(HAVE_CTIME_S)
+#ifdef NATIVE_WIN32
                ctime_s(buf, sizeof(buf), &t);
 #else
-               strncpy(buf, ctime(&t), sizeof(buf));
+               ctime_r(&t, buf);
 #endif
                if ((p = strrchr(buf, '\n')) != NULL)
                        *p = 0;
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -2303,7 +2303,7 @@ mapi_reconnect(Mapi mid)
                                );
                        return mapi_setError(mid, errbuf, "mapi_reconnect", 
MERROR);
                }
-#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && !defined(NATIVE_WIN32)
                (void) fcntl(s, F_SETFD, FD_CLOEXEC);
 #endif
                userver = (struct sockaddr_un) {
@@ -2377,7 +2377,7 @@ mapi_reconnect(Mapi mid)
 #endif
                                   , rp->ai_protocol);
                        if (s != INVALID_SOCKET) {
-#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && !defined(NATIVE_WIN32)
                                (void) fcntl(s, F_SETFD, FD_CLOEXEC);
 #endif
                                if (connect(s, rp->ai_addr, (socklen_t) 
rp->ai_addrlen) != SOCKET_ERROR)
diff --git a/clients/odbc/driver/ODBCConvert.c 
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -2452,12 +2452,10 @@ ODBCFetch(ODBCStmt *stmt,
 
                case SQL_TYPE_TIME:
                                        (void) time(&t);
-#if defined(HAVE_LOCALTIME_R)
-                                       (void) localtime_r(&t, &tm);
-#elif defined(HAVE_LOCALTIME_S)
+#ifdef NATIVE_WIN32
                                        (void) localtime_s(&tm, &t);
 #else
-                                       tm = *localtime(&t);
+                                       (void) localtime_r(&t, &tm);
 #endif
                                        tsval.year = tm.tm_year + 1900;
                                        tsval.month = tm.tm_mon + 1;
@@ -3480,12 +3478,10 @@ ODBCStore(ODBCStmt *stmt,
 
                case SQL_C_TYPE_TIME:
                                        (void) time(&t);
-#if defined(HAVE_LOCALTIME_R)
-                                       (void) localtime_r(&t, &tm);
-#elif defined(HAVE_LOCALTIME_S)
+#ifdef NATIVE_WIN32
                                        (void) localtime_s(&tm, &t);
 #else
-                                       tm = *localtime(&t);
+                                       (void) localtime_r(&t, &tm);
 #endif
                                        tsval.year = tm.tm_year + 1900;
                                        tsval.month = tm.tm_mon + 1;
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -2673,7 +2673,7 @@ socket_open(SOCKET sock, const char *nam
                (void) setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) 
&nodelay, sizeof(nodelay));
        }
 #endif
-#ifdef HAVE_FCNTL
+#ifndef NATIVE_WIN32
        {
                int fl = fcntl(sock, F_GETFL);
 
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -1223,12 +1223,10 @@ msab_deserialise(sabdb **ret, char *sdb)
                s->scens = NULL;
        } else {
                l = s->scens = malloc(sizeof(sablist));
-#if defined(HAVE_STRTOK_R)
-               p = strtok_r(scens, "'", &lasts);
-#elif defined(HAVE_STRTOK_S)
+#ifdef NATIVE_WIN32
                p = strtok_s(scens, "'", &lasts);
 #else
-#error strtok_r function or equivalent not found
+               p = strtok_r(scens, "'", &lasts);
 #endif
                if (p == NULL) {
                        l->val = strdup(scens);
@@ -1236,12 +1234,10 @@ msab_deserialise(sabdb **ret, char *sdb)
                } else {
                        l->val = strdup(p);
                        l->next = NULL;
-#if defined(HAVE_STRTOK_R)
-                       while ((p = strtok_r(NULL, "'", &lasts)) != NULL) {
-#elif defined(HAVE_STRTOK_S)
+#ifdef NATIVE_WIN32
                        while ((p = strtok_s(NULL, "'", &lasts)) != NULL) {
 #else
-#error strtok_r function or equivalent not found
+                       while ((p = strtok_r(NULL, "'", &lasts)) != NULL) {
 #endif
                                l = l->next = malloc(sizeof(sablist));
                                l->val = strdup(p);
diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h
--- a/gdk/gdk_posix.h
+++ b/gdk/gdk_posix.h
@@ -21,6 +21,7 @@
 #include <sys/timeb.h>         /* ftime */
 #else
 #include <sys/time.h>          /* gettimeofday */
+#include <sys/mman.h>
 #endif
 
 /*
@@ -29,19 +30,9 @@
 #define MT_VMUNITLOG   16
 #define MT_VMUNITSIZE  (1 << MT_VMUNITLOG)
 
-/* make sure POSIX_MADV_* and posix_madvise() are defined somehow */
-#ifdef HAVE_SYS_MMAN_H
-# ifndef __USE_BSD
-#  define __USE_BSD
-# endif
-# include <sys/mman.h>
-#endif
-
 #ifdef __linux__
-/* on Linux, posix_madvise does not seem to work, fall back to classic
- * madvise */
+/* on Linux, posix_madvise does not seem to work, fall back to classic madvise 
*/
 #undef HAVE_POSIX_MADVISE
-#undef HAVE_POSIX_FADVISE
 #undef POSIX_MADV_NORMAL
 #undef POSIX_MADV_RANDOM
 #undef POSIX_MADV_SEQUENTIAL
@@ -120,7 +111,6 @@ gdk_export int MT_munmap(void *p, size_t
 
 gdk_export bool MT_path_absolute(const char *path);
 
-
 /*
  * @+ Posix under WIN32
  * WIN32 actually supports many Posix functions directly.  Some it
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -192,12 +192,8 @@ void
 GDKlog(FILE *lockFile, const char *format, ...)
 {
        va_list ap;
-       char *p = 0, buf[1024];
+       char *p = 0, buf[1024], tbuf[26], *ctm;
        time_t tm = time(0);
-#if defined(HAVE_CTIME_R) || defined(HAVE_CTIME_S)
-       char tbuf[26];
-#endif
-       char *ctm;
 
        if (MT_pagesize() == 0 || lockFile == NULL)
                return;
@@ -213,12 +209,10 @@ GDKlog(FILE *lockFile, const char *forma
                ;
 
        fseek(lockFile, 0, SEEK_END);
-#if defined(HAVE_CTIME_R)
-       ctm = ctime_r(&tm, tbuf);
-#elif defined(HAVE_CTIME_S)
+#ifdef NATIVE_WIN32
        ctm = ctime_s(tbuf, sizeof(tbuf), &tm) ? NULL : tbuf;
 #else
-       ctm = ctime(&tm);
+       ctm = ctime_r(&tm, tbuf);
 #endif
        fprintf(lockFile, "USR=%d PID=%d TIME=%.24s @ %s\n", (int) getuid(), 
(int) getpid(), ctm, buf);
        fflush(lockFile);
@@ -1231,7 +1225,7 @@ GDKusec(void)
 {
        /* Return the time in microseconds since an epoch.  The epoch
         * is roughly the time this program started. */
-#ifdef _MSC_VER
+#ifdef NATIVE_WIN32
        static LARGE_INTEGER freq, start;       /* automatically initialized to 
0 */
        LARGE_INTEGER ctr;
 
@@ -1242,10 +1236,20 @@ GDKusec(void)
        if (start.QuadPart > 0) {
                QueryPerformanceCounter(&ctr);
                return (lng) (((ctr.QuadPart - start.QuadPart) * 1000000) / 
freq.QuadPart);
-       } else {
-               return -1;
        }
-#elif defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
+       {
+               static struct timeb tbbase;     /* automatically initialized to 
0 */
+               struct timeb tb;
+
+               if (tbbase.time == 0) {
+                       ftime(&tbbase);
+                       return (lng) tbbase.millitm * 1000;
+               }
+               ftime(&tb);
+               return (lng) (tb.time - tbbase.time) * 1000000 + (lng) 
tb.millitm * 1000;
+       }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to