Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make the context cruft work on windows; mark the pthread layer in context.* as deprec...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 15 Dec 2004 22:47:38 +0000 (22:47 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 15 Dec 2004 22:47:38 +0000 (22:47 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@643 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/xbt/context.c
src/xbt/context_private.h

index b6124ce..c7f59ed 100644 (file)
@@ -2,20 +2,25 @@
 
 /* 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;
@@ -138,10 +143,14 @@ void context_yield(context_t context)
 
   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)
@@ -247,4 +256,4 @@ MSG_error_t __MSG_context_yield(context_t context)
   return MSG_OK;
 }
 #endif /* HAVE_LIBPTHREAD */
-#endif /* USE_CONTEXT */
+#endif /* 0 */
index 52540ad..a2a8a9b 100644 (file)
@@ -8,26 +8,11 @@
 #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   */
@@ -37,6 +22,19 @@ typedef struct s_context {
   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 */