Collect more platform-specific code to sysinfo.h
authorTeemu Murtola <teemu.murtola@gmail.com>
Sun, 19 Oct 2014 04:24:36 +0000 (07:24 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Wed, 22 Oct 2014 18:44:56 +0000 (21:44 +0300)
commitdfcbad03f2293ee761cc71bcbdffdc62db266886
tree6c765682e7cc0c2be7d7988ff7ef3a66a0523008
parentcbc758b54a90a5761ac90b78140ff5b18ca77abe
Collect more platform-specific code to sysinfo.h

Move a few existing functions of this type to sysinfo.* from
basenetwork.* and cstringutil.*.  Mostly this is just code movement, but
there are two changes:
 * getuid() usage is now controlled by HAVE_UNISTD_H instead of
   HAVE_PWD_H, and excluded for MinGW (the latter is just a guess, but
   many other similar calls are excluded for MinGW).
 * Getting the current username uses getlogin_r() instead of getpwuid(),
   following the implementation in tngio.cpp instead of the original
   implementation in cstringutil.c.  If this is OK, then we can get rid
   of HAVE_PWD_H completely.  Alternative would be to make the code use
   getpwuid_r() if the old functionality is more desirable, but that is
   a bit more effort, and requires some testing for platform support, as
   that has not been used before in the code.

This allows removing platform-specific #ifdefs and #includes from
multiple files completely, making these aspects better encapsulated.

While checking the presence of #ifdefs, removed one useless #ifndef
GMX_FAHCORE from tngio.cpp; make_backup() already handles FAHCORE
internally.

Change-Id: I46876635fb254eb9558cce80b34ebe3078425375
13 files changed:
src/gromacs/fileio/tngio.cpp
src/gromacs/fileio/xvgr.cpp
src/gromacs/gmxana/gmx_covar.c
src/gromacs/gmxlib/checkpoint.cpp
src/gromacs/gmxlib/gmx_detect_hardware.cpp
src/gromacs/gmxlib/main.cpp
src/gromacs/mdlib/sim_util.cpp
src/gromacs/utility/basenetwork.cpp
src/gromacs/utility/basenetwork.h
src/gromacs/utility/cstringutil.c
src/gromacs/utility/cstringutil.h
src/gromacs/utility/sysinfo.cpp
src/gromacs/utility/sysinfo.h