aboutsummaryrefslogtreecommitdiff
path: root/src/MaskUtils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/MaskUtils.c')
-rw-r--r--src/MaskUtils.c74
1 files changed, 40 insertions, 34 deletions
diff --git a/src/MaskUtils.c b/src/MaskUtils.c
index 9dd064d..29a280a 100644
--- a/src/MaskUtils.c
+++ b/src/MaskUtils.c
@@ -23,22 +23,26 @@ CCTK_FILEVERSION(CACTUSEINSTEIN_SPACEMASK_MaskUtils_c);
SpaceMask_Registry* spacemask_registry = NULL;
-/* Prototypes */
-int SpaceMask_get_bit_nbr(int nstates);
-CCTK_INT SpaceMask_get_free_bits(int nbits);
-CCTK_INT* SpaceMask_determine_state_mask(CCTK_INT allocated_bits, int nstates);
-SpaceMask_State* SpaceMask_setup_new_state(CCTK_INT state_mask, char* name);
-SpaceMask_Type* SpaceMask_setup_new_type(CCTK_INT new_bits, char* type_name,
- int nstates, char** state_list,
- CCTK_INT* state_mask);
-void SpaceMask_append_type_to_registry(SpaceMask_Type* new_type);
-int SpaceMask_RegisterType(char* type_name, int nstates, char** state_list);
-int SpaceMask_AppendStatesToType(char* type_name, int nstates, char** state_list);
-CCTK_INT SpaceMask_GetTypeBits(char* type_name);
-CCTK_INT SpaceMask_GetStateBits(char* type_name, char* state_name);
-void SpaceMask_SetState(CCTK_INT* mask, int point, char* type_name, char* state);
-int SpaceMask_CheckState(CCTK_INT* mask, int point, char* type_name, char* state);
-
+/* prototypes for functions local to this file */
+static
+ int SpaceMask_get_bit_nbr(int nstates);
+static
+ CCTK_INT SpaceMask_get_free_bits(int nbits);
+static
+ CCTK_INT* SpaceMask_determine_state_mask(CCTK_INT allocated_bits,
+ int nstates);
+static
+ SpaceMask_State* SpaceMask_setup_new_state(CCTK_INT state_mask,
+ const char* name);
+static
+ SpaceMask_Type*
+ SpaceMask_setup_new_type(CCTK_INT new_bits, const char* type_name,
+ int nstates, const char* const state_list[],
+ const CCTK_INT state_mask[]);
+static
+ void SpaceMask_append_type_to_registry(SpaceMask_Type* new_type);
+
+/* prototypes for Fortran wrapper functions defined in this file */
void CCTK_FCALL CCTK_FNAME(SpaceMask_GetTypeBits)(CCTK_INT* type_bits,
ONE_FORTSTRING_ARG);
void CCTK_FCALL CCTK_FNAME(SpaceMask_GetStateBits)(CCTK_INT* state_bits,
@@ -59,7 +63,7 @@ void CCTK_FCALL CCTK_FNAME(SpaceMask_CheckState)(int* retval,
Cheesy divide-by-two method, maybe something else is quicker.
@enddesc
@@*/
-
+static
int
SpaceMask_get_bit_nbr(int nstates)
{
@@ -85,7 +89,7 @@ SpaceMask_get_bit_nbr(int nstates)
to satisfy the request, stop with an error.
@enddesc
@@*/
-
+static
CCTK_INT
SpaceMask_get_free_bits(int nbits)
{
@@ -133,7 +137,7 @@ SpaceMask_get_free_bits(int nbits)
non-zero (active) bits.
@enddesc
@@*/
-
+static
CCTK_INT*
SpaceMask_determine_state_mask(CCTK_INT allocated_bits, int nstates)
{
@@ -178,9 +182,9 @@ SpaceMask_determine_state_mask(CCTK_INT allocated_bits, int nstates)
a bit mask.
@enddesc
@@*/
-
+static
SpaceMask_State*
-SpaceMask_setup_new_state(CCTK_INT state_mask, char* name)
+SpaceMask_setup_new_state(CCTK_INT state_mask, const char* name)
{
SpaceMask_State* new_state;
@@ -202,11 +206,11 @@ SpaceMask_setup_new_state(CCTK_INT state_mask, char* name)
the requested states.
@enddesc
@@*/
-
+static
SpaceMask_Type*
-SpaceMask_setup_new_type(CCTK_INT new_bits, char* type_name,
- int nstates, char** state_list,
- CCTK_INT* state_mask)
+SpaceMask_setup_new_type(CCTK_INT new_bits, const char* type_name,
+ int nstates, const char* const state_list[],
+ const CCTK_INT state_mask[])
{
SpaceMask_Type* new_type;
int j;
@@ -232,7 +236,7 @@ SpaceMask_setup_new_type(CCTK_INT new_bits, char* type_name,
Adds a new type to the spacemask_registry.
@enddesc
@@*/
-
+static
void
SpaceMask_append_type_to_registry(SpaceMask_Type* new_type)
{
@@ -274,7 +278,8 @@ SpaceMask_append_type_to_registry(SpaceMask_Type* new_type)
@@*/
int
-SpaceMask_RegisterType(char* type_name, int nstates, char** state_list)
+SpaceMask_RegisterType(const char* type_name, int nstates,
+ const char* const state_list[])
{
SpaceMask_Type* new_type;
CCTK_INT new_bits;
@@ -306,14 +311,15 @@ SpaceMask_RegisterType(char* type_name, int nstates, char** state_list)
@@*/
int
-SpaceMask_AppendStatesToType(char* type_name, int nstates, char** state_list)
+SpaceMask_AppendStatesToType(const char* type_name, int nstates,
+ const char* const state_list[])
{
CCTK_INT new_bits;
CCTK_INT allocated_bits;
CCTK_INT* state_mask;
SpaceMask_Type* old_type;
SpaceMask_Type* new_type;
- char** new_state_list;
+ const char** new_state_list;
int i;
int j;
int old_type_idx;
@@ -346,7 +352,7 @@ SpaceMask_AppendStatesToType(char* type_name, int nstates, char** state_list)
state_mask = SpaceMask_determine_state_mask(allocated_bits, total_nstates);
- new_state_list = (char**) malloc (total_nstates*sizeof(char*));
+ new_state_list = (const char**) malloc (total_nstates*sizeof(char*));
i = 0;
for (j=0; j<old_type->nstates; ++j, ++i)
@@ -375,7 +381,7 @@ SpaceMask_AppendStatesToType(char* type_name, int nstates, char** state_list)
@@*/
CCTK_INT
-SpaceMask_GetTypeBits(char* type_name)
+SpaceMask_GetTypeBits(const char* type_name)
{
int i;
@@ -401,7 +407,7 @@ SpaceMask_GetTypeBits(char* type_name)
@@*/
CCTK_INT
-SpaceMask_GetStateBits(char* type_name, char* state_name)
+SpaceMask_GetStateBits(const char* type_name, const char* state_name)
{
SpaceMask_Type* type;
int i, j;
@@ -436,7 +442,7 @@ SpaceMask_GetStateBits(char* type_name, char* state_name)
@@*/
void
-SpaceMask_SetState(CCTK_INT* mask, int point, char* type_name, char* state)
+SpaceMask_SetState(CCTK_INT* mask, int point, const char* type_name, const char* state)
{
CCTK_INT type_bits;
CCTK_INT state_bits;
@@ -458,7 +464,7 @@ SpaceMask_SetState(CCTK_INT* mask, int point, char* type_name, char* state)
@@*/
int
-SpaceMask_CheckState(CCTK_INT* mask, int point, char* type_name, char* state)
+SpaceMask_CheckState(const CCTK_INT* mask, int point, const char* type_name, const char* state)
{
CCTK_INT type_bits;
CCTK_INT state_bits;