Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adapt to lastest changes in dict: Create dicts before use
[simgrid.git] / include / core.h
1 /* $Id$                     */
2
3 /* gras/core.h - Unsorted part of the GRAS public interface                 */
4
5 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2003 the OURAGAN project.                                  */
7
8 /* This program is free software; you can redistribute it and/or modify it
9    under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #ifndef GRAS_CORE_H
12 #define GRAS_CORE_H
13
14 #include <stddef.h>    /* offsetof() */
15 #include <sys/types.h>  /* size_t */
16 #include <stdarg.h>
17
18
19 /*! C++ users need love */
20 #ifndef BEGIN_DECL
21 # ifdef __cplusplus
22 #  define BEGIN_DECL extern "C" {
23 # else
24 #  define BEGIN_DECL 
25 # endif
26 #endif
27
28 /*! C++ users need love */
29 #ifndef END_DECL
30 # ifdef __cplusplus
31 #  define END_DECL }
32 # else
33 #  define END_DECL 
34 # endif
35 #endif
36 /* End of cruft for C++ */
37
38 BEGIN_DECL
39
40 /* **************************************************************************
41  * Garbage collection support
42  * **************************************************************************/
43 typedef enum { free_after_use, free_never } e_gras_free_directive_t;
44
45 /* **************************************************************************
46  * Initializing the processes
47  * **************************************************************************/
48 /**
49  * gras_process_init:
50  * 
51  * Perform the various intialisations needed by gras. Each process must run it
52  */
53 gras_error_t gras_process_init(void);
54
55 /**
56  * gras_process_finalize:
57  * 
58  * Perform the various intialisations needed by gras. Each process must run it
59  */
60 gras_error_t gras_process_finalize(void);
61
62 /****************************************************************************/
63 /* Manipulating User Data                                                   */
64 /****************************************************************************/
65 /**
66  * gras_userdata_get:
67  *
68  * Get the data associated with the current process.
69  */
70 void *gras_userdata_get(void);
71
72 /**
73  * gras_userdata_set:
74  *
75  * Set the data associated with the current process.
76  */
77 void *gras_userdata_set(void *ud);
78
79 /**
80  * gras_userdata_new:
81  *
82  * Malloc and set the data associated with the current process.
83  */
84
85 #define gras_userdata_new(type) gras_userdata_set(malloc(sizeof(type)))
86
87 /* **************************************************************************
88  * Wrappers over OS functions
89  * **************************************************************************/
90
91 /**
92  * gras_get_my_fqdn:
93  *
94  * Returns the fully-qualified name of the host machine, or NULL if the name
95  * cannot be determined.  Always returns the same value, so multiple calls
96  * cause no problems.
97  */
98 const char *
99 gras_get_my_fqdn(void);
100
101 /**
102  * gras_time:
103  * 
104  * Get the time in number of second since the Epoch.
105  * (00:00:00 UTC, January 1, 1970 in Real Life, and begining of simulation in SG)
106  */
107 double gras_time(void);
108
109 /**
110  * gras_sleep:
111  * @sec: number of seconds to sleep
112  * @usec: number of microseconds to sleep
113  * 
114  * sleeps for the given amount of seconds plus the given amount of microseconds.
115  */
116 void gras_sleep(unsigned long sec, unsigned long usec);
117
118 END_DECL
119
120 #endif /* GRAS_CORE_H */
121