Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Those files already are in examples.
[simgrid.git] / testsuite / msg / messages.h
1 /*      $Id$     */
2
3 /* Copyright (c) 2002,2003,2004 Arnaud Legrand. All rights reserved.        */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #ifndef MESSAGES_H
9 #define MESSAGES_H
10
11 #include <stdio.h>
12 #include <stdarg.h>
13 #include "msg/datatypes.h"
14 #include "xbt/error.h"
15
16 static void ASSERT(int value, const char *fmt, ...)
17 {
18   m_process_t self = MSG_process_self();
19   va_list ap;
20
21   if(!value) {
22     va_start(ap, fmt);
23     if (self)
24       fprintf(stderr, "[%Lg] P%d | ", MSG_getClock(),
25               MSG_process_get_PID(self));
26     vfprintf(stderr, fmt, ap);
27     va_end(ap);
28     
29     xbt_abort();
30   }
31   return;
32 }
33
34 static void DIE(const char *fmt, ...)
35 {
36   m_process_t self = MSG_process_self();
37   va_list ap;
38
39   va_start(ap, fmt);
40   if (self)
41     fprintf(stderr, "[%Lg] P%d | ", MSG_getClock(),
42             MSG_process_get_PID(self));
43   vfprintf(stderr, fmt, ap);
44   va_end(ap);
45
46   xbt_abort();
47   return;
48 }
49
50 static void PRINT_MESSAGE(const char *fmt, ...)
51 {
52 #ifdef VERBOSE
53   m_process_t self = MSG_process_self();
54   va_list ap;
55
56   va_start(ap, fmt);
57   if (self)
58     fprintf(stderr, "[%Lg] P%d | (%s:%s) ", MSG_getClock(),
59             MSG_process_get_PID(self), MSG_host_self()->name, self->name);
60   vfprintf(stderr, fmt, ap);
61   va_end(ap);
62 #endif
63   return;
64 }
65
66 static void PRINT_DEBUG_MESSAGE(const char *fmt, ...)
67 {
68 #ifdef VERBOSE
69   m_process_t self = MSG_process_self();
70   va_list ap;
71
72   va_start(ap, fmt);
73   if (self)
74     fprintf(stderr, "DEBUG [%Lg] P%d | (%s) ", MSG_getClock(),
75             MSG_process_get_PID(self), MSG_host_self()->name);
76   vfprintf(stderr, fmt, ap);
77   va_end(ap);
78 #endif
79   return;
80 }
81
82 #endif