From 49894e3da0a6f23f604617836e7f2afaab7e1095 Mon Sep 17 00:00:00 2001 From: mquinson Date: Fri, 11 Feb 2005 14:36:34 +0000 Subject: [PATCH] Damn code dupplication git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@980 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- testsuite/msg/messages.h | 30 ++++++++++++++++++++++++++---- testsuite/msg/msg_test.c | 2 +- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/testsuite/msg/messages.h b/testsuite/msg/messages.h index 02770d57d6..0508c142d8 100644 --- a/testsuite/msg/messages.h +++ b/testsuite/msg/messages.h @@ -5,6 +5,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. */ +/** \file messages.h + * \ingroup MSG_examples + * \brief Convenient debuging functions that should be used in combination with + * the perl-script tools/MSG_visualization/colorize.pl. +*/ + #ifndef MESSAGES_H #define MESSAGES_H @@ -13,6 +19,11 @@ #include "msg/datatypes.h" #include "xbt/error.h" +/** just like an assert. + * This function is used to ensure that a condition is true. + * If not, it prints an error message (with the virtual date and the + * PID of the #m_process_t that called it). + */ static void ASSERT(int value, const char *fmt, ...) { m_process_t self = MSG_process_self(); @@ -21,7 +32,7 @@ static void ASSERT(int value, const char *fmt, ...) if(!value) { va_start(ap, fmt); if (self) - fprintf(stderr, "[%Lg] P%d | ", MSG_getClock(), + fprintf(stderr, "[%g] P%d | ", MSG_getClock(), MSG_process_get_PID(self)); vfprintf(stderr, fmt, ap); va_end(ap); @@ -31,6 +42,10 @@ static void ASSERT(int value, const char *fmt, ...) return; } +/** Die + * Just like #ASSERT() except you already know that the condition does not hold + * true. + */ static void DIE(const char *fmt, ...) { m_process_t self = MSG_process_self(); @@ -38,7 +53,7 @@ static void DIE(const char *fmt, ...) va_start(ap, fmt); if (self) - fprintf(stderr, "[%Lg] P%d | ", MSG_getClock(), + fprintf(stderr, "[%g] P%d | ", MSG_getClock(), MSG_process_get_PID(self)); vfprintf(stderr, fmt, ap); va_end(ap); @@ -47,6 +62,10 @@ static void DIE(const char *fmt, ...) return; } +/** + * Print a one-line message with the virtual date and the PID of the #m_process_t + * that called it + */ static void PRINT_MESSAGE(const char *fmt, ...) { #ifdef VERBOSE @@ -55,7 +74,7 @@ static void PRINT_MESSAGE(const char *fmt, ...) va_start(ap, fmt); if (self) - fprintf(stderr, "[%Lg] P%d | (%s:%s) ", MSG_getClock(), + fprintf(stderr, "[%g] P%d | (%s:%s) ", MSG_getClock(), MSG_process_get_PID(self), MSG_host_self()->name, self->name); vfprintf(stderr, fmt, ap); va_end(ap); @@ -63,6 +82,9 @@ static void PRINT_MESSAGE(const char *fmt, ...) return; } +/** + * Just like #PRINT_MESSAGE() except that it prints DEBUG in front of the line. + */ static void PRINT_DEBUG_MESSAGE(const char *fmt, ...) { #ifdef VERBOSE @@ -71,7 +93,7 @@ static void PRINT_DEBUG_MESSAGE(const char *fmt, ...) va_start(ap, fmt); if (self) - fprintf(stderr, "DEBUG [%Lg] P%d | (%s) ", MSG_getClock(), + fprintf(stderr, "DEBUG [%g] P%d | (%s) ", MSG_getClock(), MSG_process_get_PID(self), MSG_host_self()->name); vfprintf(stderr, fmt, ap); va_end(ap); diff --git a/testsuite/msg/msg_test.c b/testsuite/msg/msg_test.c index 06adbb9ecf..4f192daff5 100644 --- a/testsuite/msg/msg_test.c +++ b/testsuite/msg/msg_test.c @@ -182,7 +182,7 @@ void test_all(const char *platform_file,const char *application_file) MSG_launch_application(application_file); } MSG_main(); - printf("Simulation time %Lg\n",MSG_getClock()); + printf("Simulation time %g\n",MSG_getClock()); } int main(int argc, char *argv[]) -- 2.20.1