Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fit libex into SimGrid (with an axe, I admit)
[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 #include "ucontext_stack.h"  /* loads context system definitions */
17
18 #include "xbt/context.h"
19
20 #ifdef S_SPLINT_S
21 /* Dummy definition for splint since it chokes on ucontext.h */
22 typedef struct ucontext {
23    struct ucontext *uc_link;
24    sigset_t uc_sigmask;
25    int uc_stack;
26    int uc_mcontext;
27 } ucontext_t;
28 typedef int CONTEXT;
29 #endif 
30
31 #ifdef USE_PTHREADS
32 #  include <pthread.h>
33 #else
34 #  define STACK_SIZE 524288
35 #endif     /* USE_PTHREADS */
36
37 typedef struct s_xbt_context {
38   s_xbt_swag_hookup_t hookup;
39 #ifdef USE_PTHREADS
40   pthread_cond_t cond;
41   pthread_mutex_t mutex;
42   pthread_t *thread;            /* the thread that execute the code   */
43 #else
44   ucontext_t uc;                /* the thread that execute the code   */
45   char stack[STACK_SIZE];
46   struct s_xbt_context *save;
47 #endif     /* USE_PTHREADS */
48   xbt_context_function_t code;          /* the scheduler fonction   */
49   int argc;
50   char **argv;
51   void_f_pvoid_t *startup_func;
52   void *startup_arg;
53   void_f_pvoid_t *cleanup_func;
54   void *cleanup_arg;
55 } s_xbt_context_t;
56 #else
57
58 #endif              /* _XBT_CONTEXT_PRIVATE_H */