Changeset: 8a6543eed2b2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8a6543eed2b2
Removed Files:
monetdb_config_win32.h.in
Modified Files:
CMakeLists.txt
cmake/monetdb-defines.cmake
cmake/monetdb-toolchain.cmake
common/utils/msabaoth.c
common/utils/mutils.c
common/utils/mutils.h
monetdb_config.h.in
unistd.h.in
Branch: default
Log Message:
Merged monetdb_config*.h.in and made it all compile again on Windows.
diffs (truncated from 823 to 300 lines):
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -106,14 +106,11 @@ set(PROGRAM_PERMISSIONS_DEFAULT
find_program(BASH NAMES bash DOC "bash interpreter fullpath")
+configure_file(monetdb_config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/monetdb_config.h)
if(WIN32)
- configure_file(monetdb_config_win32.h.in
- ${CMAKE_CURRENT_BINARY_DIR}/monetdb_config.h)
configure_file(unistd.h.in
${CMAKE_CURRENT_BINARY_DIR}/unistd.h)
-else()
- configure_file(monetdb_config.h.in
- ${CMAKE_CURRENT_BINARY_DIR}/monetdb_config.h)
endif()
add_library(monetdb_config_header
diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -292,6 +292,12 @@ macro(monetdb_configure_sizes)
check_type_size(long SIZEOF_LONG LANGUAGE C)
check_type_size(wchar_t SIZEOF_WCHAR_T LANGUAGE C)
check_type_size(socklen_t HAVE_SOCKLEN_T LANGUAGE C)
+ check_type_size(pid_t SIZEOF_PID_T LANGUAGE C)
+ if(NOT HAVE_SIZEOF_PID_T)
+ # Set a default value
+ set(pid_t "int")
+ set(SIZEOF_PID_T ${CMAKE_SIZEOF_INT})
+ endif()
if(INT128)
cmake_push_check_state()
diff --git a/cmake/monetdb-toolchain.cmake b/cmake/monetdb-toolchain.cmake
--- a/cmake/monetdb-toolchain.cmake
+++ b/cmake/monetdb-toolchain.cmake
@@ -65,7 +65,14 @@ function(monetdb_default_toolchain)
MT_checkCompilerFlag("-Wunreachable-code")
elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Intel")
- MT_addCompilerFlag("${COMPILER_OPTION}Wall" "${COMPILER_OPTION}Wall"
"${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
+ if(WIN32)
+ set(COMPILER_OPTION "/")
+# MT_addCompilerFlag("${COMPILER_OPTION}DNO_ATOMIC_INSTRUCTIONS"
"${COMPILER_OPTION}DNO_ATOMIC_INSTRUCTIONS=1" "${CMAKE_C_FLAGS}" "all"
CMAKE_C_FLAGS)
+ MT_addCompilerFlag("${COMPILER_OPTION}W3" "${COMPILER_OPTION}W3"
"${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
+ else()
+ set(COMPILER_OPTION "-")
+ MT_addCompilerFlag("${COMPILER_OPTION}Wall" "${COMPILER_OPTION}Wall"
"${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
+ endif()
MT_addCompilerFlag("${COMPILER_OPTION}Wcheck" "${COMPILER_OPTION}Wcheck"
"${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
MT_addCompilerFlag("${COMPILER_OPTION}Werror-all"
"${COMPILER_OPTION}Werror-all" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
MT_addCompilerFlag("${COMPILER_OPTION}${INTEL_OPTION_EXTRA}wd2259"
"${COMPILER_OPTION}${INTEL_OPTION_EXTRA}wd2259" "${CMAKE_C_FLAGS}" "all"
CMAKE_C_FLAGS)
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -38,6 +38,7 @@
#define close _close
#define unlink _unlink
#define fdopen _fdopen
+#define fileno _fileno
#endif
#ifdef HAVE_OPENSSL
@@ -49,6 +50,10 @@
#endif
#endif
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
/** the directory where the databases are (aka dbfarm) */
static char *_sabaoth_internal_dbfarm = NULL;
/** the database which is "active" */
@@ -668,6 +673,37 @@ msab_getMyStatus(sabdb** ret)
#define MAINTENANCEFILE ".maintenance"
+/* returns pid of the process holding the gdk lock, or 0 if that is not
possible.
+ * 'not possible' could be for a variety of reasons.
+ */
+static pid_t
+MT_get_locking_pid(const char *filename)
+{
+#if !defined(HAVE_FCNTL) || !defined(HAVE_F_GETLK)
+ (void)filename;
+ return 0;
+#else
+ int fd;
+ struct flock fl = {
+ .l_type = F_WRLCK,
+ .l_whence = SEEK_SET,
+ .l_start = 4,
+ .l_len = 1,
+ };
+ pid_t pid = 0;
+
+ fd = open(filename, O_RDONLY | O_CLOEXEC, 0);
+ if (fd < 0)
+ return 0;
+
+ if (fcntl(fd, F_GETLK, &fl) == 0)
+ pid = fl.l_pid;
+
+ close(fd);
+ return pid;
+#endif
+}
+
static sabdb *
msab_getSingleStatus(const char *pathbuf, const char *dbname, sabdb *next)
{
diff --git a/common/utils/mutils.c b/common/utils/mutils.c
--- a/common/utils/mutils.c
+++ b/common/utils/mutils.c
@@ -37,8 +37,6 @@
/* Some definitions that we need to compile on Windows.
* Note that Windows only runs on little endian architectures. */
-typedef unsigned int u_int32_t;
-typedef int int32_t;
#define BIG_ENDIAN 4321
#define LITTLE_ENDIAN 1234
#define BYTE_ORDER LITTLE_ENDIAN
@@ -421,37 +419,6 @@ MT_lockf(char *filename, int mode)
return -1;
}
-/* returns pid of the process holding the gdk lock, or 0 if that is not
possible.
- * 'not possible' could be for a variety of reasons.
- */
-pid_t
-MT_get_locking_pid(char *filename)
-{
-#if !defined(HAVE_FCNTL) || !defined(HAVE_F_GETLK)
- (void)filename;
- return 0;
-#else
- int fd;
- struct flock fl = {
- .l_type = F_WRLCK,
- .l_whence = SEEK_SET,
- .l_start = 4,
- .l_len = 1,
- };
- pid_t pid = 0;
-
- fd = open(filename, O_RDONLY | O_CLOEXEC, 0);
- if (fd < 0)
- return 0;
-
- if (fcntl(fd, F_GETLK, &fl) == 0)
- pid = fl.l_pid;
-
- close(fd);
- return pid;
-#endif
-}
-
#endif
#ifndef PATH_MAX
diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -68,7 +68,6 @@ mutils_export char *dirname(char *path);
#define F_LOCK 1 /* lock a region for exclusive use */
mutils_export int MT_lockf(char *filename, int mode);
-mutils_export pid_t MT_get_locking_pid(char *filename);
mutils_export void print_trace(void);
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -10,21 +10,61 @@
#ifndef MT_SEEN_MONETDB_CONFIG_H
#define MT_SEEN_MONETDB_CONFIG_H 1
+#ifdef _MSC_VER
+
+#if _MSC_VER < 1900
+#error Versions bellow Visual Studio 2015 are no longer supported
+#endif
+
+/* Prevent pollution through excessive inclusion of include files by
Windows.h. */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+
+/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+
+#endif
+
+#include <stdlib.h>
+#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
+/* In this case, malloc and friends are redefined in crtdbg.h to debug
+ * versions. We need to include stdlib.h first or else we get
+ * conflicting declarations. */
+#include <crtdbg.h>
+#endif
+
#cmakedefine HAVE_SYS_TYPES_H 1
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
-/* C99 standard includes */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+/* standard C-99 include files */
+#include <assert.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <stdarg.h>
+#include <stdbool.h>
#include <stddef.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef _MSC_VER
+
+/* Windows include files */
+#include <process.h>
+#include <windows.h>
+#include <ws2tcpip.h>
+
+/* indicate to sqltypes.h that windows.h has already been included and
+ that it doesn't have to define Windows constants */
+#define ALREADY_HAVE_WINDOWS_TYPE 1
+
+#define NATIVE_WIN32 1
+
+#endif /* _MSC_VER */
// Section: monetdb configure defines
#cmakedefine HAVE_DISPATCH_DISPATCH_H 1
@@ -156,10 +196,17 @@
#cmakedefine HAVE_GETADDRINFO 1
#cmakedefine HAVE_CUDF 1
+#ifdef _MSC_VER
+#define DIR_SEP '\\'
+#define PATH_SEP ';'
+#define DIR_SEP_STR "\\"
+#define SO_PREFIX ""
+#else
#cmakedefine DIR_SEP '@DIR_SEP@'
#cmakedefine PATH_SEP '@PATH_SEP@'
#cmakedefine DIR_SEP_STR "@DIR_SEP_STR@"
#cmakedefine SO_PREFIX "@SO_PREFIX@"
+#endif
#cmakedefine SO_EXT "@SO_EXT@"
#cmakedefine BINDIR "@BINDIR@"
@@ -188,6 +235,7 @@
#define VERSION "@MONETDB_VERSION@"
#define PACKAGE_VERSION "@MONETDB_VERSION@"
#define PACKAGE_NAME "MonetDB"
+#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION
/* Host identifier */
#cmakedefine HOST "@HOST@"
@@ -243,6 +291,9 @@
#ifndef ssize_t
#cmakedefine ssize_t @ssize_t@
#endif
+#ifndef pid_t
+#cmakedefine pid_t @pid_t@
+#endif
/* The size of `__int128', as computed by sizeof. */
#cmakedefine SIZEOF___INT128 @SIZEOF___INT128@
@@ -253,7 +304,7 @@
/* The size of `__uint128_t', as computed by sizeof. */
#cmakedefine SIZEOF___UINT128_T @SIZEOF___UINT128_T@
-#if defined(SIZEOF___INT128)
+#ifdef SIZEOF___INT128
typedef __int128 hge;
typedef unsigned __int128 uhge;
#define HAVE_HGE 1
@@ -267,20 +318,83 @@ typedef __uint128_t uhge;
// End Section: monetdb configure sizes
+/* Does your compiler support `__attribute__' extension? */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list