static void node_list_remove(fatfs_node_list_t *list, fatfs_node_t *node) { if (list->first == list->last) { if (list->first == node) { CYG_ASSERTC(list->size == 1); list->first = list->last = NULL; } else { CYG_ASSERT(false, "chain node not in list!"); } } else if (list->first == node) { CYG_ASSERTC(node->list_prev == NULL); list->first = node->list_next; list->first->list_prev = NULL; } else if (list->last == node) { CYG_ASSERTC(node->list_next == NULL); list->last = node->list_prev; list->last->list_next = NULL; } else { CYG_ASSERTC(node->list_prev != NULL && node->list_next != NULL); node->list_prev->list_next = node->list_next; node->list_next->list_prev = node->list_prev; } list->size--; }
void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) { struct super_block *sb=OFNI_BS_2SFFJ(c); CYG_ASSERTC(sb->s_gc_thread_handle); D1(printk("jffs2_stop_garbage_collect_thread\n")); /* Stop the thread and wait for it if necessary */ cyg_flag_setbits(&sb->s_gc_thread_flags,GC_THREAD_FLAG_STOP); D1(printk("jffs2_stop_garbage_collect_thread wait\n")); cyg_flag_wait(&sb->s_gc_thread_flags, GC_THREAD_FLAG_HAS_EXIT, CYG_FLAG_WAITMODE_OR| CYG_FLAG_WAITMODE_CLR); // Kill and free the resources ... this is safe due to the flag // from the thread. cyg_thread_kill(sb->s_gc_thread_handle); cyg_thread_delete(sb->s_gc_thread_handle); cyg_mutex_destroy(&sb->s_lock); cyg_flag_destroy(&sb->s_gc_thread_flags); }
static void node_hash_check(fatfs_hash_table_t *tbl) { int i, n; n = 0; for (i = 0; i < tbl->size; i++) { fatfs_node_t *lnode, *pnode; pnode = NULL; lnode = tbl->nodes[i]; while (lnode != NULL) { if (pnode != NULL) { int c = strcasecmp(pnode->dentry.filename, lnode->dentry.filename); CYG_ASSERT(c <= 0, "hash table not sorted"); CYG_ASSERT(pnode->dentry.parent_cluster != lnode->dentry.parent_cluster || 0 != c, "duplicated node in hash table"); } n++; pnode = lnode; lnode = lnode->hash_next; } } CYG_ASSERTC(tbl->n == n); }
void fatfs_node_free(fatfs_disk_t *disk, fatfs_node_t *node) { CYG_CHECK_DATA_PTRC(disk); CYG_CHECK_DATA_PTRC(node); CYG_TRACE2(TNC, "node='%s' refcnt=%d", node->dentry.filename, node->refcnt); CYG_ASSERTC(node->refcnt == 0); CYG_ASSERTC(node != disk->root); // Remove from dead list, from hash and free ptr node_list_remove(&disk->dead_nlist, node); if (!node_hash_remove(&disk->node_hash, node)) CYG_ASSERT(false, "node not in hash"); node_pool_free(disk, node); SANITY_CHECK(); }
int main(int argc, char** argv) { CYG_ASSERT( true, message); CYG_ASSERT( false, message); CYG_ASSERTC(true); CYG_ASSERTC(false); CYG_FAIL(message); CYG_CHECK_DATA_PTR( &argc, message); CYG_CHECK_DATA_PTR( 0, message); CYG_CHECK_FUNC_PTR( &main, message); CYG_CHECK_FUNC_PTR( 0, message); CYG_CHECK_DATA_PTRC(&argc); CYG_CHECK_DATA_PTRC(0); CYG_CHECK_FUNC_PTRC(&main); CYG_CHECK_FUNC_PTRC(0); CYG_PRECONDITION(true, message); CYG_PRECONDITION(false, message); CYG_PRECONDITIONC(true); CYG_PRECONDITIONC(false); CYG_POSTCONDITION(true, message); CYG_POSTCONDITION(false, message); CYG_POSTCONDITIONC(true); CYG_POSTCONDITIONC(false); CYG_LOOP_INVARIANT(true, message); CYG_LOOP_INVARIANT(false, message); CYG_LOOP_INVARIANTC(true); CYG_LOOP_INVARIANTC(false); CYG_INVARIANT(true, message); CYG_INVARIANT(false, message); CYG_INVARIANTC(true); CYG_INVARIANTC(false); CYG_TEST_PASS_FINISH("disabled assertions in C code do nothing"); return 0; }
static void node_list_check(fatfs_node_list_t *list, int min_ref, int max_ref) { int i; fatfs_node_t *node, *pnode; CYG_ASSERT((list->last == NULL && list->first == NULL) || (list->last != NULL && list->first != NULL), "list->first and list->last broken!"); if (list->first == NULL) { CYG_ASSERTC(list->size == 0); return; } CYG_ASSERTC(list->first->list_prev == NULL); CYG_ASSERTC(list->last->list_next == NULL); CYG_ASSERTC(list->first->refcnt >= min_ref && list->first->refcnt <= max_ref); CYG_ASSERTC(list->last->refcnt >= min_ref && list->last->refcnt <= max_ref); i = 1; node = list->first; pnode = NULL; while (node->list_next != NULL) { i++; CYG_ASSERTC(node->list_prev == pnode); CYG_ASSERTC(node->refcnt >= min_ref && node->refcnt <= max_ref); pnode = node; node = node->list_next; } CYG_ASSERTC(node->list_prev == pnode); CYG_ASSERTC(list->size == i); CYG_ASSERTC(node == list->last); }
void jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c) { struct super_block *sb=OFNI_BS_2SFFJ(c); CYG_ASSERTC(c); CYG_ASSERTC(!sb->s_gc_thread_handle); cyg_flag_init(&sb->s_gc_thread_flags); cyg_mutex_init(&sb->s_lock); D1(printk("jffs2_start_garbage_collect_thread\n")); /* Start the thread. Doesn't matter if it fails -- it's only an * optimisation anyway */ cyg_thread_create(CYGNUM_JFFS2_GC_THREAD_PRIORITY, jffs2_garbage_collect_thread, (cyg_addrword_t)c,"jffs2 gc thread", (void*)sb->s_gc_thread_stack, sizeof(sb->s_gc_thread_stack), &sb->s_gc_thread_handle, &sb->s_gc_thread); cyg_thread_resume(sb->s_gc_thread_handle); }
static void node_list_tail_add(fatfs_node_list_t *list, fatfs_node_t *node) { node->list_prev = list->last; node->list_next = NULL; if (NULL == list->last) { CYG_ASSERTC(list->size == 0); list->first = node; } else { list->last->list_next = node; } list->last = node; list->size++; }