obj_lock #else obj_lock_debug #endif (obj_id_t id, const object_type_t *assumed_type #ifdef OBJ_DEBUG ,const char *file, int line #endif ) { #ifdef OBJ_DEBUG if (assumed_type) fprintf(stderr,"%s:%i obj_lock(%lu, %s)\n",file,line,id,assumed_type->name); else fprintf(stderr,"%s:%i obj_lock(%lu, NULL)\n",file,line,id); #endif if (id) { unsigned int hash = hash_id(id); object_t *p = obj_tab[hash]; while (p && p->id != id) p = p->objlist_next; if (p) obj_ref(p,assumed_type); return p; } else { return NULL; } }
static int insert__(bighash_table_t *table, int count, biglist_t** entries) { int c; for(c = 0; c < count; c++) { test_entry_t *te = aim_zmalloc(sizeof(*te)); te->id = c; bighash_insert(table, &te->hash_entry, hash_id(te->id)); if(entries) { *entries = biglist_prepend(*entries, te); } /** Make sure we can find it */ test_entry_t *fe = find_by_id(table, te->id); if(fe == NULL) { AIM_DIE("inserted entry was not found, count=%d/%d", c, count); } if(fe != te) { AIM_DIE("Retreived pointer not equal."); } if(bighash_entry_count(table) != (c+1)) { AIM_DIE("Entry count mismatch: should be %d, reported as %d", (c+1), bighash_entry_count(table)); } } return 0; }
/** * This removes the current reference to an id when the operation is removed. */ int id_constraint_unregister( entry_proc_op_t * p_op ) { unsigned int hash_index; id_constraint_item_t *p_curr; id_constraint_item_t *p_prev; if ( !p_op->entry_id_is_set ) return ID_MISSING; if ( !p_op->id_is_referenced ) return ID_NOT_EXISTS; /* compute id hash value */ hash_index = hash_id( &p_op->entry_id, ID_HASH_SIZE ); /* check if the entry id exists and is a stage >= pipeline_stage */ P( id_hash[hash_index].lock ); for ( p_curr = id_hash[hash_index].id_list_first, p_prev = NULL; p_curr != NULL; p_prev = p_curr, p_curr = p_curr->p_next ) { if ( p_curr->op_ptr == p_op ) { /* found */ if ( p_prev == NULL ) id_hash[hash_index].id_list_first = p_curr->p_next; else p_prev->p_next = p_curr->p_next; /* was it the last ? */ if ( id_hash[hash_index].id_list_last == p_curr ) id_hash[hash_index].id_list_last = p_prev; p_curr->op_ptr->id_is_referenced = FALSE; id_hash[hash_index].count--; V( id_hash[hash_index].lock ); /* free the slot */ MemFree( p_curr ); return ID_OK; } } V( id_hash[hash_index].lock ); #ifdef _HAVE_FID DisplayLog( LVL_MAJOR, ENTRYPROC_TAG, "id_constraint_unregister: op not found (list %u): id [%llu, %u] record %u", hash_index, p_op->entry_id.f_seq, p_op->entry_id.f_oid, p_op->entry_id.f_ver ); #else DisplayLog( LVL_MAJOR, ENTRYPROC_TAG, "id_constraint_unregister: op not found (list %u): id [dev %llu, ino %llu]", hash_index, ( unsigned long long ) p_op->entry_id.device, ( unsigned long long ) p_op->entry_id.inode ); #endif return ID_NOT_EXISTS; }
/** * This is called to register the operation (with the ordering of pipeline) * @return ID_OK if the entry can be processed. * ID_MISSING if the ID is not set in p_op structure * ID_ALREADY if the op_structure has already been registered */ int id_constraint_register( entry_proc_op_t * p_op ) { unsigned int hash_index; id_constraint_item_t *p_new; if ( !p_op->entry_id_is_set ) return ID_MISSING; /* compute id hash value */ hash_index = hash_id( &p_op->entry_id, ID_HASH_SIZE ); P( id_hash[hash_index].lock ); /* no constraint violation detected, register the entry */ p_new = ( id_constraint_item_t * ) MemAlloc( sizeof( id_constraint_item_t ) ); p_new->op_ptr = p_op; /* always insert in queue */ p_new->p_next = NULL; if ( id_hash[hash_index].id_list_last ) id_hash[hash_index].id_list_last->p_next = p_new; else id_hash[hash_index].id_list_first = p_new; id_hash[hash_index].id_list_last = p_new; id_hash[hash_index].count++; p_op->id_is_referenced = TRUE; V( id_hash[hash_index].lock ); return ID_OK; }
static inline int __testip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t port, ip_set_ip_t *hash_ip) { struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data; if (ip < map->first_ip || ip > map->last_ip) return -ERANGE; return (hash_id(set, ip, port, hash_ip) != UINT_MAX); }
static test_entry_t * find_by_id(bighash_table_t *table, uint32_t id) { bighash_entry_t *e; for (e = bighash_first(table, hash_id(id)); e; e = bighash_next(e)) { test_entry_t *te = container_of(e, hash_entry, test_entry_t); if (te->id == id) { return te; } } return NULL; }
static void unregister_object(object_t *obj) { unsigned int hash = hash_id(obj->id); if (obj_tab[hash] == obj) { obj_tab[hash] = obj_tab[hash]->objlist_next; } else { object_t *p = obj_tab[hash]; while (p && p->objlist_next != obj) p = p->objlist_next; assert(p && "Unregistering unknown object"); p->objlist_next = obj->objlist_next; } }
void CMPTrackViewManager::Update() { #ifndef _RELEASE if (g_pGameCVars->g_mptrackview_debug) { IMovieSystem *pMovieSystem = gEnv->pMovieSystem; int numSequences=pMovieSystem->GetNumSequences(); CryWatch("num finished trackviews=%d", m_FinishedTrackViewCount); for (int i=0; i<m_FinishedTrackViewCount; i++) { const char *foundName="NOT FOUND"; // SLOW IAnimSequence *foundSequence = FindTrackviewSequence(m_FinishedTrackViews[i]); if (foundSequence) { foundName = foundSequence->GetName(); } CryWatch("finished[%d] hash=%x; time=%f; foundName=%s", i, m_FinishedTrackViews[i], m_FinishedTrackViewTimes[i], foundName); } int numPlaying=pMovieSystem->GetNumPlayingSequences(); for(int i = 0; i < numPlaying; ++i) { IAnimSequence* pSequence = pMovieSystem->GetPlayingSequence(i); if( pSequence ) { const char *name=pSequence->GetName(); if (!name) { name = "[NULL]"; } CryHashStringId hash_id(pSequence->GetName()); float timeValue = pMovieSystem->GetPlayingTime(pSequence); CryWatch("Seq[%d]: name=%s; time=%f; hash=%x", i, name, timeValue, hash_id.id); } } } #endif }
static inline int __delip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t port, ip_set_ip_t *hash_ip) { struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data; ip_set_ip_t id; ip_set_ip_t *elem; if (ip < map->first_ip || ip > map->last_ip) return -ERANGE; id = hash_id(set, ip, port, hash_ip); if (id == UINT_MAX) return -EEXIST; elem = HARRAY_ELEM(map->members, ip_set_ip_t *, id); *elem = 0; return 0; }
/** * Get the first operation for a given id. * @return an operation to be processed when it is possible. * NULL else. * */ entry_proc_op_t *id_constraint_get_first_op( entry_id_t * p_id ) { unsigned int hash_index; id_constraint_item_t *p_curr; entry_proc_op_t *p_op = NULL; /* compute id hash value */ hash_index = hash_id( p_id, ID_HASH_SIZE ); P( id_hash[hash_index].lock ); for ( p_curr = id_hash[hash_index].id_list_first; p_curr != NULL; p_curr = p_curr->p_next ) { if ( entry_id_equal( p_id, &p_curr->op_ptr->entry_id ) ) { p_op = p_curr->op_ptr; break; } } #ifdef _DEBUG_ID_CONSTRAINT if ( p_op ) printf( "first op on id "DFID" at stage %u (list %u)\n", PFID(&p_op->entry_id), p_op->pipeline_stage, hash_index ); else { printf( "no registered operation on "DFID"?\n", PFID(p_id)); printf( "etat de la file %u:\n", hash_index ); for ( p_curr = id_hash[hash_index].id_list_first; p_curr != NULL; p_curr = p_curr->p_next ) printf( DFID"\n", PFID(&p_curr->op_ptr->entry_id) ); } #endif V( id_hash[hash_index].lock ); return p_op; }
/** * Applies or removes a PKCS#1 v1.5 encryption padding. * * @param[out] m - the buffer to pad. * @param[out] p_len - the number of added pad bytes. * @param[in] m_len - the message length in bytes. * @param[in] k_len - the key length in bytes. * @param[in] operation - flag to indicate the operation type. * @return STS_ERR if errors occurred, STS_OK otherwise. */ static int pad_pkcs1(bn_t m, int *p_len, int m_len, int k_len, int operation) { uint8_t *id, pad = 0; int len, result = STS_OK; bn_t t; bn_null(t); TRY { bn_new(t); switch (operation) { case RSA_ENC: /* EB = 00 | 02 | PS | 00 | D. */ bn_zero(m); bn_lsh(m, m, 8); bn_add_dig(m, m, RSA_PUB); *p_len = k_len - 3 - m_len; for (int i = 0; i < *p_len; i++) { bn_lsh(m, m, 8); do { rand_bytes(&pad, 1); } while (pad == 0); bn_add_dig(m, m, pad); } bn_lsh(m, m, 8); bn_add_dig(m, m, 0); /* Make room for the real message. */ bn_lsh(m, m, m_len * 8); break; case RSA_DEC: m_len = k_len - 1; bn_rsh(t, m, 8 * m_len); if (!bn_is_zero(t)) { result = STS_ERR; } *p_len = m_len; m_len--; bn_rsh(t, m, 8 * m_len); pad = (uint8_t)t->dp[0]; if (pad != RSA_PUB) { result = STS_ERR; } do { m_len--; bn_rsh(t, m, 8 * m_len); pad = (uint8_t)t->dp[0]; } while (pad != 0); /* Remove padding and trailing zero. */ *p_len -= (m_len - 1); bn_mod_2b(m, m, (k_len - *p_len) * 8); break; case RSA_SIG: /* EB = 00 | 01 | PS | 00 | D. */ id = hash_id(MD_MAP, &len); bn_zero(m); bn_lsh(m, m, 8); bn_add_dig(m, m, RSA_PRV); *p_len = k_len - 3 - m_len - len; for (int i = 0; i < *p_len; i++) { bn_lsh(m, m, 8); bn_add_dig(m, m, RSA_PAD); } bn_lsh(m, m, 8); bn_add_dig(m, m, 0); bn_lsh(m, m, 8 * len); bn_read_bin(t, id, len); bn_add(m, m, t); /* Make room for the real message. */ bn_lsh(m, m, m_len * 8); break; case RSA_SIG_HASH: /* EB = 00 | 01 | PS | 00 | D. */ bn_zero(m); bn_lsh(m, m, 8); bn_add_dig(m, m, RSA_PRV); *p_len = k_len - 3 - m_len; for (int i = 0; i < *p_len; i++) { bn_lsh(m, m, 8); bn_add_dig(m, m, RSA_PAD); } bn_lsh(m, m, 8); bn_add_dig(m, m, 0); /* Make room for the real message. */ bn_lsh(m, m, m_len * 8); break; case RSA_VER: m_len = k_len - 1; bn_rsh(t, m, 8 * m_len); if (!bn_is_zero(t)) { result = STS_ERR; } m_len--; bn_rsh(t, m, 8 * m_len); pad = (uint8_t)t->dp[0]; if (pad != RSA_PRV) { result = STS_ERR; } do { m_len--; bn_rsh(t, m, 8 * m_len); pad = (uint8_t)t->dp[0]; } while (pad != 0 && m_len > 0); if (m_len == 0) { result = STS_ERR; } /* Remove padding and trailing zero. */ id = hash_id(MD_MAP, &len); m_len -= len; bn_rsh(t, m, m_len * 8); int r = 0; for (int i = 0; i < len; i++) { pad = (uint8_t)t->dp[0]; r |= pad - id[len - i - 1]; bn_rsh(t, t, 8); } *p_len = k_len - m_len; bn_mod_2b(m, m, m_len * 8); result = (r == 0 ? STS_OK : STS_ERR); break; case RSA_VER_HASH: m_len = k_len - 1; bn_rsh(t, m, 8 * m_len); if (!bn_is_zero(t)) { result = STS_ERR; } m_len--; bn_rsh(t, m, 8 * m_len); pad = (uint8_t)t->dp[0]; if (pad != RSA_PRV) { result = STS_ERR; } do { m_len--; bn_rsh(t, m, 8 * m_len); pad = (uint8_t)t->dp[0]; } while (pad != 0 && m_len > 0); if (m_len == 0) { result = STS_ERR; } /* Remove padding and trailing zero. */ *p_len = k_len - m_len; bn_mod_2b(m, m, m_len * 8); break; } } CATCH_ANY { result = STS_ERR; } FINALLY { bn_free(t); } return result; }
static void register_object(object_t *obj) { unsigned int hash = hash_id(obj->id); obj->objlist_next = obj_tab[hash]; obj_tab[hash] = obj; }
uint32 cam_comp_widget::type() { return hash_id("nscam_comp"); }
component_selection_widget::component_selection_widget(QWidget *parent) : QWidget(parent), m_edit_ent(NULL), m_ui(new Ui::component_selection_widget), m_prev(NULL) { m_ui->setupUi(this); m_icons[hash_id("nsanim_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nstile_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nsterrain_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nstile_brush_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nsrender_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nssel_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nscam_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nsparticle_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nsoccupy_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nslight_comp")] = ":/ResourceIcons/icons/default_comp.png"; m_icons[hash_id("nstform_comp")] = ":/ResourceIcons/icons/default_comp.png"; }
static inline int __testip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip) { return (ip && hash_id(set, ip, hash_ip) != UINT_MAX); }