From d5ae55fdcc9fa5a1a54c55d7269aa77805aafc91 Mon Sep 17 00:00:00 2001 From: Rich Graham Date: Mon, 26 Jan 2004 20:32:19 +0000 Subject: [PATCH] change the pointers in the lam item to be volatile. Add some to the list unit test. This commit was SVN r547. --- src/lam/lfc/list.h | 14 +++++++------- src/tools/laminfo/version.cc | 4 ++-- test/lam/lfc/list_test.c | 29 +++++++++++++++++++++++++++++ test/support/support.c | 3 ++- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/lam/lfc/list.h b/src/lam/lfc/list.h index c65d0ffc3b..bfe320123b 100644 --- a/src/lam/lfc/list.h +++ b/src/lam/lfc/list.h @@ -30,8 +30,8 @@ typedef struct lam_list_item { lam_object_t super; lam_list_type_t lam_list_type; - struct lam_list_item *lam_list_next; - struct lam_list_item *lam_list_prev; + volatile struct lam_list_item *lam_list_next; + volatile struct lam_list_item *lam_list_prev; } lam_list_item_t; #if defined(c_plusplus) || defined(__cplusplus) @@ -103,7 +103,7 @@ static inline void lam_list_set_size(lam_list_t* list, size_t size) */ static inline lam_list_item_t* lam_list_get_first(lam_list_t* list) { - return list->lam_list_head.lam_list_next; + return (lam_list_item_t *)list->lam_list_head.lam_list_next; } /* @@ -111,7 +111,7 @@ static inline lam_list_item_t* lam_list_get_first(lam_list_t* list) */ static inline lam_list_item_t* lam_list_get_last(lam_list_t* list) { - return list->lam_list_tail.lam_list_prev; + return (lam_list_item_t *)list->lam_list_tail.lam_list_prev; } /* @@ -151,8 +151,8 @@ static inline lam_list_item_t *lam_list_remove_item /* check to see that the item is in the list */ for (item_ptr = lam_list_get_first(list); item_ptr != lam_list_get_end(list); - item_ptr = item_ptr->lam_list_next) { - if (item_ptr == item) { + item_ptr = (lam_list_item_t *)(item_ptr->lam_list_next)) { + if (item_ptr == (lam_list_item_t *) item) { found = true; break; } @@ -169,7 +169,7 @@ static inline lam_list_item_t *lam_list_remove_item /* reset previous pointer of next element */ item->lam_list_next->lam_list_prev=item->lam_list_prev; - return item->lam_list_prev; + return (lam_list_item_t *)item->lam_list_prev; } #if defined(c_plusplus) || defined(__cplusplus) diff --git a/src/tools/laminfo/version.cc b/src/tools/laminfo/version.cc index 5f5a5b882b..cafd3a23ef 100644 --- a/src/tools/laminfo/version.cc +++ b/src/tools/laminfo/version.cc @@ -150,8 +150,8 @@ static void show_module_version(const string& type_name, modules = module_map[type_name]; for (item = lam_list_get_first(modules); - lam_list_get_end(modules) != item; - item = lam_list_get_next(item)) { + lam_list_get_last(modules) != item; + item = (lam_list_item *) lam_list_get_next(item)) { module = (mca_base_module_t *) item; if (want_all_modules || module->mca_module_name == module_name) { show_mca_version(module, scope, ver_type); diff --git a/test/lam/lfc/list_test.c b/test/lam/lfc/list_test.c index fef0066678..74bb975e35 100644 --- a/test/lam/lfc/list_test.c +++ b/test/lam/lfc/list_test.c @@ -7,7 +7,36 @@ int main(int argc, char **argv) { + /* local variables */ + lam_list_t list; + lam_list_type_t list_type,list_type_out; + size_t list_size; + test_init("List"); + + /* initialize list */ + lam_list_init(&list); + + /* check length of list */ + list_size=lam_list_get_size(&list); + if( 0 == list_size ) { + test_success(); + } else { + test_failure(" lam_list_get_size"); + } + + /* check list type */ + list_type=2; + lam_list_set_type(&list,list_type); + list_type_out=0; + list_type_out=lam_list_get_type(&list); + if( list_type_out == list_type ) { + test_success(); + } else { + test_failure(" lam_list_set/get_type"); + } + + test_finalize(); return 0; } diff --git a/test/support/support.c b/test/support/support.c index 5763f39c39..ed76078073 100644 --- a/test/support/support.c +++ b/test/support/support.c @@ -84,7 +84,8 @@ int test_finalize(void) return_value=1; if( lam_n_tests == lam_n_success) { - fprintf(stderr," SUPPORT :: LAM Test Passed :: %s \n",lam_description); + fprintf(stderr," SUPPORT :: LAM Test Passed :: %s %d tests \n", + lam_description,lam_n_tests); fflush(stderr); } else { fprintf(stderr," SUPPORT :: LAM Test failed :: %s :: %d of %d failed\n"