Convert gmxfio to C++
authorTeemu Murtola <teemu.murtola@gmail.com>
Thu, 2 Jul 2015 18:22:33 +0000 (21:22 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Thu, 2 Jul 2015 18:22:33 +0000 (21:22 +0300)
- Remove unused variables.
- Add missing extern "C" in thread-MPI.

Change-Id: I595f60ee27ab851e8c7c304b1f02a8f4aa15932f

src/external/thread_mpi/include/thread_mpi/lock.h
src/gromacs/fileio/gmxfio-xdr.cpp [moved from src/gromacs/fileio/gmxfio-xdr.c with 100% similarity]
src/gromacs/fileio/gmxfio.cpp [moved from src/gromacs/fileio/gmxfio.c with 98% similarity]

index f30e8bf740e594b1f879e7f96479d67dbcb0df6c..84a9794fdd2c0418896292335337db70ed32495f 100644 (file)
 #include "wait.h"
 #include "atomic.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /** Fast (possibly busy-wait-based) lock type
  *
  *  This lock type forms an intermediate between the spinlocks and mutexes:
@@ -102,6 +106,8 @@ int tMPI_Lock_trylock(tMPI_Lock_t *lock);
 TMPI_EXPORT
 int tMPI_Lock_islocked(tMPI_Lock_t *lock);
 
-
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* TMPI_FASTLOCK_H_ */
similarity index 98%
rename from src/gromacs/fileio/gmxfio.c
rename to src/gromacs/fileio/gmxfio.cpp
index 3f92499313029947239e51cd79cfe8c08c540687..67ab811570f8f3f70d05c6b937ed07c54d9bc691 100644 (file)
@@ -185,8 +185,6 @@ static void gmx_fio_insert(t_fileio *fio)
    NOTE: We also assume that the open_file_mutex has been locked */
 static void gmx_fio_remove(t_fileio *fio)
 {
-    t_fileio *prev;
-
     /* lock prev, because we're changing it */
     gmx_fio_lock(fio->prev);
 
@@ -275,10 +273,8 @@ static void gmx_fio_stop_getting_next(t_fileio *fio)
 t_fileio *gmx_fio_open(const char *fn, const char *mode)
 {
     t_fileio *fio = NULL;
-    int       i;
     char      newmode[5];
     gmx_bool  bRead, bReadWrite;
-    int       xdrid;
 
     /* sanitize the mode string */
     if (strncmp(mode, "r+", 2) == 0)
@@ -464,7 +460,7 @@ int gmx_fio_fp_close(t_fileio *fio)
 
 FILE * gmx_fio_fopen(const char *fn, const char *mode)
 {
-    FILE     *fp, *ret;
+    FILE     *ret;
     t_fileio *fio;
 
     fio = gmx_fio_open(fn, mode);
@@ -478,7 +474,6 @@ FILE * gmx_fio_fopen(const char *fn, const char *mode)
 int gmx_fio_fclose(FILE *fp)
 {
     t_fileio *cur;
-    t_fileio *found = NULL;
     int       rc    = -1;
 
     cur = gmx_fio_get_first();
@@ -608,8 +603,6 @@ int gmx_fio_get_file_md5(t_fileio *fio, gmx_off_t offset,
 /* The fio_mutex should ALWAYS be locked when this function is called */
 static int gmx_fio_int_get_file_position(t_fileio *fio, gmx_off_t *offset)
 {
-    char buf[STRLEN];
-
     /* Flush the file, so we are sure it is written */
     if (gmx_fio_int_flush(fio))
     {
@@ -635,11 +628,8 @@ static int gmx_fio_int_get_file_position(t_fileio *fio, gmx_off_t *offset)
 int gmx_fio_get_output_file_positions(gmx_file_position_t **p_outputfiles,
                                       int                  *p_nfiles)
 {
-    int                   i, nfiles, rc, nalloc;
-    int                   pos_hi, pos_lo;
-    long                  pos;
+    int                   nfiles, nalloc;
     gmx_file_position_t * outputfiles;
-    char                  buf[STRLEN];
     t_fileio             *cur;
 
     nfiles = 0;
@@ -655,7 +645,6 @@ int gmx_fio_get_output_file_positions(gmx_file_position_t **p_outputfiles,
            we call this routine... */
         if (cur->bOpen && !cur->bRead && cur->iFTP != efCPT)
         {
-            int ret;
             /* This is an output file currently open for writing, add it */
             if (nfiles == nalloc)
             {
@@ -754,8 +743,6 @@ int gmx_fio_flush(t_fileio* fio)
 static int gmx_fio_int_fsync(t_fileio *fio)
 {
     int rc    = 0;
-    int filen = -1;
-
 
     if (fio->fp)
     {