Don't install headers depending on GMX_INTERNAL_XDR
authorTeemu Murtola <teemu.murtola@gmail.com>
Tue, 26 Nov 2013 19:14:42 +0000 (21:14 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sun, 1 Dec 2013 23:54:08 +0000 (00:54 +0100)
There should be no need to install xdrf.h; if some user wants to use the
API, some higher-level API is probably better suitable.  With some
reorganization of the headers, all cases where the header was included
from some other installed header were actually unnecessary:
 - gmx_fio_getxdr() is now in xdrf.h (somewhat ugly, but so are the
   alternatives).
 - xdr_datatype is mainly used for edr reading (also for checkpoint
   precision), but put it into a separate header for now that can be
   installed.  It is actually completely independent of the other stuff
   in xdrf.h.

Change-Id: I74a66388a8c09cbf4eb9b7b44d7cd13be2776e9c

CMakeLists.txt
src/gromacs/fileio/CMakeLists.txt
src/gromacs/fileio/enxio.h
src/gromacs/fileio/gmxfio.h
src/gromacs/fileio/gmxfio_int.h
src/gromacs/fileio/libxdrf.c
src/gromacs/fileio/xdr_datatype.h [new file with mode: 0644]
src/gromacs/fileio/xdrf.h
src/gromacs/fileio/xtcio.h
src/gromacs/gmxlib/checkpoint.c
tests/CppCheck.cmake

index 64d5342e93910b8c42a9c15f785a873b4cb0a3a7..42a2232ff4f33c2ea62cb1865dbbdf42ee6c97ab 100644 (file)
@@ -704,7 +704,6 @@ include(gmxTestXDR)
 gmx_test_xdr(GMX_SYSTEM_XDR)
 if(NOT GMX_SYSTEM_XDR)
     set(GMX_INTERNAL_XDR 1)
-    set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_INTERNAL_XDR")
 endif(NOT GMX_SYSTEM_XDR)
 
 # include avx test source, used if the AVX flags are set below
index bf8426890435293c46130870173013a193b000fa..876a6397bbd6e9e98a7938b812e4e53f7a17aabe 100644 (file)
@@ -40,7 +40,6 @@ set(FILEIO_PUBLIC_HEADERS
     enxio.h
     filenm.h
     futil.h
-    gmx_system_xdr.h
     gmxfio.h
     matio.h
     mdoutf.h
@@ -50,7 +49,7 @@ set(FILEIO_PUBLIC_HEADERS
     trnio.h
     trx.h
     trxio.h
-    xdrf.h
+    xdr_datatype.h
     xtcio.h
     )
 gmx_install_headers(fileio ${FILEIO_PUBLIC_HEADERS})
index 6a7b27505db4282aa1c1bf3a7dbc8a1cb166a6d4..122941a291c22cad7afd03c84c2304c9d41aeb28 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-
 #ifndef GMX_FILEIO_ENXIO_H
 #define GMX_FILEIO_ENXIO_H
 
-#include "../legacyheaders/sysstuff.h"
 #include "../legacyheaders/typedefs.h"
 #include "../legacyheaders/pbc.h"
 #include "gmxfio.h"
+#include "xdr_datatype.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -216,4 +215,4 @@ void add_subblocks_enxblock(t_enxblock *eb, int n);
 }
 #endif
 
-#endif  /* GMX_FILEIO_ENERIO_H */
+#endif
index 07d4dba37e0a36f4a7b06eec69eb148e1c680fe1..a9ffc11c5d96931676e538d83d699a8caf0eb968 100644 (file)
@@ -40,7 +40,6 @@
 
 #include <stdio.h>
 #include "../legacyheaders/typedefs.h"
-#include "xdrf.h"
 #include "futil.h"
 
 #ifdef __cplusplus
@@ -169,12 +168,6 @@ int gmx_fio_seek(t_fileio *fio, gmx_off_t fpos);
 FILE *gmx_fio_getfp(t_fileio *fio);
 /* Return the file pointer itself */
 
-XDR *gmx_fio_getxdr(t_fileio *fio);
-/* Return the file pointer itself */
-
-
-
-
 
 /* Element with information about position in a currently open file.
  * gmx_off_t should be defined by autoconf if your system does not have it.
index 0fefe60fc53e49a91b7a4fa2a4e6fe2ed3bde8c6..f598d704eaa5148c15472fbd0c91400c2e6f2d7a 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-
 #ifndef GMX_FILEIO_GMXFIO_INT_H
 #define GMX_FILEIO_GMXFIO_INT_H
 
-
 /* This is the new improved and thread safe version of gmxfio.  */
 
 
@@ -59,6 +57,7 @@
 #define USE_XDR
 
 #include "gromacs/legacyheaders/thread_mpi/lock.h"
+#include "xdrf.h"
 
 /* the reader/writer functions  for t_iotype */
 typedef gmx_bool read_func (t_fileio *fio, void *item, int nitem, int eio,
index 60dba86d0136d4079b0cadbed72ea0ae26e24a0a..4cc63820bcc49ac16cba7e4bccc8f81472630726 100644 (file)
@@ -45,6 +45,7 @@
 #include <string.h>
 #include "statutil.h"
 #include "xdrf.h"
+#include "xdr_datatype.h"
 #include "string2.h"
 #include "futil.h"
 #include "gmx_fatal.h"
diff --git a/src/gromacs/fileio/xdr_datatype.h b/src/gromacs/fileio/xdr_datatype.h
new file mode 100644 (file)
index 0000000..8953782
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2013, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+#ifndef GMX_FILEIO_XDR_DATATYPE_H
+#define GMX_FILEIO_XDR_DATATYPE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* the xdr data types; note that there is no data type 'real' because
+   here we deal with the types as they are actually written to disk.  */
+typedef enum
+{
+    xdr_datatype_int,
+    xdr_datatype_float,
+    xdr_datatype_double,
+    xdr_datatype_large_int,
+    xdr_datatype_char,
+    xdr_datatype_string
+} xdr_datatype;
+
+/* names corresponding to the xdr_datatype enum */
+extern const char *xdr_datatype_names[];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 1edafcc1ec918792d263548a348e5c9b330eba2a..7e2714c0c7b4a0ef9d16718ad195c89edb02e839 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-
 #ifndef GMX_FILEIO_XDRF_H
 #define GMX_FILEIO_XDRF_H
 
-
 #include <stdio.h>
 #include "../legacyheaders/typedefs.h"
 
@@ -46,7 +44,8 @@
 #define int64_t long long
 #endif
 
-#include "../utility/gmx_header_config.h"
+#include "config.h"
+
 #ifdef GMX_INTERNAL_XDR
 #include "gmx_system_xdr.h"
 #else
 extern "C" {
 #endif
 
-
-/* THESE 3 FUNCTIONS (xdropen, xdrclose and xdr_get_fp) ARE NOW OBSOLETE
-   AND ONLY PROVIDED FOR BACKWARD COMPATIBILITY OF 3D PARTY TOOLS.
-   THEY SHOULD NOT BE USED ANYWHERE IN GROMACS ITSELF.
-   int xdropen(XDR *xdrs, const char *filename, const char *type);
-   int xdrclose(XDR *xdrs);
- */
-
-/* the xdr data types; note that there is no data type 'real' because
-   here we deal with the types as they are actually written to disk.  */
-typedef enum
-{
-    xdr_datatype_int,
-    xdr_datatype_float,
-    xdr_datatype_double,
-    xdr_datatype_large_int,
-    xdr_datatype_char,
-    xdr_datatype_string
-} xdr_datatype;
-
-/* names corresponding to the xdr_datatype enum */
-extern const char *xdr_datatype_names[];
+struct t_fileio;
 
 /* Read or write reduced precision *float* coordinates */
 int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision);
@@ -114,6 +92,16 @@ float xdr_xtc_get_last_frame_time(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bO
 
 int xdr_xtc_get_last_frame_number(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK);
 
+
+/* Defined in gmxfio.c.
+ * TODO: It would be nice to decouple this header from t_fileio completely,
+ * and not need the XDR struct in gmxfio.h, but that would require some
+ * extra code that is not warranted for this single function.
+ * Can be reconsidered if the file I/O gets refactored in the future.
+ */
+XDR *gmx_fio_getxdr(struct t_fileio *fio);
+/* Return the file pointer itself */
+
 #ifdef __cplusplus
 }
 #endif
index c21e7e8e25719271ff7e7389bc5e7965a0d5de40..494cd863beb12afc577af0b1ae6c0b154a84fea9 100644 (file)
@@ -40,7 +40,6 @@
 
 #include "../legacyheaders/typedefs.h"
 #include "gmxfio.h"
-#include "xdrf.h"
 
 #ifdef __cplusplus
 extern "C" {
index bb263c4f28a4ea5da8eb2727ed4c93a84d06ba70..63cde1c278e928e4abed372c401b610ed24c6e5b 100644 (file)
 #include <sys/locking.h>
 #endif
 
-
-#include "gromacs/fileio/filenm.h"
 #include "names.h"
 #include "typedefs.h"
 #include "smalloc.h"
-#include "gromacs/fileio/gmxfio.h"
-#include "gromacs/fileio/xdrf.h"
 #include "statutil.h"
 #include "txtdump.h"
 #include "vec.h"
 #include "network.h"
 #include "gmx_random.h"
 #include "checkpoint.h"
-#include "gromacs/fileio/futil.h"
 #include "string2.h"
 #include <fcntl.h>
 
+#include "gromacs/fileio/filenm.h"
+#include "gromacs/fileio/futil.h"
+#include "gromacs/fileio/gmxfio.h"
+#include "gromacs/fileio/xdrf.h"
+#include "gromacs/fileio/xdr_datatype.h"
+
 #include "buildinfo.h"
 
 #ifdef GMX_FAHCORE
index 4e64e29afcf2ef854863d09a305d1d3c66f25ac4..16eb8218b8df0ea661ed83119286a06ebf3c8c4e 100644 (file)
@@ -74,6 +74,7 @@ if (CPPCHECK_EXECUTABLE AND UNIX)
         -I src/gromacs/gmxpreprocess
         -I src/programs/mdrun
         --suppress=variableScope
+        --suppress=unnecessaryForwardDeclaration
         --suppress=unusedVariable
         --suppress=unreadVariable
         --suppress=unusedStructMember