Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Cleanup #includes
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 2 Oct 2015 11:35:40 +0000 (13:35 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 9 Oct 2015 12:11:23 +0000 (14:11 +0200)
src/mc/AddressSpace.hpp
src/mc/mc_client.cpp
src/mc/mc_comm_pattern.h
src/mc/mc_dwarf.cpp
src/mc/mc_dwarf_expression.cpp
src/mc/mc_global.cpp
src/mc/mc_hash.cpp
src/mc/mc_record.cpp
src/mc/mc_server.h

index b498665..2dea315 100644 (file)
@@ -7,13 +7,12 @@
 #ifndef SIMGRID_MC_ADDRESS_SPACE_H
 #define SIMGRID_MC_ADDRESS_SPACE_H
 
+#include <cstddef>
 #include <cstdint>
 #include <type_traits>
 
 #include <xbt/misc.h>
 
-#include <stdint.h>
-
 #include "mc_forward.hpp"
 
 namespace simgrid {
index 6109240..5ed0cf3 100644 (file)
@@ -4,9 +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 <stdlib.h>
-#include <errno.h>
-#include <error.h>
+#include <cstdlib>
+#include <cerrno>
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -37,7 +36,7 @@ void MC_client_init(void)
     return;
   }
 
-  char* fd_env = getenv(MC_ENV_SOCKET_FD);
+  char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
   if (!fd_env)
     xbt_die("MC socket not found");
 
index 1a340df..5b2215b 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef SIMGRID_MC_COMM_PATTERN_H
 #define SIMGRID_MC_COMM_PATTERN_H
 
-#include <stdint.h>
+#include <stddef.h>
 
 #include <simgrid_config.h>
 #include <xbt/dynar.h>
index 774eb33..185d4be 100644 (file)
@@ -10,7 +10,7 @@
 #include <algorithm>
 #include <memory>
 
-#include <stdlib.h>
+#include <cstdlib>
 #define DW_LANG_Objc DW_LANG_ObjC       /* fix spelling error in older dwarf.h */
 #include <dwarf.h>
 #include <elfutils/libdw.h>
index 7bf2335..cc9b6a6 100644 (file)
@@ -4,8 +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 <stdint.h>
-#include <stdarg.h>
+#include <cstdint>
+#include <cstdarg>
 
 #include <dwarf.h>
 #include <elfutils/libdw.h>
@@ -107,7 +107,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
   for (size_t i = 0; i != n; ++i) {
     int error = 0;
     const Dwarf_Op *op = ops + i;
-    uint8_t atom = op->atom;
+    std::uint8_t atom = op->atom;
 
     switch (atom) {
 
@@ -181,7 +181,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
       {
         if (!state->frame_base)
           return MC_EXPRESSION_E_MISSING_FRAME_BASE;
-        uintptr_t fb = ((uintptr_t) state->frame_base) + op->number;
+        std::uintptr_t fb = ((std::uintptr_t) state->frame_base) + op->number;
         error = mc_dwarf_push_value(state, fb);
         break;
       }
@@ -233,7 +233,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
         return MC_EXPRESSION_E_NO_BASE_ADDRESS;
       if (state->stack_size == MC_EXPRESSION_STACK_SIZE)
         return MC_EXPRESSION_E_STACK_OVERFLOW;
-      Dwarf_Off addr = (Dwarf_Off) (uintptr_t)
+      Dwarf_Off addr = (Dwarf_Off) (std::uintptr_t)
         state->object_info->base_address() + op->number;
       error = mc_dwarf_push_value(state, addr);
       break;
@@ -279,7 +279,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
       if (state->stack_size < 2)
         return MC_EXPRESSION_E_STACK_UNDERFLOW;
       {
-        uintptr_t temp = state->stack[state->stack_size - 2];
+        std::uintptr_t temp = state->stack[state->stack_size - 2];
         state->stack[state->stack_size - 2] =
             state->stack[state->stack_size - 1];
         state->stack[state->stack_size - 1] = temp;
@@ -302,7 +302,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
       if (state->stack_size < 2)
         return MC_EXPRESSION_E_STACK_UNDERFLOW;
       {
-        uintptr_t result =
+        std::uintptr_t result =
             state->stack[state->stack_size - 2] +
             state->stack[state->stack_size - 1];
         state->stack[state->stack_size - 2] = result;
@@ -314,7 +314,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
       if (state->stack_size < 2)
         return MC_EXPRESSION_E_STACK_UNDERFLOW;
       {
-        uintptr_t result =
+        std::uintptr_t result =
             state->stack[state->stack_size - 2] -
             state->stack[state->stack_size - 1];
         state->stack[state->stack_size - 2] = result;
@@ -350,7 +350,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
       if (state->stack_size < 2)
         return MC_EXPRESSION_E_STACK_UNDERFLOW;
       {
-        uintptr_t result =
+        std::uintptr_t result =
             state->stack[state->stack_size - 2] -
             state->stack[state->stack_size - 1];
         state->stack[state->stack_size - 2] = result;
@@ -362,7 +362,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
       if (state->stack_size < 2)
         return MC_EXPRESSION_E_STACK_UNDERFLOW;
       {
-        uintptr_t result =
+        std::uintptr_t result =
             state->stack[state->stack_size -
                          2] & state->stack[state->stack_size - 1];
         state->stack[state->stack_size - 2] = result;
@@ -374,7 +374,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
       if (state->stack_size < 2)
         return MC_EXPRESSION_E_STACK_UNDERFLOW;
       {
-        uintptr_t result =
+        std::uintptr_t result =
             state->stack[state->stack_size -
                          2] | state->stack[state->stack_size - 1];
         state->stack[state->stack_size - 2] = result;
@@ -386,7 +386,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
       if (state->stack_size < 2)
         return MC_EXPRESSION_E_STACK_UNDERFLOW;
       {
-        uintptr_t result =
+        std::uintptr_t result =
             state->stack[state->stack_size -
                          2] ^ state->stack[state->stack_size - 1];
         state->stack[state->stack_size - 2] = result;
@@ -407,7 +407,7 @@ int mc_dwarf_execute_expression(size_t n, const Dwarf_Op * ops,
         return MC_EXPRESSION_E_STACK_UNDERFLOW;
       {
         // Computed address:
-        uintptr_t address = (uintptr_t) state->stack[state->stack_size - 1];
+        std::uintptr_t address = (std::uintptr_t) state->stack[state->stack_size - 1];
         if (!state->address_space)
           xbt_die("Missing address space");
         state->address_space->read_bytes(
@@ -546,10 +546,10 @@ void mc_dwarf_location_list_init(
 {
   list->clear();
 
-  ptrdiff_t offset = 0;
+  std::ptrdiff_t offset = 0;
   Dwarf_Addr base, start, end;
   Dwarf_Op *ops;
-  size_t len;
+  std::size_t len;
 
   while (1) {
 
index d9680d8..ccda078 100644 (file)
@@ -6,9 +6,10 @@
 
 #include <cinttypes>
 
-#include <assert.h>
-#include <string.h>
-#include <stdint.h>
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
 
 #include "mc_base.h"
 
@@ -542,7 +543,7 @@ void MC_dump_stacks(FILE* file)
       unw_get_reg(&c, UNW_X86_64_RIP, &rip);
       unw_get_reg(&c, UNW_X86_64_RSP, &rsp);
       fprintf(file, "  %i: %s (RIP=0x%" PRIx64 " RSP=0x%" PRIx64 ")\n",
-        nframe, name, rip, rsp);
+        nframe, name, (std::uint64_t) rip, (std::uint64_t) rsp);
 #else
       fprintf(file, "  %i: %s\n", nframe, name);
 #endif
index eac6cc9..a3c9b69 100644 (file)
@@ -6,8 +6,7 @@
 
 #include <cinttypes>
 
-#include <stdint.h>
-#include <stdbool.h>
+#include <cstdint>
 
 #include "mc_private.h"
 #include "mc/datatypes.h"
@@ -25,7 +24,7 @@ namespace mc {
 template<class T>
 static void hash_update(hash_type& hash, T const& value)
 {
-  hash = (hash << 5) + hash + (uint64_t) value;
+  hash = (hash << 5) + hash + (std::uint64_t) value;
 }
 
 // ***** Hash state
index d6f1097..53fe654 100644 (file)
@@ -4,8 +4,9 @@
 /* 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 <stdio.h>
-#include <stdlib.h>
+#include <cstring>
+#include <cstdio>
+#include <cstdlib>
 
 #include <xbt.h>
 #include <simgrid/simix.h>
@@ -26,9 +27,9 @@ extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_record, mc,
   " Logging specific to MC record/replay facility");
 
-char* MC_record_path = NULL;
+char* MC_record_path = nullptr;
 
-void MC_record_replay(mc_record_item_t start, size_t len)
+void MC_record_replay(mc_record_item_t start, std::size_t len)
 {
   MC_wait_for_requests();
   mc_record_item_t end = start + len;
@@ -62,9 +63,9 @@ xbt_dynar_t MC_record_from_string(const char* data)
 {
   XBT_INFO("path=%s", data);
   if (!data || !data[0])
-    return NULL;
+    return nullptr;
 
-  xbt_dynar_t dynar = xbt_dynar_new(sizeof(s_mc_record_item_t), NULL);
+  xbt_dynar_t dynar = xbt_dynar_new(sizeof(s_mc_record_item_t), nullptr);
 
   const char* current = data;
   while (*current) {
@@ -76,8 +77,8 @@ xbt_dynar_t MC_record_from_string(const char* data)
     xbt_dynar_push(dynar, &item);
 
     // Find next chunk:
-    const char* end = strchr(current, ';');
-    if(end==NULL)
+    const char* end = std::strchr(current, ';');
+    if(end == nullptr)
       break;
     else
       current = end + 1;
@@ -87,15 +88,15 @@ xbt_dynar_t MC_record_from_string(const char* data)
 
 fail:
   xbt_dynar_free(&dynar);
-  return NULL;
+  return nullptr;
 }
 
 #ifdef HAVE_MC
 static char* MC_record_stack_to_string_liveness(xbt_fifo_t stack)
 {
   char* buffer;
-  size_t size;
-  FILE* file = open_memstream(&buffer, &size);
+  std::size_t size;
+  std::FILE* file = open_memstream(&buffer, &size);
 
   xbt_fifo_item_t item;
   xbt_fifo_item_t start = xbt_fifo_get_last_item(stack);
@@ -110,13 +111,13 @@ static char* MC_record_stack_to_string_liveness(xbt_fifo_t stack)
       // Serialization the (pid, value) pair:
       const char* sep = (item!=start) ? ";" : "";
       if (value)
-        fprintf(file, "%s%u/%u", sep, pid, value);
+        std::fprintf(file, "%s%u/%u", sep, pid, value);
       else
-        fprintf(file, "%s%u", sep, pid);
+        std::fprintf(file, "%s%u", sep, pid);
     }
   }
 
-  fclose(file);
+  std::fclose(file);
   return buffer;
 }
 
@@ -134,8 +135,8 @@ char* MC_record_stack_to_string(xbt_fifo_t stack)
   }
 
   char* buffer;
-  size_t size;
-  FILE* file = open_memstream(&buffer, &size);
+  std::size_t size;
+  std::FILE* file = open_memstream(&buffer, &size);
 
   xbt_fifo_item_t item;
   for (item = start; item; item = xbt_fifo_get_prev_item(item)) {
@@ -150,12 +151,12 @@ char* MC_record_stack_to_string(xbt_fifo_t stack)
     // Serialization the (pid, value) pair:
     const char* sep = (item!=start) ? ";" : "";
     if (value)
-      fprintf(file, "%s%u/%u", sep, pid, value);
+      std::fprintf(file, "%s%u/%u", sep, pid, value);
     else
-      fprintf(file, "%s%u", sep, pid);
+      std::fprintf(file, "%s%u", sep, pid);
   }
 
-  fclose(file);
+  std::fclose(file);
   return buffer;
 }
 
@@ -164,7 +165,7 @@ void MC_record_dump_path(xbt_fifo_t stack)
   if (MC_record_is_active()) {
     char* path = MC_record_stack_to_string(stack);
     XBT_INFO("Path = %s", path);
-    free(path);
+    std::free(path);
   }
 }
 #endif
index a620d17..422172b 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <poll.h>
 
-#include <stdint.h>
 #include <stdbool.h>
 
 #include <sys/signalfd.h>