X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e486bcb39da0b905b7e7b6151c728e7b366be717..92bb2be06658bec5abe69a30642ed469e47708fd:/examples/msg/messages.h diff --git a/examples/msg/messages.h b/examples/msg/messages.h new file mode 100644 index 0000000000..02770d57d6 --- /dev/null +++ b/examples/msg/messages.h @@ -0,0 +1,82 @@ +/* $Id$ */ + +/* Copyright (c) 2002,2003,2004 Arnaud Legrand. 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. */ + +#ifndef MESSAGES_H +#define MESSAGES_H + +#include +#include +#include "msg/datatypes.h" +#include "xbt/error.h" + +static void ASSERT(int value, const char *fmt, ...) +{ + m_process_t self = MSG_process_self(); + va_list ap; + + if(!value) { + va_start(ap, fmt); + if (self) + fprintf(stderr, "[%Lg] P%d | ", MSG_getClock(), + MSG_process_get_PID(self)); + vfprintf(stderr, fmt, ap); + va_end(ap); + + xbt_abort(); + } + return; +} + +static void DIE(const char *fmt, ...) +{ + m_process_t self = MSG_process_self(); + va_list ap; + + va_start(ap, fmt); + if (self) + fprintf(stderr, "[%Lg] P%d | ", MSG_getClock(), + MSG_process_get_PID(self)); + vfprintf(stderr, fmt, ap); + va_end(ap); + + xbt_abort(); + return; +} + +static void PRINT_MESSAGE(const char *fmt, ...) +{ +#ifdef VERBOSE + m_process_t self = MSG_process_self(); + va_list ap; + + va_start(ap, fmt); + if (self) + fprintf(stderr, "[%Lg] P%d | (%s:%s) ", MSG_getClock(), + MSG_process_get_PID(self), MSG_host_self()->name, self->name); + vfprintf(stderr, fmt, ap); + va_end(ap); +#endif + return; +} + +static void PRINT_DEBUG_MESSAGE(const char *fmt, ...) +{ +#ifdef VERBOSE + m_process_t self = MSG_process_self(); + va_list ap; + + va_start(ap, fmt); + if (self) + fprintf(stderr, "DEBUG [%Lg] P%d | (%s) ", MSG_getClock(), + MSG_process_get_PID(self), MSG_host_self()->name); + vfprintf(stderr, fmt, ap); + va_end(ap); +#endif + return; +} + +#endif