From: Teemu Murtola Date: Tue, 26 Nov 2013 19:14:42 +0000 (+0200) Subject: Don't install headers depending on GMX_INTERNAL_XDR X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=c0eea94a33ce4a33ccdfec9ca97f9f4c08914776;p=alexxy%2Fgromacs.git Don't install headers depending on GMX_INTERNAL_XDR 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 64d5342e93..42a2232ff4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/gromacs/fileio/CMakeLists.txt b/src/gromacs/fileio/CMakeLists.txt index bf84268904..876a6397bb 100644 --- a/src/gromacs/fileio/CMakeLists.txt +++ b/src/gromacs/fileio/CMakeLists.txt @@ -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}) diff --git a/src/gromacs/fileio/enxio.h b/src/gromacs/fileio/enxio.h index 6a7b27505d..122941a291 100644 --- a/src/gromacs/fileio/enxio.h +++ b/src/gromacs/fileio/enxio.h @@ -34,14 +34,13 @@ * 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 diff --git a/src/gromacs/fileio/gmxfio.h b/src/gromacs/fileio/gmxfio.h index 07d4dba37e..a9ffc11c5d 100644 --- a/src/gromacs/fileio/gmxfio.h +++ b/src/gromacs/fileio/gmxfio.h @@ -40,7 +40,6 @@ #include #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. diff --git a/src/gromacs/fileio/gmxfio_int.h b/src/gromacs/fileio/gmxfio_int.h index 0fefe60fc5..f598d704ea 100644 --- a/src/gromacs/fileio/gmxfio_int.h +++ b/src/gromacs/fileio/gmxfio_int.h @@ -34,11 +34,9 @@ * 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, diff --git a/src/gromacs/fileio/libxdrf.c b/src/gromacs/fileio/libxdrf.c index 60dba86d01..4cc63820bc 100644 --- a/src/gromacs/fileio/libxdrf.c +++ b/src/gromacs/fileio/libxdrf.c @@ -45,6 +45,7 @@ #include #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 index 0000000000..89537826c6 --- /dev/null +++ b/src/gromacs/fileio/xdr_datatype.h @@ -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 diff --git a/src/gromacs/fileio/xdrf.h b/src/gromacs/fileio/xdrf.h index 1edafcc1ec..7e2714c0c7 100644 --- a/src/gromacs/fileio/xdrf.h +++ b/src/gromacs/fileio/xdrf.h @@ -34,11 +34,9 @@ * 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 #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 @@ -58,28 +57,7 @@ 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 diff --git a/src/gromacs/fileio/xtcio.h b/src/gromacs/fileio/xtcio.h index c21e7e8e25..494cd863be 100644 --- a/src/gromacs/fileio/xtcio.h +++ b/src/gromacs/fileio/xtcio.h @@ -40,7 +40,6 @@ #include "../legacyheaders/typedefs.h" #include "gmxfio.h" -#include "xdrf.h" #ifdef __cplusplus extern "C" { diff --git a/src/gromacs/gmxlib/checkpoint.c b/src/gromacs/gmxlib/checkpoint.c index bb263c4f28..63cde1c278 100644 --- a/src/gromacs/gmxlib/checkpoint.c +++ b/src/gromacs/gmxlib/checkpoint.c @@ -41,23 +41,24 @@ #include #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 +#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 diff --git a/tests/CppCheck.cmake b/tests/CppCheck.cmake index 4e64e29afc..16eb8218b8 100644 --- a/tests/CppCheck.cmake +++ b/tests/CppCheck.cmake @@ -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