Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert last change since it did nothing beside arming the code esthetic ;)
[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 S_SPLINT_S
25 /* Dummy definition for splint since it chokes on ucontext.h */
26 typedef struct ucontext {
27    struct ucontext *uc_link;
28    sigset_t uc_sigmask;
29    int uc_stack;
30    int uc_mcontext;
31 } ucontext_t;
32 typedef int CONTEXT;
33 #endif 
34
35 #ifdef USE_PTHREADS
36 #  include <pthread.h>
37 #else
38 #  define STACK_SIZE 128*1024 /* Lower this if you want to reduce the memory consumption */
39 #endif     /* USE_PTHREADS */
40
41 typedef struct s_xbt_context {
42   s_xbt_swag_hookup_t hookup;
43 #ifdef USE_PTHREADS
44   pthread_cond_t cond;
45   pthread_mutex_t mutex;
46   pthread_t *thread;            /* the thread that execute the code   */
47 #else
48   ucontext_t uc;                /* the thread that execute the code   */
49   char stack[STACK_SIZE];
50   struct s_xbt_context *save;
51 #endif     /* USE_PTHREADS */
52   xbt_context_function_t code;          /* the scheduler fonction   */
53   int argc;
54   char **argv;
55   void_f_pvoid_t *startup_func;
56   void *startup_arg;
57   void_f_pvoid_t *cleanup_func;
58   void *cleanup_arg;
59   ex_ctx_t *exception;          /* exception */
60 } s_xbt_context_t;
61 #else
62
63 #endif              /* _XBT_CONTEXT_PRIVATE_H */