Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't use %t in log format, but %P; revalidate the output after listener introduction
[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 CONTEXT_THREADS
25 #  include "xbt/xbt_os_thread.h"
26 #else
27 #  include <ucontext.h>
28 #  define STACK_SIZE 128*1024 /* Lower this if you want to reduce the memory consumption */
29 #endif     /* not CONTEXT_THREADS */
30
31
32 typedef struct s_xbt_context {
33         s_xbt_swag_hookup_t hookup;
34         char *name;
35
36         /* Declaration of the thread running the process */
37 #ifdef JAVA_SIMGRID /* come first because other ones are defined too */
38         jobject jprocess;  /* the java process instance                 */
39         JNIEnv* jenv;      /* jni interface pointer for this thread     */
40         ex_ctx_t *exception; /* exception container -- only in ucontext&java, os_threads deals with it for us otherwise */
41 #else   
42 # ifdef CONTEXT_THREADS
43         xbt_os_thread_t thread; /* a plain dumb thread (portable to posix or windows) */
44 # else
45         ucontext_t uc;       /* the thread that execute the code */
46         char stack[STACK_SIZE];
47         struct s_xbt_context *save;
48         ex_ctx_t *exception; /* exception container -- only in ucontext&java, os_threads deals with it for us otherwise */
49 # endif /* CONTEXT_THREADS */
50 #endif /* JAVA_SIMGRID */
51    
52         /* What we need to synchronize the process */        
53 #if defined(JAVA_SIMGRID) || defined(CONTEXT_THREADS)
54         xbt_os_cond_t cond;             /* the condition used to synchronize the process        */
55         xbt_os_mutex_t mutex;           /* the mutex used to synchronize the process            */
56 #endif
57
58         /* What to run */
59         xbt_main_func_t code;   /* the scheduled fonction           */
60         int argc;
61         char **argv;
62    
63         /* Init/exit functions */   
64         void_f_pvoid_t *startup_func;
65         void *startup_arg;
66         void_f_pvoid_t *cleanup_func;
67         void *cleanup_arg;
68
69         int iwannadie;                  /* Set to true by the context when it wants to commit suicide */
70
71    
72 } s_xbt_context_t;
73
74
75 #endif  /* !_XBT_CONTEXT_PRIVATE_H */