/* a fast and simple context switching library */
-/* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */
+/* Copyright (c) 2004 Arnaud Legrand. */
+/* Copyright (c) 2004 Martin Quinson. */
+/* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "portable.h"
#include "context_private.h"
#include "xbt/error.h"
#include "xbt/dynar.h"
#include "gras_config.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(context, xbt, "Context");
-
-/************************ GNU LIBC CONTEXTS **************************/
-#if USE_CONTEXT==1
+#ifndef HAVE_UCONTEXT_H
+/* don't want to play with conditional compilation in automake tonight, sorry.
+ include directly the c file from here when needed. */
+# include "context_win32.c"
+#endif
static context_t current_context = NULL;
static xbt_dynar_t context_to_destroy = NULL;
return;
}
-#else
+
/****************************** PTHREADS ***************************/
-/* #if HAVE_LIBPTHREAD==1 */
+
+/* FIXME: this is dead code as we don't really need it.
+ If you have pthreads, you have contexts (which are better) */
+
+#if 0
#ifdef HAVE_LIBPTHREAD /* Nevermind, let's use pthreads... */
static void *__MSG_process_launcher(void *p)
return MSG_OK;
}
#endif /* HAVE_LIBPTHREAD */
-#endif /* USE_CONTEXT */
+#endif /* 0 */
#ifndef _XBT_CONTEXT_PRIVATE_H
#define _XBT_CONTEXT_PRIVATE_H
-#define HAVE_CONTEXT 1
#include "xbt/sysdep.h"
#include "xbt/context.h"
+#include "portable.h" /* loads context system definitions */
-#ifdef HAVE_LIBPTHREAD
-#include <pthread.h>
-typedef struct s_context {
- pthread_cond_t cond;
- pthread_mutex_t mutex;
- pthread_t *thread; /* the thread that execute the code */
- context_function_t code; /* the scheduler fonction */
- int argc;
- char *argv[];
-} s_context_t;
-#endif
-
-#if HAVE_CONTEXT==1
-#include <stdlib.h>
-#include <ucontext.h>
#define STACK_SIZE 524288
typedef struct s_context {
ucontext_t uc; /* the thread that execute the code */
char **argv;
struct s_context *save;
} s_context_t;
-#endif
+
+
+#if 0 /* FIXME: KILLME */
+//#ifdef HAVE_LIBPTHREAD
+#include <pthread.h>
+typedef struct s_context {
+ pthread_cond_t cond;
+ pthread_mutex_t mutex;
+ pthread_t *thread; /* the thread that execute the code */
+ context_function_t code; /* the scheduler fonction */
+ int argc;
+ char *argv[];
+} s_context_t;
+#endif /* ENDOFKILLME*/
#endif /* _XBT_CONTEXT_PRIVATE_H */