From 6bbc7d5fa2ee44fd7d78ab7c2b931207ce164667 Mon Sep 17 00:00:00 2001 From: goodale Date: Mon, 17 May 2004 12:28:57 +0000 Subject: Untabified. Please try to adhere to the Cactus coding guidelines when modifying or adding files. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/SpaceMask/trunk@42 a491c6a4-70bf-4b89-8b36-d6c0cb1f094e --- src/MaskUtils.c | 184 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/src/MaskUtils.c b/src/MaskUtils.c index 1394267..77350ac 100644 --- a/src/MaskUtils.c +++ b/src/MaskUtils.c @@ -30,29 +30,29 @@ static CCTK_INT SpaceMask_get_free_bits(int nbits); static CCTK_INT* SpaceMask_determine_state_mask(CCTK_INT allocated_bits, - int nstates); + int nstates); static SpaceMask_State* SpaceMask_setup_new_state(CCTK_INT state_mask, - const char* name); + 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[]); + 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); + ONE_FORTSTRING_ARG); void CCTK_FCALL CCTK_FNAME(SpaceMask_GetStateBits)(CCTK_INT* state_bits, - TWO_FORTSTRING_ARG); + TWO_FORTSTRING_ARG); void CCTK_FCALL CCTK_FNAME(SpaceMask_SetState)(CCTK_INT* mask, - CCTK_INT* point, TWO_FORTSTRING_ARG); + CCTK_INT* point, TWO_FORTSTRING_ARG); void CCTK_FCALL CCTK_FNAME(SpaceMask_CheckState)(int* retval, - CCTK_INT* mask, - CCTK_INT* point, - TWO_FORTSTRING_ARG); + CCTK_INT* mask, + CCTK_INT* point, + TWO_FORTSTRING_ARG); /*@@ @routine SpaceMask_get_bit_nbr @@ -60,7 +60,7 @@ void CCTK_FCALL CCTK_FNAME(SpaceMask_CheckState)(int* retval, @date 15 October 2002 @desc Return the number of bits required to represent a given number. - Cheesy divide-by-two method, maybe something else is quicker. + Cheesy divide-by-two method, maybe something else is quicker. @enddesc @@*/ static @@ -84,9 +84,9 @@ SpaceMask_get_bit_nbr(int nstates) @date 15 October 2002 @desc Determine the mask bits which have not yet been allocated. - The return value is a bitmask with the requested number of - free bits set to 1. If there are not enough free bits left - to satisfy the request, stop with an error. + The return value is a bitmask with the requested number of + free bits set to 1. If there are not enough free bits left + to satisfy the request, stop with an error. @enddesc @@*/ static @@ -103,7 +103,7 @@ SpaceMask_get_free_bits(int nbits) if (spacemask_registry != NULL) { for (i=0; intypes; ++i) - used_bits |= spacemask_registry->type_list[i]->bitmask; + used_bits |= spacemask_registry->type_list[i]->bitmask; } n=1; @@ -112,10 +112,10 @@ SpaceMask_get_free_bits(int nbits) for (i=0; i < (int) sizeof(CCTK_INT)*8 && jstate_list[j] = SpaceMask_setup_new_state(state_mask[j], - NULL); + new_type->state_list[j] = SpaceMask_setup_new_state(state_mask[j], + NULL); } else { for (j=0; jstate_list[j] = SpaceMask_setup_new_state(state_mask[j], - state_list[j]); + new_type->state_list[j] = SpaceMask_setup_new_state(state_mask[j], + state_list[j]); } return new_type; @@ -264,7 +264,7 @@ SpaceMask_append_type_to_registry(SpaceMask_Type* new_type) if (spacemask_registry == NULL) { spacemask_registry = - (SpaceMask_Registry*) malloc (sizeof(SpaceMask_Registry)); + (SpaceMask_Registry*) malloc (sizeof(SpaceMask_Registry)); ntypes = 1; new_type_list = (SpaceMask_Type**) malloc (sizeof(SpaceMask_Type*)); new_type_list[0] = new_type; @@ -273,9 +273,9 @@ SpaceMask_append_type_to_registry(SpaceMask_Type* new_type) { ntypes = spacemask_registry->ntypes + 1; new_type_list = - (SpaceMask_Type**) malloc (ntypes*sizeof(SpaceMask_Type*)); + (SpaceMask_Type**) malloc (ntypes*sizeof(SpaceMask_Type*)); for (i=0; itype_list[i]; + new_type_list[i] = spacemask_registry->type_list[i]; new_type_list[ntypes-1] = new_type; free(spacemask_registry->type_list); } @@ -290,13 +290,13 @@ SpaceMask_append_type_to_registry(SpaceMask_Type* new_type) @date 15 October 2002 @desc Allocates a set of bits of the SpaceMask to represent - a set of states of the named type. + a set of states of the named type. @enddesc @@*/ int SpaceMask_RegisterType(const char* type_name, int nstates, - const char* const state_list[]) + const char* const state_list[]) { SpaceMask_Type* new_type; CCTK_INT new_bits; @@ -312,7 +312,7 @@ SpaceMask_RegisterType(const char* type_name, int nstates, state_mask = SpaceMask_determine_state_mask(new_bits, nstates); new_type = SpaceMask_setup_new_type(new_bits, type_name, nstates, - state_list, state_mask); + state_list, state_mask); if (new_type == NULL) return -1; @@ -327,15 +327,15 @@ SpaceMask_RegisterType(const char* type_name, int nstates, @date 15 October 2002 @desc Adds a new set of possible states to an already existing - type. If required, new bits of the mask are allocated to the - given state. If bits are not available for this, then an - error is returned. + type. If required, new bits of the mask are allocated to the + given state. If bits are not available for this, then an + error is returned. @enddesc @@*/ int SpaceMask_AppendStatesToType(const char* type_name, int nstates, - const char* const state_list[]) + const char* const state_list[]) { CCTK_INT new_bits; CCTK_INT allocated_bits; @@ -353,16 +353,16 @@ SpaceMask_AppendStatesToType(const char* type_name, int nstates, for (i=0; intypes; ++i) { if (!strcmp(spacemask_registry->type_list[i]->name, type_name)) - { - old_type = spacemask_registry->type_list[i]; - old_type_idx = i; - } + { + old_type = spacemask_registry->type_list[i]; + old_type_idx = i; + } } if (old_type == NULL) { CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING, - "Mask type \"%s\" has not been registered", type_name); + "Mask type \"%s\" has not been registered", type_name); return -1; } @@ -388,7 +388,7 @@ SpaceMask_AppendStatesToType(const char* type_name, int nstates, new_state_list[i] = state_list[j]; new_type = SpaceMask_setup_new_type(allocated_bits, type_name, total_nstates, - new_state_list, state_mask); + new_state_list, state_mask); if (new_type == NULL) return -1; @@ -405,8 +405,8 @@ SpaceMask_AppendStatesToType(const char* type_name, int nstates, @date 15 October 2002 @desc Returns the bitmask corresponding to the given type. Bits - which are allocated to the given type are set to 1, all other - bits are 0. + which are allocated to the given type are set to 1, all other + bits are 0. @enddesc @@*/ @@ -418,11 +418,11 @@ SpaceMask_GetTypeBits(const char* type_name) for (i=0; intypes; ++i) { if (!strcmp(spacemask_registry->type_list[i]->name, type_name)) - return spacemask_registry->type_list[i]->bitmask; + return spacemask_registry->type_list[i]->bitmask; } CCTK_VInfo (CCTK_THORNSTRING, "Type \"%s\" has not been registered.\n", - type_name); + type_name); return 0; } @@ -433,7 +433,7 @@ SpaceMask_GetTypeBits(const char* type_name) @date 15 October 2002 @desc Returns the bitmask corresponding to the given state, or - -1 if the state does not exist. + -1 if the state does not exist. @enddesc @@*/ @@ -446,19 +446,19 @@ SpaceMask_GetStateBits(const char* type_name, const char* state_name) for (i=0; intypes; ++i) { if (!strcmp(spacemask_registry->type_list[i]->name, type_name)) - { - type = spacemask_registry->type_list[i]; - for (j=0; jnstates; ++j) - { - if (!strcmp(type->state_list[j]->name, state_name)) - return type->state_list[j]->bitmask; - } - } + { + type = spacemask_registry->type_list[i]; + for (j=0; jnstates; ++j) + { + if (!strcmp(type->state_list[j]->name, state_name)) + return type->state_list[j]->bitmask; + } + } } CCTK_VInfo (CCTK_THORNSTRING, - "Requested state \"%s\" could not be found in type \"%s\"\n", - state_name, type_name); + "Requested state \"%s\" could not be found in type \"%s\"\n", + state_name, type_name); return -1; } @@ -469,9 +469,9 @@ SpaceMask_GetStateBits(const char* type_name, const char* state_name) @date 25 May 2003 @desc Returns a list of all of the state masks allocated - for a given type. The number of elements in the list - is equal to the number of states of the type. - If the type name is not recognised, NULL is returned. + for a given type. The number of elements in the list + is equal to the number of states of the type. + If the type name is not recognised, NULL is returned. @enddesc @@*/ @@ -485,20 +485,20 @@ SpaceMask_GetStateBitsList(const char* type_name) for (i=0; intypes; ++i) { if (!strcmp(spacemask_registry->type_list[i]->name, type_name)) - { - type = spacemask_registry->type_list[i]; - state_bits_list = (CCTK_INT*) - malloc (sizeof(CCTK_INT)*(type->nstates)); + { + type = spacemask_registry->type_list[i]; + state_bits_list = (CCTK_INT*) + malloc (sizeof(CCTK_INT)*(type->nstates)); - for (j=0; jnstates; ++j) - state_bits_list[j] = type->state_list[j]->bitmask; + for (j=0; jnstates; ++j) + state_bits_list[j] = type->state_list[j]->bitmask; - return state_bits_list; - } + return state_bits_list; + } } CCTK_VInfo (CCTK_THORNSTRING, - "Requested type \"%s\" could not be found\n", type_name); + "Requested type \"%s\" could not be found\n", type_name); return NULL; } @@ -530,7 +530,7 @@ SpaceMask_SetState(CCTK_INT* mask, int point, const char* type_name, const char* @date 15 October 2002 @desc Checks that the mask at a point has the given state, in which - case return 1, otherwise return 0. + case return 1, otherwise return 0. @enddesc @@*/ @@ -554,7 +554,7 @@ SpaceMask_CheckState(const CCTK_INT* mask, int point, const char* type_name, con /* How do you pass the char** state list from fortran??? void CCTK_FCALL CCTK_FNAME(SpaceMask_RegisterType)(int* ierr, char* type_name, - int* nstates, char** state_list) + int* nstates, char** state_list) { *ierr = SpaceMask_RegisterType(type_name, *nstates, state_list); } @@ -562,7 +562,7 @@ CCTK_FCALL CCTK_FNAME(SpaceMask_RegisterType)(int* ierr, char* type_name, void CCTK_FCALL CCTK_FNAME(SpaceMask_GetTypeBits)(CCTK_INT* type_bits, - ONE_FORTSTRING_ARG) + ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(type_name) @@ -573,7 +573,7 @@ CCTK_FCALL CCTK_FNAME(SpaceMask_GetTypeBits)(CCTK_INT* type_bits, void CCTK_FCALL CCTK_FNAME(SpaceMask_GetStateBits)(CCTK_INT* state_bits, - TWO_FORTSTRING_ARG) + TWO_FORTSTRING_ARG) { TWO_FORTSTRING_CREATE(type_name, state_name) @@ -586,7 +586,7 @@ CCTK_FCALL CCTK_FNAME(SpaceMask_GetStateBits)(CCTK_INT* state_bits, void CCTK_FCALL CCTK_FNAME(SpaceMask_SetState)(CCTK_INT* mask, - CCTK_INT* point, TWO_FORTSTRING_ARG) + CCTK_INT* point, TWO_FORTSTRING_ARG) { TWO_FORTSTRING_CREATE(type_name, state) @@ -598,9 +598,9 @@ CCTK_FCALL CCTK_FNAME(SpaceMask_SetState)(CCTK_INT* mask, void CCTK_FCALL CCTK_FNAME(SpaceMask_CheckState)(int* retval, - CCTK_INT* mask, - CCTK_INT* point, - TWO_FORTSTRING_ARG) + CCTK_INT* mask, + CCTK_INT* point, + TWO_FORTSTRING_ARG) { TWO_FORTSTRING_CREATE(type_name, state) -- cgit v1.2.3