*/
answer_t find_closest(const_node_t node, unsigned int destination_id)
{
- int i;
answer_t answer = answer_init(destination_id);
/* We find the corresponding bucket for the id */
const_bucket_t bucket = routing_table_find_bucket(node->table, destination_id);
/* However, if we don't have enough elements in our bucket, we NEED to include at least "BUCKET_SIZE" elements
* (if, of course, we know at least "BUCKET_SIZE" elements. So we're going to look unsigned into the other buckets.
*/
- for (i = 1; answer->size < BUCKET_SIZE && ((bucket_id - i > 0) || (bucket_id + i < IDENTIFIER_SIZE)); i++) {
+ for (int i = 1; answer->size < BUCKET_SIZE && ((bucket_id - i > 0) || (bucket_id + i < IDENTIFIER_SIZE)); i++) {
/* We check the previous buckets */
if (bucket_id - i >= 0) {
const_bucket_t bucket_p = &node->table->buckets[bucket_id - i];
/** @brief Frees the routing table */
void routing_table_free(routing_table_t table)
{
- unsigned int i;
// Free the buckets.
- for (i = 0; i <= IDENTIFIER_SIZE; i++) {
+ for (unsigned int i = 0; i <= IDENTIFIER_SIZE; i++) {
xbt_dynar_free(&table->buckets[i].nodes);
}
xbt_free(table->buckets);
/**@brief prints the routing table, to debug stuff. */
void routing_table_print(const_routing_table_t table)
{
- unsigned int j;
- unsigned int value;
XBT_INFO("Routing table of %08x:", table->id);
for (unsigned int i = 0; i <= IDENTIFIER_SIZE; i++) {
if (!xbt_dynar_is_empty(table->buckets[i].nodes)) {
XBT_INFO("Bucket number %u: ", i);
+ unsigned int j;
+ unsigned int value;
xbt_dynar_foreach (table->buckets[i].nodes, j, value) {
XBT_INFO("Element %u: %08x", j, value);
}
bool Node::join(unsigned int known_id)
{
const Answer* node_list;
- unsigned int i;
bool got_answer = false;
/* Add the guy we know to our routing table and ourselves. */
/* Second step: Send a FIND_NODE to a a random node in buckets */
unsigned int bucket_id = table.findBucket(known_id)->getId();
xbt_assert(bucket_id <= IDENTIFIER_SIZE);
- for (i = 0; ((bucket_id > i) || (bucket_id + i) <= IDENTIFIER_SIZE) && i < JOIN_BUCKETS_QUERIES; i++) {
+ for (unsigned int i = 0; ((bucket_id > i) || (bucket_id + i) <= IDENTIFIER_SIZE) && i < JOIN_BUCKETS_QUERIES; i++) {
if (bucket_id > i) {
unsigned int id_in_bucket = get_id_in_prefix(id_, bucket_id - i);
findNode(id_in_bucket, false);
min_usage = -1;
min_bound = -1;
saturated_constraints.clear();
- int pos;
- for (pos = 0; pos < cnst_light_num; pos++) {
+ for (int pos = 0; pos < cnst_light_num; pos++) {
xbt_assert(not cnst_light_tab[pos].cnst->active_element_set_.empty(),
"Cannot saturate more a constraint that has"
" no active element! You may want to change the maxmin precision (--cfg=maxmin/precision:<new_value>)"
const simgrid::mc::Type* subtype;
const simgrid::mc::Type* subsubtype;
int elm_size;
- int i;
xbt_assert(type != nullptr);
switch (type->type) {
default:
return false;
}
- for (i = 0; i < type->element_count; i++) {
+ for (int i = 0; i < type->element_count; i++) {
size_t off = i * elm_size;
if (areas_differ_with_type(state, (const char*)real_area1 + off, snapshot1, region1,
(const char*)real_area2 + off, snapshot2, region2, type->subtype, pointer_level))
int result = 1;
Dwarf_Die child;
- int res;
- for (res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child)) {
+ for (int res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child)) {
int child_tag = dwarf_tag(&child);
if (child_tag == DW_TAG_subrange_type || child_tag == DW_TAG_enumeration_type)
result *= MC_dwarf_subrange_element_count(&child, unit);
static void MC_dwarf_add_members(const simgrid::mc::ObjectInformation* /*info*/, Dwarf_Die* die,
const Dwarf_Die* /*unit*/, simgrid::mc::Type* type)
{
- int res;
Dwarf_Die child;
xbt_assert(type->members.empty());
- for (res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child)) {
+ for (int res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child)) {
int tag = dwarf_tag(&child);
if (tag == DW_TAG_member || tag == DW_TAG_inheritance) {
// Skip declarations:
{
// For each child DIE:
Dwarf_Die child;
- int res;
- for (res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child))
+ for (int res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child))
MC_dwarf_handle_die(info, &child, unit, frame, ns);
}
xbt_free(tkey);
if(*flag!=0){
int replace=0;
- int i=0;
- for (i=0; i<*valuelen; i++){
+ for (int i = 0; i < *valuelen; i++) {
if(value[i]=='\0')
replace=1;
if(replace)
void mpi_info_get_nthkey_ ( int* info, int* n, char *key, int* ierr, unsigned int keylen){
*ierr = MPI_Info_get_nthkey( simgrid::smpi::Info::f2c(*info), *n, key);
- unsigned int i = 0;
- for (i=strlen(key); i<keylen; i++)
+ for (unsigned int i = strlen(key); i < keylen; i++)
key[i]=' ';
}
void mpi_startall_(int* count, int* requests, int* ierr) {
MPI_Request* reqs;
- int i;
reqs = xbt_new(MPI_Request, *count);
- for(i = 0; i < *count; i++) {
+ for (int i = 0; i < *count; i++) {
reqs[i] = simgrid::smpi::Request::f2c(requests[i]);
}
*ierr = MPI_Startall(*count, reqs);
void mpi_waitany_(int* count, int* requests, int* index, MPI_Status* status, int* ierr) {
MPI_Request* reqs;
- int i;
reqs = xbt_new(MPI_Request, *count);
- for(i = 0; i < *count; i++) {
+ for (int i = 0; i < *count; i++) {
reqs[i] = simgrid::smpi::Request::f2c(requests[i]);
}
*ierr = MPI_Waitany(*count, reqs, index, status);
void mpi_testany_ (int* count, int* requests, int *index, int *flag, MPI_Status* status, int* ierr)
{
MPI_Request* reqs;
- int i;
reqs = xbt_new(MPI_Request, *count);
- for(i = 0; i < *count; i++) {
+ for (int i = 0; i < *count; i++) {
reqs[i] = simgrid::smpi::Request::f2c(requests[i]);
}
*ierr = MPI_Testany(*count, reqs, index, flag, FORT_STATUS_IGNORE(status));
void mpi_type_struct_ (int* count, int* blocklens, int* indices, int* old_types, int* newtype, int* ierr) {
MPI_Datatype tmp;
- int i=0;
MPI_Datatype* types = static_cast<MPI_Datatype*>(xbt_malloc(*count*sizeof(MPI_Datatype)));
MPI_Aint* indices_aint=new MPI_Aint[*count];
- for(i=0; i< *count; i++){
+ for (int i = 0; i < *count; i++) {
indices_aint[i]=indices[i];
types[i] = simgrid::smpi::Datatype::f2c(old_types[i]);
}
void mpi_type_create_struct_(int* count, int* blocklens, MPI_Aint* indices, int* old_types, int* newtype, int* ierr){
MPI_Datatype tmp;
- int i=0;
MPI_Datatype* types = static_cast<MPI_Datatype*>(xbt_malloc(*count*sizeof(MPI_Datatype)));
- for(i=0; i< *count; i++){
+ for (int i = 0; i < *count; i++) {
types[i] = simgrid::smpi::Datatype::f2c(old_types[i]);
}
*ierr = MPI_Type_create_struct(*count, blocklens, indices, types, &tmp);
}
int Win::lock_all(int assert){
- int i=0;
int retval = MPI_SUCCESS;
- for (i=0; i<comm_->size();i++){
- int ret = this->lock(MPI_LOCK_SHARED, i, assert);
- if(ret != MPI_SUCCESS)
- retval = ret;
+ for (int i = 0; i < comm_->size(); i++) {
+ int ret = this->lock(MPI_LOCK_SHARED, i, assert);
+ if (ret != MPI_SUCCESS)
+ retval = ret;
}
return retval;
}
}
int Win::unlock_all(){
- int i=0;
int retval = MPI_SUCCESS;
- for (i=0; i<comm_->size();i++){
+ for (int i = 0; i < comm_->size(); i++) {
int ret = this->unlock(i);
if (ret != MPI_SUCCESS)
retval = ret;
*/
signed int xbt_dynar_search_or_negative(const_xbt_dynar_t dynar, const void* elem)
{
- unsigned long it;
-
- for (it = 0; it < dynar->used; it++)
+ for (unsigned long it = 0; it < dynar->used; it++)
if (not memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
return it;
}
*/
int xbt_dynar_member(const_xbt_dynar_t dynar, const void* elem)
{
- unsigned long it;
-
- for (it = 0; it < dynar->used; it++)
+ for (unsigned long it = 0; it < dynar->used; it++)
if (not memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
return 1;
}
char *const data = (char *) dynar->data;
const unsigned long elmsize = dynar->elmsize;
const unsigned long used = dynar->used;
- unsigned long i;
_sanity_check_dynar(dynar);
- for (i = 0; i < used; i++) {
+ for (unsigned long i = 0; i < used; i++) {
char* elm = data + i * elmsize;
op(elm);
}
static xbt_log_category_t _xbt_log_cat_searchsub(xbt_log_category_t cat, const char* name)
{
- xbt_log_category_t child;
- xbt_log_category_t res;
-
XBT_DEBUG("Search '%s' into '%s' (firstChild='%s'; nextSibling='%s')", name,
cat->name, (cat->firstChild ? cat->firstChild->name : "none"),
(cat->nextSibling ? cat->nextSibling->name : "none"));
if (strcmp(cat->name, name) == 0)
return cat;
- for (child = cat->firstChild; child != nullptr; child = child->nextSibling) {
+ for (xbt_log_category_t child = cat->firstChild; child != nullptr; child = child->nextSibling) {
XBT_DEBUG("Dig into %s", child->name);
- res = _xbt_log_cat_searchsub(child, name);
+ xbt_log_category_t res = _xbt_log_cat_searchsub(child, name);
if (res)
return res;
}
*/
void xbt_mallocator_free(xbt_mallocator_t m)
{
- int i;
xbt_assert(m != NULL, "Invalid parameter");
XBT_VERB("Frees mallocator %p (size:%d/%d)", m, m->current_size, m->max_size);
- for (i = 0; i < m->current_size; i++) {
+ for (int i = 0; i < m->current_size; i++) {
m->free_f(m->objects[i]);
}
xbt_free(m->objects);
if (m->current_size <= 0) {
/* No object is ready yet. Create a bunch of them to try to group the
* mallocs on the same memory pages (to help the cache lines) */
- int i;
int amount = MIN(m->max_size / 2, 1000);
- for (i = 0; i < amount; i++)
+ for (int i = 0; i < amount; i++)
m->objects[i] = m->new_f();
m->current_size = amount;
}
* properly, we need to make the align function publicly visible, too */
static void initialize(xbt_mheap_t mdp)
{
- int i;
- malloc_info mi; /* to compute the offset of the swag hook */
-
// Update mdp meta-data:
mdp->heapsize = HEAP / BLOCKSIZE;
mdp->heapinfo = (malloc_info *)
initialize_heapinfo_heapinfo(mdp);
- for (i=0;i<BLOCKLOG;i++) {
- xbt_swag_init(&(mdp->fraghead[i]),
- xbt_swag_offset(mi, freehook));
+ for (int i = 0; i < BLOCKLOG; i++) {
+ malloc_info mi; /* to compute the offset of the swag hook */
+ xbt_swag_init(&(mdp->fraghead[i]), xbt_swag_offset(mi, freehook));
}
}
/* Check if we need to grow the info table (in a multiplicative manner) */
if ((size_t) BLOCK((char *) result + size) > mdp->heapsize) {
- int it;
-
size_t newsize = mdp->heapsize;
while ((size_t) BLOCK((char *) result + size) > newsize)
newsize *= 2;
/* mark the space previously occupied by the block info as free by first marking it
* as occupied in the regular way, and then freing it */
- for (it=0; it<BLOCKIFY(mdp->heapsize * sizeof(malloc_info)); it++){
+ for (int it = 0; it < BLOCKIFY(mdp->heapsize * sizeof(malloc_info)); it++) {
newinfo[BLOCK(oldinfo)+it].type = MMALLOC_TYPE_UNFRAGMENTED;
newinfo[BLOCK(oldinfo)+it].busy_block.ignore = 0;
}
/* Full blocks -> Full blocks; see if we can hold it in place. */
blocks = BLOCKIFY(size);
if (blocks < mdp->heapinfo[block].busy_block.size) {
- size_t it;
/* The new size is smaller; return excess memory to the free list. */
- for (it= block+blocks; it< mdp->heapinfo[block].busy_block.size ; it++){
+ for (size_t it = block + blocks; it < mdp->heapinfo[block].busy_block.size; it++) {
mdp->heapinfo[it].type = MMALLOC_TYPE_UNFRAGMENTED; // FIXME that should be useless, type should already be 0 here
mdp->heapinfo[it].busy_block.ignore = 0;
mdp->heapinfo[it].busy_block.size = 0;
int errs = 0;
int size;
int rank;
- int i;
int* buf;
int count;
MPI_File fh;
MPI_Barrier( comm );
- for (i=0; i<size; i++) buf[i] = -1;
+ for (int i = 0; i < size; i++)
+ buf[i] = -1;
MPI_File_read_at_all( fh, sizeof(int)*rank, buf, 10, MPI_INT, &status );
// if (buf[0] != rank) {
// errs++;
int errs = 0;
int size;
int rank;
- int i;
int* buf;
int count;
MPI_File fh;
MPI_Barrier( comm );
MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET );
- for (i=0; i<size; i++) buf[i] = -1;
+ for (int i = 0; i < size; i++)
+ buf[i] = -1;
MPI_File_read_all( fh, buf, 10, MPI_INT, &status );
// if (buf[0] != rank) {
// errs++;
int errs = 0;
int size;
int rank;
- int i;
int* buf;
int count;
MPI_File fh;
}
MPI_Barrier( comm );
MPI_File_seek_shared( fh, 0, MPI_SEEK_SET );
- for (i=0; i<size; i++) buf[i] = -1;
+ for (int i = 0; i < size; i++)
+ buf[i] = -1;
MPI_File_read_ordered( fh, buf, 10, MPI_INT, &status );
MPI_Barrier(comm);
int errs = 0;
int size;
int rank;
- int i;
int* buf;
int count;
MPI_File fh;
MPI_Barrier( comm );
- for (i=0; i<size; i++) buf[i] = -1;
+ for (int i = 0; i < size; i++)
+ buf[i] = -1;
MPI_File_read_at( fh, sizeof(int)*rank, buf, 1, MPI_INT, &status );
// if (buf[0] != rank) {
// errs++;
int errs = 0;
int size;
int rank;
- int i;
int* buf;
int count;
MPI_File fh;
MPI_Barrier( comm );
MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET );
- for (i=0; i<size; i++) buf[i] = -1;
+ for (int i = 0; i < size; i++)
+ buf[i] = -1;
MPI_File_read( fh, buf, 1, MPI_INT, &status );
// if (buf[0] != rank) {
// errs++;