From: Gabriel Corona Date: Mon, 4 Jul 2016 14:55:57 +0000 (+0200) Subject: Avoid depending on C++11 stuff when including C/SMPI headers X-Git-Tag: v3_14~811 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1555ef43eee251e5892a2f7fd49bc96e99d68fef Avoid depending on C++11 stuff when including C/SMPI headers The user might compile C++ without C++11 and would not be able to compile the code even if he would be able to compile it in C. --- diff --git a/examples/simdag/test/sd_test.cpp b/examples/simdag/test/sd_test.cpp index f4eaf759d6..a73be5f92e 100644 --- a/examples/simdag/test/sd_test.cpp +++ b/examples/simdag/test/sd_test.cpp @@ -6,6 +6,7 @@ #include "simgrid/simdag.h" #include "xbt/ex.h" +#include #include "xbt/log.h" XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test, "Logging specific to this SimDag example"); diff --git a/include/xbt/ex.h b/include/xbt/ex.h index ce91604eeb..8fbd00d8ae 100644 --- a/include/xbt/ex.h +++ b/include/xbt/ex.h @@ -45,11 +45,6 @@ #include -#ifdef __cplusplus -#include -#include -#endif - #include "xbt/base.h" #include "xbt/sysdep.h" #include "xbt/misc.h" @@ -97,23 +92,6 @@ typedef enum { vm_error /**< vm error */ } xbt_errcat_t; -#ifdef __cplusplus -XBT_PUBLIC_CLASS xbt_ex : - public std::runtime_error, - public simgrid::xbt::WithContextException { -public: - xbt_ex() : std::runtime_error("") {} - xbt_ex(const char* message) : std::runtime_error(message) {} - ~xbt_ex() override; - - xbt_errcat_t category; /**< category like HTTP (what went wrong) */ - int value; /**< like errno (why did it went wrong) */ - const char *file; /**< Thrown point */ - int line; /**< Thrown point */ - const char *func; /**< Thrown point */ -}; -#endif - SG_BEGIN_DECL() XBT_PUBLIC(const char *) xbt_ex_catname(xbt_errcat_t cat); diff --git a/include/xbt/ex.hpp b/include/xbt/ex.hpp new file mode 100644 index 0000000000..1afc1bba74 --- /dev/null +++ b/include/xbt/ex.hpp @@ -0,0 +1,66 @@ +/* Copyright (c) 2005-2015. The SimGrid Team. + * All rights reserved. */ + +/* Copyright (c) 2002-2004 Ralf S. Engelschall */ +/* Copyright (c) 2002-2004 The OSSP Project */ +/* Copyright (c) 2002-2004 Cable & Wireless */ +/* All rights reserved. */ + +/* This code is inspirated from the OSSP version (as retrieved back in 2004)*/ +/* It was heavily modified to fit the SimGrid framework. */ + +/* The OSSP version has the following copyright notice: +** OSSP ex - Exception Handling +** Copyright (c) 2002-2004 Ralf S. Engelschall +** Copyright (c) 2002-2004 The OSSP Project +** Copyright (c) 2002-2004 Cable & Wireless +** +** This file is part of OSSP ex, an exception handling library +** which can be found at http://www.ossp.org/pkg/lib/ex/. +** +** Permission to use, copy, modify, and distribute this software for +** any purpose with or without fee is hereby granted, provided that +** the above copyright notice and this permission notice appear in all +** copies. +** +** THIS SOFTWARE IS PROVIDED `AS IS'' AND ANY EXPRESSED OR IMPLIED +** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR +** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +** SUCH DAMAGE. + */ + +/* The extensions made for the SimGrid project can either be distributed */ +/* under the same license, or under the LGPL v2.1 */ + +#ifndef SIMGRID_XBT_EX_HPP +#define SIMGRID_XBT_EX_HPP + +#include +#include + +#include + +struct XBT_PUBLIC() xbt_ex : + public std::runtime_error, + public simgrid::xbt::WithContextException { +public: + xbt_ex() : std::runtime_error("") {} + xbt_ex(const char* message) : std::runtime_error(message) {} + ~xbt_ex() override; + + xbt_errcat_t category; /**< category like HTTP (what went wrong) */ + int value; /**< like errno (why did it went wrong) */ + const char *file; /**< Thrown point */ + int line; /**< Thrown point */ + const char *func; /**< Thrown point */ +}; + +#endif diff --git a/src/bindings/java/JavaContext.cpp b/src/bindings/java/JavaContext.cpp index 19f760108e..2f63009980 100644 --- a/src/bindings/java/JavaContext.cpp +++ b/src/bindings/java/JavaContext.cpp @@ -12,10 +12,12 @@ #include #include #include +#include #include "JavaContext.hpp" #include "jxbt_utilities.h" #include "xbt/dynar.h" #include "../../simix/smx_private.h" + extern JavaVM *__java_vm; XBT_LOG_NEW_DEFAULT_CATEGORY(jmsg, "MSG for Java(TM)"); diff --git a/src/bindings/java/jmsg_process.cpp b/src/bindings/java/jmsg_process.cpp index e9a59f6451..c6d0e7fda1 100644 --- a/src/bindings/java/jmsg_process.cpp +++ b/src/bindings/java/jmsg_process.cpp @@ -6,6 +6,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 + #include "jmsg_process.h" #include "jmsg.h" diff --git a/src/bindings/java/jmsg_synchro.cpp b/src/bindings/java/jmsg_synchro.cpp index 0ae09a7066..7cbac4cb7c 100644 --- a/src/bindings/java/jmsg_synchro.cpp +++ b/src/bindings/java/jmsg_synchro.cpp @@ -6,6 +6,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 + #include "jmsg.h" #include "xbt/synchro_core.h" #include "jmsg_synchro.h" diff --git a/src/bindings/java/jmsg_vm.cpp b/src/bindings/java/jmsg_vm.cpp index 8ce32c8c01..063819d0af 100644 --- a/src/bindings/java/jmsg_vm.cpp +++ b/src/bindings/java/jmsg_vm.cpp @@ -6,6 +6,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 + #include "jmsg.h" #include "jmsg_vm.h" #include "jmsg_host.h" diff --git a/src/instr/instr_paje_values.cpp b/src/instr/instr_paje_values.cpp index ee6c353400..7d69e51f7b 100644 --- a/src/instr/instr_paje_values.cpp +++ b/src/instr/instr_paje_values.cpp @@ -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 + #include "src/instr/instr_private.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)"); diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index c9cd6f41a2..d3b5016501 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -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 + #include "src/simix/smx_private.h" /* MSG_task_listen looks inside the rdv directly. Not clean. */ #include "msg_private.h" #include "mc/mc.h" diff --git a/src/msg/msg_mailbox.cpp b/src/msg/msg_mailbox.cpp index 06413a6342..470b4c67de 100644 --- a/src/msg/msg_mailbox.cpp +++ b/src/msg/msg_mailbox.cpp @@ -6,6 +6,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 + #include "simgrid/msg.h" #include "msg_private.h" diff --git a/src/msg/msg_synchro.cpp b/src/msg/msg_synchro.cpp index fa6cad5cea..ff5d328659 100644 --- a/src/msg/msg_synchro.cpp +++ b/src/msg/msg_synchro.cpp @@ -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 + #include "msg_private.h" #include "xbt/sysdep.h" #include "xbt/synchro_core.h" diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 351a03c86d..88364918a3 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -9,6 +9,8 @@ * 2. use parallel tasks to simulate CPU overhead and remove the experimental code generating micro computation tasks */ +#include + #include "msg_private.h" #include "xbt/sysdep.h" #include "xbt/log.h" diff --git a/src/s4u/s4u_conditionVariable.cpp b/src/s4u/s4u_conditionVariable.cpp index 52b5b9089a..ae293522bb 100644 --- a/src/s4u/s4u_conditionVariable.cpp +++ b/src/s4u/s4u_conditionVariable.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include "simgrid/s4u/conditionVariable.hpp" diff --git a/src/simix/smx_deployment.cpp b/src/simix/smx_deployment.cpp index db1becc063..b7bd180750 100644 --- a/src/simix/smx_deployment.cpp +++ b/src/simix/smx_deployment.cpp @@ -8,6 +8,7 @@ #include #include "smx_private.h" +#include #include "xbt/sysdep.h" #include "xbt/log.h" #include "xbt/dict.h" diff --git a/src/simix/smx_environment.cpp b/src/simix/smx_environment.cpp index 372f25520a..eb362756b0 100644 --- a/src/simix/smx_environment.cpp +++ b/src/simix/smx_environment.cpp @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "smx_private.h" +#include #include "xbt/sysdep.h" #include "xbt/log.h" #include "xbt/xbt_os_time.h" diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 12aaf1b358..4449d497cc 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "smx_private.h" +#include #include "xbt/sysdep.h" #include "mc/mc.h" #include "src/mc/mc_replay.h" diff --git a/src/simix/smx_io.cpp b/src/simix/smx_io.cpp index c43a07f7e4..1d737c3dc7 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -6,6 +6,7 @@ #include "src/surf/surf_interface.hpp" #include "smx_private.h" +#include #include "xbt/sysdep.h" #include "xbt/log.h" #include "xbt/dict.h" diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 9274071348..c2f5b841ac 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -5,6 +5,8 @@ #include +#include + #include "src/surf/surf_interface.hpp" #include "src/simix/smx_private.h" #include "xbt/log.h" diff --git a/src/simix/smx_process.cpp b/src/simix/smx_process.cpp index bb91a10762..2ee77d7a0d 100644 --- a/src/simix/smx_process.cpp +++ b/src/simix/smx_process.cpp @@ -10,6 +10,7 @@ #include "src/surf/surf_interface.hpp" #include "smx_private.h" +#include #include "xbt/sysdep.h" #include "xbt/log.h" #include "xbt/dict.h" diff --git a/src/simix/smx_synchro.cpp b/src/simix/smx_synchro.cpp index c8ec7fe32c..305fc32c0f 100644 --- a/src/simix/smx_synchro.cpp +++ b/src/simix/smx_synchro.cpp @@ -7,7 +7,8 @@ #include "src/surf/surf_interface.hpp" #include "smx_private.h" -#include "xbt/log.h" +#include +#include #include "src/simix/SynchroRaw.hpp" diff --git a/src/smpi/smpi_bench.cpp b/src/smpi/smpi_bench.cpp index 3128889670..1b887eb1ee 100644 --- a/src/smpi/smpi_bench.cpp +++ b/src/smpi/smpi_bench.cpp @@ -12,6 +12,7 @@ #include "src/internal_config.h" #include "private.h" #include "private.hpp" +#include #include "xbt/dict.h" #include "xbt/sysdep.h" #include "xbt/ex.h" diff --git a/src/smpi/smpi_comm.cpp b/src/smpi/smpi_comm.cpp index 6d3f9a9a54..ab6fa84096 100644 --- a/src/smpi/smpi_comm.cpp +++ b/src/smpi/smpi_comm.cpp @@ -7,6 +7,7 @@ #include #include "private.h" +#include #include "xbt/dict.h" #include "smpi_mpi_dt_private.h" #include "limits.h" diff --git a/src/smpi/smpi_mpi_dt.cpp b/src/smpi/smpi_mpi_dt.cpp index 74edd06575..43af712336 100644 --- a/src/smpi/smpi_mpi_dt.cpp +++ b/src/smpi/smpi_mpi_dt.cpp @@ -13,6 +13,7 @@ #include "smpi_mpi_dt_private.h" #include "mc/mc.h" #include "xbt/replay.h" +#include #include "simgrid/modelchecker.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi_dt, smpi, "Logging specific to SMPI (datatype)"); diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index cf6d2f1a4a..eb4e4909e9 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -5,6 +5,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 + #include "private.h" #include "smpi_mpi_dt_private.h" diff --git a/src/xbt/config.cpp b/src/xbt/config.cpp index b2210e3923..6041903496 100644 --- a/src/xbt/config.cpp +++ b/src/xbt/config.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include "xbt/misc.h" @@ -822,6 +823,7 @@ int xbt_cfg_get_boolean(const char *key) #include "xbt.h" #include "xbt/ex.h" +#include #include diff --git a/src/xbt/cunit.cpp b/src/xbt/cunit.cpp index 1cfd7f8449..4ca449fb6f 100644 --- a/src/xbt/cunit.cpp +++ b/src/xbt/cunit.cpp @@ -12,6 +12,7 @@ #include "src/internal_config.h" #include +#include #include "xbt/sysdep.h" /* bvprintf */ #include "xbt/cunit.h" #include "xbt/dynar.h" diff --git a/src/xbt/dict.cpp b/src/xbt/dict.cpp index 1eb3cb618f..9035e7ad76 100644 --- a/src/xbt/dict.cpp +++ b/src/xbt/dict.cpp @@ -6,10 +6,13 @@ /* 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 #include + #include "xbt/dict.h" #include "xbt/ex.h" +#include #include "xbt/log.h" #include "xbt/mallocator.h" #include "src/xbt_modinter.h" @@ -574,6 +577,7 @@ void xbt_dict_postexit(void) #include #include "xbt.h" #include "xbt/ex.h" +#include #include "src/internal_config.h" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_dict); diff --git a/src/xbt/dynar.cpp b/src/xbt/dynar.cpp index 35ca11ac1b..dbd8961101 100644 --- a/src/xbt/dynar.cpp +++ b/src/xbt/dynar.cpp @@ -10,6 +10,7 @@ #include "xbt/sysdep.h" #include "xbt/log.h" #include "xbt/ex.h" +#include #include "xbt/dynar.h" #include diff --git a/src/xbt/ex.cpp b/src/xbt/ex.cpp index 2ba06986dd..0c11397a21 100644 --- a/src/xbt/ex.cpp +++ b/src/xbt/ex.cpp @@ -48,6 +48,7 @@ #include #include "src/internal_config.h" /* execinfo when available */ #include "xbt/ex.h" +#include #include "xbt/log.h" #include "xbt/log.hpp" #include "xbt/backtrace.h" @@ -146,6 +147,7 @@ const char *xbt_ex_catname(xbt_errcat_t cat) #ifdef SIMGRID_TEST #include #include "xbt/ex.h" +#include XBT_TEST_SUITE("xbt_ex", "Exception Handling"); diff --git a/src/xbt/xbt_replay.cpp b/src/xbt/xbt_replay.cpp index 705cd0fce0..2d1a2cefd5 100644 --- a/src/xbt/xbt_replay.cpp +++ b/src/xbt/xbt_replay.cpp @@ -4,6 +4,7 @@ /* 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 #include "src/internal_config.h" #include "xbt/sysdep.h" #include "xbt/log.h" diff --git a/src/xbt/xbt_str.cpp b/src/xbt/xbt_str.cpp index fb38748d24..8a956b797d 100644 --- a/src/xbt/xbt_str.cpp +++ b/src/xbt/xbt_str.cpp @@ -6,6 +6,7 @@ /* 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 #include "src/internal_config.h" #include "xbt/misc.h" #include "xbt/sysdep.h" @@ -516,6 +517,7 @@ double xbt_str_parse_double(const char* str, const char* error_msg) } #ifdef SIMGRID_TEST +#include #include "xbt/str.h" XBT_TEST_SUITE("xbt_str", "String Handling"); diff --git a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp index e06412a148..c0df99999f 100644 --- a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp +++ b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp @@ -4,6 +4,7 @@ /* 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 #include "simgrid/msg.h" XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); diff --git a/teshsuite/xbt/mmalloc/mmalloc_test.cpp b/teshsuite/xbt/mmalloc/mmalloc_test.cpp index c5706b6fd5..43edad418d 100644 --- a/teshsuite/xbt/mmalloc/mmalloc_test.cpp +++ b/teshsuite/xbt/mmalloc/mmalloc_test.cpp @@ -14,6 +14,8 @@ #include #include +#include + XBT_LOG_NEW_DEFAULT_CATEGORY(test,"this test"); #define BUFFSIZE 204800 diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index e8a4abd547..1e6ac4f7e0 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -676,6 +676,7 @@ set(headers_to_install include/xbt/dynar.h include/xbt/dynar.hpp include/xbt/ex.h + include/xbt/ex.hpp include/xbt/exception.hpp include/xbt/backtrace.h include/xbt/backtrace.hpp