Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adapt header to last change in code
[simgrid.git] / include / xbt / sysdep.h
1 /* $Id$ */
2
3 /* gras/sysdep.h -- all system dependency                                   */
4 /*  no system header should be loaded out of this file so that we have only */
5 /*  one file to check when porting to another OS                            */
6
7 /* Authors: Martin Quinson                                                  */
8 /* Copyright (C) 2004 the OURAGAN project.                                  */
9
10 /* This program is free software; you can redistribute it and/or modify it
11    under the terms of the license (GNU LGPL) which comes with this package. */
12
13
14 #ifndef _GRAS_SYSDEP_H
15 #define _GRAS_SYSDEP_H
16
17 #include <string.h> /* Included directly for speed */
18
19 #include <time.h> /* FIXME: remove */
20 #include <unistd.h> /* FIXME: remove */
21
22 #ifdef  __cplusplus
23 extern "C" 
24 #endif
25
26 void* gras_malloc  (long int bytes);
27 void* gras_malloc0 (long int bytes);
28 void* gras_realloc (void  *memory, long int bytes);
29 void  gras_free    (void  *memory);
30
31 #define gras_new(type, count)  ((type*)gras_malloc (sizeof (type) * (count)))
32 #define gras_new0(type, count) ((type*)gras_malloc0 (sizeof (type) * (count)))
33
34 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
35 #define _GRAS_GNUC_PRINTF( format_idx, arg_idx )    \
36            __attribute__((__format__ (__printf__, format_idx, arg_idx)))
37 #define _GRAS_GNUC_SCANF( format_idx, arg_idx )     \
38                __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
39 #define _GRAS_GNUC_FORMAT( arg_idx )                \
40                    __attribute__((__format_arg__ (arg_idx)))
41 #define _GRAS_GNUC_NORETURN                         \
42      __attribute__((__noreturn__))
43 #else   /* !__GNUC__ */
44 #define _GRAS_GNUC_PRINTF( format_idx, arg_idx )
45 #define _GRAS_GNUC_SCANF( format_idx, arg_idx )
46 #define _GRAS_GNUC_FORMAT( arg_idx )
47 #define _GRAS_GNUC_NORETURN
48 #endif  /* !__GNUC__ */
49
50 void gras_abort(void) _GRAS_GNUC_NORETURN;
51
52 /* FIXME: This is a very good candidate to rewrite (along with a proper string stuff) 
53    but I'm too lazy right now, so copy the definition */
54 long int strtol(const char *nptr, char **endptr, int base);
55 double strtod(const char *nptr, char **endptr);
56 int atoi(const char *nptr);
57
58
59    
60 #ifdef  __cplusplus
61 }
62 #endif
63
64 #endif /* _GRAS_SYSDEP_H */