From: pini Date: Fri, 17 Dec 2010 20:21:16 +0000 (+0000) Subject: Only evaluate the arguments needed. X-Git-Tag: v3.6_beta2~632 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/95a4b82ee320381d28ffab2f80b95bb2ee93098e Only evaluate the arguments needed. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9293 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index cb9488380e..56e92e4a80 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -6,6 +6,7 @@ ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Modules message(STATUS "Cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}") include(CheckFunctionExists) +include(CheckTypeSize) include(CheckIncludeFile) include(CheckIncludeFiles) include(CheckLibraryExists) @@ -111,6 +112,12 @@ else(enable_model-checking AND HAVE_MMAP) SET(MMALLOC_WANT_OVERIDE_LEGACY 0) endif(enable_model-checking AND HAVE_MMAP) +#-------------------------------------------------------------------------------------------------- +### Check for some architecture dependent values +CHECK_TYPE_SIZE(int SIZEOF_INT) +CHECK_TYPE_SIZE(void* SIZEOF_VOIDP) + + #-------------------------------------------------------------------------------------------------- ### Initialize of CONTEXT THREADS diff --git a/buildtools/Cmake/gras_config.h.in b/buildtools/Cmake/gras_config.h.in index 9078297e59..72f723ef17 100644 --- a/buildtools/Cmake/gras_config.h.in +++ b/buildtools/Cmake/gras_config.h.in @@ -13,6 +13,9 @@ #endif #endif +#cmakedefine SIZEOF_INT @SIZEOF_INT@ +#cmakedefine SIZEOF_VOIDP @SIZEOF_VOIDP@ + #ifndef __STRICT_ANSI__ #cmakedefine __STRICT_ANSI__ @__STRICT_ANSI__@ #endif @@ -332,4 +335,4 @@ #endif /* Define to `unsigned int' if does not define. */ -#cmakedefine size_t @size_t@ \ No newline at end of file +#cmakedefine size_t @size_t@ diff --git a/src/simix/smx_context_sysv.c b/src/simix/smx_context_sysv.c index 5c607b8f92..b81509aa0b 100644 --- a/src/simix/smx_context_sysv.c +++ b/src/simix/smx_context_sysv.c @@ -7,9 +7,11 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include + #include "smx_context_sysv_private.h" #include "xbt/parmap.h" #include "simix/private.h" +#include "gras_config.h" #ifdef HAVE_VALGRIND_VALGRIND_H # include @@ -103,20 +105,17 @@ smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code, context->uc.uc_stack.ss_size); #endif /* HAVE_VALGRIND_VALGRIND_H */ ctx_addr = (uintptr_t)context; - /* This switch select a case base on a static value: the compiler optimizes it out */ - /* It could be replaced by a set of #ifdef/#else/#endif blocks */ - switch(sizeof(uintptr_t) / sizeof(int)) { - case 1: - makecontext(&((smx_ctx_sysv_t) context)->uc, (void (*)())smx_ctx_sysv_wrapper, - 2, 1, (int)ctx_addr); - break; - case 2: - makecontext(&((smx_ctx_sysv_t) context)->uc, (void (*)())smx_ctx_sysv_wrapper, - 3, 2, (int)(ctx_addr >> (8 * sizeof(int))), (int)(ctx_addr)); - break; - default: - THROW_IMPOSSIBLE; - } + makecontext(&((smx_ctx_sysv_t) context)->uc, (void (*)())smx_ctx_sysv_wrapper, + SIZEOF_VOIDP / SIZEOF_INT + 1, SIZEOF_VOIDP / SIZEOF_INT, +#if (SIZEOF_VOIDP == SIZEOF_INT) + (int)ctx_addr +#elif (SIZEOF_VOIDP == 2 * SIZEOF_INT) + (int)(ctx_addr >> (8 * sizeof(int))), + (int)(ctx_addr) +#else +#error Your architecture is not supported yet +#endif + ); }else{ maestro_context = context; }