-/* Copyright (c) 2012, 2014. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* Returns the next element iterated by iterator it, NULL if there are no more elements */
void *xbt_dynar_iterator_next(xbt_dynar_iterator_t it)
{
- int *next;
if (it->current >= it->length) {
return NULL;
} else {
- next = xbt_dynar_get_ptr(it->indices_list, it->current);
+ int* next = xbt_dynar_get_ptr(it->indices_list, it->current);
it->current++;
return xbt_dynar_get_ptr(it->list, *next);
}
get_mailbox(node->pred_id, mailbox);
task_data_t req_data_s = xbt_new0(s_task_data_t,1);
req_data_s->type = TASK_SUCCESSOR_LEAVING;
- req_data_s->request_id = node->fingers[0].id;
req_data_s->request_id = node->pred_id;
get_mailbox(node->id, req_data_s->answer_to);
req_data_s->issuer_host_name = MSG_host_get_name(MSG_host_self());
*/
void answer_add_bucket(bucket_t bucket, answer_t answer)
{
- unsigned int cpt;
- unsigned int id;
- unsigned int distance;
- node_contact_t contact;
xbt_assert((bucket != NULL), "Provided a NULL bucket");
xbt_assert((bucket->nodes != NULL), "Provided a bucket which nodes are NULL");
+
+ unsigned int cpt;
+ unsigned int id;
xbt_dynar_foreach(bucket->nodes, cpt, id) {
- distance = id ^ answer->destination_id;
- contact = node_contact_new(id, distance);
+ unsigned int distance = id ^ answer->destination_id;
+ node_contact_t contact = node_contact_new(id, distance);
xbt_dynar_push(answer->nodes, &contact);
answer->size++;
}
unsigned int i = 0;
unsigned int j = 0;
unsigned int destination = node_list->destination_id;
- node_contact_t node_to_query;
while (j < kademlia_alpha && i < node_list->size) {
/* We need to have at most "kademlia_alpha" requests each time, according to the protocol */
/* Gets the node we want to send the query to */
- node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
+ node_contact_t node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
if (node_to_query->id != node->id) { /* No need to query ourselves */
send_find_node(node, node_to_query->id, destination);
j++;
static int server(int argc, char *argv[])
{
msg_task_t task1 = NULL, task2 = NULL;
- msg_comm_t comm_received1 = NULL, comm_received2 = NULL;
- comm_received1 = MSG_task_irecv(&task1, "mymailbox");
- comm_received2 = MSG_task_irecv(&task2, "mymailbox");
+ msg_comm_t comm_received1 = MSG_task_irecv(&task1, "mymailbox");
+ msg_comm_t comm_received2 = MSG_task_irecv(&task2, "mymailbox");
MSG_comm_wait(comm_received1, -1);
MSG_comm_wait(comm_received2, -1);
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s");
long slaves_count = xbt_str_parse_int(argv[4], "Invalid amount of slaves: %s");
- int i;
-
XBT_INFO("Got %ld slaves and %ld tasks to process", slaves_count, number_of_tasks);
- for (i = 0; i < number_of_tasks; i++) {
+ for (int i = 0; i < number_of_tasks; i++) {
char mailbox[256];
char sprintf_buffer[256];
- msg_task_t task = NULL;
snprintf(mailbox,256, "slave-%ld", i % slaves_count);
snprintf(sprintf_buffer,256, "Task_%d", i);
- task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
+ msg_task_t task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
if (number_of_tasks < 10000 || i % 10000 == 0)
XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
}
XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
- for (i = 0; i < slaves_count; i++) {
+ for (int i = 0; i < slaves_count; i++) {
char mailbox[80];
snprintf(mailbox,80, "slave-%ld", i % slaves_count);
class Future {
public:
Future() = default;
- Future(std::shared_ptr<FutureState<T>> state): state_(std::move(state)) {}
+ Future(std::shared_ptr<FutureState<T>> state) : state_(std::move(state)) {}
// Move type:
Future(Future&) = delete;
{
#ifdef XBT_DJB2_HASH_FUNCTION
/* fast implementation of djb2 algorithm */
- int c;
unsigned int hash = 5381;
while (str_len--) {
- c = *str++;
+ int c = *str++;
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
}
# elif defined(XBT_FNV_HASH_FUNCTION)
# Disable some rules on some files
-sonar.issue.ignore.multicriteria=j1,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5,f1
+sonar.issue.ignore.multicriteria=j1,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5a,c5b,f1
# The Object.finalize() method should not be overriden
# But we need to clean the native memory with JNI
# Replace alternative operator "not" with "!"
# I like it better so please leave me alone
-sonar.issue.ignore.multicriteria.c5.ruleKey=cpp:S3659
-sonar.issue.ignore.multicriteria.c5.resourceKey=**/*.cpp
+sonar.issue.ignore.multicriteria.c5a.ruleKey=cpp:S3659
+sonar.issue.ignore.multicriteria.c5a.resourceKey=**/*.cpp
+sonar.issue.ignore.multicriteria.c5b.ruleKey=cpp:S3659
+sonar.issue.ignore.multicriteria.c5b.resourceKey=**/*.hpp
# "reinterpret_cast" should not be used
}
-
DefineVariableTypeEvent::DefineVariableTypeEvent(type_t type)
{
this->event_type = PAJE_DefineVariableType;
void sg_config_finalize()
{
- if (!_sg_cfg_init_status)
+ if (not _sg_cfg_init_status)
return; /* Not initialized yet. Nothing to do */
xbt_cfg_free(&simgrid_config);
def handle(fd, func, simcalls, guarded_simcalls):
- def nonempty(e):
+ def nonempty(e):
return e != ''
fd.write('\n'.join(filter(nonempty, (func(simcall) for simcall in simcalls))))
- for guard, list in guarded_simcalls.items():
+ for guard, ll in guarded_simcalls.items():
fd.write('\n#if %s\n' % (guard))
- fd.write('\n'.join(func(simcall) for simcall in list))
+ fd.write('\n'.join(func(simcall) for simcall in ll))
fd.write('\n#endif\n')
if __name__ == '__main__':
Group::Group(int n) : size_(n)
{
- int i;
rank_to_index_map_ = xbt_new(int, size_);
index_to_rank_map_ = xbt_dict_new_homogeneous(xbt_free_f);
refcount_ = 1;
- for (i = 0; i < size_; i++) {
+ for (int i = 0; i < size_; i++) {
rank_to_index_map_[i] = MPI_UNDEFINED;
}
}
Group::Group(MPI_Group origin)
{
- char *key;
- char *ptr_rank;
- xbt_dict_cursor_t cursor = nullptr;
-
- int i;
if(origin != MPI_GROUP_NULL
&& origin != MPI_GROUP_EMPTY)
{
rank_to_index_map_ = xbt_new(int, size_);
index_to_rank_map_ = xbt_dict_new_homogeneous(xbt_free_f);
refcount_ = 1;
- for (i = 0; i < size_; i++) {
+ for (int i = 0; i < size_; i++) {
rank_to_index_map_[i] = origin->rank_to_index_map_[i];
}
+ char* key;
+ char* ptr_rank;
+ xbt_dict_cursor_t cursor = nullptr;
xbt_dict_foreach(origin->index_to_rank_map_, cursor, key, ptr_rank) {
int * cp = static_cast<int*>(xbt_malloc(sizeof(int)));
*cp=*reinterpret_cast<int*>(ptr_rank);
int i;
int index;
int rank;
- int sz;
result = MPI_IDENT;
if (size_ != group2->size()) {
result = MPI_UNEQUAL;
} else {
- sz = group2->size();
+ int sz = group2->size();
for (i = 0; i < sz; i++) {
index = this->index(i);
rank = group2->rank(index);
xbt_dict_t index_to_rank_map_;
int refcount_;
public:
- Group();
- Group(int size);
- Group(Group* origin);
+ explicit Group();
+ explicit Group(int size);
+ explicit Group(Group* origin);
~Group();
void set_mapping(int index, int rank);
}
xbt_automaton_exp_label_t xbt_automaton_exp_label_new(int type, ...){
- xbt_automaton_exp_label_t label = NULL;
- label = xbt_new0(struct xbt_automaton_exp_label, 1);
+ xbt_automaton_exp_label_t label = xbt_new0(struct xbt_automaton_exp_label, 1);
label->type = type;
xbt_automaton_exp_label_t left;
xbt_automaton_exp_label_t right;
/* Initialize the default malloc descriptor. */
void *mmalloc_preinit(void)
{
- int res;
if (__mmalloc_default_mdp == NULL) {
if(!xbt_pagesize)
xbt_pagesize = getpagesize();
/* Fixme? only the default mdp in protected against forks */
// This is mandated to protect the mmalloced areas through forks. Think of tesh.
// Nah, removing the mutex isn't a good idea either for tesh
- res = xbt_os_thread_atfork(mmalloc_fork_prepare,
- mmalloc_fork_parent, mmalloc_fork_child);
+ int res = xbt_os_thread_atfork(mmalloc_fork_prepare, mmalloc_fork_parent, mmalloc_fork_child);
if (res != 0)
THROWF(system_error,0,"xbt_os_thread_atfork() failed: return value %d",res);
}
// if ((errcode=pthread_key_delete(xbt_self_thread_key)))
// THROWF(system_error,errcode,"pthread_key_delete failed for xbt_self_thread_key");
+ free(main_thread->name);
free(main_thread);
main_thread = NULL;
thread_mod_inited = 0;
set(tesh_files ${tesh_files} PARENT_SCOPE)
if(enable_java)
- ADD_TESH(tesh-java-semaphoreGC --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/semaphoreGC ${CMAKE_HOME_DIRECTORY}/teshsuite/java/semaphoreGC/SemaphoreGC.tesh)
- ADD_TESH(tesh-java-sleepHostOff --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/sleepHostOff ${CMAKE_HOME_DIRECTORY}/teshsuite/java/sleepHostOff/SleepHostOff.tesh)
+ ADD_TESH(tesh-java-semaphoreGC --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/semaphoreGC ${CMAKE_HOME_DIRECTORY}/teshsuite/java/semaphoreGC/semaphoreGC.tesh)
+ ADD_TESH(tesh-java-sleepHostOff --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/sleepHostOff ${CMAKE_HOME_DIRECTORY}/teshsuite/java/sleepHostOff/sleepHostOff.tesh)
endif()
COMMAND ${SED_EXE} -i ${string15} src/surf/xml/simgrid_dtd.c
COMMAND ${SED_EXE} -i 's/int yyl\;/unsigned int yyl\;/' src/surf/xml/simgrid_dtd.c
COMMAND ${SED_EXE} -i 's/int surf_parse_leng\;/unsigned int surf_parse_leng\;/' src/surf/xml/simgrid_dtd.c
- COMMAND ${SED_EXE} -i 's/n = 0\; n < max_size/n = 0\; n < (size_t)max_size/' src/surf/xml/simgrid_dtd.c
+ COMMAND ${SED_EXE} -i 's/n = 0\; n < max_size/n = 0\; n < (size_t) max_size/' src/surf/xml/simgrid_dtd.c
COMMAND ${SED_EXE} -i "s/register //" src/surf/xml/simgrid_dtd.c
COMMAND ${CMAKE_COMMAND} -E echo " Generated surf/xml/simgrid_dtd.c"
# print "WARNING: Output were only sorted using the $sort_prefix first chars.\n"
# if ( $sort_prefix > 0 );
# print "WARNING: Use <! output sort 19> to sort by simulated date and process ID only.\n";
-#
+#
# print "----8<--------------- Begin of unprocessed observed output (as it should appear in file):\n";
# map {print "> $_\n"} @{$cmd{'unsorted got'}};
# print "--------------->8---- End of the unprocessed observed output.\n";
self.timeout *= 20
self.args = TeshState().wrapper + self.args
elif re.match(".*smpirun.*", self.args) is not None:
- self.args = "sh " + self.args
+ self.args = "sh " + self.args
if TeshState().jenkins and self.timeout != None:
self.timeout *= 10