Commit 2b60e240 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Clarify namespace states.

parent 13e2e31d
......@@ -64,10 +64,10 @@ static const union namespaceSwitchValue
static struct Namespace
{
statusCode resStage;
enum namespaceStatus resStage;
union namespaceSwitchValue switches[NUM_NAMESPACE_SWITCH];
} initialNamespace = {
.resStage = STAGE_DEFINITION,
.resStage = NAMESPACE_STATUS_INUSE,
.switches = defaultSwitches
};
......@@ -153,7 +153,7 @@ namespaceNew()
{
/* namespace is already available and only needs reinitialization */
for (unsigned i = 0; i < namespacesSize; ++i)
if (namespaces[i].resStage == STAGE_UNUSED)
if (namespaces[i].resStage == NAMESPACE_STATUS_UNUSED)
{
newNamespaceID = (int)i;
break;
......@@ -184,16 +184,16 @@ namespaceNew()
}
xassert(newNamespaceID >= 0 && newNamespaceID < NUM_NAMESPACES);
++nNamespaces;
namespaces[newNamespaceID].resStage = STAGE_DEFINITION;
#if defined (SX) || defined (__cplusplus)
namespaces[newNamespaceID].resStage = NAMESPACE_STATUS_INUSE;
#if defined (SX) || defined (__cplusplus)
memcpy(namespaces[newNamespaceID].switches,
defaultSwitches_,
sizeof (namespaces[newNamespaceID].switches));
#else
#else
memcpy(namespaces[newNamespaceID].switches,
(union namespaceSwitchValue[NUM_NAMESPACE_SWITCH])defaultSwitches,
sizeof (namespaces[newNamespaceID].switches));
#endif
#endif
reshListCreate(newNamespaceID);
NAMESPACE_UNLOCK();
return newNamespaceID;
......@@ -207,7 +207,7 @@ namespaceDelete(int namespaceID)
xassert(namespaceID >= 0 && (unsigned)namespaceID < namespacesSize
&& nNamespaces);
reshListDestruct(namespaceID);
namespaces[namespaceID].resStage = STAGE_UNUSED;
namespaces[namespaceID].resStage = NAMESPACE_STATUS_UNUSED;
--nNamespaces;
NAMESPACE_UNLOCK();
}
......@@ -221,7 +221,7 @@ int namespaceGetNumber ()
void namespaceSetActive ( int nId )
{
xassert((unsigned)nId < namespacesSize
&& namespaces[nId].resStage != STAGE_UNUSED);
&& namespaces[nId].resStage != NAMESPACE_STATUS_UNUSED);
activeNamespace = nId;
}
......@@ -265,14 +265,14 @@ int namespaceAdaptKey2 ( int originResH )
}
void namespaceDefResStatus ( statusCode argResStatus )
void namespaceDefResStatus (enum namespaceStatus argResStatus )
{
int nsp = namespaceGetActive ();
namespaces[nsp].resStage = argResStatus;
}
statusCode namespaceInqResStatus ( void )
enum namespaceStatus namespaceInqResStatus ( void )
{
int nsp = namespaceGetActive ();
return namespaces[nsp].resStage;
......@@ -297,7 +297,7 @@ void cdiReset(void)
NAMESPACE_INIT();
NAMESPACE_LOCK();
for (unsigned namespaceID = 0; namespaceID < namespacesSize; ++namespaceID)
if (namespaces[namespaceID].resStage != STAGE_UNUSED)
if (namespaces[namespaceID].resStage != NAMESPACE_STATUS_UNUSED)
namespaceDelete((int)namespaceID);
if (namespaces != &initialNamespace)
{
......
......@@ -6,10 +6,10 @@
#endif
typedef enum {
STAGE_DEFINITION = 0,
STAGE_UNUSED = 3,
} statusCode;
enum namespaceStatus {
NAMESPACE_STATUS_INUSE,
NAMESPACE_STATUS_UNUSED,
};
typedef struct {
int idx;
......@@ -66,8 +66,8 @@ int namespaceIdxEncode2 ( int, int );
namespaceTuple_t namespaceResHDecode ( int );
int namespaceAdaptKey ( int originResH, int originNamespace);
int namespaceAdaptKey2 ( int );
void namespaceDefResStatus ( statusCode );
statusCode namespaceInqResStatus ( void );
void namespaceDefResStatus ( enum namespaceStatus );
enum namespaceStatus namespaceInqResStatus ( void );
void namespaceSwitchSet(enum namespaceSwitch sw,
union namespaceSwitchValue value);
union namespaceSwitchValue namespaceSwitchGet(enum namespaceSwitch sw);
......
......@@ -30,10 +30,10 @@ cdiPioClientStreamOpen(const char *filename, char filemode,
int fileID;
if ( filemode == 'w' )
{
statusCode nspStatus = namespaceInqResStatus ();
enum namespaceStatus nspStatus = namespaceInqResStatus ();
switch ( nspStatus )
{
case STAGE_DEFINITION:
case NAMESPACE_STATUS_INUSE:
{
MPI_Comm comm = cdiPioInqInterComm();
int clientRank = commInqRankModel(),
......@@ -96,11 +96,11 @@ cdiPioClientStreamOpen(const char *filename, char filemode,
static void
cdiPioClientStreamDefVlist_(int streamID, int vlistID)
{
statusCode nspStatus = namespaceInqResStatus ();
enum namespaceStatus nspStatus = namespaceInqResStatus ();
cdiStreamDefVlist_(streamID, vlistID);
switch ( nspStatus )
{
case STAGE_DEFINITION:
case NAMESPACE_STATUS_INUSE:
{
int clientRank = commInqRankModel(),
numClients = cdiPioCommInqSizeClients(),
......@@ -184,7 +184,7 @@ cdiPioClientStreamWriteVarPart(int streamID, int varID, const void *data,
{
switch (namespaceInqResStatus())
{
case STAGE_DEFINITION:
case NAMESPACE_STATUS_INUSE:
pioBufferPartData(streamID, varID, data, nmiss, partDesc);
return;
default:
......@@ -201,7 +201,7 @@ cdiPioClientStreamWriteScatteredVarPart(int streamID, int varID,
{
switch (namespaceInqResStatus())
{
case STAGE_DEFINITION:
case NAMESPACE_STATUS_INUSE:
cdiPioBufferPartDataGather(streamID, varID, data, numBlocks,
blocklengths, displacements, nmiss, partDesc);
return;
......@@ -228,12 +228,12 @@ cdiPioClientStreamNOP(stream_t *streamptr)
static void
cdiPioClientStreamClose(stream_t *streamptr, int recordBufIsToBeDeleted)
{
statusCode nspStatus = namespaceInqResStatus ();
enum namespaceStatus nspStatus = namespaceInqResStatus ();
(void)recordBufIsToBeDeleted;
int streamID = streamptr->self;
switch ( nspStatus )
{
case STAGE_DEFINITION:
case NAMESPACE_STATUS_INUSE:
{
int clientRank = commInqRankModel(),
numClients = cdiPioCommInqSizeClients(),
......@@ -281,11 +281,11 @@ static int
cdiPioClientStreamDefTimestep_(stream_t *streamptr, int tsID)
{
struct winHeaderEntry header;
statusCode nspStatus = namespaceInqResStatus ();
enum namespaceStatus nspStatus = namespaceInqResStatus ();
int taxisID;
switch ( nspStatus )
{
case STAGE_DEFINITION:
case NAMESPACE_STATUS_INUSE:
taxisID = vlistInqTaxis(streamptr->vlistID);
header = (struct winHeaderEntry){
.id = STREAMDEFTIMESTEP,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment