enable_language(C)
enable_language(CXX)
+set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
set(CPACK_PACKAGE_NAME "gromacs")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
endif()
if(WIN32 AND NOT CYGWIN)
- set(GMX_WSOCKLIB_PATH CACHE PATH "Path to winsock (wsock32.lib) library.")
- mark_as_advanced(GMX_WSOCKLIB_PATH)
- find_library(WSOCK32_LIBRARY NAMES wsock32 PATHS ${GMX_WSOCKLIB_PATH})
- if(WSOCK32_LIBRARY)
- list(APPEND GMX_EXTRA_LIBRARIES ${WSOCK32_LIBRARY})
- add_definitions(-DGMX_HAVE_WINSOCK)
- else()
- message(STATUS "No winsock found. Cannot use interactive molecular dynamics (IMD).")
- endif(WSOCK32_LIBRARY)
+ list(APPEND GMX_EXTRA_LIBRARIES "wsock32")
+ add_definitions(-DGMX_HAVE_WINSOCK)
endif()
--- /dev/null
+#define _WIN32_WINNT 0x0601 /*Require Windows7 (needed for MingW)*/
+#include <windows.h>
+int main()
+{
+ PROCESSOR_NUMBER p;
+ return 0;
+}
ENDMACRO(TMPI_TEST_ATOMICS VARIABLE)
+try_compile(HAVE_PROCESSOR_NUMBER ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/cmake/TestWinProcNum.c")
include(FindThreads)
-if (CMAKE_USE_PTHREADS_INIT)
+if (CMAKE_USE_WIN32_THREADS_INIT AND HAVE_PROCESSOR_NUMBER)
+ set(THREAD_WINDOWS 1)
+ set(THREAD_LIB)
+elseif (CMAKE_USE_PTHREADS_INIT)
check_include_files(pthread.h HAVE_PTHREAD_H)
set(THREAD_PTHREADS 1)
set(THREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
-elseif (CMAKE_USE_WIN32_THREADS_INIT)
- set(THREAD_WINDOWS 1)
- set(THREAD_LIB)
else()
message(FATAL_ERROR "Thread support required")
endif ()
if(OPENMP_FOUND)
# CMake on Windows doesn't support linker flags passed to target_link_libraries
# (i.e. it treats /openmp as \openmp library file). Also, no OpenMP linker flags are needed.
- if(NOT (WIN32 AND NOT CYGWIN))
+ if(NOT (WIN32 AND NOT CYGWIN AND NOT MINGW))
if(CMAKE_COMPILER_IS_GNUCC AND GMX_PREFER_STATIC_OPENMP AND NOT APPLE)
set(OpenMP_LINKER_FLAGS "-Wl,-static -lgomp -lrt -Wl,-Bdynamic -lpthread")
set(OpenMP_SHARED_LINKER_FLAGS "")
endif()
endif()
endif()
+ if(MINGW)
+ #GCC Bug 48659
+ set(OpenMP_C_FLAGS "${OpenMP_C_FLAGS} -mstackrealign")
+ endif()
else()
message(WARNING
"The compiler you are using does not support OpenMP parallelism. This might hurt your performance a lot, in particular with GPUs. Try using a more recent version, or a different compiler. For now, we are proceeding by turning off OpenMP.")
# VARIABLE will be set to true if libxml2 support is present
include(CheckLibraryExists)
+include(CheckIncludeFiles)
include(gmxOptionUtilities)
function(GMX_TEST_LIBXML2 VARIABLE)
if(LIBXML2_FOUND)
unset(LIBXML2_LINKS_OK CACHE)
endif()
check_library_exists("${LIBXML2_LIBRARIES}" "xmlTextWriterEndAttribute" "" LIBXML2_LINKS_OK)
- set(${VARIABLE} ${LIBXML2_LINKS_OK} PARENT_SCOPE)
+ if(LIBXML2_LINKS_OK)
+ #check that xml headers can be included
+ set(CMAKE_REQUIRED_INCLUDES "${LIBXML2_INCLUDE_DIR}")
+ check_include_files("libxml/parser.h" LIBXML2_INCL_OK)
+ if(NOT LIBXML2_INCL_OK)
+ #xml headers depend on iconv.h. Test whether adding its path fixes the problem
+ find_path(ICONV_INCLUDE_DIR iconv.h)
+ if(ICONV_INCLUDE_DIR)
+ set(CMAKE_REQUIRED_INCLUDES "${LIBXML2_INCLUDE_DIR};${ICONV_INCLUDE_DIR}")
+ unset(LIBXML2_INCL_OK CACHE)
+ check_include_files("libxml/parser.h" LIBXML2_INCL_OK)
+ set(LIBXML2_INCLUDE_DIR "${LIBXML2_INCLUDE_DIR};${ICONV_INCLUDE_DIR}" CACHE PATH "Libxml2 include path" FORCE)
+ endif()
+ endif()
+ set(${VARIABLE} ${LIBXML2_INCL_OK} PARENT_SCOPE)
+ else()
+ set(${VARIABLE} OFF PARENT_SCOPE)
+ endif()
else()
set(${VARIABLE} OFF PARENT_SCOPE)
endif()
*
* \inlibraryapi
*/
+#ifndef GMX_CONFIG_H
+#define GMX_CONFIG_H
#include "gromacs/utility/gmx_header_config.h"
/* TODO: For now, disable Doxygen warnings from here */
/* Define if we have zlib */
#cmakedefine HAVE_ZLIB
+#endif
+
/*! \endcond */
include_directories(BEFORE ${GTEST_DIR})
include_directories(BEFORE ${GMOCK_INCLUDE_DIRS})
include_directories(BEFORE ${GMOCK_DIR})
+
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag(-Wno-unused-variable HAS_NO_UNUSED_VARIABLE)
+if (HAS_NO_UNUSED_VARIABLE)
+ set_source_files_properties(${GTEST_SOURCES} PROPERTIES COMPILE_FLAGS "-Wno-unused-variable")
+endif()
+
add_library(gmock STATIC ${UNITTEST_TARGET_OPTIONS} ${GMOCK_SOURCES} ${GTEST_SOURCES})
set_property(TARGET gmock APPEND PROPERTY COMPILE_DEFINITIONS "${GMOCK_COMPILE_DEFINITIONS}")
if (errorcode != TMPI_ERR_IO)
{
-#if !(defined( _WIN32 ) || defined( _WIN64 ) )
+#ifndef _MSC_VER
strncpy(strn, tmpi_errmsg[errorcode], TMPI_MAX_ERROR_STRING);
#else
strncpy_s(strn, TMPI_MAX_ERROR_STRING, tmpi_errmsg[errorcode],
}
else
{
-#if !(defined( _WIN32 ) || defined( _WIN64 ) )
+#ifndef _MSC_VER
snprintf(strn, TMPI_MAX_ERROR_STRING,
"%s: %s", tmpi_errmsg[errorcode], strerror(errno));
#else
#include <unistd.h>
#endif
+#if defined( _WIN32 ) || defined( _WIN64 )
+#include <windows.h>
+#endif
+
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include "config.h"
#endif
+#ifdef THREAD_WINDOWS
+ #ifdef __MINGW32__
+ #define _WIN32_WINNT 0x0601 /* Windows 7*/
+ #endif
+#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include <dmalloc.h>
#endif
-
-#if !(defined(WIN32) || defined( _WIN32 ) || defined(WIN64) || defined( _WIN64 )) || defined (__CYGWIN__) || defined (__CYGWIN32__)
-
+#ifndef THREAD_WINDOWS
/* We don't have specific NUMA aware allocators: */
Scott Field (sfield@microsoft.com) Jan-2011
*/
-//#define _WIN32_WINNT 0x0601
#include <windows.h>
-
-
/*
__declspec(align()) may not be supported by all compilers, so define the
size of the structure manually to force alignment
return;
}
+#if defined(WIN64) || defined( _WIN64 )
+ hPriorValue = (HANDLE *)InterlockedCompareExchange64(
+ (LONGLONG volatile *)&g_hHeap,
+ (LONGLONG) hHeapNew,
+ 0
+ );
+#else
hPriorValue = (HANDLE *)InterlockedCompareExchange(
(LONG volatile *)&g_hHeap,
(LONG) hHeapNew,
0
);
+#endif
if (hPriorValue != NULL)
{
};
/* the thread_starter function that sets the thread id */
+#ifdef __MINGW32__
+__attribute__((force_align_arg_pointer))
+#endif
static void *tMPI_Thread_starter(void *arg)
{
struct tMPI_Thread_starter *starter = (struct tMPI_Thread_starter *)arg;
digits = 1;
}
}
-#if !(defined( _WIN32 ) || defined( _WIN64 ) )
+#ifndef _MSC_VER
strcpy(name, "thread #");
#else
strncpy_s(name, TMPI_MAX_PROCESSOR_NAME, "thread #", TMPI_MAX_PROCESSOR_NAME);
#ifdef THREAD_WINDOWS
/* the win32 header */
+#ifdef __MINGW32__
+/* Couple of types (e.g. PROCESSOR_NUMBER) are only available since
+ * WinServer2008 (0x600) and Windows7 (0x601). MingW doesn't have
+ * it defined for 0x600 in the headers */
+#define _WIN32_WINNT 0x0601
+#endif
#include <windows.h>
#include "thread_mpi/atomic.h"
#include "thread_mpi/threads.h"
#include "impl.h"
+#include "unused.h"
#include "winthreads.h"
struct tMPI_Thread *thread;
};
+#ifdef __GNUC__
+__attribute__((force_align_arg_pointer))
+#endif
static DWORD WINAPI tMPI_Win32_thread_starter( LPVOID lpParam )
{
struct tMPI_Thread_starter_param *prm =
}
-void tMPI_Thread_exit(void *value_ptr)
+void tMPI_Thread_exit(void tmpi_unused *value_ptr)
{
/* TODO: call destructors for thread-local storage */
ExitThread( 0 );
-int tMPI_Thread_key_create(tMPI_Thread_key_t *key, void (*destructor)(void *))
+int tMPI_Thread_key_create(tMPI_Thread_key_t *key, void (*destructor)(void *) tmpi_unused)
{
if (key == NULL)
{
#endif /* USE_STD_INTTYPES_H */
-
#ifndef USE_WINDOWS
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
#define USE_WINDOWS
#endif /* win32... */
#endif /* not defined USE_WINDOWS */
+#ifdef USE_WINDOWS
+#define TNG_PRIsize "Iu"
+#else
+#define TNG_PRIsize "zu"
+#endif
+
#ifndef DECLSPECDLLEXPORT
#ifdef USE_WINDOWS
#define DECLSPECDLLEXPORT __declspec(dllexport)
#include "compression/tng_compress.h"
#include "tng/version.h"
-#ifdef _MSC_VER
-#define fseeko _fseeki64
-#define ftello _ftelli64
+#if defined( _WIN32 ) || defined( _WIN64 )
+ #ifndef fseeko
+ #define fseeko _fseeki64
+ #endif
+ #ifndef ftello
+ #ifdef __MINGW32__
+ #define ftello ftello64
+ #else
+ #define ftello _ftelli64
+ #endif
+ #endif
#endif
struct tng_bond {
*block_p = malloc(sizeof(struct tng_gen_block));
if(!*block_p)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"TNG_PRIsize" bytes). %s: %d\n",
sizeof(struct tng_gen_block), __FILE__, __LINE__);
return(TNG_CRITICAL);
}
frame_set->n_particle_data_blocks);
if(!data)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"TNG_PRIsize" bytes). %s: %d\n",
sizeof(struct tng_particle_data) *
frame_set->n_particle_data_blocks,
__FILE__, __LINE__);
tng_data->n_particle_data_blocks);
if(!data)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"TNG_PRIsize" bytes). %s: %d\n",
sizeof(struct tng_particle_data) *
tng_data->n_particle_data_blocks,
__FILE__, __LINE__);
temp_name = realloc(block->name, len);
if(!temp_name)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lud bytes). %s: %d\n", len,
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"TNG_PRIsize" bytes). %s: %d\n", len,
__FILE__, __LINE__);
free(block->name);
block->name = 0;
frame_set->n_data_blocks);
if(!data)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"TNG_PRIsize" bytes). %s: %d\n",
sizeof(struct tng_non_particle_data) * frame_set->n_data_blocks,
__FILE__, __LINE__);
free(frame_set->tr_data);
tng_data->n_data_blocks);
if(!data)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"TNG_PRIsize" bytes). %s: %d\n",
sizeof(struct tng_non_particle_data) * tng_data->n_data_blocks,
__FILE__, __LINE__);
free(tng_data->non_tr_data);
*molecule_p = malloc(sizeof(struct tng_molecule));
if(!*molecule_p)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"TNG_PRIsize" bytes). %s: %d\n",
sizeof(struct tng_molecule), __FILE__, __LINE__);
return(TNG_CRITICAL);
}
*tng_data_p = malloc(sizeof(struct tng_trajectory));
if(!*tng_data_p)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"TNG_PRIsize" bytes). %s: %d\n",
sizeof(struct tng_trajectory), __FILE__, __LINE__);
return(TNG_CRITICAL);
}
*dest_p = malloc(sizeof(struct tng_trajectory));
if(!*dest_p)
{
- fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+ fprintf(stderr, "TNG library: Cannot allocate memory (%"TNG_PRIsize" bytes). %s: %d\n",
sizeof(struct tng_trajectory), __FILE__, __LINE__);
return(TNG_CRITICAL);
}
return errorString;
}
-#elif defined(_MSC_VER)
+#elif defined( _WIN32 ) || defined( _WIN64 )
#include <windows.h>
static CHAR szBuf[80];
DWORD dw = GetLastError();
- sprintf(szBuf, "vmddlopen failed: GetLastError returned %u\n", dw);
+ sprintf(szBuf, "vmddlopen failed: GetLastError returned %lu\n", dw);
return szBuf;
}
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
/* Set the nice level */
-#ifdef HAVE_UNISTD_H
+#if defined(HAVE_UNISTD_H) && !defined(__MINGW32__)
#ifndef GMX_NO_NICE
/* The some system, e.g. the catamount kernel on cray xt3 do not have nice(2). */
if (nicelevel != 0 && !bExit)
#endif
#ifdef GMX_NATIVE_WINDOWS
+#include <windows.h>
#include <direct.h>
#include <io.h>
#endif
return ftello(stream);
#else
#ifdef HAVE__FSEEKI64
+#ifndef __MINGW32__
return _ftelli64(stream);
+#else
+ return ftello64(stream);
+#endif
#else
return ftell(stream);
#endif
/* Our own implementation of dirent-like functionality to scan directories. */
struct gmx_directory
{
-#ifdef HAVE_DIRENT_H
- DIR * dirent_handle;
-#elif (defined GMX_NATIVE_WINDOWS)
+#if defined(GMX_NATIVE_WINDOWS)
intptr_t windows_handle;
struct _finddata_t finddata;
int first;
+#elif defined(HAVE_DIRENT_H)
+ DIR * dirent_handle;
#else
int dummy;
#endif
*p_gmxdir = gmxdir;
-#ifdef HAVE_DIRENT_H
- if ( (gmxdir->dirent_handle = opendir(dirname)) != NULL)
- {
- rc = 0;
- }
- else
- {
- sfree(gmxdir);
- *p_gmxdir = NULL;
- rc = EINVAL;
- }
-#elif (defined GMX_NATIVE_WINDOWS)
-
+#if defined(GMX_NATIVE_WINDOWS)
if (dirname != NULL && strlen(dirname) > 0)
{
char * tmpname;
{
rc = EINVAL;
}
+#elif defined(HAVE_DIRENT_H)
+ if ( (gmxdir->dirent_handle = opendir(dirname)) != NULL)
+ {
+ rc = 0;
+ }
+ else
+ {
+ sfree(gmxdir);
+ *p_gmxdir = NULL;
+ rc = EINVAL;
+ }
#else
gmx_fatal(FARGS,
"Source compiled without POSIX dirent or windows support - cannot scan directories.\n"
{
int rc;
-#ifdef HAVE_DIRENT_H
+#if defined(GMX_NATIVE_WINDOWS)
+ if (gmxdir != NULL)
+ {
+ if (gmxdir->windows_handle <= 0)
+ {
+ name[0] = '\0';
+ rc = ENOENT;
+ }
+ else if (gmxdir->first == 1)
+ {
+ strncpy(name, gmxdir->finddata.name, maxlength_name);
+ rc = 0;
+ gmxdir->first = 0;
+ }
+ else
+ {
+ if (_findnext(gmxdir->windows_handle, &gmxdir->finddata) == 0)
+ {
+ strncpy(name, gmxdir->finddata.name, maxlength_name);
+ rc = 0;
+ }
+ else
+ {
+ name[0] = '\0';
+ rc = ENOENT;
+ }
+ }
+ }
+ else
+ {
+ name[0] = '\0';
+ rc = EINVAL;
+ }
+#elif defined(HAVE_DIRENT_H)
struct dirent * direntp_large;
struct dirent * p;
name[0] = '\0';
rc = EINVAL;
}
-
-#elif (defined GMX_NATIVE_WINDOWS)
-
- if (gmxdir != NULL)
- {
- if (gmxdir->windows_handle <= 0)
- {
-
- name[0] = '\0';
- rc = ENOENT;
- }
- else if (gmxdir->first == 1)
- {
- strncpy(name, gmxdir->finddata.name, maxlength_name);
- rc = 0;
- gmxdir->first = 0;
- }
- else
- {
- if (_findnext(gmxdir->windows_handle, &gmxdir->finddata) == 0)
- {
- strncpy(name, gmxdir->finddata.name, maxlength_name);
- rc = 0;
- }
- else
- {
- name[0] = '\0';
- rc = ENOENT;
- }
- }
- }
-
#else
gmx_fatal(FARGS,
"Source compiled without POSIX dirent or windows support - cannot scan directories.\n");
gmx_directory_close(gmx_directory_t gmxdir)
{
int rc;
-#ifdef HAVE_DIRENT_H
- rc = (gmxdir != NULL) ? closedir(gmxdir->dirent_handle) : EINVAL;
-#elif (defined GMX_NATIVE_WINDOWS)
+#if defined(GMX_NATIVE_WINDOWS)
rc = (gmxdir != NULL) ? _findclose(gmxdir->windows_handle) : EINVAL;
+#elif defined(HAVE_DIRENT_H)
+ rc = (gmxdir != NULL) ? closedir(gmxdir->dirent_handle) : EINVAL;
#else
gmx_fatal(FARGS,
"Source compiled without POSIX dirent or windows support - cannot scan directories.\n");
int gmx_truncatefile(char *path, gmx_off_t length)
{
-#ifdef _MSC_VER
+#ifdef GMX_NATIVE_WINDOWS
/* Microsoft visual studio does not have "truncate" */
HANDLE fh;
LARGE_INTEGER win_length;
// tng_last_program_name_set(*tng, programInfo);
// }
-#ifdef HAVE_UNISTD_H
+#if defined(HAVE_UNISTD_H) && !defined(__MINGW32__)
char username[256];
if (!getlogin_r(username, 256))
{
#include <string.h>
#include <assert.h>
+#include <config.h>
/*
* Plugin header files; get plugin source from www.ks.uiuc.edu/Research/vmd"
*/
#ifndef GMX_NATIVE_WINDOWS
#include <glob.h>
#else
+#ifndef _WIN32_IE
+#define _WIN32_IE 0x0500 /* SHGetFolderPath is available since WinXP/IE5 */
+#endif
#include <windows.h>
#include <shlobj.h>
#endif
return -1;
}
+#ifdef _MSC_VER
return _chsize_s( fileno(fp), size);
+#else
+ return _chsize( fileno(fp), size);
+#endif
#endif
}
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#ifdef _MSC_VER
+#ifdef GMX_NATIVE_WINDOWS
/* MSVC definition for __cpuid() */
-#include <intrin.h>
+ #ifdef _MSC_VER
+ #include <intrin.h>
+ #endif
/* sysinfo functions */
-#include <windows.h>
+ #include <windows.h>
#endif
#ifdef HAVE_UNISTD_H
/* sysconf() definition */
-#include <unistd.h>
+ #include <unistd.h>
#endif
#include "gmx_cpuid.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#if defined(HAVE_SCHED_H)
+#ifdef HAVE_SCHED_AFFINITY
# ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
# endif
{
gmx_incons("gmx_gethostname called with len<8");
}
-#if defined(HAVE_UNISTD_H) && !defined(__native_client__)
+#if defined(HAVE_UNISTD_H) && !defined(__native_client__) && !defined(__MINGW32__)
if (gethostname(name, len-1) != 0)
{
strncpy(name, "unknown", 8);
sprintf(err_buf, "tau-p must be > 0 instead of %g\n", ir->tau_p);
CHECK(ir->tau_p <= 0);
- if (ir->tau_p/dt_pcoupl < pcouple_min_integration_steps(ir->epc))
+ if (ir->tau_p/dt_pcoupl < pcouple_min_integration_steps(ir->epc) - 10*GMX_REAL_EPS)
{
sprintf(warn_buf, "For proper integration of the %s barostat, tau-p (%g) should be at least %d times larger than nstpcouple*dt (%g)",
EPCOUPLTYPE(ir->epc), ir->tau_p, pcouple_min_integration_steps(ir->epc), dt_pcoupl);
nstcmin = tcouple_min_integration_steps(ir->etc);
if (nstcmin > 1)
{
- if (tau_min/(ir->delta_t*ir->nsttcouple) < nstcmin)
+ if (tau_min/(ir->delta_t*ir->nsttcouple) < nstcmin - 10*GMX_REAL_EPS)
{
sprintf(warn_buf, "For proper integration of the %s thermostat, tau-t (%g) should be at least %d times larger than nsttcouple*dt (%g)",
ETCOUPLTYPE(ir->etc),
#include <config.h>
#endif
+#include <assert.h>
#include <math.h>
#include <string.h>
{
return;
}
- if ((pr->nr == 0) && (pr->param != NULL))
- {
- fprintf(stderr, "Warning: dangling pointer at %lx\n",
- (unsigned long)pr->param);
- pr->param = NULL;
- }
+ assert(!((pr->nr == 0) && (pr->param != NULL)));
if (pr->nr+extra > pr->maxnr)
{
pr->maxnr = max(1.2*pr->maxnr, pr->maxnr + extra);
char *
gmx_ctime_r(const time_t *clock, char *buf, int n)
{
- char tmpbuf[STRLEN];
-
-#ifdef GMX_NATIVE_WINDOWS
+#ifdef _MSC_VER
/* Windows */
- ctime_s( tmpbuf, STRLEN, clock );
+ ctime_s( buf, n, clock );
+#elif defined(GMX_NATIVE_WINDOWS)
+ char *tmpbuf = ctime( clock );
+ strncpy(buf, tmpbuf, n-1);
+ buf[n-1] = '\0';
#elif (defined(__sun))
/*Solaris*/
- ctime_r(clock, tmpbuf, n);
+ ctime_r(clock, buf, n);
#else
+ char tmpbuf[STRLEN];
ctime_r(clock, tmpbuf);
-#endif
strncpy(buf, tmpbuf, n-1);
buf[n-1] = '\0';
-
+#endif
return buf;
}
#define GMX_CYGWIN
#endif
-/* We currently don't support MingW. And ICC also defines it */
-#ifdef _MSC_VER
+#if defined( _WIN32 ) || defined( _WIN64 )
#define GMX_NATIVE_WINDOWS
#endif
*/
static gmx_inline void gmx_pause()
{
-#ifndef GMX_NATIVE_WINDOWS
+#ifndef _MSC_VER
/* Ugly hack because the openmp implementation below hacks into the SIMD
* settings to decide when to use _mm_pause(). This should eventually be
* changed into proper detection of the intrinsics uses, not SIMD.
*/
-#if (defined GMX_SIMD_X86_SSE2) || (defined GMX_SIMD_X86_SSE4_1) || \
+#if ((defined GMX_SIMD_X86_SSE2) || (defined GMX_SIMD_X86_SSE4_1) || \
(defined GMX_SIMD_X86_AVX_128_FMA) || (defined GMX_SIMD_X86_AVX_256) || \
- (defined GMX_SIMD_X86_AVX2_256)
+ (defined GMX_SIMD_X86_AVX2_256)) && !defined(__MINGW32__)
/* Replace with tbb::internal::atomic_backoff when/if we use TBB */
_mm_pause();
#elif defined __MIC__
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif
+#ifdef HAVE__ALIGNED_MALLOC
+#include <malloc.h>
+#endif
#include "gromacs/legacyheaders/gmx_fatal.h"
}
/* This routine can NOT be called with any pointer */
-void save_free_aligned(const char *name, const char *file, int line, void *ptr)
+void save_free_aligned(const char gmx_unused *name, const char gmx_unused *file, int gmx_unused line, void *ptr)
{
int i, j;
void *free = ptr;
// TODO fix this when we have an encapsulation layer for handling
// environment variables
#ifdef GMX_NATIVE_WINDOWS
- _putenv_s("GMX_MAXBACKUP", s_maxBackup.c_str());
+ _putenv(("GMX_MAXBACKUP="+s_maxBackup).c_str());
#else
setenv("GMX_MAXBACKUP", s_maxBackup.c_str(), true);
#endif