Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make the implementation more robust: don't die if something to destroy is already...
[simgrid.git] / src / xbt / context_private.h
1 /*      $Id$     */
2
3 /* Copyright (c) 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 _XBT_CONTEXT_PRIVATE_H
9 #define _XBT_CONTEXT_PRIVATE_H
10
11
12 #include "xbt/sysdep.h"
13 #include "xbt/swag.h"
14 #include "xbt/dynar.h" /* void_f_pvoid_t */
15 #include "portable.h"  /* loads context system definitions */
16
17 #if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32) && !defined(__TOS_WIN__)
18 #include "ucontext_stack.h"  /* loads context system definitions */
19 #endif
20
21 #include "xbt/context.h"
22 #include "xbt/ex.h"
23
24 #ifdef USE_PTHREADS
25 #  include <pthread.h>
26 #elif defined(USE_WIN_THREADS)
27 #  include "win_thread.h"
28 #else
29 #  define STACK_SIZE 128*1024 /* Lower this if you want to reduce the memory consumption */
30 #endif     /* USE_PTHREADS */
31
32
33 typedef struct s_xbt_context 
34 {
35         s_xbt_swag_hookup_t hookup;
36         #ifdef USE_PTHREADS
37         pthread_cond_t cond;
38         pthread_mutex_t mutex;
39         pthread_t *thread;                              /* the thread that execute the code     */
40         #elif defined(USE_WIN_THREADS)
41         win_thread_cond_t cond;
42         win_thread_mutex_t mutex;
43         win_thread_t thread;                    /* the thread that execute the code     */ 
44         #else
45         ucontext_t uc;                                  /* the thread that execute the code     */
46         char stack[STACK_SIZE];
47         struct s_xbt_context *save;
48         #endif /* USE_PTHREADS || USE_WIN_THREADS */
49         xbt_context_function_t code;    /* the scheduler fonction                       */
50         int argc;
51         char **argv;
52         void_f_pvoid_t *startup_func;
53         void *startup_arg;
54         void_f_pvoid_t *cleanup_func;
55         void *cleanup_arg;
56         ex_ctx_t *exception;                    /* exception                                            */
57 } s_xbt_context_t;
58
59
60 #endif  /* !_XBT_CONTEXT_PRIVATE_H */