From 5954f11308de69ea37c6f6fdd993925f90749984 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Tue, 15 Mar 2016 13:18:19 +0100 Subject: [PATCH] [mc] Remove C typedefs (mc_foobar_t) and mc_forward.h --- include/xbt/mmalloc.h | 1 - src/mc/Frame.hpp | 2 +- src/mc/ModelChecker.hpp | 2 +- src/mc/ObjectInformation.hpp | 2 +- src/mc/Type.hpp | 2 +- src/mc/Variable.hpp | 2 +- src/mc/mc_checkpoint.cpp | 20 ++++++++++---------- src/mc/mc_compare.cpp | 16 +++++++++------- src/mc/mc_diff.cpp | 18 +++++++++--------- src/mc/mc_forward.h | 30 ------------------------------ src/mc/mc_private.h | 5 ++++- src/mc/mc_safety.h | 2 +- src/mc/mc_snapshot.cpp | 4 ++-- src/mc/mc_snapshot.h | 16 ++++++++-------- src/mc/mc_state.h | 2 +- src/simix/libsmx.cpp | 2 +- src/simix/popping_bodies.cpp | 2 +- src/simix/popping_generated.cpp | 2 +- src/simix/popping_private.h | 1 - src/simix/simcalls.py | 4 ++-- tools/cmake/DefinePackages.cmake | 2 -- 21 files changed, 54 insertions(+), 83 deletions(-) delete mode 100644 src/mc/mc_forward.h diff --git a/include/xbt/mmalloc.h b/include/xbt/mmalloc.h index af930324cd..a8b49c46f4 100644 --- a/include/xbt/mmalloc.h +++ b/include/xbt/mmalloc.h @@ -18,7 +18,6 @@ #include "xbt/dynar.h" #include "xbt/dict.h" -#include "src/mc/mc_forward.h" SG_BEGIN_DECL() diff --git a/src/mc/Frame.hpp b/src/mc/Frame.hpp index 243610a8db..2619402bb7 100644 --- a/src/mc/Frame.hpp +++ b/src/mc/Frame.hpp @@ -13,7 +13,7 @@ #include #include -#include "src/mc/mc_forward.h" +#include "src/mc/mc_forward.hpp" #include "src/mc/LocationList.hpp" #include "src/mc/Variable.hpp" #include "src/mc/Frame.hpp" diff --git a/src/mc/ModelChecker.hpp b/src/mc/ModelChecker.hpp index 1f7665d957..7babe6a6ea 100644 --- a/src/mc/ModelChecker.hpp +++ b/src/mc/ModelChecker.hpp @@ -36,7 +36,7 @@ class ModelChecker { PageStore page_store_; std::unique_ptr process_; public: - mc_snapshot_t parent_snapshot_; + simgrid::mc::Snapshot* parent_snapshot_; public: ModelChecker(ModelChecker const&) = delete; diff --git a/src/mc/ObjectInformation.hpp b/src/mc/ObjectInformation.hpp index 56f80dc0c4..9a55d87bfc 100644 --- a/src/mc/ObjectInformation.hpp +++ b/src/mc/ObjectInformation.hpp @@ -15,7 +15,7 @@ #include #include "src/xbt/memory_map.hpp" -#include "src/mc/mc_forward.h" +#include "src/mc/mc_forward.hpp" #include "src/mc/Type.hpp" #include "src/mc/Frame.hpp" diff --git a/src/mc/Type.hpp b/src/mc/Type.hpp index 5839a3b89b..972b08de26 100644 --- a/src/mc/Type.hpp +++ b/src/mc/Type.hpp @@ -17,7 +17,7 @@ #include -#include "src/mc/mc_forward.h" +#include "src/mc/mc_forward.hpp" #include "src/mc/LocationList.hpp" namespace simgrid { diff --git a/src/mc/Variable.hpp b/src/mc/Variable.hpp index f3b8e0a4bb..5f43e5c79f 100644 --- a/src/mc/Variable.hpp +++ b/src/mc/Variable.hpp @@ -11,7 +11,7 @@ #include -#include "src/mc/mc_forward.h" +#include "src/mc/mc_forward.hpp" #include "src/mc/LocationList.hpp" namespace simgrid { diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index f4f6cd86d6..961936eafe 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -115,7 +115,7 @@ RegionSnapshot privatized_region( #endif static -void add_region(int index, mc_snapshot_t snapshot, +void add_region(int index, simgrid::mc::Snapshot* snapshot, simgrid::mc::RegionType type, simgrid::mc::ObjectInformation* object_info, void *start_addr, void* permanent_addr, @@ -148,7 +148,7 @@ void add_region(int index, mc_snapshot_t snapshot, return; } -static void get_memory_regions(simgrid::mc::Process* process, mc_snapshot_t snapshot) +static void get_memory_regions(simgrid::mc::Process* process, simgrid::mc::Snapshot* snapshot) { const size_t n = process->object_infos.size(); snapshot->snapshot_regions.resize(n + 1); @@ -394,7 +394,7 @@ static std::vector unwind_stack_frames(simgrid::mc::UnwindCo return std::move(result); }; -static std::vector take_snapshot_stacks(mc_snapshot_t * snapshot) +static std::vector take_snapshot_stacks(simgrid::mc::Snapshot* * snapshot) { std::vector res; @@ -425,7 +425,7 @@ static std::vector take_snapshot_stacks(mc_snapshot_t * s } -static void snapshot_handle_ignore(mc_snapshot_t snapshot) +static void snapshot_handle_ignore(simgrid::mc::Snapshot* snapshot) { xbt_assert(snapshot->process()); @@ -447,7 +447,7 @@ static void snapshot_handle_ignore(mc_snapshot_t snapshot) } -static void snapshot_ignore_restore(mc_snapshot_t snapshot) +static void snapshot_ignore_restore(simgrid::mc::Snapshot* snapshot) { for (auto const& ignored_data : snapshot->ignored_data) snapshot->process()->write_bytes( @@ -540,13 +540,13 @@ static std::vector get_current_fds(pid_t pid) return std::move(fds); } -mc_snapshot_t take_snapshot(int num_state) +simgrid::mc::Snapshot* take_snapshot(int num_state) { XBT_DEBUG("Taking snapshot %i", num_state); simgrid::mc::Process* mc_process = &mc_model_checker->process(); - mc_snapshot_t snapshot = new simgrid::mc::Snapshot(mc_process); + simgrid::mc::Snapshot* snapshot = new simgrid::mc::Snapshot(mc_process); snapshot->num_state = num_state; @@ -584,7 +584,7 @@ mc_snapshot_t take_snapshot(int num_state) } static inline -void restore_snapshot_regions(mc_snapshot_t snapshot) +void restore_snapshot_regions(simgrid::mc::Snapshot* snapshot) { for(std::unique_ptr const& region : snapshot->snapshot_regions) { // For privatized, variables we decided it was not necessary to take the snapshot: @@ -605,7 +605,7 @@ void restore_snapshot_regions(mc_snapshot_t snapshot) } static inline -void restore_snapshot_fds(mc_snapshot_t snapshot) +void restore_snapshot_fds(simgrid::mc::Snapshot* snapshot) { if (mc_mode == MC_MODE_SERVER) xbt_die("FD snapshot not implemented in client/server mode."); @@ -624,7 +624,7 @@ void restore_snapshot_fds(mc_snapshot_t snapshot) } } -void restore_snapshot(mc_snapshot_t snapshot) +void restore_snapshot(simgrid::mc::Snapshot* snapshot) { XBT_DEBUG("Restore snapshot %i", snapshot->num_state); const bool use_soft_dirty = _sg_mc_sparse_checkpoint && _sg_mc_soft_dirty; diff --git a/src/mc/mc_compare.cpp b/src/mc/mc_compare.cpp index 33371e4453..22dbfaf170 100644 --- a/src/mc/mc_compare.cpp +++ b/src/mc/mc_compare.cpp @@ -13,6 +13,7 @@ #include #include "src/internal_config.h" +#include "src/mc/mc_forward.hpp" #include "src/mc/mc_safety.h" #include "src/mc/mc_liveness.h" #include "src/mc/mc_private.h" @@ -70,8 +71,8 @@ extern "C" { static int compare_areas_with_type(ComparisonState& state, int process_index, - void* real_area1, mc_snapshot_t snapshot1, mc_mem_region_t region1, - void* real_area2, mc_snapshot_t snapshot2, mc_mem_region_t region2, + void* real_area1, simgrid::mc::Snapshot* snapshot1, mc_mem_region_t region1, + void* real_area2, simgrid::mc::Snapshot* snapshot2, mc_mem_region_t region2, simgrid::mc::Type* type, int pointer_level) { simgrid::mc::Process* process = &mc_model_checker->process(); @@ -227,8 +228,8 @@ static int compare_areas_with_type(ComparisonState& state, static int compare_global_variables(simgrid::mc::ObjectInformation* object_info, int process_index, mc_mem_region_t r1, - mc_mem_region_t r2, mc_snapshot_t snapshot1, - mc_snapshot_t snapshot2) + mc_mem_region_t r2, simgrid::mc::Snapshot* snapshot1, + simgrid::mc::Snapshot* snapshot2) { xbt_assert(r1 && r2, "Missing region."); @@ -290,8 +291,8 @@ static int compare_global_variables(simgrid::mc::ObjectInformation* object_info, } static int compare_local_variables(int process_index, - mc_snapshot_t snapshot1, - mc_snapshot_t snapshot2, + simgrid::mc::Snapshot* snapshot1, + simgrid::mc::Snapshot* snapshot2, mc_snapshot_stack_t stack1, mc_snapshot_stack_t stack2) { @@ -351,7 +352,8 @@ int snapshot_compare(void *state1, void *state2) { simgrid::mc::Process* process = &mc_model_checker->process(); - mc_snapshot_t s1, s2; + simgrid::mc::Snapshot* s1; + simgrid::mc::Snapshot* s2; int num1, num2; if (_sg_mc_liveness) { /* Liveness MC */ diff --git a/src/mc/mc_diff.cpp b/src/mc/mc_diff.cpp index 6e2bb9fadf..f0d0896d4f 100644 --- a/src/mc/mc_diff.cpp +++ b/src/mc/mc_diff.cpp @@ -288,7 +288,7 @@ void reset_heap_information() // TODO, have a robust way to find it in O(1) static inline -mc_mem_region_t MC_get_heap_region(mc_snapshot_t snapshot) +mc_mem_region_t MC_get_heap_region(simgrid::mc::Snapshot* snapshot) { size_t n = snapshot->snapshot_regions.size(); for (size_t i=0; i!=n; ++i) { @@ -299,7 +299,7 @@ mc_mem_region_t MC_get_heap_region(mc_snapshot_t snapshot) xbt_die("No heap region"); } -int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) +int mmalloc_compare_heap(simgrid::mc::Snapshot* snapshot1, simgrid::mc::Snapshot* snapshot2) { simgrid::mc::Process* process = &mc_model_checker->process(); struct s_mc_diff *state = mc_diff_info; @@ -653,8 +653,8 @@ int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2) */ static int compare_heap_area_without_type(struct s_mc_diff *state, int process_index, const void *real_area1, const void *real_area2, - mc_snapshot_t snapshot1, - mc_snapshot_t snapshot2, + simgrid::mc::Snapshot* snapshot1, + simgrid::mc::Snapshot* snapshot2, xbt_dynar_t previous, int size, int check_ignore) { @@ -742,8 +742,8 @@ static int compare_heap_area_without_type(struct s_mc_diff *state, int process_i */ static int compare_heap_area_with_type(struct s_mc_diff *state, int process_index, const void *real_area1, const void *real_area2, - mc_snapshot_t snapshot1, - mc_snapshot_t snapshot2, + simgrid::mc::Snapshot* snapshot1, + simgrid::mc::Snapshot* snapshot2, xbt_dynar_t previous, simgrid::mc::Type* type, int area_size, int check_ignore, int pointer_level) @@ -951,7 +951,7 @@ top: */ static simgrid::mc::Type* get_offset_type(void *real_base_address, simgrid::mc::Type* type, int offset, int area_size, - mc_snapshot_t snapshot, int process_index) + simgrid::mc::Snapshot* snapshot, int process_index) { // Beginning of the block, the infered variable type if the type of the block: @@ -1005,8 +1005,8 @@ static simgrid::mc::Type* get_offset_type(void *real_base_address, simgrid::mc:: * @param pointer_level * @return 0 (same), 1 (different), -1 */ -int compare_heap_area(int process_index, const void *area1, const void *area2, mc_snapshot_t snapshot1, - mc_snapshot_t snapshot2, xbt_dynar_t previous, +int compare_heap_area(int process_index, const void *area1, const void *area2, simgrid::mc::Snapshot* snapshot1, + simgrid::mc::Snapshot* snapshot2, xbt_dynar_t previous, simgrid::mc::Type* type, int pointer_level) { simgrid::mc::Process* process = &mc_model_checker->process(); diff --git a/src/mc/mc_forward.h b/src/mc/mc_forward.h deleted file mode 100644 index 40d9993b0e..0000000000 --- a/src/mc/mc_forward.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2007-2015. 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. */ - -/** \file mc_forward.h - * - * Define type names for pointers of MC objects for the C code - */ - -#ifndef SIMGRID_MC_FORWARD_H -#define SIMGRID_MC_FORWARD_H - -#ifdef __cplusplus - -// If we're in C++, we give the real definition: -#include "mc_forward.hpp" -typedef simgrid::mc::Snapshot *mc_snapshot_t; -typedef simgrid::mc::Type *mc_type_t; - -#else - -// Otherwise we use dummy opaque structs: -typedef struct _mc_snapshot_t *mc_snapshot_t; -typedef struct _s_mc_type_t *mc_type_t; - -#endif - -#endif diff --git a/src/mc/mc_private.h b/src/mc/mc_private.h index de35d2064e..964e94d316 100644 --- a/src/mc/mc_private.h +++ b/src/mc/mc_private.h @@ -38,7 +38,10 @@ #include "xbt/parmap.h" #include -#include "src/mc/mc_forward.h" +#ifdef __cplusplus +#include "src/mc/mc_forward.hpp" +#endif + #include "src/mc/mc_protocol.h" SG_BEGIN_DECL() diff --git a/src/mc/mc_safety.h b/src/mc/mc_safety.h index 931584bb40..689d93a867 100644 --- a/src/mc/mc_safety.h +++ b/src/mc/mc_safety.h @@ -31,7 +31,7 @@ extern XBT_PRIVATE simgrid::mc::ReductionMode reduction_mode; int modelcheck_safety(void); struct XBT_PRIVATE VisitedState { - mc_snapshot_t system_state; + simgrid::mc::Snapshot* system_state; size_t heap_bytes_used; int nb_processes; int num; diff --git a/src/mc/mc_snapshot.cpp b/src/mc/mc_snapshot.cpp index 12a3ef6086..49147ba42c 100644 --- a/src/mc/mc_snapshot.cpp +++ b/src/mc/mc_snapshot.cpp @@ -148,8 +148,8 @@ int MC_snapshot_region_memcmp( * @return same as memcmp * */ int MC_snapshot_memcmp( - const void* addr1, mc_snapshot_t snapshot1, - const void* addr2, mc_snapshot_t snapshot2, int process_index, size_t size) + const void* addr1, simgrid::mc::Snapshot* snapshot1, + const void* addr2, simgrid::mc::Snapshot* snapshot2, int process_index, size_t size) { mc_mem_region_t region1 = mc_get_snapshot_region(addr1, snapshot1, process_index); mc_mem_region_t region2 = mc_get_snapshot_region(addr2, snapshot2, process_index); diff --git a/src/mc/mc_snapshot.h b/src/mc/mc_snapshot.h index e73b22813f..2711b69370 100644 --- a/src/mc/mc_snapshot.h +++ b/src/mc/mc_snapshot.h @@ -129,7 +129,7 @@ typedef struct XBT_PRIVATE s_mc_snapshot_stack { } s_mc_snapshot_stack_t, *mc_snapshot_stack_t; typedef struct s_mc_global_t { - mc_snapshot_t snapshot; + simgrid::mc::Snapshot* snapshot; int prev_pair; char *prev_req; int initial_communications_pattern_done; @@ -169,7 +169,7 @@ public: // To be private extern "C" { static inline __attribute__ ((always_inline)) -mc_mem_region_t mc_get_region_hinted(void* addr, mc_snapshot_t snapshot, int process_index, mc_mem_region_t region) +mc_mem_region_t mc_get_region_hinted(void* addr, simgrid::mc::Snapshot* snapshot, int process_index, mc_mem_region_t region) { if (region->contain(simgrid::mc::remote(addr))) return region; @@ -177,7 +177,7 @@ mc_mem_region_t mc_get_region_hinted(void* addr, mc_snapshot_t snapshot, int pro return mc_get_snapshot_region(addr, snapshot, process_index); } -static const void* mc_snapshot_get_heap_end(mc_snapshot_t snapshot); +static const void* mc_snapshot_get_heap_end(simgrid::mc::Snapshot* snapshot); } @@ -186,8 +186,8 @@ static const void* mc_snapshot_get_heap_end(mc_snapshot_t snapshot); namespace simgrid { namespace mc { -XBT_PRIVATE mc_snapshot_t take_snapshot(int num_state); -XBT_PRIVATE void restore_snapshot(mc_snapshot_t); +XBT_PRIVATE simgrid::mc::Snapshot* take_snapshot(int num_state); +XBT_PRIVATE void restore_snapshot(simgrid::mc::Snapshot*); } } @@ -207,11 +207,11 @@ int MC_snapshot_region_memcmp( const void* addr1, mc_mem_region_t region1, const void* addr2, mc_mem_region_t region2, std::size_t size); XBT_PRIVATE int MC_snapshot_memcmp( - const void* addr1, mc_snapshot_t snapshot1, - const void* addr2, mc_snapshot_t snapshot2, int process_index, std::size_t size); + const void* addr1, simgrid::mc::Snapshot* snapshot1, + const void* addr2, simgrid::mc::Snapshot* snapshot2, int process_index, std::size_t size); static inline __attribute__ ((always_inline)) -const void* mc_snapshot_get_heap_end(mc_snapshot_t snapshot) +const void* mc_snapshot_get_heap_end(simgrid::mc::Snapshot* snapshot) { if(snapshot==NULL) xbt_die("snapshot is NULL"); diff --git a/src/mc/mc_state.h b/src/mc/mc_state.h index 40c9a6eb33..292d15ceb2 100644 --- a/src/mc/mc_state.h +++ b/src/mc/mc_state.h @@ -47,7 +47,7 @@ typedef struct XBT_PRIVATE mc_state { s_smx_simcall_t executed_req; /* The executed request of the state */ int req_num; /* The request number (in the case of a multi-request like waitany ) */ - mc_snapshot_t system_state; /* Snapshot of system state */ + simgrid::mc::Snapshot* system_state; /* Snapshot of system state */ int num; int in_visited_states; // comm determinism verification (xbt_dynar_t): diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 5eacc32a52..278ce88e7c 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -17,7 +17,7 @@ #include "src/mc/mc_replay.h" #include "smx_private.h" -#include "src/mc/mc_forward.h" +#include "src/mc/mc_forward.hpp" #include "xbt/ex.h" #include "mc/mc.h" #include "src/simix/smx_host_private.h" diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 05e6b825ad..f5035a21de 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -14,7 +14,7 @@ */ #include "smx_private.h" -#include "src/mc/mc_forward.h" +#include "src/mc/mc_forward.hpp" #include "xbt/ex.h" #include diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index ecaa6b8526..d7a8dc8a11 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -16,7 +16,7 @@ #include #include "smx_private.h" #if HAVE_MC -#include "src/mc/mc_forward.h" +#include "src/mc/mc_forward.hpp" #endif XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping); diff --git a/src/simix/popping_private.h b/src/simix/popping_private.h index 0d5427b7bc..71bd4ed173 100644 --- a/src/simix/popping_private.h +++ b/src/simix/popping_private.h @@ -16,7 +16,6 @@ SG_BEGIN_DECL() XBT_PUBLIC_DATA(const char*) simcall_names[]; /* Name of each simcall */ #include "popping_enum.h" /* Definition of e_smx_simcall_t, with one value per simcall */ -#include "src/mc/mc_forward.h" /* Definition of mc_snapshot_t, used by one simcall */ typedef int (*simix_match_func_t)(void *, void *, smx_synchro_t); typedef void (*simix_copy_data_func_t)(smx_synchro_t, void*, size_t); diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index 02653461a4..3bf49a5464 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -309,7 +309,7 @@ if __name__ == '__main__': fd.write('#include \n') fd.write('#include "smx_private.h"\n') fd.write('#if HAVE_MC\n') - fd.write('#include "src/mc/mc_forward.h"\n') + fd.write('#include "src/mc/mc_forward.hpp"\n') fd.write('#endif\n') fd.write('\n') fd.write('XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);\n\n') @@ -362,7 +362,7 @@ if __name__ == '__main__': # fd = header('popping_bodies.cpp') fd.write('#include "smx_private.h"\n') - fd.write('#include "src/mc/mc_forward.h"\n') + fd.write('#include "src/mc/mc_forward.hpp"\n') fd.write('#include "xbt/ex.h"\n') fd.write('#include \n') handle(fd, Simcall.body, simcalls, simcalls_dict) diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 79e7ee3d59..5047e92390 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -568,8 +568,6 @@ set(MC_SRC src/mc/Type.hpp src/mc/Variable.cpp src/mc/Variable.hpp - - src/mc/mc_forward.h src/mc/mc_forward.hpp src/mc/Process.hpp src/mc/Process.cpp -- 2.20.1