Skip to content

Commit

Permalink
Impose proper file scoping and header usage.
Browse files Browse the repository at this point in the history
Clean up the header files to only contain those things that
need to be shared between .c files.

Functions that are not shared are now declared static to
make their file scope explicit.  Functions that ARE shared
are declared in appropriate headers.

I am not going to claim that I caugh everything, but at
least it is a good start.
  • Loading branch information
morrone committed Nov 12, 2011
1 parent e7fea4f commit a60ad0b
Show file tree
Hide file tree
Showing 14 changed files with 533 additions and 492 deletions.
4 changes: 4 additions & 0 deletions contrib/cbif.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
*
\******************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bin_PROGRAMS += IOR
endif

ior_SOURCES = ior.c utilities.c parse_options.c
ior_SOURCES += ior.h aiori.h iordef.h
ior_SOURCES += ior.h utilities.h parse_options.h aiori.h iordef.h
ior_LDADD =

if USE_POSIX_AIORI
Expand Down
90 changes: 45 additions & 45 deletions src/aiori-HDF5.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
*
\******************************************************************************/

#include "aiori.h" /* abstract IOR interface */
#include <errno.h> /* sys_errlist */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdio.h> /* only for fprintf() */
#include <stdlib.h>
#include <sys/stat.h>
#include <hdf5.h>
#include <mpi.h>

#include "aiori.h" /* abstract IOR interface */
#include "utilities.h"
#include "iordef.h"

#define NUM_DIMS 1 /* number of dimensions to data set */

Expand Down Expand Up @@ -69,37 +76,32 @@
#endif /* H5_VERS_MAJOR > 1 && H5_VERS_MINOR > 6 */
/**************************** P R O T O T Y P E S *****************************/

static IOR_offset_t SeekOffset_HDF5(void *, IOR_offset_t, IOR_param_t *);
void SetupDataSet_HDF5(void *, IOR_param_t *);

