From 36360f35fad6a78d7bcd1100ff08098eb3f1a633 Mon Sep 17 00:00:00 2001 From: navarrop Date: Mon, 4 Oct 2010 15:04:14 +0000 Subject: [PATCH] Now cluster Tag don't necessary need libpcre. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8342 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- buildtools/Cmake/CompleteInFiles.cmake | 4 +- buildtools/Cmake/gras_config.h.in | 3 ++ include/surf/surfxml_parse.h | 2 - src/surf/surf_routing.c | 65 +++++++++++++++++++++++++- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index c1e9ab30ea..7ec404f469 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -200,7 +200,7 @@ endif(HAVE_CGRAPH_LIB AND HAVE_CGRAPH_H) #-------------------------------------------------------------------------------------------------- ### Initialize of pcre find_library(PATH_PCRE_LIB pcre "/usr/lib/") - +set(HAVE_PCRE_LIB 0) if(PATH_PCRE_LIB) string(REGEX REPLACE "/libpcre.*[.]so$" "" PATHLIBPCRE "${PATH_PCRE_LIB}") string(REGEX MATCH "-L${PATHLIBPCRE} " operation "${CMAKE_C_FLAGS}") @@ -209,7 +209,7 @@ if(PATH_PCRE_LIB) endif(NOT operation) set(HAVE_PCRE_LIB 1) else(PATH_PCRE_LIB) - message(FATAL_ERROR "You must have libpcre installed (please install the libpcre3-dev package or equivalent)") + message(WARNING "You should install libpcre (please install the libpcre3-dev package or equivalent)") endif(PATH_PCRE_LIB) #-------------------------------------------------------------------------------------------------- diff --git a/buildtools/Cmake/gras_config.h.in b/buildtools/Cmake/gras_config.h.in index 210a3f1788..3f5468facd 100644 --- a/buildtools/Cmake/gras_config.h.in +++ b/buildtools/Cmake/gras_config.h.in @@ -36,6 +36,9 @@ #cmakedefine MMALLOC_WANT_OVERIDE_LEGACY @MMALLOC_WANT_OVERIDE_LEGACY@ #cmakedefine HAVE_MC @HAVE_MC@ +/* Set to true if lib pcre is present */ +#cmakedefine HAVE_PCRE_LIB @HAVE_PCRE_LIB@ + /* Define if building universal (internal helper macro) */ #cmakedefine AC_APPLE_UNIVERSAL_BUILD @AC_APPLE_UNIVERSAL_BUILD@ diff --git a/include/surf/surfxml_parse.h b/include/surf/surfxml_parse.h index 07cf3535c2..3b988a6733 100644 --- a/include/surf/surfxml_parse.h +++ b/include/surf/surfxml_parse.h @@ -90,7 +90,6 @@ extern unsigned int surfxml_buffer_stack_stack[1024]; #define SURFXML_START_TAG(tag) do{ \ surfxml_buffer_stack_stack[surfxml_buffer_stack_stack_ptr] = AX_ptr;\ - DEBUG2("surfxml_buffer_stack_stack[%d]=%d",surfxml_buffer_stack_stack_ptr,surfxml_buffer_stack_stack[surfxml_buffer_stack_stack_ptr]);\ surfxml_buffer_stack_stack_ptr++;\ STag_surfxml_##tag(); \ }while(0) @@ -98,7 +97,6 @@ extern unsigned int surfxml_buffer_stack_stack[1024]; #define SURFXML_END_TAG(tag) do{ \ surfxml_buffer_stack_stack_ptr--;\ AX_ptr = surfxml_buffer_stack_stack[surfxml_buffer_stack_stack_ptr-1];\ - DEBUG1("AX_ptr=%d",AX_ptr);\ ETag_surfxml_##tag();\ } while(0) diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index eaa3f87228..4dc768419d 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -4,8 +4,14 @@ /* 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 -#include /* regular expresion library */ +#include "gras_config.h" + +#ifdef HAVE_PCRE_LIB + #include /* regular expresion library */ +#endif #include "surf_private.h" #include "xbt/dynar.h" #include "xbt/str.h" @@ -2376,6 +2382,11 @@ static void routing_full_parse_Scluster(void) int start, end, i; xbt_dynar_t radical_elements; xbt_dynar_t radical_ends; + #ifndef HAVE_PCRE_LIB + xbt_dynar_t tab_elements_num = xbt_dynar_new(sizeof(int), NULL); + char *route_src,*route_dst; + int j; + #endif static unsigned int surfxml_buffer_stack_stack_ptr = 1; static unsigned int surfxml_buffer_stack_stack[1024]; @@ -2384,9 +2395,14 @@ static void routing_full_parse_Scluster(void) surfxml_bufferstack_push(1); - DEBUG1("",cluster_id); SURFXML_BUFFER_SET(AS_id, cluster_id); +#ifdef HAVE_PCRE_LIB SURFXML_BUFFER_SET(AS_routing, "RuleBased"); + DEBUG1("",cluster_id); +#else + SURFXML_BUFFER_SET(AS_routing, "Full"); + DEBUG1("",cluster_id); +#endif SURFXML_START_TAG(AS); radical_elements = xbt_str_split(cluster_radical, ","); @@ -2398,6 +2414,9 @@ static void routing_full_parse_Scluster(void) case 1: surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *)); host_id = bprintf("%s%d%s", cluster_prefix, start, cluster_suffix); + #ifndef HAVE_PCRE_LIB + xbt_dynar_push_as(tab_elements_num, int, start); + #endif link_id = bprintf("%s_link_%d", cluster_id, start); DEBUG2("",host_id,cluster_power); @@ -2436,6 +2455,9 @@ static void routing_full_parse_Scluster(void) for (i = start; i <= end; i++) { host_id = bprintf("%s%d%s", cluster_prefix, i, cluster_suffix); + #ifndef HAVE_PCRE_LIB + xbt_dynar_push_as(tab_elements_num, int, i); + #endif link_id = bprintf("%s_link_%d", cluster_id, i); DEBUG2("",host_id,cluster_power); @@ -2521,6 +2543,8 @@ static void routing_full_parse_Scluster(void) DEBUG0(" "); +#ifdef HAVE_PCRE_LIB + DEBUG2("",route_src_dst,route_src_dst); SURFXML_BUFFER_SET(route_src, route_src_dst); SURFXML_BUFFER_SET(route_dst, route_src_dst); @@ -2543,6 +2567,43 @@ static void routing_full_parse_Scluster(void) DEBUG0(""); SURFXML_END_TAG(route); +#else + for(i=0 ; i<=tab_elements_num->elmsize ; i++) + { + for(j=0 ; j<=tab_elements_num->elmsize ; j++) + { + route_src = bprintf("%s%d%s",cluster_prefix,xbt_dynar_get_as(tab_elements_num,i,int),cluster_suffix); + route_dst = bprintf("%s%d%s",cluster_prefix,xbt_dynar_get_as(tab_elements_num,j,int),cluster_suffix); + + DEBUG2("",route_src,route_dst); + SURFXML_BUFFER_SET(route_src, route_src); + SURFXML_BUFFER_SET(route_dst, route_dst); + SURFXML_START_TAG(route); + + route_src = bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,i,int)); + route_dst = bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,j,int)); + + DEBUG2("",cluster_id,xbt_dynar_get_as(tab_elements_num,i,int)); + SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,i,int))); + SURFXML_START_TAG(link_ctn); + SURFXML_END_TAG(link_ctn); + + DEBUG1("",cluster_id); + SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_backbone",cluster_id)); + SURFXML_START_TAG(link_ctn); + SURFXML_END_TAG(link_ctn); + + DEBUG2("",cluster_id,xbt_dynar_get_as(tab_elements_num,j,int)); + SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,j,int))); + SURFXML_START_TAG(link_ctn); + SURFXML_END_TAG(link_ctn); + + DEBUG0(""); + SURFXML_END_TAG(route); + } + } + xbt_dynar_free(&tab_elements_num); +#endif DEBUG0(""); SURFXML_END_TAG(AS); -- 2.20.1