diff --git a/acx_pthread.m4 b/acx_pthread.m4 index bedf51c32af..8b7271fbf19 100644 --- a/acx_pthread.m4 +++ b/acx_pthread.m4 @@ -74,6 +74,9 @@ case "${host_cpu}-${host_os}" in acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" ;; + *mingw*) + acx_pthread_flags="none" + ;; esac if test x"$acx_pthread_ok" = xno; then diff --git a/builds/posix/Makefile.in b/builds/posix/Makefile.in index d2871b3dca2..8fd479d238e 100644 --- a/builds/posix/Makefile.in +++ b/builds/posix/Makefile.in @@ -315,7 +315,7 @@ $(RE2_LIB): $(RE2_Objs) libcds: mkdir -p $(LIBCDS)/lib/$(TARGET) cd $(LIBCDS)/lib/$(TARGET); \ - cmake -DCMAKE_BUILD_TYPE=$(FB_CMAKE_BUILD_TYPE) -DCMAKE_CXX_COMPILER="$(CXX)" -DCMAKE_CXX_FLAGS=-fPIC $(LIBCDS) + cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$(FB_CMAKE_BUILD_TYPE) -DCMAKE_CXX_COMPILER="$(CXX)" -DCMAKE_CXX_FLAGS=-fPIC $(LIBCDS) AR="$(AR)" $(MAKE) -C $(LIBCDS)/lib/$(TARGET) ifeq ($(TARGET),Debug) @@ -551,10 +551,15 @@ $(LIBIBUTIL_SO): $(UTIL_Objects) utilities: firebird_server fb_lock_print fbguard fbsvcmgr fbtracemgr gbak gfix gsec gsplit gstat isql nbackup udfsupport +ifeq ($(PLATFORM),win32) +.PHONY: instreg instsvc instclient +utilities +: instreg instsvc instclient +endif + firebird_server: $(FB_DAEMON) $(FB_DAEMON): $(Remote_Server_Objects) $(COMMON_LIB) - $(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + $(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LIB_GUI) $(LINK_LIBS) fb_lock_print: $(LOCKPRINT) @@ -564,7 +569,7 @@ $(LOCKPRINT): $(LOCKPRINT_Objects) $(COMMON_LIB) fbguard: $(FBGUARD) $(FBGUARD): $(FBGUARD_Objects) $(COMMON_LIB) - $(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + $(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LIB_GUI) $(LINK_LIBS) fbsvcmgr: $(FBSVCMGR) @@ -614,6 +619,21 @@ nbackup: $(NBACKUP) $(NBACKUP): $(NBACKUP_Objects) $(COMMON_LIB) $(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) +instreg: $(INSTREG) + +$(INSTREG): $(INSTREG_Objects) $(COMMON_LIB) + $(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +instsvc: $(INSTSVC) + +$(INSTSVC): $(INSTSVC_Objects) $(COMMON_LIB) + $(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + +instclient: $(INSTCLIENT) + +$(INSTCLIENT): $(INSTCLIENT_Objects) $(COMMON_LIB) + $(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) + #___________________________________________________________________________ # plugins - some of them are required to build examples, use separate entry for them @@ -636,6 +656,8 @@ ifeq ($(TARGET),Debug) BUILD_DEBUG:=auth_debug endif +PLUGIN_SONAME=$(notdir $@).0 + plugins: udr legacy_user_management legacy_auth_server srp_user_management trace $(BUILD_DEBUG) udf_compat chacha profiler udr: $(UDR_PLUGIN) $(PLUGINS)/udr_engine.conf @@ -644,31 +666,31 @@ $(PLUGINS)/udr_engine.conf: $(ROOT)/src/plugins/udr_engine/udr_engine.conf cp $^ $@ $(UDR_PLUGIN): $(UDRENG_Objects) $(COMMON_LIB) - $(LINK_UDRENG) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_UDRENG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ + $(LINK_UDRENG) $(call LIB_LINK_SONAME,$(PLUGIN_SONAME)) -o $@ $^ $(LINK_UDRENG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/libudr_engine.$(SHRLIB_EXT)) legacy_user_management: $(LEGACY_USER_MANAGER) $(LEGACY_USER_MANAGER): $(LEGACY_USERS_MANAGE_Objects) $(COMMON_LIB) - $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(RE2LIB) $(FIREBIRD_LIBRARY_LINK)\ + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(PLUGIN_SONAME)) -o $@ $^ $(LINK_PLUG_LIBS) $(RE2LIB) $(FIREBIRD_LIBRARY_LINK)\ $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/libLegacy_UserManager.$(SHRLIB_EXT)) chacha: $(CHACHA) $(CHACHA): $(Chacha_Objects) $(COMMON_LIB) - $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(PLUGIN_SONAME)) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/libChaCha.$(SHRLIB_EXT)) legacy_auth_server: $(LEGACY_AUTH_SERVER) $(LEGACY_AUTH_SERVER): $(LEGACY_AUTH_SERVER_Objects) $(COMMON_LIB) - $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(PLUGIN_SONAME)) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/libLegacy_Auth.$(SHRLIB_EXT)) profiler: $(PROFILER) $(PROFILER): $(Profiler_Objects) $(COMMON_LIB) - $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(PLUGIN_SONAME)) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/libDefault_Profiler.$(SHRLIB_EXT)) trace: $(FBTRACE) @@ -679,13 +701,13 @@ $(FBTRACE): $(FBTRACE_UTIL_Objects) $(COMMON_LIB) auth_debug: $(AUTH_DEBUGGER) $(AUTH_DEBUGGER): $(AUTH_DEBUGGER_Objects) $(COMMON_LIB) - $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(PLUGIN_SONAME)) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/libAuth_Debug.$(SHRLIB_EXT)) srp_user_management: $(SRP_USER_MANAGER) $(SRP_USER_MANAGER): $(SRP_USERS_MANAGE_Objects) $(COMMON_LIB) - $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(PLUGIN_SONAME)) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK)\ $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/libSrp.$(SHRLIB_EXT)) udf_compat: $(UDF_BACKWARD_COMPATIBILITY) $(COMPAT_SQL) diff --git a/builds/posix/Makefile.in.examples b/builds/posix/Makefile.in.examples index d0f89738301..86a9cf256b6 100644 --- a/builds/posix/Makefile.in.examples +++ b/builds/posix/Makefile.in.examples @@ -67,8 +67,11 @@ export PATH #endif GPRE_FLAGS= -m -z -n +ifneq ($(PLATFORM),win32) +LIB_PREFIX = lib LIB_LINK_RPATH = $(call LIB_PLATFORM_RPATH,$(if $(subst intl,,$(1)),$(LIB),$(LIB)/../intl)) LINK_DARWIN_RPATH = -Wl,-rpath,@loader_path/../$(TARGET)/firebird +endif LIB_LINK_MAPFILE = EXAMPLES_DEST= $(GEN_ROOT)/examples @@ -91,7 +94,7 @@ EMPLOYEE_DB= $(EXAMPLES_DEST)/employee.fdb FINAL_EMPDB= $(EXAMPLES_FB)/empbuild/employee.fdb INTLEMP_DB= $(EXAMPLES_DEST)/intlemp.fdb -EXTAUTH_PLUGIN= $(EXAMPLES_FB)/prebuilt/libfbSampleExtAuth.$(SHRLIB_EXT) +EXTAUTH_PLUGIN= $(EXAMPLES_FB)/prebuilt/$(LIB_PREFIX)fbSampleExtAuth.$(SHRLIB_EXT) .PHONY: all examples diff --git a/examples/extauth/Makefile b/builds/posix/Makefile.in.extauth similarity index 86% rename from examples/extauth/Makefile rename to builds/posix/Makefile.in.extauth index 9da7bbd357f..933ef28c10a 100644 --- a/examples/extauth/Makefile +++ b/builds/posix/Makefile.in.extauth @@ -28,7 +28,9 @@ BIN=$(ROOT)/bin LIB=$(ROOT)/lib LIB_PREFIX=lib -SHRLIB_EXT=so +SHRLIB_EXT=@SHRLIB_EXT@ +EXEC_EXT=@EXEEXT@ +PLATFORM=@PLATFORM@ ifndef INTERMED INTERMED=. @@ -42,7 +44,12 @@ else OUT_PLUG=. endif +ifeq ($(PLATFORM),win32) +LIB_PREFIX= +TOMCRYPT_COMPILE=-DUSE_LTM -DLTM_DESC +else TOMCRYPT_COMPILE=-DLTC_PTHREAD -DUSE_LTM -DLTM_DESC +endif OwnInclude=$(shell [ -d tomcrypt.include ] && echo Yes || echo No) ifeq ($(OwnInclude), Yes) TOMCRYPT_COMPILE += -Itomcrypt.include @@ -53,7 +60,7 @@ SIMPLE_KEY_AUTH_NAME=$(LIB_PREFIX)fbSampleExtAuth.$(SHRLIB_EXT) BLD_SIMPLE_KEY_AUTH=$(OUT_PLUG)/$(SIMPLE_KEY_AUTH_NAME) SIMPLE_KEY_AUTH=$(PLUGINS)/$(SIMPLE_KEY_AUTH_NAME) -KEYGEN_NAME=fbSampleExtAuthKeygen +KEYGEN_NAME=fbSampleExtAuthKeygen$(EXEC_EXT) BLD_KEYGEN=$(OUT_BIN)/$(KEYGEN_NAME) KEYGEN=$(BIN)/$(KEYGEN_NAME) @@ -61,8 +68,13 @@ KEYGEN_objects=$(INTERMED)/keygen.o TCWRAP_objects=$(INTERMED)/TcWrapper.o KEY_AUTH_objects=$(INTERMED)/ExtAuth.o -CXXFLAGS=-std=c++11 -pthread -I$(ROOT)/include -fPIC $(TOMCRYPT_COMPILE) +ifeq ($(PLATFORM),win32) +CXXFLAGS=-std=c++17 -I$(ROOT)/include $(TOMCRYPT_COMPILE) +LDFLAGS=-L$(LIB) +else +CXXFLAGS=-std=c++17 -pthread -I$(ROOT)/include -fPIC $(TOMCRYPT_COMPILE) LDFLAGS=-pthread -L$(LIB) -Wl,-rpath,'$$ORIGIN/../lib' $(TOMCRYPT_LINK) +endif LINK_LIBS=-lfbclient -ltomcrypt -ltommath diff --git a/builds/posix/Makefile.in.plugins_examples b/builds/posix/Makefile.in.plugins_examples index 641c5104884..1a95e4a27f7 100644 --- a/builds/posix/Makefile.in.plugins_examples +++ b/builds/posix/Makefile.in.plugins_examples @@ -60,6 +60,16 @@ include $(ROOT)/gen/make.shared.variables all: udrcpp_example dc_example kh_example crypt_app +ifeq ($(PLATFORM),win32) +PLUGIN_SONAME=$(notdir $@) +PLUGINS_DIR=$(FIREBIRD)/examples/prebuilt/plugins +SAMPLES_DIR=$(FIREBIRD)/examples/prebuilt/bin +makePluginName=$(PLUGINS_DIR)/$(1).$(SHRLIB_EXT) +else +PLUGIN_SONAME=$(notdir $@).0 +PLUGINS_DIR=$(PLUGINS) +SAMPLES_DIR=$(BIN) +endif UDR_Objects = $(call dirObjects,../examples/udr) UDR_Plugin = $(PLUGINS)/udr/$(LIB_PREFIX)udrcpp_example.$(SHRLIB_EXT) @@ -72,7 +82,7 @@ ifeq ($(PLATFORM),DARWIN) $(LIB_LINK) $(LIB_BUNDLE_OPTIONS) -o $@ $^ @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ \ $(FIREBIRD_LIBRARY_LINK) else - $(LIB_LINK) $(LIB_LINK_OPTIONS) $(LIB_LINK_SONAME)udrcpp_example.$(SHRLIB_EXT) \ + $(LIB_LINK) $(LIB_LINK_OPTIONS) $(call LIB_LINK_SONAME,udrcpp_example.$(SHRLIB_EXT)) \ $(LIB_PATH_OPTS) -o $@ $^ $(THR_LIBS) \ $(FIREBIRD_LIBRARY_LINK) endif @@ -85,8 +95,8 @@ AllObjects += $(DC_Objects) dc_example: $(DC_Plugin) $(DC_Plugin): $(DC_Objects) - $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK) - $(CP) $(EXA_ROOT)/dbcrypt/fbSampleDbCrypt.conf $(PLUGINS) + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(PLUGIN_SONAME)) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK) + $(CP) $(EXA_ROOT)/dbcrypt/fbSampleDbCrypt.conf $(PLUGINS_DIR) KH_Objects = $(call makeObjects,../examples/dbcrypt,CryptKeyHolder.cpp) @@ -96,12 +106,12 @@ AllObjects += $(KH_Objects) kh_example: $(KH_Plugin) $(KH_Plugin): $(KH_Objects) - $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(notdir $@).0) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK) - $(CP) $(EXA_ROOT)/dbcrypt/fbSampleKeyHolder.conf $(PLUGINS) + $(LINK_PLUGIN) $(call LIB_LINK_SONAME,$(PLUGIN_SONAME)) -o $@ $^ $(LINK_PLUG_LIBS) $(FIREBIRD_LIBRARY_LINK) + $(CP) $(EXA_ROOT)/dbcrypt/fbSampleKeyHolder.conf $(PLUGINS_DIR) CA_Objects = $(call makeObjects,../examples/dbcrypt,CryptApplication.cpp) -CRYPT_APP = $(BIN)/fbSampleDbCryptApp$(EXEC_EXT) +CRYPT_APP = $(SAMPLES_DIR)/fbSampleDbCryptApp$(EXEC_EXT) AllObjects += $(CA_Objects) crypt_app: $(CRYPT_APP) diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults index 3c28683f6f8..e472d624cbb 100755 --- a/builds/posix/make.defaults +++ b/builds/posix/make.defaults @@ -172,7 +172,7 @@ INLINE_EDIT_SED:= -i SH= sh -c RM= rm -f -RM_R= rm -rf +RM_R= rm -rf CHMOD= chmod CHMOD_6= chmod 666 CHMOD_7= chmod 777 @@ -196,6 +196,7 @@ CXX = @CXX@ LD = @CXX@ OBJCOPY = @OBJCOPY@ READELF = @READELF@ +WINDRES = @WINDRES@ AC_CFLAGS = @CFLAGS@ AC_CXXFLAGS = @CXXFLAGS@ @@ -215,7 +216,7 @@ SO_LINK_LIBS = @LIBS@ $(DECLIB) $(I128LIB) ARCH_EXT= .a EXEC_EXT= @EXEEXT@ -SHRLIB_EXT=@SHRLIB_EXT@ +SHRLIB_EXT= @SHRLIB_EXT@ LIB_PREFIX= lib SHRLIB_FOREIGN_EXT= $(SHRLIB_EXT) @@ -233,7 +234,7 @@ include $(ROOT)/gen/Make.Version vpath %.so $(LIB) vpath %.a $(LIB) -vpath %.dll $(LIB) +vpath %.dll $(BIN) #_____________________________________________________________________________ @@ -357,7 +358,7 @@ endif LIB_PATH_OPTS = $(call LIB_LINK_RPATH,lib) $(call LIB_LINK_RPATH,intl) LIB_LINK_SONAME= -Wl,-soname,$(1) LIB_LINK_MAPFILE= -Wl,--version-script,$(1) -FIREBIRD_LIBRARY_LINK= -L$(LIB) -L$(STATIC_LIB) -lfbclient $(MATHLIB) $(CRYPTLIB) +FIREBIRD_LIBRARY_LINK= -L$(LIB) -L$(STATIC_LIB) -lfbclient $(CRYPTLIB) $(MATHLIB) EXE_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) $(call LINK_DARWIN_RPATH,..) $(LINK_EMPTY_SYMBOLS) LIB_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) -shared @@ -383,7 +384,7 @@ LINK_TRACE_LIBS = -L$(LIB) -L$(STATIC_LIB) $(SO_LINK_LIBS) LINK_FIREBIRD = $(LIB_LINK) $(LINK_FIREBIRD_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_FIREBIRD_OPTIONS) $(UNDEF_FLAGS)\ $(call LIB_LINK_SONAME,$(LibrarySoName)) $(call LIB_LINK_RPATH,lib) $(call LINK_DARWIN_RPATH,..) -LINK_FIREBIRD_LIBS = -L$(LIB) -L$(STATIC_LIB) $(LIB_GUI) $(SO_LINK_LIBS) $(MATHLIB) +LINK_FIREBIRD_LIBS = -L$(LIB) -L$(STATIC_LIB) $(LIB_GUI) $(SO_LINK_LIBS) $(CRYPTLIB) $(MATHLIB) LINK_ENGINE = $(LIB_LINK) $(LINK_PLUGIN_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_FIREBIRD_OPTIONS) $(UNDEF_FLAGS)\ $(call LIB_LINK_SONAME,$(EngineSoName)) $(call LIB_LINK_RPATH,lib) $(call LINK_DARWIN_RPATH,..) @@ -414,6 +415,7 @@ RUN_GFIX = $(RBIN)/gfix$(EXEC_EXT) FBGUARD = $(BIN)/fbguard$(EXEC_EXT) INSTREG = $(BIN)/instreg$(EXEC_EXT) INSTSVC = $(BIN)/instsvc$(EXEC_EXT) +INSTCLIENT = $(BIN)/instclient$(EXEC_EXT) SECURITY_FDB = $(FIREBIRD)/security6.fdb diff --git a/builds/posix/make.rules b/builds/posix/make.rules index 3bbd2580fea..82c150249bb 100644 --- a/builds/posix/make.rules +++ b/builds/posix/make.rules @@ -147,8 +147,8 @@ $(OBJ)/%.o: $(ROOT)/%.cpp # Rules for making resource files -$(GEN_ROOT)/%.res: $(SRC_ROOT)/%.rc - windres --output-format=coff --include-dir=$( #include -using std::auto_ptr; +using std::unique_ptr; using std::cerr; using std::endl; using std::exception; @@ -66,7 +66,7 @@ static void run(int argc, const char* argv[]) Parser parser(&lexer); parser.parse(); - auto_ptr generator; + unique_ptr generator; if (outFormat == "c++") { diff --git a/extern/ttmath/ttmathtypes.h b/extern/ttmath/ttmathtypes.h index 3d9ddbe7b0b..ac92fc8e98f 100644 --- a/extern/ttmath/ttmathtypes.h +++ b/extern/ttmath/ttmathtypes.h @@ -158,7 +158,7 @@ namespace ttmath /*! on 32 bit platform ulint and slint will be equal 64 bits */ - #ifdef _MSC_VER + #ifdef _WIN32 // long long on MS Windows (Visual and GCC mingw compilers) have 64 bits // stdint.h is not available on Visual Studio prior to VS 2010 version typedef unsigned long long int ulint; @@ -205,7 +205,7 @@ namespace ttmath /*! on 64bit platforms one word (uint, sint) will be equal 64bits */ - #ifdef _MSC_VER + #ifdef _WIN32 /* in VC 'long' type has 32 bits, __int64 is VC extension */ typedef unsigned __int64 uint; typedef signed __int64 sint; diff --git a/src/common/classes/FpeControl.h b/src/common/classes/FpeControl.h index bffe8759077..a1428c1a11e 100644 --- a/src/common/classes/FpeControl.h +++ b/src/common/classes/FpeControl.h @@ -30,7 +30,7 @@ #define CLASSES_FPE_CONTROL_H #include -#if defined(WIN_NT) +#if defined(_MSC_VER) #include #else #include @@ -78,7 +78,7 @@ class FpeControl } } -#if defined(WIN_NT) +#if defined(_MSC_VER) static void maskAll() noexcept { _clearfp(); // always call _clearfp() before setting control word @@ -215,7 +215,7 @@ class FpeControl inline bool isNegativeInf(double x) { -#ifdef WIN_NT +#ifdef _MSC_VER return _fpclass(x) == _FPCLASS_NINF; #else return x == -INFINITY; diff --git a/src/common/isc_sync.cpp b/src/common/isc_sync.cpp index 9a3d98bce9c..ccc899e317b 100644 --- a/src/common/isc_sync.cpp +++ b/src/common/isc_sync.cpp @@ -1847,7 +1847,11 @@ SharedMemoryBase::SharedMemoryBase(const TEXT* filename, ULONG length, IpcObject } PathName mappedName; +#ifdef MINGW + if (!getMappedFileName(address, mappedName)) +#else if (!getMappedFileName(address, mappedName) || mappedName != expanded_filename) +#endif { UnmapViewOfFile(address); CloseHandle(file_obj); @@ -2096,7 +2100,7 @@ static const int DEFAULT_INTERLOCKED_SPIN_COUNT_SMP = 200; static SLONG pid = 0; -typedef WINBASEAPI BOOL (WINAPI *pfnSwitchToThread) (); +typedef BOOL (WINAPI *pfnSwitchToThread) (); static inline BOOL switchToThread() { static pfnSwitchToThread fnSwitchToThread = NULL; diff --git a/src/common/os/win32/pathtools.cpp b/src/common/os/win32/pathtools.cpp new file mode 100644 index 00000000000..3c5963f303f --- /dev/null +++ b/src/common/os/win32/pathtools.cpp @@ -0,0 +1,582 @@ +/* + .Some useful path tools. + .ASCII only for now. + .Written by Ray Donnelly in 2014. + .Licensed under CC0 (and anything. + .else you need to license it under). + .No warranties whatsoever. + .email: . + */ + +#if defined(__MINGW32__) + +#if defined(__APPLE__) +#include +#else +#include +#endif +#include +#include +#include +#if defined(__linux__) || defined(__CYGWIN__) || defined(__MSYS__) +#include +#endif +#include + +/* If you don't define this, then get_executable_path() + can only use argv[0] which will often not work well */ +#define IMPLEMENT_SYS_GET_EXECUTABLE_PATH + +#if defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) +#if defined(__linux__) || defined(__CYGWIN__) || defined(__MSYS__) +/* Nothing needed, unistd.h is enough. */ +#elif defined(__APPLE__) +#include +#elif defined(_WIN32) +#define WIN32_MEAN_AND_LEAN +#include +#include +#endif +#endif /* defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) */ + +#include "../common/pathtools.h" + +char * +malloc_copy_string(char const * original) +{ + char * result = (char *) malloc (sizeof (char*) * strlen (original)+1); + if (result != NULL) + { + strcpy (result, original); + } + return result; +} + +void +sanitise_path(char * path) +{ + size_t path_size = strlen (path); + + /* Replace any '\' with '/' */ + char * path_p = path; + while ((path_p = strchr (path_p, '\\')) != NULL) + { + *path_p = '/'; + } + /* Replace any '//' with '/' */ + path_p = path + !!*path; /* skip first character, if any, to handle UNC paths correctly */ + while ((path_p = strstr (path_p, "//")) != NULL) + { + memmove (path_p, path_p + 1, path_size--); + } + return; +} + +char * +get_relative_path(char const * from_in, char const * to_in) +{ + size_t from_size = (from_in == NULL) ? 0 : strlen (from_in); + size_t to_size = (to_in == NULL) ? 0 : strlen (to_in); + size_t max_size = (from_size + to_size) * 2 + 4; + char * scratch_space = (char *) alloca (from_size + 1 + to_size + 1 + max_size + max_size); + char * from; + char * to; + char * common_part; + char * result; + size_t count; + + /* No to, return "./" */ + if (to_in == NULL) + { + return malloc_copy_string ("./"); + } + + /* If alloca failed or no from was given return a copy of to */ + if ( from_in == NULL + || scratch_space == NULL ) + { + return malloc_copy_string (to_in); + } + + from = scratch_space; + strcpy (from, from_in); + to = from + from_size + 1; + strcpy (to, to_in); + common_part = to + to_size + 1; + result = common_part + max_size; + simplify_path (from); + simplify_path (to); + + result[0] = '\0'; + + size_t match_size_dirsep = 0; /* The match size up to the last /. Always wind back to this - 1 */ + size_t match_size = 0; /* The running (and final) match size. */ + size_t largest_size = (from_size > to_size) ? from_size : to_size; + int to_final_is_slash = (to[to_size-1] == '/') ? 1 : 0; + char from_c; + char to_c; + for (match_size = 0; match_size < largest_size; ++match_size) + { + /* To simplify the logic, always pretend the strings end with '/' */ + from_c = (match_size < from_size) ? from[match_size] : '/'; + to_c = (match_size < to_size) ? to[match_size] : '/'; + + if (from_c != to_c) + { + if (from_c != '\0' || to_c != '\0') + { + match_size = match_size_dirsep; + } + break; + } + else if (from_c == '/') + { + match_size_dirsep = match_size; + } + } + strncpy (common_part, from, match_size); + common_part[match_size] = '\0'; + from += match_size; + to += match_size; + size_t ndotdots = 0; + char const* from_last = from + strlen(from) - 1; + while ((from = strchr (from, '/')) && from != from_last) + { + ++ndotdots; + ++from; + } + for (count = 0; count < ndotdots; ++count) + { + strcat(result, "../"); + } + if (strlen(to) > 0) + { + strcat(result, to+1); + } + /* Make sure that if to ends with '/' result does the same, and + vice-versa. */ + size_t size_result = strlen(result); + if ((to_final_is_slash == 1) + && (!size_result || result[size_result-1] != '/')) + { + strcat (result, "/"); + } + else if (!to_final_is_slash + && size_result && result[size_result-1] == '/') + { + result[size_result-1] = '\0'; + } + + return malloc_copy_string (result); +} + +void +simplify_path(char * path) +{ + ssize_t n_toks = 1; /* in-case we need an empty initial token. */ + ssize_t i, j; + size_t tok_size; + size_t in_size = strlen (path); + int it_ended_with_a_slash = (path[in_size - 1] == '/') ? 1 : 0; + char * result = path; + if (path[0] == '/' && path[1] == '/') { + /* preserve UNC path */ + path++; + in_size--; + result++; + } + sanitise_path(result); + char * result_p = result; + + do + { + ++n_toks; + ++result_p; + } while ((result_p = strchr (result_p, '/')) != NULL); + + result_p = result; + char const ** toks = (char const **) alloca (sizeof (char const*) * n_toks); + n_toks = 0; + do + { + if (result_p > result) + { + *result_p++ = '\0'; + } + else if (*result_p == '/') + { + /* A leading / creates an empty initial token. */ + toks[n_toks++] = result_p; + *result_p++ = '\0'; + } + toks[n_toks++] = result_p; + } while ((result_p = strchr (result_p, '/')) != NULL); + + /* Remove all non-leading '.' and any '..' we can match + with an earlier forward path (i.e. neither '.' nor '..') */ + for (i = 1; i < n_toks; ++i) + { + int removals[2] = { -1, -1 }; + if ( strcmp (toks[i], "." ) == 0) + { + removals[0] = i; + } + else if ( strcmp (toks[i], ".." ) == 0) + { + /* Search backwards for a forward path to collapse. + If none are found then the .. also stays. */ + for (j = i - 1; j > -1; --j) + { + if ( strcmp (toks[j], "." ) + && strcmp (toks[j], ".." ) ) + { + removals[0] = j; + removals[1] = i; + break; + } + } + } + for (j = 0; j < 2; ++j) + { + if (removals[j] >= 0) /* Can become -2 */ + { + --n_toks; + memmove (&toks[removals[j]], &toks[removals[j]+1], (n_toks - removals[j])*sizeof (char*)); + --i; + if (!j) + { + --removals[1]; + } + } + } + } + result_p = result; + for (i = 0; i < n_toks; ++i) + { + tok_size = strlen(toks[i]); + memmove (result_p, toks[i], tok_size); + result_p += tok_size; + if ((!i || tok_size) && ((i < n_toks - 1) || it_ended_with_a_slash == 1)) + { + *result_p = '/'; + ++result_p; + } + } + *result_p = '\0'; +} + +/* Returns actual_to by calculating the relative path from -> to and + applying that to actual_from. An assumption that actual_from is a + dir is made, and it may or may not end with a '/' */ +char const * +get_relocated_path (char const * from, char const * to, char const * actual_from) +{ + char const * relative_from_to = get_relative_path (from, to); + char * actual_to = (char *) malloc (strlen(actual_from) + 2 + strlen(relative_from_to)); + return actual_to; +} + +int +get_executable_path(char const * argv0, char * result, ssize_t max_size) +{ + char * system_result = (char *) alloca (max_size); + ssize_t system_result_size = -1; + ssize_t result_size = -1; + + if (system_result != NULL) + { +#if defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) +#if defined(__linux__) || defined(__CYGWIN__) || defined(__MSYS__) + system_result_size = readlink("/proc/self/exe", system_result, max_size); +#elif defined(__APPLE__) + uint32_t bufsize = (uint32_t)max_size; + if (_NSGetExecutablePath(system_result, &bufsize) == 0) + { + system_result_size = (ssize_t)bufsize; + } +#elif defined(_WIN32) + unsigned long bufsize = (unsigned long)max_size; + system_result_size = GetModuleFileNameA(NULL, system_result, bufsize); + if (system_result_size == 0 || system_result_size == (ssize_t)bufsize) + { + /* Error, possibly not enough space. */ + system_result_size = -1; + } + else + { + /* Early conversion to unix slashes instead of more changes + everywhere else .. */ + char * winslash; + system_result[system_result_size] = '\0'; + while ((winslash = strchr (system_result, '\\')) != NULL) + { + *winslash = '/'; + } + } +#else +#warning "Don't know how to get executable path on this system" +#endif +#endif /* defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) */ + } + /* Use argv0 as a default in-case of failure */ + if (system_result_size != -1) + { + strncpy (result, system_result, system_result_size); + result[system_result_size] = '\0'; + } + else + { + if (argv0 != NULL) + { + strncpy (result, argv0, max_size); + result[max_size-1] = '\0'; + } + else + { + result[0] = '\0'; + } + } + result_size = strlen (result); + return result_size; +} + +#if defined(_WIN32) +int +get_dll_path(char * result, unsigned long max_size) +{ + HMODULE handle; + char * p; + int ret; + + if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCSTR) &get_dll_path, &handle)) + { + return -1; + } + + ret = GetModuleFileNameA(handle, result, max_size); + if (ret == 0 || ret == (int)max_size) + { + return -1; + } + + /* Early conversion to unix slashes instead of more changes + everywhere else .. */ + result[ret] = '\0'; + p = result - 1; + while ((p = strchr (p + 1, '\\')) != NULL) + { + *p = '/'; + } + + return ret; +} +#endif + +char const * +strip_n_prefix_folders(char const * path, size_t n) +{ + if (path == NULL) + { + return NULL; + } + + if (path[0] != '/') + { + return path; + } + + char const * last = path; + while (n-- && path != NULL) + { + last = path; + path = strchr (path + 1, '/'); + } + return (path == NULL) ? last : path; +} + +void +strip_n_suffix_folders(char * path, size_t n) +{ + if (path == NULL) + { + return; + } + while (n--) + { + if (strrchr (path + 1, '/')) + { + *strrchr (path + 1, '/') = '\0'; + } + else + { + return; + } + } + return; +} + +size_t +split_path_list(char const * path_list, char split_char, char *** arr) +{ + size_t path_count; + size_t path_list_size; + char const * path_list_p; + + path_list_p = path_list; + if (path_list == NULL || path_list[0] == '\0') + { + return 0; + } + path_list_size = strlen (path_list); + + path_count = 0; + do + { + ++path_count; + ++path_list_p; + } + while ((path_list_p = strchr (path_list_p, split_char)) != NULL); + + /* allocate everything in one go. */ + char * all_memory = (char *) malloc (sizeof (char *) * path_count + strlen(path_list) + 1); + if (all_memory == NULL) + return 0; + *arr = (char **)all_memory; + all_memory += sizeof (char *) * path_count; + + path_count = 0; + path_list_p = path_list; + char const * next_path_list_p = 0; + do + { + next_path_list_p = strchr (path_list_p, split_char); + if (next_path_list_p != NULL) + { + ++next_path_list_p; + } + size_t this_size = (next_path_list_p != NULL) + ? next_path_list_p - path_list_p - 1 + : &path_list[path_list_size] - path_list_p; + memcpy (all_memory, path_list_p, this_size); + all_memory[this_size] = '\0'; + (*arr)[path_count++] = all_memory; + all_memory += this_size + 1; + } while ((path_list_p = next_path_list_p) != NULL); + + return path_count; +} + +char * +get_relocated_path_list(char const * from, char const * to_path_list) +{ + char exe_path[MAX_PATH]; + char * temp; + get_executable_path (NULL, &exe_path[0], sizeof (exe_path) / sizeof (exe_path[0])); + if ((temp = strrchr (exe_path, '/')) != NULL) + { + temp[1] = '\0'; + } + + char **arr = NULL; + /* Ask Alexey why he added this. Are we not 100% sure + that we're dealing with unix paths here? */ + char split_char = ':'; + if (strchr (to_path_list, ';')) + { + split_char = ';'; + } + size_t count = split_path_list (to_path_list, split_char, &arr); + int result_size = 1 + (count - 1); /* count - 1 is for ; delim. */ + size_t exe_path_size = strlen (exe_path); + size_t i; + /* Space required is: + count * (exe_path_size + strlen (rel_to_datadir)) + rel_to_datadir upper bound is: + (count * strlen (from)) + (3 * num_slashes (from)) + + strlen(arr[i]) + 1. + .. pathalogically num_slashes (from) is strlen (from) + (from = ////////) */ + size_t space_required = (count * (exe_path_size + 4 * strlen (from))) + count - 1; + for (i = 0; i < count; ++i) + { + space_required += strlen (arr[i]); + } + char * scratch = (char *) alloca (space_required); + if (scratch == NULL) + return NULL; + for (i = 0; i < count; ++i) + { + char * rel_to_datadir = get_relative_path (from, arr[i]); + scratch[0] = '\0'; + arr[i] = scratch; + strcat (scratch, exe_path); + strcat (scratch, rel_to_datadir); + simplify_path (arr[i]); + size_t arr_i_size = strlen (arr[i]); + result_size += arr_i_size; + scratch = arr[i] + arr_i_size + 1; + } + char * result = (char *) malloc (result_size); + if (result == NULL) + { + return NULL; + } + result[0] = '\0'; + for (i = 0; i < count; ++i) + { + strcat (result, arr[i]); + if (i != count-1) + { +#if defined(_WIN32) + strcat (result, ";"); +#else + strcat (result, ":"); +#endif + } + } + free ((void*)arr); + return result; +} + +char * +single_path_relocation(const char *from, const char *to) +{ +#if defined(__MINGW32__) + char exe_path[PATH_MAX]; + get_executable_path (NULL, &exe_path[0], sizeof(exe_path)/sizeof(exe_path[0])); + if (strrchr (exe_path, '/') != NULL) + { + strrchr (exe_path, '/')[1] = '\0'; + } + char * rel_to_datadir = get_relative_path (from, to); + strcat (exe_path, rel_to_datadir); + simplify_path (&exe_path[0]); + return malloc_copy_string(exe_path); +#else + return malloc_copy_string(to); +#endif +} + +char * +pathlist_relocation(const char *from_path, const char *to_path_list) +{ +#if defined(__MINGW32__) + static char stored_path[PATH_MAX]; + static int stored = 0; + if (stored == 0) + { + char const * relocated = get_relocated_path_list(from_path, to_path_list); + strncpy (stored_path, relocated, PATH_MAX); + stored_path[PATH_MAX-1] = '\0'; + free ((void *)relocated); + stored = 1; + } + return stored_path; +#else + return (to_path_list); +#endif +} + +#endif /* __MINGW32__ */ diff --git a/src/common/pathtools.h b/src/common/pathtools.h new file mode 100644 index 00000000000..6773f323d57 --- /dev/null +++ b/src/common/pathtools.h @@ -0,0 +1,61 @@ +/* + .Some useful path tools. + .ASCII only for now. + .Written by Ray Donnelly in 2014. + .Licensed under CC0 (and anything. + .else you need to license it under). + .No warranties whatsoever. + .email: . + */ + +#ifndef PATHTOOLS_H +#define PATHTOOLS_H + +#if defined(__MINGW32__) + +#include +#if defined(__APPLE__) +#include +#else +#include +#endif +#include + +char * malloc_copy_string(char const * original); + +/* In-place replaces any '\' with '/' and any '//' with '/' */ +void sanitise_path(char * path); + +/* Uses a host OS specific function to determine the path of the executable, + if IMPLEMENT_SYS_GET_EXECUTABLE_PATH is defined, otherwise uses argv0. */ +int get_executable_path(char const * argv0, char * result, ssize_t max_size); + +#if defined(_WIN32) +int get_dll_path(char * result, unsigned long max_size); +#endif + +/* Where possible, in-place removes occourances of '.' and 'path/..' */ +void simplify_path(char * path); + +/* Allocates (via malloc) and returns the path to get from from to to. */ +char * get_relative_path(char const * from, char const * to); + +size_t split_path_list(char const * path_list, char split_char, char *** arr); + +/* Advances path along by the amount that removes n prefix folders. */ +char const * +strip_n_prefix_folders(char const * path, size_t n); + +/* NULL terminates path to remove n suffix folders. */ +void +strip_n_suffix_folders(char * path, size_t n); + +char const * get_relocated_path (char const * from, char const * to, char const * actual_from); +char * get_relocated_path_list(char const * from, char const * to_path_list); + +char * single_path_relocation(const char *from, const char *to); +char * pathlist_relocation(const char *from_path, const char *to_path_list); + +#endif /* __MINGW32__ */ + +#endif /* PATHTOOLS_H */ diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp index ce9ffd31cf6..556eb61f7f1 100644 --- a/src/common/unicode_util.cpp +++ b/src/common/unicode_util.cpp @@ -56,9 +56,12 @@ using namespace Firebird; namespace { -#if defined(WIN_NT) +#if defined(_MSC_VER) const char* const inTemplate = "icuin%s.dll"; const char* const ucTemplate = "icuuc%s.dll"; +#elif defined(MINGW) +const char* const inTemplate = "libicuin%s.dll"; +const char* const ucTemplate = "libicuuc%s.dll"; #elif defined(DARWIN) const char* const inTemplate = "lib/libicui18n.%s.dylib"; const char* const ucTemplate = "lib/libicuuc.%s.dylib"; @@ -1328,7 +1331,7 @@ UnicodeUtil::ConversionICU& UnicodeUtil::getConversionICU() for (int major = 79; major >= 3;) { -#ifdef WIN_NT +#ifdef _MSC_VER int minor = 0; #else int minor = 9; diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 9f8497d5b5c..bb322ffbbca 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -47,6 +47,7 @@ #include "../common/classes/locks.h" #include "../common/classes/init.h" #include "../common/isc_proto.h" +#include "../common/pathtools.h" #include "../jrd/constants.h" #include "firebird/impl/inf_pub.h" #include "../jrd/align.h" @@ -1220,9 +1221,30 @@ Firebird::PathName getPrefix(unsigned int prefType, const char* name) char tmp[MAXPATHLEN]; const char* configDir[] = { +#ifdef MINGW + single_path_relocation(FB_BINDIR,FB_BINDIR), + single_path_relocation(FB_BINDIR,FB_SBINDIR), + single_path_relocation(FB_BINDIR,FB_CONFDIR), + single_path_relocation(FB_BINDIR,FB_LIBDIR), + single_path_relocation(FB_BINDIR,FB_INCDIR), + single_path_relocation(FB_BINDIR,FB_DOCDIR), + single_path_relocation(FB_BINDIR,""), + single_path_relocation(FB_BINDIR,FB_SAMPLEDIR), + single_path_relocation(FB_BINDIR,FB_SAMPLEDBDIR), + single_path_relocation(FB_BINDIR,""), + single_path_relocation(FB_BINDIR,FB_INTLDIR), + single_path_relocation(FB_BINDIR,FB_MISCDIR), + single_path_relocation(FB_BINDIR,FB_SECDBDIR), + single_path_relocation(FB_BINDIR,FB_MSGDIR), + single_path_relocation(FB_BINDIR,FB_LOGDIR), + single_path_relocation(FB_BINDIR,FB_GUARDDIR), + single_path_relocation(FB_BINDIR,FB_PLUGDIR), + single_path_relocation(FB_BINDIR,FB_TZDATADIR) +#else FB_BINDIR, FB_SBINDIR, FB_CONFDIR, FB_LIBDIR, FB_INCDIR, FB_DOCDIR, "", FB_SAMPLEDIR, FB_SAMPLEDBDIR, "", FB_INTLDIR, FB_MISCDIR, FB_SECDBDIR, FB_MSGDIR, FB_LOGDIR, FB_GUARDDIR, FB_PLUGDIR, FB_TZDATADIR +#endif }; fb_assert(FB_NELEM(configDir) == Firebird::IConfigManager::DIR_COUNT); diff --git a/src/common/utils_proto.h b/src/common/utils_proto.h index 72f897cd365..05e391aec15 100644 --- a/src/common/utils_proto.h +++ b/src/common/utils_proto.h @@ -127,10 +127,10 @@ namespace fb_utils #if FB_INT64_COMPARE_FAILED // avoid compiler bug when comparing minimum INT64 - const SINT64 MININT64 = 0x8000000000000000; - if (n1 == MININT64) - return n2 == MININT64 ? 0 : 2; - if (n2 == MININT64) + const SINT64 MIN_INT64 = 0x8000000000000000; + if (n1 == MIN_INT64) + return n2 == MIN_INT64 ? 0 : 2; + if (n2 == MIN_INT64) return -2; #endif diff --git a/src/gpre/languages/fbrmclib.cpp b/src/gpre/languages/fbrmclib.cpp index cc9fc289e4c..a5d9a245c2c 100644 --- a/src/gpre/languages/fbrmclib.cpp +++ b/src/gpre/languages/fbrmclib.cpp @@ -89,7 +89,7 @@ struct date_fmt }; #ifdef __WIN32__ -#define EXPORT __declspec(dllexport) +#define EXPORT extern __declspec(dllexport) #define CDECL __cdecl #else #define EXPORT diff --git a/src/include/firebird.h b/src/include/firebird.h index 391d7707ce6..eb1b120e023 100644 --- a/src/include/firebird.h +++ b/src/include/firebird.h @@ -63,11 +63,13 @@ #include "../common/common.h" #endif +#if !defined(MINGW) #ifdef NULL #undef NULL #endif #define NULL nullptr +#endif #if defined(WIN_NT) #define TRUSTED_AUTH diff --git a/src/iscguard/iscguard.cpp b/src/iscguard/iscguard.cpp index 983a7ba2d05..0b4f8acf768 100644 --- a/src/iscguard/iscguard.cpp +++ b/src/iscguard/iscguard.cpp @@ -726,7 +726,7 @@ THREAD_ENTRY_DECLARE start_and_watch_server(THREAD_ENTRY_PARAM) } // wait for process to terminate - DWORD exit_status; + DWORD exit_status = 0; if (service_flag) { while (WaitForSingleObject(procHandle, 500) == WAIT_OBJECT_0) diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 08f560ddf73..bd1004aea3c 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -8886,7 +8886,7 @@ namespace THREAD_ENTRY_DECLARE attachmentShutdownThread(THREAD_ENTRY_PARAM arg) { #ifdef WIN_NT - ThreadModuleRef thdRef(attachmentShutdownThread, &engineShutdown); + ThreadModuleRef thdRef((void*)attachmentShutdownThread, &engineShutdown); #endif AttShutParams* params = static_cast(arg); diff --git a/src/jrd/version.h b/src/jrd/version.h index 094ffef206a..3ca40f8264e 100644 --- a/src/jrd/version.h +++ b/src/jrd/version.h @@ -154,7 +154,7 @@ #endif -#ifdef RC_ARH_x64 +#if defined(RC_ARH_x64) || defined(__x86_64__) #define VER_ARCH "64-bit" #else #define VER_ARCH "32-bit" diff --git a/src/misc/writeBuildNum.sh b/src/misc/writeBuildNum.sh index d25e4ac8ff7..d3ee68cb120 100755 --- a/src/misc/writeBuildNum.sh +++ b/src/misc/writeBuildNum.sh @@ -105,12 +105,16 @@ grep ODS_VERSION $OdsH | grep -v ENCODE_ODS >$Mini cat >$TestCpp < typedef unsigned short USHORT; +#ifdef __MINGW32__ +#include "miniods.h" +#else #include "$Mini" +#endif int main() { return ODS_VERSION; } eof -[ -z "$CXX" ] && CXX=g++ +[ -z "$CXX" ] && CXX=g++ && CXX=c++ $CXX -std=c++17 $TestCpp -o $AOut if [ -x $AOut ] diff --git a/src/remote/inet.cpp b/src/remote/inet.cpp index 552afde30ec..9099526ecbc 100644 --- a/src/remote/inet.cpp +++ b/src/remote/inet.cpp @@ -1207,7 +1207,7 @@ static rem_port* listener_socket(rem_port* port, USHORT flag, const addrinfo* pa forkEvent = CreateEvent(NULL, FALSE, FALSE, NULL); forkSockets = FB_NEW SocketsArray(*getDefaultMemoryPool()); - Thread::start(forkThread, (void*) flag, THREAD_medium); + Thread::start(forkThread, (void*)(U_IPTR) flag, THREAD_medium); } forkSockets->add(s); SetEvent(forkEvent); diff --git a/src/yvalve/config/os/win32/config_root.cpp b/src/yvalve/config/os/win32/config_root.cpp index 3658ee3d89d..c3d9fdea2b6 100644 --- a/src/yvalve/config/os/win32/config_root.cpp +++ b/src/yvalve/config/os/win32/config_root.cpp @@ -28,6 +28,7 @@ #include "fb_types.h" #include "../../../../common/classes/fb_string.h" #include "../../../../common/dllinst.h" +#include "../../../../common/pathtools.h" #include "../../../../yvalve/config/os/config_root.h" using Firebird::PathName; @@ -60,7 +61,11 @@ bool getPathFromHInstance(PathName& root) void ConfigRoot::osConfigRoot() { +#ifdef MINGW + root_dir = single_path_relocation(FB_BINDIR,FB_PREFIX); +#else root_dir = install_dir; +#endif } void ConfigRoot::osConfigInstallDir() @@ -107,7 +112,11 @@ void ConfigRoot::osConfigInstallDir() if (install_dir.isEmpty()) { // As a last resort get it from the default install directory +#ifdef MINGW + install_dir = single_path_relocation(FB_BINDIR,FB_PREFIX); +#else install_dir = FB_PREFIX; +#endif } PathUtils::ensureSeparator(install_dir); diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp index 765b36d5850..fba2603b4c7 100644 --- a/src/yvalve/gds.cpp +++ b/src/yvalve/gds.cpp @@ -64,6 +64,10 @@ #include "../common/ThreadStart.h" #include "../common/Int128.h" +#ifdef MINGW +#include "../common/pathtools.h" +#endif + #ifdef HAVE_UNISTD_H #include #endif @@ -104,7 +108,7 @@ #ifdef WIN_NT #include -#if _MSC_VER <= 1500 +#if defined(_MSC_VER) && (_MSC_VER<=1500) #include #endif #define _WINSOCKAPI_ @@ -4336,13 +4340,21 @@ class InitPrefix { prefix = Firebird::Config::getRootDirectory(); if (prefix.isEmpty() && !GetProgramFilesDir(prefix)) +#ifdef MINGW + prefix = FB_CONFDIR[0] ? single_path_relocation(FB_BINDIR,FB_CONFDIR) : single_path_relocation(FB_BINDIR,FB_PREFIX); +#else prefix = FB_CONFDIR[0] ? FB_CONFDIR : FB_PREFIX; +#endif } catch (const Firebird::Exception&) { // CVC: Presumably here we failed because the config file can't be located. if (!GetProgramFilesDir(prefix)) +#ifdef MINGW + prefix = FB_CONFDIR[0] ? single_path_relocation(FB_BINDIR,FB_CONFDIR) : single_path_relocation(FB_BINDIR,FB_PREFIX); +#else prefix = FB_CONFDIR[0] ? FB_CONFDIR : FB_PREFIX; +#endif } prefix.copyTo(fb_prefix_val, sizeof(fb_prefix_val)); fb_prefix = fb_prefix_val; @@ -4405,7 +4417,11 @@ class InitPrefix if (FB_MSGDIR[0] && PathUtils::isRelative(FB_MSGDIR)) PathUtils::concatPath(msgPrefix, prefix, FB_MSGDIR); else +#ifdef MINGW + msgPrefix = FB_MSGDIR[0] ? single_path_relocation(FB_BINDIR,FB_MSGDIR) : prefix; +#else msgPrefix = FB_MSGDIR[0] ? FB_MSGDIR : prefix; +#endif } msgPrefix.copyTo(fb_prefix_msg_val, sizeof(fb_prefix_msg_val)); fb_prefix_msg = fb_prefix_msg_val;