void *IOR_Create_HDF5(char *, IOR_param_t *);
void *IOR_Open_HDF5(char *, IOR_param_t *);
IOR_offset_t IOR_Xfer_HDF5(int, void *, IOR_size_t *,
static IOR_offset_t SeekOffset(void *, IOR_offset_t, IOR_param_t *);
static void SetupDataSet(void *, IOR_param_t *);
static void *HDF5_Create(char *, IOR_param_t *);
static void *HDF5_Open(char *, IOR_param_t *);
static IOR_offset_t HDF5_Xfer(int, void *, IOR_size_t *,
IOR_offset_t, IOR_param_t *);
void IOR_Close_HDF5(void *, IOR_param_t *);
void IOR_Delete_HDF5(char *, IOR_param_t *);
void IOR_SetVersion_HDF5(IOR_param_t *);
void IOR_Fsync_HDF5(void *, IOR_param_t *);
IOR_offset_t IOR_GetFileSize_HDF5(IOR_param_t *, MPI_Comm, char *);
static void HDF5_Close(void *, IOR_param_t *);
static void HDF5_Delete(char *, IOR_param_t *);
static void HDF5_SetVersion(IOR_param_t *);
static void HDF5_Fsync(void *, IOR_param_t *);
static IOR_offset_t HDF5_GetFileSize(IOR_param_t *, MPI_Comm, char *);

/************************** D E C L A R A T I O N S ***************************/

ior_aiori_t hdf5_aiori = {
"HDF5",
IOR_Create_HDF5,
IOR_Open_HDF5,
IOR_Xfer_HDF5,
IOR_Close_HDF5,
IOR_Delete_HDF5,
IOR_SetVersion_HDF5,
IOR_Fsync_HDF5,
IOR_GetFileSize_HDF5
HDF5_Create,
HDF5_Open,
HDF5_Xfer,
HDF5_Close,
HDF5_Delete,
HDF5_SetVersion,
HDF5_Fsync,
HDF5_GetFileSize
};

extern int errno, /* error number */
rank, rankOffset, verbose; /* verbose output */
extern MPI_Comm testComm;

static hid_t xferPropList; /* xfer property list */
hid_t dataSet; /* data set id */
hid_t dataSpace; /* data space id */
Expand All @@ -112,15 +114,15 @@ int newlyOpenedFile; /* newly opened file */
/*
* Create and open a file through the HDF5 interface.
*/
void *IOR_Create_HDF5(char *testFileName, IOR_param_t * param)
static void *HDF5_Create(char *testFileName, IOR_param_t * param)
{
return IOR_Open_HDF5(testFileName, param);
return HDF5_Open(testFileName, param);
}

/*
* Open a file through the HDF5 interface.
*/
void *IOR_Open_HDF5(char *testFileName, IOR_param_t * param)
static void *HDF5_Open(char *testFileName, IOR_param_t * param)
{
hid_t accessPropList, createPropList;
hsize_t memStart[NUM_DIMS],
Expand Down Expand Up @@ -322,10 +324,8 @@ void *IOR_Open_HDF5(char *testFileName, IOR_param_t * param)
/*
* Write or read access to file using the HDF5 interface.
*/
IOR_offset_t
IOR_Xfer_HDF5(int access,
void *fd,
IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param)
static IOR_offset_t HDF5_Xfer(int access, void *fd, IOR_size_t * buffer,
IOR_offset_t length, IOR_param_t * param)
{
static int firstReadCheck = FALSE, startNewDataSet;
IOR_offset_t segmentPosition, segmentSize;
Expand Down Expand Up @@ -374,10 +374,10 @@ IOR_Xfer_HDF5(int access,
HDF5_CHECK(H5Sclose(fileDataSpace),
"cannot close file data space");
}
SetupDataSet_HDF5(fd, param);
SetupDataSet(fd, param);
}

SeekOffset_HDF5(fd, param->offset, param);
SeekOffset(fd, param->offset, param);

/* this is necessary to reset variables for reaccessing file */
startNewDataSet = FALSE;
Expand All @@ -401,15 +401,15 @@ IOR_Xfer_HDF5(int access,
/*
* Perform fsync().
*/
void IOR_Fsync_HDF5(void *fd, IOR_param_t * param)
static void HDF5_Fsync(void *fd, IOR_param_t * param)
{
;
}

/*
* Close a file through the HDF5 interface.
*/
void IOR_Close_HDF5(void *fd, IOR_param_t * param)
static void HDF5_Close(void *fd, IOR_param_t * param)
{
if (param->fd_fppReadCheck == NULL) {
HDF5_CHECK(H5Dclose(dataSet), "cannot close data set");
Expand All @@ -428,7 +428,7 @@ void IOR_Close_HDF5(void *fd, IOR_param_t * param)
/*
* Delete a file through the HDF5 interface.
*/
void IOR_Delete_HDF5(char *testFileName, IOR_param_t * param)
static void HDF5_Delete(char *testFileName, IOR_param_t * param)
{
if (unlink(testFileName) != 0)
WARN("cannot delete file");
Expand All @@ -437,7 +437,7 @@ void IOR_Delete_HDF5(char *testFileName, IOR_param_t * param)
/*
* Determine api version.
*/
void IOR_SetVersion_HDF5(IOR_param_t * test)
static void HDF5_SetVersion(IOR_param_t * test)
{
unsigned major, minor, release;
if (H5get_libversion(&major, &minor, &release) < 0) {
Expand All @@ -456,8 +456,8 @@ void IOR_SetVersion_HDF5(IOR_param_t * test)
/*
* Seek to offset in file using the HDF5 interface and set up hyperslab.
*/
static IOR_offset_t SeekOffset_HDF5(void *fd, IOR_offset_t offset,
IOR_param_t * param)
static static HDF5_offset_t SeekOffset(void *fd, IOR_offset_t offset,
IOR_param_t * param)
{
IOR_offset_t segmentSize;
hsize_t hsStride[NUM_DIMS], hsCount[NUM_DIMS], hsBlock[NUM_DIMS];
Expand Down Expand Up @@ -491,12 +491,12 @@ static IOR_offset_t SeekOffset_HDF5(void *fd, IOR_offset_t offset,
hsStart, hsStride, hsCount, hsBlock),
"cannot select hyperslab");
return (offset);
} /* SeekOffset_HDF5() */
}

/*
* Create HDF5 data set.
*/
static void SetupDataSet_HDF5(void *fd, IOR_param_t * param)
static static void SetupDataSet(void *fd, IOR_param_t * param)
{
char dataSetName[MAX_STR];
hid_t dataSetPropList;
Expand Down Expand Up @@ -557,8 +557,8 @@ static void SetupDataSet_HDF5(void *fd, IOR_param_t * param)
/*
* Use MPIIO call to get file size.
*/
IOR_offset_t
IOR_GetFileSize_HDF5(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
static IOR_offset_t
HDF5_GetFileSize(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
return (IOR_GetFileSize_MPIIO(test, testComm, testFileName));
return (MPIIO_GetFileSize(test, testComm, testFileName));
}
Loading

0 comments on commit a60ad0b

Please sign in to comment.