From de6f834747f9af2af9f110ee3ba3bb9f3f0d01f3 Mon Sep 17 00:00:00 2001 From: mquinson Date: Wed, 15 Dec 2004 22:47:38 +0000 Subject: [PATCH] Make the context cruft work on windows; mark the pthread layer in context.* as deprecated. We will need threads around, but not here git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@643 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/xbt/context.c | 23 ++++++++++++++++------- src/xbt/context_private.h | 32 +++++++++++++++----------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/xbt/context.c b/src/xbt/context.c index b6124ce9bb..c7f59edb76 100644 --- a/src/xbt/context.c +++ b/src/xbt/context.c @@ -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 */ diff --git a/src/xbt/context_private.h b/src/xbt/context_private.h index 52540ad69b..a2a8a9b6d2 100644 --- a/src/xbt/context_private.h +++ b/src/xbt/context_private.h @@ -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 -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 -#include #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 +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 */ -- 2.20.1