Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ef4ae2e40999f6f19803d5023c77c3e9d50ffd7c
[simgrid.git] / include / xbt / misc.h
1 /* $Id$ */
2
3 /* xbt.h - Public interface to the xbt (gras's toolbox)                     */
4
5 /* Copyright (c) 2004 Martin Quinson.                                       */
6 /* Copyright (c) 2004 Arnaud Legrand.                                       */
7 /* All rights reserved.                                                     */
8
9 /* This program is free software; you can redistribute it and/or modify it
10  * under the terms of the license (GNU LGPL) which comes with this package. */
11
12 #ifndef XBT_MISC_H
13 #define XBT_MISC_H
14
15 /* Attributes are only in recent versions of GCC */
16 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
17 # define _XBT_GNUC_PRINTF( format_idx, arg_idx )    \
18            __attribute__((__format__ (__printf__, format_idx, arg_idx)))
19 # define _XBT_GNUC_SCANF( format_idx, arg_idx )     \
20                __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
21 # define _XBT_GNUC_FORMAT( arg_idx )                \
22                    __attribute__((__format_arg__ (arg_idx)))
23 # define _XBT_GNUC_NORETURN __attribute__((__noreturn__))
24 # define _XBT_GNUC_UNUSED  __attribute__((unused))
25
26 #else   /* !__GNUC__ */
27 # define _XBT_GNUC_PRINTF( format_idx, arg_idx )
28 # define _XBT_GNUC_SCANF( format_idx, arg_idx )
29 # define _XBT_GNUC_FORMAT( arg_idx )
30 # define _XBT_GNUC_NORETURN
31 # define _XBT_GNUC_UNUSED
32
33 #endif  /* !__GNUC__ */
34
35 /* inline and __FUNCTION__ are only in GCC when -ansi is off */
36
37 #if defined(__GNUC__) && ! defined(__STRICT_ANSI__)
38 # define _XBT_FUNCTION __FUNCTION__
39 # define _XBT_INLINE inline
40 #elif (defined(__STDC__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
41 # define _XBT_FUNC__ __func__      /* ISO-C99 compliant */
42 # define _XBT_INLINE inline
43 #else
44 # define _XBT_FUNCTION "function"
45 # define _XBT_INLINE 
46 #endif
47
48
49
50 #ifndef max
51 #  define max(a, b) (((a) > (b))?(a):(b))
52 #endif
53 #ifndef min
54 #  define min(a, b) (((a) < (b))?(a):(b))
55 #endif
56
57 #define TRUE  1
58 #define FALSE 0
59
60 #define XBT_MAX_CHANNEL 10 /* FIXME: killme */
61 /*! C++ users need love */
62 #ifndef SG_BEGIN_DECL
63 # ifdef __cplusplus
64 #  define SG_BEGIN_DECL() extern "C" {
65 # else
66 #  define SG_BEGIN_DECL() 
67 # endif
68 #endif
69
70 /*! C++ users need love */
71 #ifndef SG_END_DECL
72 # ifdef __cplusplus
73 #  define SG_END_DECL() }
74 # else
75 #  define SG_END_DECL() 
76 # endif
77 #endif
78 /* End of cruft for C++ */
79
80 SG_BEGIN_DECL()
81
82 const char *xbt_procname(void);
83
84 #define XBT_BACKTRACE_SIZE 10 /* FIXME: better place? Do document */
85    
86 SG_END_DECL()
87
88 #endif /* XBT_MISC_H */