Compiles in MSVC with cmake
authorunknown <Sander@.(none)>
Mon, 17 Aug 2009 11:17:20 +0000 (13:17 +0200)
committerSander Pronk <sander@csbm09.cbr.su.se>
Wed, 19 Aug 2009 12:20:24 +0000 (14:20 +0200)
13 files changed:
include/thread_mpi/winthreads.h
include/types/fcdata.h
src/gmxlib/futil.c
src/gmxlib/gmx_fatal.c
src/gmxlib/main.c
src/gmxlib/pargs.c
src/gmxlib/symtab.c
src/gmxlib/thread_mpi/winthreads.c
src/gmxlib/wman.c
src/kernel/xlate.c
src/mdlib/domdec.c
src/tools/gmx_dipoles.c
src/tools/nsc.c

index b538e9306fd98a0c7c9854ab5c8644df2cc1ffca..44177211b71ca144ace4819d0b29e98e5ac4d52e 100644 (file)
@@ -48,8 +48,11 @@ any papers on the package - you can find them in the top README file.
  */
 
 
-/* we need this for all the data types */
+/* we need this for all the data types. We use WIN32_LEAN_AND_MEAN to avoid 
+   polluting the global namespace. */
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
 
 /*! \brief Status for one-time initialization of thread stuff.
  *
index b8123ccb3ef9fd69c80f75283d5dd8c26d8ecdfd..a2db4794b303944e787b7f3eb851cdfc4c76af70 100644 (file)
@@ -64,6 +64,7 @@ typedef struct {
 #endif
 } t_disresdata;
 
+
 /* Orientation restraining stuff */
 typedef struct {
   real   fc;          /* Force constant for the restraints                  */
index 27946842d4c06c141577a800142f5f35155b6d76..9eb328aa1eb64df2edff20d8c58157f664bac8ae 100644 (file)
@@ -92,10 +92,11 @@ void no_buffers(void)
 
 void push_ps(FILE *fp)
 {
+    t_pstack *ps;
+
 #ifdef GMX_THREADS
     tMPI_Thread_mutex_lock(&pstack_mutex);
 #endif
-    t_pstack *ps;
 
     snew(ps,1);
     ps->fp   = fp;
@@ -136,10 +137,10 @@ static int pclose(FILE *fp)
 
 void ffclose(FILE *fp)
 {
+    t_pstack *ps,*tmp;
 #ifdef GMX_THREADS
     tMPI_Thread_mutex_lock(&pstack_mutex);
 #endif
-    t_pstack *ps,*tmp;
 
     ps=pstack;
     if (ps == NULL) {
@@ -178,10 +179,10 @@ void ffclose(FILE *fp)
 
 void frewind(FILE *fp)
 {
+    t_pstack *ps;
 #ifdef GMX_THREADS
     tMPI_Thread_mutex_lock(&pstack_mutex);
 #endif
-    t_pstack *ps;
 
     ps=pstack;
     while (ps != NULL) {
@@ -202,10 +203,10 @@ void frewind(FILE *fp)
 
 bool is_pipe(FILE *fp)
 {
+    t_pstack *ps;
 #ifdef GMX_THREADS
     tMPI_Thread_mutex_lock(&pstack_mutex);
 #endif
-    t_pstack *ps;
 
     ps=pstack;
     while (ps != NULL) {
index 77027389764380a957b8b632a9d6b33437a5c3f3..4592227d0273710b0e2136bb2505bd165c103ac9 100644 (file)
@@ -752,20 +752,20 @@ void _gmx_error(const char *key,const char *msg,const char *file,int line)
 {
   char buf[10240],tmpbuf[1024];
   int  cqnum;
+  const char *llines = "-------------------------------------------------------";
 
 #ifdef GMX_THREADS
     tMPI_Thread_mutex_lock(&debug_mutex);
 #endif
   /* protect the audience from suggestive discussions */
-  const char *lines = "-------------------------------------------------------";
   
   cool_quote(tmpbuf,1023,&cqnum);
   sprintf(buf,"\n%s\nProgram %s, %s\n"
          "Source code file: %s, line: %d\n\n"
          "%s:\n%s\nFor more information and tips for trouble shooting please check the GROMACS Wiki at\n"
          "http://wiki.gromacs.org/index.php/Errors\n%s\n\n%s\n",
-         lines,ShortProgram(),GromacsVersion(),file,line,
-         gmx_strerror(key),msg ? msg : warn_buf,lines,tmpbuf);
+         llines,ShortProgram(),GromacsVersion(),file,line,
+         gmx_strerror(key),msg ? msg : warn_buf,llines,tmpbuf);
 #ifdef GMX_THREADS
     tMPI_Thread_mutex_unlock(&debug_mutex);
 #endif
index 0e6ac34dccaf6af93eb6ae0ea5216b97d81342b4..cf60c456fa19ea886912559647f72b5c7961f649 100644 (file)
@@ -114,7 +114,7 @@ static void par_fn(char *base,int ftp,const t_commrec *cr,
 {
   int n;
   
-  if(bufsize<(strlen(base)+4))
+  if((size_t)bufsize<(strlen(base)+4))
      gmx_mem("Character buffer too small!");
 
   /* Copy to buf, and strip extension */
index 2be0c222d47f341d64229724d913adb636c52698..1fe490f987de90d5b51941b4b347166c2a5bed10 100644 (file)
@@ -242,8 +242,8 @@ const char *opt2parg_enum(const char *option,int nparg,t_pargs pa[])
 
 char *pa_val(t_pargs *pa, char buf[], int sz)
 {
-  char buf_str[1256]; buf_str[0]='\0';
   real r;
+  char buf_str[1256]; buf_str[0]='\0';
 
   buf[0]='\0';
 
@@ -268,7 +268,7 @@ char *pa_val(t_pargs *pa, char buf[], int sz)
     break;
   case etSTR:
     if (*(pa->u.c)) {
-      if (strlen(*(pa->u.c)) >= sz)
+      if (strlen(*(pa->u.c)) >= (size_t)sz)
        gmx_fatal(FARGS,"Argument too long: \"%d\"\n",*(pa->u.c));
       else
        strcpy(buf,*(pa->u.c));
index 5959b6c23c56553d44d98e36ae3368981db95cb0..fb1a95528612bd1691dd32303292b6f6af5e16df 100644 (file)
@@ -59,7 +59,7 @@ static char *trim_string(const char *s,char *out, int maxlen)
 {
   int len,i;
  
-  if(strlen(s)>maxlen-1)
+  if(strlen(s)>(size_t)(maxlen-1))
     gmx_fatal(FARGS,"Character buffer size too small\n");
   
   for (; (*s)&&((*s)==' '); s++);
index b73a8ae1dda92f8287e975088be73d63b90d01db..175a6e9342d3d376486822e71ddb77ffa89d8c47 100644 (file)
@@ -62,6 +62,7 @@ any papers on the package - you can find them in the top README file.
 
 
 #include "thread_mpi/threads.h"
+#include "thread_mpi/atomic.h"
 
 /*! \brief System mutex for all one-time initialization 
  *
@@ -69,10 +70,12 @@ any papers on the package - you can find them in the top README file.
  *  independent of the thread library implementation. Anyway, it
  *  will only be locked a handful of times at the start of program execution.
  */
+/*
 enum tMPI_Thread_once_status tMPI_Thread_system_lock_state=
                              TMPI_THREAD_ONCE_STATUS_NOTCALLED;
 static CRITICAL_SECTION tMPI_Thread_system_lock;
-
+*/
+tMPI_Spinlock_t tMPI_Thread_system_lock=TMPI_SPINLOCK_INITIALIZER;
 
 
 void tMPI_Fatal_error(const char *file, int line, const char *message, ...)
@@ -236,7 +239,8 @@ static int tMPI_Thread_mutex_init_once(tMPI_Thread_mutex_t *mtx)
      */ 
 
     /* Lock the common one-time init mutex so we can check carefully */
-    EnterCriticalSection( &tMPI_Thread_system_lock );
+    /*EnterCriticalSection( &tMPI_Thread_system_lock );*/
+    tMPI_Spinlock_lock( &tMPI_Thread_system_lock );
 
 
 #if 0
@@ -268,7 +272,8 @@ static int tMPI_Thread_mutex_init_once(tMPI_Thread_mutex_t *mtx)
         ret = 0;
     }
     
-    LeaveCriticalSection( &tMPI_Thread_system_lock );
+    /*LeaveCriticalSection( &tMPI_Thread_system_lock );*/
+    tMPI_Spinlock_unlock( &tMPI_Thread_system_lock );
 
     return ret;
 }
@@ -447,7 +452,8 @@ static int tMPI_Thread_cond_init_once(tMPI_Thread_cond_t *cond)
     * the memory barriers right. Trust me, you don't want a deadlock here...
     */ 
     /* Lock the common one-time init mutex so we can check carefully */
-    EnterCriticalSection( &tMPI_Thread_system_lock );
+    /*EnterCriticalSection( &tMPI_Thread_system_lock );*/
+    tMPI_Spinlock_lock( &tMPI_Thread_system_lock );
     /* Do the actual (locked) check - system mutex is locked if we get here */
        if (cond->init_state != TMPI_THREAD_ONCE_STATUS_READY)
     {
@@ -457,8 +463,8 @@ static int tMPI_Thread_cond_init_once(tMPI_Thread_cond_t *cond)
     {
         ret = 0;
     }
-    LeaveCriticalSection( &tMPI_Thread_system_lock );
-    
+    /*LeaveCriticalSection( &tMPI_Thread_system_lock );*/
+    tMPI_Spinlock_lock( &tMPI_Thread_system_lock );
     return ret;
 }
 
@@ -583,7 +589,8 @@ static int tMPI_Thread_barrier_init_once(tMPI_Thread_barrier_t *barrier, int n)
     * the memory barriers right. Trust me, you don't want a deadlock here...
     */ 
     /* Lock the common one-time init mutex so we can check carefully */
-    EnterCriticalSection( &tMPI_Thread_system_lock );
+    /*EnterCriticalSection( &tMPI_Thread_system_lock );*/
+    tMPI_Spinlock_lock( &tMPI_Thread_system_lock );
     /* Do the actual (locked) check - system mutex is locked if we get here */
     if (barrier->init_state != TMPI_THREAD_ONCE_STATUS_READY)
     {
@@ -593,7 +600,8 @@ static int tMPI_Thread_barrier_init_once(tMPI_Thread_barrier_t *barrier, int n)
     {
         ret = 0;
     }
-    LeaveCriticalSection( &tMPI_Thread_system_lock );
+    /*LeaveCriticalSection( &tMPI_Thread_system_lock );*/
+    tMPI_Spinlock_lock( &tMPI_Thread_system_lock );
     
     return ret;
 }
index 9baa9513ce66be85291cf6861423dc481c73839f..ae63e5535a53785131878c173b61333a4912cceb 100644 (file)
@@ -527,7 +527,7 @@ print_tty_formatted(FILE *out, int nldesc, const char **desc,int indent,
       temp=NWR(desc[i]);
     else
       temp=check_tty(desc[i]);
-    if (strlen(buf) + strlen(temp) >= buflen-2) {
+    if (strlen(buf) + strlen(temp) >= (size_t)(buflen-2)) {
       buflen += strlen(temp);
       srenew(buf,buflen);
     }
index 2d8910747661e58305466d4cf1c47aa8ca862542..842c55f574510774ce7e0827a07872ba1a4e5632 100644 (file)
@@ -125,7 +125,7 @@ void rename_atoms(t_atoms *atoms,t_symtab *symtab,t_aa_names *aan)
     strcpy(atombuf,*(atoms->atomname[a]));
     if (isdigit(atombuf[0])) {
       c = atombuf[0];
-      for (i=0; (i<strlen(atombuf)-1); i++)
+      for (i=0; ((size_t)i<strlen(atombuf)-1); i++)
        atombuf[i]=atombuf[i+1];
       atombuf[i]=c;
     }
index 24a6a5bc5f70bc8154559500c2f51360803148c7..a25ae8012ff1ea81fa7362931b57de2401ad7182 100644 (file)
@@ -3098,6 +3098,7 @@ static void set_dd_cell_sizes_dlb_root(gmx_domdec_t *dd,
     real change_limit = 0.1;
     real relax = 0.5;
     bool bPBC;
+    int range[] = { 0, 0 };
 
     comm = dd->comm;
 
@@ -3193,7 +3194,7 @@ static void set_dd_cell_sizes_dlb_root(gmx_domdec_t *dd,
             }
         }
     }
-    int range[] = { 0, ncd };
+    range[1]=ncd;
     root->cell_f[0] = 0;
     root->cell_f[ncd] = 1;
     dd_cell_sizes_dlb_root_enforce_limits(dd, d, dim, root, ddbox, bUniform, step, cellsize_limit_f, range);
index b37ee2d02023f6389f9f2ca9c83974a5ccca9839..0956b019d6972518889ef2219f32b22354ab2e14 100644 (file)
@@ -147,6 +147,7 @@ static void rvec2sprvec(rvec dipcart,rvec dipsp)
 }
 
 
+
 void do_gkr(t_gkrbin *gb,int ncos,int *ngrp,int *molindex[],
            int mindex[],rvec x[],rvec mu[],
            int ePBC,matrix box,t_atom *atom,int *nAtom)
index fe47bff6e92a3fb9817b01b689796f5db8812c59..7698e0578133d65fba4efc6015d11af577f5b93f 100644 (file)
@@ -71,6 +71,9 @@ int    last_cubus=0;
 const char * __file__;   /* declared versions of macros */
 int  __line__;           /* __FILE__  and __LINE__ */
 
+#ifdef ERROR
+#undef ERROR
+#endif
 #define ERROR UPDATE_FL,error
 void error(const char *fmt, ...) {
   va_list args;