From: Martin Quinson Date: Wed, 6 Jul 2011 15:33:31 +0000 (+0200) Subject: trivial merge of changes about gras architecture X-Git-Tag: v3_6_2~203 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/eccb848c9b78eb0a1bffa80e4eb90fc1cd6b4007?hp=35623150364de198acec466c14a210eb8ab63ae6 trivial merge of changes about gras architecture --- diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index 4685f06700..d7a20d4305 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -352,36 +352,18 @@ endif(pthread) ############### ## SVN version check ## -if(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn) - find_file(SVN ".svn" ${CMAKE_HOME_DIRECTORY}) - exec_program("svnversion ${CMAKE_HOME_DIRECTORY}" OUTPUT_VARIABLE "SVN_VERSION") - message(STATUS "svn version ${SVN_VERSION}") -else(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn) - exec_program("git config --get svn-remote.svn.url" - OUTPUT_VARIABLE url - RETURN_VALUE ret) -endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn) +exec_program("git remote" OUTPUT_VARIABLE remote RETURN_VALUE ret) +exec_program("git config --get remote.${remote}.url" OUTPUT_VARIABLE url RETURN_VALUE ret) if(url) exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --oneline -1" OUTPUT_VARIABLE "GIT_VERSION") + message(STATUS "Git version: ${GIT_VERSION}") exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --format=%ai ." OUTPUT_VARIABLE "GIT_DATE") - + message(STATUS "Git date: ${GIT_DATE}") string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}") STRING(REPLACE " +0000" "" GIT_DATE ${GIT_DATE}) STRING(REPLACE " " "~" GIT_DATE ${GIT_DATE}) STRING(REPLACE ":" "-" GIT_DATE ${GIT_DATE}) - - exec_program("git svn info" ${CMAKE_HOME_DIRECTORY} - OUTPUT_VARIABLE "GIT_SVN_VERSION") - string(REPLACE "\n" ";" GIT_SVN_VERSION ${GIT_SVN_VERSION}) - foreach(line ${GIT_SVN_VERSION}) - string(REGEX MATCH "^Revision:.*" line_good ${line}) - if(line_good) - string(REPLACE "Revision: " "" - line_good ${line_good}) - set(SVN_VERSION ${line_good}) - endif(line_good) - endforeach(line ${GIT_SVN_VERSION}) endif(url) @@ -432,6 +414,7 @@ endif(BIGENDIAN) # If you really need to change stuff, please also bump # GRAS_PROTOCOL_VERSION in src/gras/Msg/msg_interface.h +SET(GRAS_THISARCH "none") if(val_big MATCHES "l_C:1/1:_I:2/1:4/1:4/1:8/1:_P:4/1:4/1:_D:4/1:8/1:") #gras_arch=0; gras_size=32; gras_arch_name=little32_1; @@ -490,6 +473,10 @@ if(val_big MATCHES "B_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/4:") SET(GRAS_THISARCH 10) endif(val_big MATCHES "B_C:1/1:_I:2/2:4/4:8/8:8/8:_P:8/8:8/8:_D:4/4:8/4:") +if(GRAS_THISARCH MATCHES "none") + message(STATUS "architecture: ${val_big}") + message(FATAL_ERROR "GRAS_THISARCH is empty: '${GRAS_THISARCH}'") +endif(GRAS_THISARCH MATCHES "none") # Check architecture signature end try_run(RUN_GRAS_VAR COMPILE_GRAS_VAR diff --git a/buildtools/Cmake/PrintArgs.cmake b/buildtools/Cmake/PrintArgs.cmake index 9e7c532922..d39ef8db5b 100644 --- a/buildtools/Cmake/PrintArgs.cmake +++ b/buildtools/Cmake/PrintArgs.cmake @@ -74,10 +74,10 @@ if(enable_print_message) message("") endif(enable_print_message) -message("\nConfiguration of package `simgrid' (revision ${SVN_VERSION}) on arch (=${GRAS_THISARCH}):") +message("\nConfiguration of package `simgrid' on arch (=${GRAS_THISARCH}):") message(" BUILDNAME : ${BUILDNAME}") message(" SITE : ${SITE}") -message(" Release : simgrid-${release_version}~rev${SVN_VERSION}") +message(" Release : simgrid-${release_version}") message("") message(" Compiler: c++ : ${CMAKE_CXX_COMPILER}") message(" version: ${COMPILER_CXX_VERSION}") diff --git a/buildtools/Cmake/gras_config.h.in b/buildtools/Cmake/gras_config.h.in index 32496eea97..c58ef93b74 100644 --- a/buildtools/Cmake/gras_config.h.in +++ b/buildtools/Cmake/gras_config.h.in @@ -103,6 +103,7 @@ #cmakedefine PROCESSOR_i686 @PROCESSOR_i686@ #cmakedefine PROCESSOR_x86_64 @PROCESSOR_x86_64@ #cmakedefine CMAKE_SYSTEM_PROCESSOR @CMAKE_SYSTEM_PROCESSOR@ +#cmakedefine HAVE_RAWCTX @HAVE_RAWCTX@ /* Defined if arrays in struct can straddle struct alignment boundaries. This is like than the structure compaction above, but this time, the argument to diff --git a/buildtools/Cmake/simgrid.nsi.in b/buildtools/Cmake/simgrid.nsi.in index f0795122cc..c6b2f4d882 100644 --- a/buildtools/Cmake/simgrid.nsi.in +++ b/buildtools/Cmake/simgrid.nsi.in @@ -1,14 +1,39 @@ -# define installer name -outFile "SimGrid@SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@_win@WIN_ARCH@@BIN_EXE@" +!include "MUI2.nsh" -# set the default installation directory -InstallDir $PROGRAMFILES\SimGrid +;-------------------------------- +;Interface Configuration -# The text to prompt the user to enter a directory -DirText "This will install Simgrid on your computer. Choose a directory" + !define MUI_HEADERIMAGE + !define MUI_HEADERIMAGE_BITMAP "@CMAKE_HOME_DIRECTORY@\doc\webcruft\simgrid_logo_win.bmp" ; optional + !define MUI_ABORTWARNING -# default section start -section +;-------------------------------- +;Pages + + !insertmacro MUI_PAGE_LICENSE "@CMAKE_HOME_DIRECTORY@\LICENSE-LGPL-2.1" + !insertmacro MUI_PAGE_COMPONENTS + !insertmacro MUI_PAGE_DIRECTORY + !insertmacro MUI_PAGE_INSTFILES + !insertmacro MUI_PAGE_FINISH + + !insertmacro MUI_UNPAGE_CONFIRM + !insertmacro MUI_UNPAGE_INSTFILES + !insertmacro MUI_UNPAGE_FINISH + +;-------------------------------- +;Languages + !insertmacro MUI_LANGUAGE "English" + !insertmacro MUI_LANGUAGE "French" +;-------------------------------- + +Name "Simgrid" +outFile "SimGrid@SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@_@CMAKE_SYSTEM_PROCESSOR@@BIN_EXE@" +Icon "@CMAKE_HOME_DIRECTORY@\doc\webcruft\SimGrid.ico" + +# set the default installation directory +InstallDir c:\SimGrid@SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@ + +Section "Libraries and Headers" LibSection # install lib CreateDirectory $INSTDIR\lib @@ -114,6 +139,9 @@ section file @CMAKE_HOME_DIRECTORY@\include\simix\datatypes.h file @CMAKE_HOME_DIRECTORY@\include\simix\context.h +SectionEnd +Section "Binaries" BinSection + # insatll bin CreateDirectory $INSTDIR\bin setOutPath $INSTDIR\bin @@ -127,24 +155,73 @@ section file bin\smpirun file bin\tesh - #install doc +SectionEnd +Section "Documentation" DocSection + + # install doc CreateDirectory $INSTDIR\doc setOutPath $INSTDIR\doc file /nonfatal /r @CMAKE_HOME_DIRECTORY@\doc\html + # create a shortcut in the start menu programs directory + CreateDirectory "$SMPROGRAMS\SimGrid" + createShortCut "$SMPROGRAMS\SimGrid\Documentation.lnk" "$INSTDIR\doc\html\index.html" + +SectionEnd +Section "Examples" ExamplesSection + + # install examples + CreateDirectory $INSTDIR\examples + setOutPath $INSTDIR\examples + file /r @CMAKE_HOME_DIRECTORY@\examples\platforms + file /r @CMAKE_HOME_DIRECTORY@\doc\HelloWorld + # create a shortcut in the start menu programs directory + createShortCut "$SMPROGRAMS\SimGrid\HelloWorld project.lnk" "$INSTDIR\examples\HelloWorld" + +SectionEnd +# default section start +section # define uninstaller name writeUninstaller $INSTDIR\uninstaller@BIN_EXE@ # create a shortcut in the start menu programs directory CreateDirectory "$SMPROGRAMS\SimGrid" createShortCut "$SMPROGRAMS\SimGrid\Uninstall simgrid.lnk" "$INSTDIR\uninstaller@BIN_EXE@" - createShortCut "$SMPROGRAMS\SimGrid\Documentation.lnk" "$INSTDIR\doc\index.html" + + # Include for some of the windows message defines + !include "winmessages.nsh" + # HKLM (all users) vs HKCU (current user) defines + !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' + !define env_hkcu 'HKCU "Environment"' + # Set Variables + WriteRegExpandStr ${env_hklm} SIMGRID_ROOT $INSTDIR + WriteRegExpandStr ${env_hklm} SIMGRID_VERSION @SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@ + + WriteRegStr HKCU "SOFTWARE\SimGrid" "Version" "@SIMGRID_VERSION_MAJOR@.@SIMGRID_VERSION_MINOR@.@SIMGRID_VERSION_PATCH@" + WriteRegStr HKCU "SOFTWARE\SimGrid" "InstallPath" "$INSTDIR" - MessageBox MB_OK "Installation was successful." + SetRebootFlag true # default section end sectionEnd +LangString DESC_LibSection ${LANG_ENGLISH} "Install Simgrid and gras libraries with associated headers." +LangString DESC_BinSection ${LANG_ENGLISH} "Install some useful tools for Simgrid." +LangString DESC_DocSection ${LANG_ENGLISH} "Generated (doxygen) documentation." +LangString DESC_ExamplesSection ${LANG_ENGLISH} "Simgrid's HelloWorld example and some classical platforms." + +LangString DESC_LibSection ${LANG_FRENCH} "Installer les librairies Simgrid et Gras et leurs EntĂȘtes." +LangString DESC_BinSection ${LANG_FRENCH} "Installer les outils optionnels." +LangString DESC_DocSection ${LANG_FRENCH} "Installer la documentation." +LangString DESC_ExamplesSection ${LANG_FRENCH} "Installer un exemple 'HelloWorld' et des fichiers de plate-formes types." + +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${LibSection} $(DESC_LibSection) + !insertmacro MUI_DESCRIPTION_TEXT ${BinSection} $(DESC_BinSection) + !insertmacro MUI_DESCRIPTION_TEXT ${DocSection} $(DESC_DocSection) + !insertmacro MUI_DESCRIPTION_TEXT ${ExamplesSection} $(DESC_ExamplesSection) +!insertmacro MUI_FUNCTION_DESCRIPTION_END + # create a section to define what the uninstaller does. # the section will always be named "Uninstall" section "Uninstall" @@ -236,6 +313,7 @@ section "Uninstall" # delete link delete "$SMPROGRAMS\SimGrid\Uninstall simgrid.lnk" delete "$SMPROGRAMS\SimGrid\Documentation.lnk" + delete "$SMPROGRAMS\SimGrid\HelloWorld project.lnk" # now delete directories RMDir "$INSTDIR\bin" @@ -252,8 +330,13 @@ section "Uninstall" RMDir "$INSTDIR\include\xbt" RMDir "$INSTDIR\include" RMDir /r "$INSTDIR\doc" + RMDir /r "$INSTDIR\examples" RMDir "$SMPROGRAMS\SimGrid" - RMDir "$PROGRAMFILES\SimGrid" - + + # Delete variable + DeleteRegValue ${env_hklm} SIMGRID_ROOT + DeleteRegValue ${env_hklm} SIMGRID_VERSION + DeleteRegKey HKCU "SOFTWARE\SimGrid" + # uninstall section end sectionEnd \ No newline at end of file diff --git a/buildtools/Cmake/tesh.pl b/buildtools/Cmake/tesh.pl index 28296d6a32..a5b53c437a 100755 --- a/buildtools/Cmake/tesh.pl +++ b/buildtools/Cmake/tesh.pl @@ -32,6 +32,8 @@ else{ $OS = "WIN"; } +print "OS: ".$OS."\n"; + # make sure we received a tesh file scalar @ARGV > 0 || die "Usage:\n tesh [*options*] *tesh_file*\n"; @@ -175,6 +177,8 @@ sub exec_cmd { # cleanup the command line if($OS eq "WIN"){ $cmd{'cmd'} =~ s/\${EXEEXT:=}/.exe/g; + $cmd{'cmd'} =~ s/\${EXEEXT}/.exe/g; + $cmd{'cmd'} =~ s/\$EXEEXT/.exe/g; } else{ $cmd{'cmd'} =~ s/\${EXEEXT:=}//g; diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 255096d9af..ee1b029ec6 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -1512,7 +1512,8 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = DOXYGEN \ DOXYGEN_SKIP_IT \ - XBT_PUBLIC= + XBT_PUBLIC= \ + XBT_INLINE= # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. diff --git a/doc/FAQ.doc b/doc/FAQ.doc index dc275a5ed4..f0889d3d32 100644 --- a/doc/FAQ.doc +++ b/doc/FAQ.doc @@ -115,7 +115,8 @@ For Windows : \li cmake 2.8 (download page) \li perl strawberry (download page) \li pcre-7.0 (download page) - + \li git (download page) + \subsubsection faq_cmakeoption1 Liste of options \verbatim @@ -228,6 +229,7 @@ make On Windows +Open the "Git Bash" window. \verbatim cmake -G"Unix Makefiles" -D[name]=[value] ... ./ gmake diff --git a/doc/HelloWorld/CMakeLists.txt b/doc/HelloWorld/CMakeLists.txt new file mode 100644 index 0000000000..cfeb96300f --- /dev/null +++ b/doc/HelloWorld/CMakeLists.txt @@ -0,0 +1,41 @@ +### This is a template for building targets with simgrid +cmake_minimum_required(VERSION 2.8) + +### Need to set rc ccompiler before enable language +if(WIN32) + SET(CMAKE_RC_COMPILER "windres") +endif(WIN32) + +project(HelloWorld C) +set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE) +set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE) + +############################### +# Test the build dependencies # +############################### +include(FindPCRE.cmake) +message(STATUS "Looking for lib Simgrid") +if("$ENV{SIMGRID_ROOT}" STREQUAL "") + message(STATUS "Looking for lib Simgrid - Not found") + message(FATAL_ERROR "Simgrid not found, reinstall it or set SIMGRID_ROOT") +else("$ENV{SIMGRID_ROOT}" STREQUAL "") + link_directories($ENV{SIMGRID_ROOT}/lib) + include_directories($ENV{SIMGRID_ROOT}/include) + include_directories($ENV{SIMGRID_ROOT}/src) + include_directories($ENV{SIMGRID_ROOT}/src/include) + add_library(libsimgrid STATIC IMPORTED) + message(STATUS "Looking for lib Simgrid - found") +endif("$ENV{SIMGRID_ROOT}" STREQUAL "") + +########### +# TARGETS # +########### + +######################### +# add_executable # +# args1 target name # +# args2 sources # +######################### +add_executable(HelloWorld HelloWorld.c) +# Any targets need to be linked with simgrid and pcre +target_link_libraries(HelloWorld simgrid pcre) diff --git a/doc/HelloWorld/FindPCRE.cmake b/doc/HelloWorld/FindPCRE.cmake new file mode 100644 index 0000000000..9454da7151 --- /dev/null +++ b/doc/HelloWorld/FindPCRE.cmake @@ -0,0 +1,71 @@ +### SET THE LIBRARY EXTENSION AND GCC VERSION +if(APPLE) #MAC + set(LIB_EXE "dylib") +else(APPLE) + if(WIN32) #WINDOWS + set(LIB_EXE "a") + set(BIN_EXE ".exe") + else(WIN32) #UNIX + set(LIB_EXE "so") + endif(WIN32) +endif(APPLE) + +find_library(PATH_PCRE_LIB + NAMES pcre + HINTS + $ENV{LD_LIBRARY_PATH} + $ENV{PCRE_LIBRARY_PATH} + PATH_SUFFIXES lib/ GnuWin32/lib + PATHS + /opt + /opt/local + /opt/csw + /sw + /usr) + +find_path(PATH_PCRE_H "pcre.h" + HINTS + $ENV{LD_LIBRARY_PATH} + $ENV{PCRE_LIBRARY_PATH} + PATH_SUFFIXES include/ GnuWin32/include + PATHS + /opt + /opt/local + /opt/csw + /sw + /usr) + +set(HAVE_PCRE_LIB 0) + +message(STATUS "Looking for pcre.h") +if(PATH_PCRE_H) +message(STATUS "Looking for pcre.h - found") +else(PATH_PCRE_H) +message(STATUS "Looking for pcre.h - not found") +endif(PATH_PCRE_H) + +message(STATUS "Looking for lib pcre") +if(PATH_PCRE_LIB) +message(STATUS "Looking for lib pcre - found") +else(PATH_PCRE_LIB) +message(STATUS "Looking for lib pcre - not found") +endif(PATH_PCRE_LIB) + +if(PATH_PCRE_LIB AND PATH_PCRE_H) + string(REGEX REPLACE "/libpcre.*[.]${LIB_EXE}$" "" PATHLIBPCRE "${PATH_PCRE_LIB}") + string(REGEX REPLACE "/pcre.h" "" PATH_PCRE_H "${PATH_PCRE_H}") + string(REGEX MATCH "-L${PATHLIBPCRE} " operation "${CMAKE_C_FLAGS}") + if(NOT operation) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${PATHLIBPCRE} ") + endif(NOT operation) + string(REGEX MATCH "-I${PATH_PCRE_H} " operation "${CMAKE_C_FLAGS}") + if(NOT operation) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${PATH_PCRE_H} ") + endif(NOT operation) + set(HAVE_PCRE_LIB 1) +else(PATH_PCRE_LIB) + message(FATAL_ERROR "Please install the libpcre3-dev package or equivalent before using it.") +endif(PATH_PCRE_LIB AND PATH_PCRE_H) + +mark_as_advanced(PATH_PCRE_H) +mark_as_advanced(PATH_PCRE_LIB) \ No newline at end of file diff --git a/doc/HelloWorld/HelloWorld.c b/doc/HelloWorld/HelloWorld.c new file mode 100644 index 0000000000..796b67a95e --- /dev/null +++ b/doc/HelloWorld/HelloWorld.c @@ -0,0 +1,7 @@ +#include "xbt/log.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(HelloWorld, + "Messages specific for this Hello World example"); +void main() +{ + XBT_INFO("Hello World !!!"); +} diff --git a/doc/HelloWorld/README b/doc/HelloWorld/README new file mode 100644 index 0000000000..2fcbf6976d --- /dev/null +++ b/doc/HelloWorld/README @@ -0,0 +1,35 @@ +This is a very simple example to explain how to compile with simgrid. + +1) How to compile an example: (HelloWorld) + +- Run "Git bash" (installed with git). +- Open HelloWorld Directory ('cd' command line). +- Create a build directory and change directory. (optional) +- Type 'cmake -G"Unix Makefiles" ' +- Run gmake +- You should obtain a runnable example ("HelloWorld.exe"). + +2) Content of this directory + +- HelloWorld.c + The example source file. +- CMakeLists.txt + It allows to configure the project. +- FindPCRE.cmake + Simgrid needs pcre regular expression. + This finds and links to the pcre library. +- README + This explaination. + +3) How to add and compile a new example + +- Put your source file into the helloWord directory. +- Edit CMakeLists.txt : + * In the Targets section add those two lines: + add_executable(TARGET_NAME SOURCES) + target_link_libraries(TARGET_NAME simgrid pcre) + * It creates a target called 'TARGET_NAME.exe' with the sources 'SOURCES'. +- To initialize your project, you'll need to run 'cmake -G"Unix Makefiles" .' +- To build you project, run "cmake ." +- Run "gmake" +- You should obtain "TARGET_NAME.exe". \ No newline at end of file diff --git a/doc/webcruft/SimGrid.ico b/doc/webcruft/SimGrid.ico new file mode 100644 index 0000000000..619a707afb Binary files /dev/null and b/doc/webcruft/SimGrid.ico differ diff --git a/doc/webcruft/simgrid_logo_win.bmp b/doc/webcruft/simgrid_logo_win.bmp new file mode 100644 index 0000000000..bb32badb32 Binary files /dev/null and b/doc/webcruft/simgrid_logo_win.bmp differ diff --git a/include/xbt/dynar.h b/include/xbt/dynar.h index 210efb751f..67418d11d9 100644 --- a/include/xbt/dynar.h +++ b/include/xbt/dynar.h @@ -69,13 +69,7 @@ XBT_PUBLIC(xbt_dynar_t) xbt_dynar_new_sync(const unsigned long elm_size, XBT_INLINE XBT_PUBLIC(void) xbt_dynar_free(xbt_dynar_t * dynar); XBT_PUBLIC(void) xbt_dynar_free_voidp(void *dynar); XBT_PUBLIC(void) xbt_dynar_free_container(xbt_dynar_t * dynar); - -XBT_INLINE XBT_PUBLIC(unsigned long) xbt_dynar_length(const xbt_dynar_t - dynar); -XBT_INLINE XBT_PUBLIC(int) xbt_dynar_is_empty(const xbt_dynar_t dynar); -XBT_PUBLIC(void) xbt_dynar_reset(xbt_dynar_t const dynar); XBT_PUBLIC(void) xbt_dynar_shrink(xbt_dynar_t dynar, int empty_slots); - XBT_PUBLIC(void) xbt_dynar_dump(xbt_dynar_t dynar); /** @} */ @@ -108,6 +102,19 @@ XBT_INLINE XBT_PUBLIC(int) xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2, int(*compar)(const void *, const void *)); XBT_INLINE XBT_PUBLIC(void *) xbt_dynar_to_array (xbt_dynar_t dynar); +/** @} */ +/** @defgroup XBT_dynar_misc Dynar miscellaneous functions + * @ingroup XBT_dynar + * + * @{ + */ + +XBT_INLINE XBT_PUBLIC(unsigned long) xbt_dynar_length(const xbt_dynar_t + dynar); +XBT_INLINE XBT_PUBLIC(int) xbt_dynar_is_empty(const xbt_dynar_t dynar); +XBT_PUBLIC(void) xbt_dynar_reset(xbt_dynar_t const dynar); + + /** @} */ /** @defgroup XBT_dynar_perl Perl-like use of dynars * @ingroup XBT_dynar diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index ac2949dc05..842dc7fd2a 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -11,6 +11,11 @@ #ifdef HAVE_TRACING +/* Need to define function drand48 for Windows */ +#ifdef _WIN32 +# define drand48() (rand()/(RAND_MAX + 1.0)) +#endif + #define INSTR_DEFAULT_STR_SIZE 500 #include "instr/instr.h" diff --git a/src/simix/smx_context.c b/src/simix/smx_context.c index ca29ef5915..9fc1b5d3e7 100644 --- a/src/simix/smx_context.c +++ b/src/simix/smx_context.c @@ -43,15 +43,17 @@ void SIMIX_context_mod_init(void) } else { /* use the factory specified by --cfg=contexts/factory:value */ - if (smx_context_factory_name == NULL) { + if (smx_context_factory_name == NULL) { /* use the default factory */ -#ifdef CONTEXT_UCONTEXT - SIMIX_ctx_sysv_factory_init(&simix_global->context_factory); -#else - SIMIX_ctx_thread_factory_init(&simix_global->context_factory); -#endif - } - else if (!strcmp(smx_context_factory_name, "ucontext")) { + #ifdef HAVE_RAWCTX + SIMIX_ctx_raw_factory_init(&simix_global->context_factory); + #elif CONTEXT_UCONTEXT + SIMIX_ctx_sysv_factory_init(&simix_global->context_factory); + #else + SIMIX_ctx_thread_factory_init(&simix_global->context_factory); + #endif + } + else if (!strcmp(smx_context_factory_name, "ucontext")) { /* use ucontext */ #ifdef CONTEXT_UCONTEXT SIMIX_ctx_sysv_factory_init(&simix_global->context_factory); diff --git a/src/simix/smx_context_raw.c b/src/simix/smx_context_raw.c index 0284d5e05b..059870eb84 100644 --- a/src/simix/smx_context_raw.c +++ b/src/simix/smx_context_raw.c @@ -38,7 +38,7 @@ extern void raw_swapcontext(raw_stack_t* old, raw_stack_t new); #ifdef PROCESSOR_i686 __asm__ ( -#ifdef APPLE +#if defined(APPLE) || defined(_WIN32) ".text\n" ".globl _raw_makecontext\n" "_raw_makecontext:\n" @@ -64,7 +64,7 @@ __asm__ ( ); __asm__ ( -#ifdef APPLE +#if defined(APPLE) || defined(_WIN32) ".text\n" ".globl _raw_swapcontext\n" "_raw_swapcontext:\n" @@ -90,7 +90,7 @@ __asm__ ( ); #elif PROCESSOR_x86_64 __asm__ ( -#ifdef APPLE +#if defined(APPLE) || defined(_WIN32) ".text\n" ".globl _raw_makecontext\n" "_raw_makecontext:\n" @@ -121,7 +121,7 @@ __asm__ ( ); __asm__ ( -#ifdef APPLE +#if defined(APPLE) || defined(_WIN32) ".text\n" ".globl _raw_swapcontext\n" "_raw_swapcontext:\n" diff --git a/src/xbt/mallocator.c b/src/xbt/mallocator.c index f1972a00d0..1b0a3ced13 100644 --- a/src/xbt/mallocator.c +++ b/src/xbt/mallocator.c @@ -111,17 +111,27 @@ void *xbt_mallocator_get(xbt_mallocator_t m) { void *object; - if (m->current_size > 0) { - /* there is at least an available object */ - /* XBT_DEBUG("Reuse an old object for mallocator %p (size:%d/%d)", m, - m->current_size, m->max_size); */ - object = m->objects[--m->current_size]; - } else { - /* otherwise we must allocate a new object */ + if (m->current_size <= 0) { + /* No object is ready yet. Create a bunch of them to try to group the mallocs + * on the same memory pages (to help the cache lines) */ + /* XBT_DEBUG("Create a new object for mallocator %p (size:%d/%d)", m, m->current_size, m->max_size); */ - object = (*(m->new_f)) (); + int i; + int amount=MIN( (m->max_size) /2,1000); + for (i=0;iobjects[i] = (*(m->new_f)) (); + m->current_size=amount; } + + /* there is at least an available object, now */ + /* XBT_DEBUG("Reuse an old object for mallocator %p (size:%d/%d)", m, + m->current_size, m->max_size); */ + if (MC_IS_ENABLED) /* no mallocator with MC */ + object = (*(m->new_f)) (); + else + object = m->objects[--m->current_size]; + (*(m->reset_f)) (object); return object; }