Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid (conditionnaly) including C++ headers files in C headers
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 5 Jul 2016 09:30:46 +0000 (11:30 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 5 Jul 2016 09:31:13 +0000 (11:31 +0200)
24 files changed:
include/simgrid/host.h
src/bindings/java/jmsg.cpp
src/bindings/java/jmsg_as.cpp
src/bindings/java/jmsg_host.cpp
src/bindings/java/jmsg_task.cpp
src/instr/instr_paje_containers.cpp
src/msg/msg_global.cpp
src/msg/msg_io.cpp
src/msg/msg_vm.cpp
src/s4u/s4u_as.cpp
src/simix/SynchroExec.cpp
src/simix/SynchroSleep.cpp
src/simix/smx_global.cpp
src/simix/smx_io.cpp
src/simix/smx_network.cpp
src/simix/smx_process.cpp
src/smpi/colls/smpi_automatic_selector.cpp
src/smpi/smpi_comm.cpp
src/smpi/smpi_dvfs.cpp
src/surf/AsNone.cpp
src/surf/AsVivaldi.cpp
src/surf/surf_routing.cpp
src/surf/xml/platf.hpp
teshsuite/simdag/flatifier/flatifier.cpp

index 7ea67cc..45d28b7 100644 (file)
 
 #include <simgrid/forward.h>
 
-#ifdef __cplusplus
-#include <simgrid/s4u/host.hpp>
-#endif
-
 SG_BEGIN_DECL()
 
 XBT_PUBLIC(size_t) sg_host_count(void);
index 187a7f6..f970603 100644 (file)
@@ -6,10 +6,14 @@
 /* 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. */
 
+#include <locale.h>
+
 #include <simgrid/msg.h>
 #include <simgrid/simix.h>
-#include "simgrid/plugins/energy.h"
-#include <locale.h>
+#include <simgrid/plugins/energy.h>
+
+#include <simgrid/s4u/host.hpp>
+
 #include <src/simix/smx_private.h>
 
 #include "jmsg_process.h"
index 8f7b031..cd18404 100644 (file)
@@ -6,8 +6,12 @@
 /* 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. */
 
-#include "xbt/str.h"
-#include "xbt/dict.h"
+#include <xbt/str.h>
+#include <xbt/dict.h>
+#include <xbt/dynar.h>
+
+#include <simgrid/s4u/host.hpp>
+
 #include "simgrid/msg.h"
 #include "jmsg_as.h"
 #include "jmsg_host.h"
index 0dc3098..9e16cc0 100644 (file)
@@ -6,13 +6,20 @@
 /* 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. */
 
-#include "xbt/str.h"
+#include <xbt/dict.h>
+#include <xbt/dynar.h>
+#include <xbt/log.h>
+#include <xbt/str.h>
+
+#include <surf/surf_routing.h>
+
+#include <simgrid/s4u/host.hpp>
+
 #include "simgrid/msg.h"
 #include "jmsg.h"
 #include "jmsg_host.h"
 #include "jxbt_utilities.h"
 #include "jmsg_storage.h"
-#include <surf/surf_routing.h>
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
 
index a7d5545..f298008 100644 (file)
@@ -6,14 +6,19 @@
 /* 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. */
 
+#include <xbt/log.h>
+#include <xbt/str.h>
+#include <xbt/sysdep.h>
+
+#include <simgrid/msg.h>
+#include <simgrid/s4u/host.hpp>
+
 #include "jmsg.h"
 #include "jmsg_host.h"
 #include "jmsg_task.h"
 #include "jmsg_process.h"
 #include "jxbt_utilities.h"
 
-#include <simgrid/msg.h>
-
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
 
 static jmethodID jtask_method_Comm_constructor;
index 8dfd00c..5f05440 100644 (file)
@@ -4,10 +4,16 @@
 /* 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. */
 
+#include <simgrid/s4u/host.hpp>
+
+#include <xbt/dict.h>
+#include <xbt/lib.h>
+#include <xbt/log.h>
+
+#include <surf/surf.h>
+#include <surf/surf_routing.h>
+
 #include "src/instr/instr_private.h"
-#include "xbt/lib.h"
-#include "surf/surf.h"
-#include "surf/surf_routing.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_containers, instr, "Paje tracing event system (containers)");
 
index 0e45156..f056efd 100644 (file)
@@ -4,6 +4,8 @@
 /* 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. */
 
+#include <simgrid/s4u/host.hpp>
+
 #include "simgrid/msg.h"
 #include "instr/instr_interface.h"
 #include "msg_private.h"
index 7faed32..4b0c1ce 100644 (file)
@@ -4,6 +4,8 @@
 /* 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. */
 
+#include <simgrid/s4u/host.hpp>
+
 #include "msg_private.h"
 #include "xbt/log.h"
 
index 8836491..c341322 100644 (file)
@@ -11,6 +11,8 @@
 
 #include <xbt/ex.hpp>
 
+#include <simgrid/s4u/host.hpp>
+
 #include "msg_private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
index 14827e0..2e798e4 100644 (file)
@@ -4,9 +4,11 @@
 /* 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. */
 
-#include "xbt/log.h"
+#include <xbt/log.h>
+
+#include <simgrid/s4u/host.hpp>
+#include <simgrid/s4u/As.hpp>
 
-#include "simgrid/s4u/As.hpp"
 #include "src/surf/surf_routing.hpp"
 #include "src/surf/network_interface.hpp" // Link FIXME: move to proper header
 
index 99d2b74..9f08b4b 100644 (file)
@@ -3,6 +3,8 @@
 /* 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. */
 
+#include <simgrid/s4u/host.hpp>
+
 #include "src/simix/SynchroExec.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "src/simix/smx_host_private.h"
index febf52d..bc6cbe0 100644 (file)
@@ -3,6 +3,10 @@
 /* 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. */
 
+#include <xbt/log.h>
+
+#include <simgrid/s4u/host.hpp>
+
 #include "src/simix/SynchroSleep.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "src/simix/popping_private.h"
index 7544d36..90a2f88 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <xbt/functional.hpp>
 
+#include <simgrid/s4u/host.hpp>
+
 #include "src/surf/surf_interface.hpp"
 #include "src/surf/storage_interface.hpp"
 #include "src/surf/xml/platf.hpp"
index 1d737c3..41a1ff3 100644 (file)
@@ -4,13 +4,17 @@
 /* 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. */
 
+#include <xbt/ex.hpp>
+#include <xbt/sysdep.h>
+#include <xbt/log.h>
+#include <xbt/dict.h>
+
+#include <simgrid/s4u/host.hpp>
+
+#include <mc/mc.h>
+
 #include "src/surf/surf_interface.hpp"
 #include "smx_private.h"
-#include <xbt/ex.hpp>
-#include "xbt/sysdep.h"
-#include "xbt/log.h"
-#include "xbt/dict.h"
-#include "mc/mc.h"
 
 #include "src/simix/SynchroIo.hpp"
 
index c2f5b84..e6ce384 100644 (file)
@@ -7,6 +7,8 @@
 
 #include <xbt/ex.hpp>
 
+#include <simgrid/s4u/host.hpp>
+
 #include "src/surf/surf_interface.hpp"
 #include "src/simix/smx_private.h"
 #include "xbt/log.h"
index 2ee77d7..5f28c68 100644 (file)
@@ -4,21 +4,28 @@
 /* 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. */
 
+#include <exception>
+#include <functional>
+#include <string>
+#include <utility>
+
 #include <boost/range/algorithm.hpp>
 
 #include <xbt/functional.hpp>
+#include <xbt/ex.hpp>
+#include <xbt/sysdep.h>
+#include <xbt/log.h>
+#include <xbt/dict.h>
+
+#include <simgrid/s4u/host.hpp>
+
+#include <mc/mc.h>
 
 #include "src/surf/surf_interface.hpp"
 #include "smx_private.h"
-#include <xbt/ex.hpp>
-#include "xbt/sysdep.h"
-#include "xbt/log.h"
-#include "xbt/dict.h"
-#include "mc/mc.h"
 #include "src/mc/mc_replay.h"
 #include "src/mc/Client.hpp"
 #include "src/msg/msg_private.h"
-
 #include "src/simix/SynchroSleep.hpp"
 #include "src/simix/SynchroRaw.hpp"
 #include "src/simix/SynchroIo.hpp"
index 4898c5c..c79cea5 100644 (file)
@@ -4,9 +4,12 @@
 /* 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. */
 
-#include "colls_private.h"
 #include <float.h>
 
+#include <exception>
+
+#include "colls_private.h"
+
 //attempt to do a quick autotuning version of the collective,
 
 #define TRACE_AUTO_COLL(cat) if (TRACE_is_enabled()){\
index ab6fa84..d91a5df 100644 (file)
@@ -5,15 +5,18 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdlib.h>
+#include <limits.h>
 
-#include "private.h"
+#include <xbt/dict.h>
+#include <xbt/ex.h>
 #include <xbt/ex.hpp>
-#include "xbt/dict.h"
+
+#include <simgrid/s4u/host.hpp>
+
+#include "private.h"
 #include "smpi_mpi_dt_private.h"
-#include "limits.h"
 #include "src/simix/smx_private.h"
 #include "colls/colls.h"
-#include "xbt/ex.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi, "Logging specific to SMPI (comm)");
 
index e78e5b7..8c16192 100644 (file)
@@ -4,10 +4,15 @@
 /* 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. */
 
-#include "simgrid/plugins/energy.h" // FIXME: this plugin should be separated from the core
-#include "xbt/log.h"
-#include "simgrid/simix.h"
-#include "smpi/smpi.h"
+#include <xbt/log.h>
+
+// FIXME: this plugin should be separated from the core
+#include <simgrid/plugins/energy.h>
+#include <simgrid/simix.h>
+#include <simgrid/s4u/host.hpp>
+
+#include <smpi/smpi.h>
+
 #include "src/internal_config.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_dvfs, smpi, "Logging specific to SMPI (experimental DVFS support)");
index 4d4dfbf..3683fa3 100644 (file)
@@ -3,15 +3,21 @@
 /* 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. */
 
+#include <xbt/dict.h>
+#include <xbt/graph.h>
+#include <xbt/log.h>
+
 #include "src/surf/AsNone.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_none, surf, "Routing part of surf");
 
 namespace simgrid {
 namespace routing {
+
 AsNone::AsNone(const char*name)
   : AsImpl(name)
 {}
+
 AsNone::~AsNone()
 {}
 
@@ -23,5 +29,6 @@ void AsNone::getGraph(xbt_graph_t /*graph*/, xbt_dict_t /*nodes*/, xbt_dict_t /*
 {
   XBT_ERROR("No routing no graph");
 }
+
 }
 }
index f9d772a..9a3bf1a 100644 (file)
@@ -3,6 +3,10 @@
 /* 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. */
 
+#include <xbt/dynar.h>
+
+#include <simgrid/s4u/host.hpp>
+
 #include "src/surf/AsVivaldi.hpp"
 #include "src/surf/network_interface.hpp"
 
index 7875245..313b39d 100644 (file)
@@ -4,6 +4,12 @@
 /* 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. */
 
+#include <vector>
+
+#include <xbt/signal.hpp>
+
+#include <simgrid/s4u/host.hpp>
+
 #include "surf_routing.hpp"
 
 #include "simgrid/sg_config.h"
@@ -12,8 +18,6 @@
 #include "src/surf/AsImpl.hpp"
 #include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area
 
-#include <vector>
-
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
 
 namespace simgrid {
index d001631..e3e81a8 100644 (file)
@@ -7,9 +7,10 @@
 #ifndef _SURF_SURFXML_PARSE_H
 #define _SURF_SURFXML_PARSE_H
 
-#include "xbt/misc.h"
-#include "xbt/function_types.h"
-#include "xbt/dict.h"
+#include <xbt/dict.h>
+#include <xbt/function_types.h>
+#include <xbt/misc.h>
+#include <xbt/signal.hpp>
 
 SG_BEGIN_DECL()
 
index 4a68e5e..6e9499a 100644 (file)
@@ -4,28 +4,41 @@
 /* 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. */
 
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include <xbt/dict.h>
+#include <xbt/lib.h>
+#include <xbt/log.h>
+#include <xbt/sysdep.h>
+#include <xbt/xbt_os_time.h>
+
+#include <simgrid/s4u/host.hpp>
+
+#include <simgrid/simdag.h>
+
 #include "src/surf/network_interface.hpp"
-#include "simgrid/simdag.h"
-#include "xbt/xbt_os_time.h"
+
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(flatifier, "Logging specific to this platform parsing tool");
 
 static int name_compare_hosts(const void *n1, const void *n2)
 {
-  return strcmp(sg_host_get_name(*(sg_host_t *) n1), sg_host_get_name(*(sg_host_t *) n2));
+  return std::strcmp(sg_host_get_name(*(sg_host_t *) n1), sg_host_get_name(*(sg_host_t *) n2));
 }
 
 static int name_compare_links(const void *n1, const void *n2)
 {
-  return strcmp(sg_link_name(*(SD_link_t *) n1),sg_link_name(*(SD_link_t *) n2));
+  return std::strcmp(sg_link_name(*(SD_link_t *) n1),sg_link_name(*(SD_link_t *) n2));
 }
 
 static int parse_cmdline(int *timings, char **platformFile, int argc, char **argv)
 {
   int wrong_option = 0;
   for (int i = 1; i < argc; i++) {
-    if (strlen(argv[i]) > 1 && argv[i][0] == '-' && argv[i][1] == '-') {
-      if (!strcmp(argv[i], "--timings")) {
+    if (std::strlen(argv[i]) > 1 && argv[i][0] == '-' && argv[i][1] == '-') {
+      if (!std::strcmp(argv[i], "--timings")) {
         *timings = 1;
       } else {
           wrong_option = 1;
@@ -80,30 +93,30 @@ int main(int argc, char **argv)
     XBT_INFO("Parsing time: %fs (%zu hosts, %d links)", xbt_os_timer_elapsed(parse_time),
              sg_host_count(), sg_link_count());
   } else {
-    printf("<?xml version='1.0'?>\n");
-    printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n");
-    printf("<platform version=\"%d\">\n", version);
-    printf("<AS id=\"AS0\" routing=\"Full\">\n");
+    std::printf("<?xml version='1.0'?>\n");
+    std::printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n");
+    std::printf("<platform version=\"%d\">\n", version);
+    std::printf("<AS id=\"AS0\" routing=\"Full\">\n");
 
     // Hosts
     unsigned int totalHosts = sg_host_count();
     sg_host_t *hosts = sg_host_list();
-    qsort((void *) hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);
+    std::qsort((void *) hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);
 
     for (i = 0; i < totalHosts; i++) {
-      printf("  <host id=\"%s\" speed=\"%.0f\"", sg_host_get_name(hosts[i]), sg_host_speed(hosts[i]));
+      std::printf("  <host id=\"%s\" speed=\"%.0f\"", sg_host_get_name(hosts[i]), sg_host_speed(hosts[i]));
       props = sg_host_get_properties(hosts[i]);
       if (hosts[i]->coresCount()>1) {
-        printf(" core=\"%d\"", hosts[i]->coresCount());
+        std::printf(" core=\"%d\"", hosts[i]->coresCount());
       }
       if (props && !xbt_dict_is_empty(props)) {
-        printf(">\n");
+        std::printf(">\n");
         xbt_dict_foreach(props, cursor, key, data) {
-          printf("    <prop id=\"%s\" value=\"%s\"/>\n", key, data);
+          std::printf("    <prop id=\"%s\" value=\"%s\"/>\n", key, data);
         }
-        printf("  </host>\n");
+        std::printf("  </host>\n");
       } else {
-        printf("/>\n");
+        std::printf("/>\n");
       }
     }
 
@@ -111,7 +124,7 @@ int main(int argc, char **argv)
     xbt_lib_foreach(as_router_lib, cursor_src, key, value1) {
       value1 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib, key, ROUTING_ASR_LEVEL);
       if(value1->isRouter()) {
-        printf("  <router id=\"%s\"/>\n",key);
+        std::printf("  <router id=\"%s\"/>\n",key);
       }
     }
 
@@ -119,17 +132,17 @@ int main(int argc, char **argv)
     unsigned int totalLinks = sg_link_count();
     SD_link_t *links = sg_link_list();
 
-    qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links);
+    std::qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links);
 
     for (i = 0; i < totalLinks; i++) {
-      printf("  <link id=\"");
+      std::printf("  <link id=\"");
 
-      printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", sg_link_name(links[i]),
+      std::printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", sg_link_name(links[i]),
              sg_link_bandwidth(links[i]), sg_link_latency(links[i]));
       if (sg_link_is_shared(links[i])) {
-        printf("/>\n");
+        std::printf("/>\n");
       } else {
-        printf(" sharing_policy=\"FATPIPE\"/>\n");
+        std::printf(" sharing_policy=\"FATPIPE\"/>\n");
       }
     }
 
@@ -141,23 +154,23 @@ int main(int argc, char **argv)
         value2 = sg_host_by_name(dst)->pimpl_netcard;
         routing_platf->getRouteAndLatency(value1, value2, route,nullptr);
         if (! route->empty()){
-          printf("  <route src=\"%s\" dst=\"%s\">\n  ", src, dst);
+          std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", src, dst);
           for (auto link: *route)
-            printf("<link_ctn id=\"%s\"/>",link->getName());
-          printf("\n  </route>\n");
+            std::printf("<link_ctn id=\"%s\"/>",link->getName());
+          std::printf("\n  </route>\n");
         }
         delete route;
       }
       xbt_lib_foreach(as_router_lib, cursor_dst, dst, value2){ //to router
         value2 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL);
         if(value2->isRouter()){
-          printf("  <route src=\"%s\" dst=\"%s\">\n  ", src, dst);
+          std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", src, dst);
           std::vector<Link*> *route = new std::vector<Link*>();
           routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route,nullptr);
           for (auto link : *route)
-            printf("<link_ctn id=\"%s\"/>",link->getName());
+            std::printf("<link_ctn id=\"%s\"/>",link->getName());
           delete route;
-          printf("\n  </route>\n");
+          std::printf("\n  </route>\n");
         }
       }
     }
@@ -168,32 +181,32 @@ int main(int argc, char **argv)
         xbt_lib_foreach(as_router_lib, cursor_dst, dst, value2){ //to router
           value2 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL);
           if(value2->isRouter()){
-            printf("  <route src=\"%s\" dst=\"%s\">\n  ", src, dst);
+            std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", src, dst);
             std::vector<Link*> *route = new std::vector<Link*>();
             routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route,nullptr);
             for(auto link :*route)
-              printf("<link_ctn id=\"%s\"/>",link->getName());
+              std::printf("<link_ctn id=\"%s\"/>",link->getName());
             delete route;
-            printf("\n  </route>\n");
+            std::printf("\n  </route>\n");
           }
         }
         xbt_dict_foreach(host_list, cursor_dst, dst, value2){ //to host
-          printf("  <route src=\"%s\" dst=\"%s\">\n  ",src, dst);
+          std::printf("  <route src=\"%s\" dst=\"%s\">\n  ",src, dst);
           std::vector<Link*> *route = new std::vector<Link*>();
           value2 = sg_host_by_name(dst)->pimpl_netcard;
           routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route, nullptr);
           for(auto link : *route)
-            printf("<link_ctn id=\"%s\"/>",link->getName());
+            std::printf("<link_ctn id=\"%s\"/>",link->getName());
           delete route;
-          printf("\n  </route>\n");
+          std::printf("\n  </route>\n");
         }
       }
     }
 
-    printf("</AS>\n");
-    printf("</platform>\n");
-    free(hosts);
-    free(links);
+    std::printf("</AS>\n");
+    std::printf("</platform>\n");
+    std::free(hosts);
+    std::free(links);
   }
 
   SD_exit();