X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/234b2f4e892e942c28fa9c8bc4f57af1214b1424..3297da9f47ce18371941b2b48a2f4018b4793ced:/include/xbt/ex.h diff --git a/include/xbt/ex.h b/include/xbt/ex.h index f8751366f7..ed4056626b 100644 --- a/include/xbt/ex.h +++ b/include/xbt/ex.h @@ -1,5 +1,4 @@ -/* Copyright (c) 2005-2018. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2005-2018. 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. */ @@ -9,10 +8,10 @@ #include -#include "xbt/base.h" -#include "xbt/sysdep.h" -#include "xbt/misc.h" -#include "xbt/virtu.h" +#include +#include +#include +#include /** @addtogroup XBT_ex_c * @brief Exceptions support (C) @@ -51,13 +50,13 @@ SG_BEGIN_DECL() /** Get the name of a category * @ingroup XBT_ex_c */ -XBT_PUBLIC(const char *) xbt_ex_catname(xbt_errcat_t cat); +XBT_PUBLIC const char* xbt_ex_catname(xbt_errcat_t cat); typedef struct xbt_ex xbt_ex_t; /** Helper function used to throw exceptions in C */ -XBT_ATTRIB_NORETURN XBT_PUBLIC(void) - _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func); +XBT_ATTRIB_NORETURN XBT_PUBLIC void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, + int line, const char* func); /** Builds and throws an exception * @ingroup XBT_ex_c @@ -71,23 +70,17 @@ XBT_ATTRIB_NORETURN XBT_PUBLIC(void) */ #define THROWF(c, v, ...) _xbt_throw(bprintf(__VA_ARGS__), (xbt_errcat_t) c, v, __FILE__, __LINE__, __func__) -/** Throw an exception because someting impossible happened +XBT_ATTRIB_NORETURN void xbt_throw_impossible(const char* file, int line, const char* func); +/** Throw an exception because something impossible happened * @ingroup XBT_ex_c */ -#define THROW_IMPOSSIBLE \ - THROWF(unknown_error, 0, "The Impossible Did Happen (yet again)") +#define THROW_IMPOSSIBLE xbt_throw_impossible(__FILE__, __LINE__, __func__) -/** Throw an exception because someting unimplemented stuff has been attempted +/** Throw an exception because something unimplemented stuff has been attempted * @ingroup XBT_ex_c */ -#define THROW_UNIMPLEMENTED \ - THROWF(unknown_error, 0, "Function %s unimplemented",__func__) - -/** Throw an exception because some dead code was reached - * @ingroup XBT_ex_c - */ -#define THROW_DEADCODE \ - THROWF(unknown_error, 0, "Function %s was supposed to be DEADCODE, but it's not",__func__) +XBT_ATTRIB_NORETURN void xbt_throw_unimplemented(const char* file, int line, const char* func); +#define THROW_UNIMPLEMENTED xbt_throw_unimplemented(__FILE__, __LINE__, __func__) /** Die because something impossible happened * @ingroup XBT_ex_c @@ -95,7 +88,7 @@ XBT_ATTRIB_NORETURN XBT_PUBLIC(void) #define DIE_IMPOSSIBLE xbt_die("The Impossible Did Happen (yet again)") /** Display an exception */ -XBT_PUBLIC(void) xbt_ex_display(xbt_ex_t * e); +XBT_PUBLIC void xbt_ex_display(xbt_ex_t* e); SG_END_DECL()