Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Now cluster Tag don't necessary need libpcre.
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 4 Oct 2010 15:04:14 +0000 (15:04 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 4 Oct 2010 15:04:14 +0000 (15:04 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8342 48e7efb5-ca39-0410-a469-dd3cf9ba447f

buildtools/Cmake/CompleteInFiles.cmake
buildtools/Cmake/gras_config.h.in
include/surf/surfxml_parse.h
src/surf/surf_routing.c

index c1e9ab3..7ec404f 100644 (file)
@@ -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)
 
 #--------------------------------------------------------------------------------------------------
index 210a3f1..3f5468f 100644 (file)
@@ -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@
 
index 07cf353..3b988a6 100644 (file)
@@ -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)
 
index eaa3f87..4dc7684 100644 (file)
@@ -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 <float.h>
-#include <pcre.h> /* regular expresion library */
+#include "gras_config.h"
+
+#ifdef HAVE_PCRE_LIB
+       #include <pcre.h> /* 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("<AS id=\"%s\"\trouting=\"RuleBased\">",cluster_id);
        SURFXML_BUFFER_SET(AS_id, cluster_id);
+#ifdef HAVE_PCRE_LIB
        SURFXML_BUFFER_SET(AS_routing, "RuleBased");
+       DEBUG1("<AS id=\"%s\"\trouting=\"RuleBased\">",cluster_id);
+#else
+       SURFXML_BUFFER_SET(AS_routing, "Full");
+       DEBUG1("<AS id=\"%s\"\trouting=\"Full\">",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\tid=\"%s\"\tpower=\"%s\"/>",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\tid=\"%s\"\tpower=\"%s\"/>",host_id,cluster_power);
@@ -2521,6 +2543,8 @@ static void routing_full_parse_Scluster(void)
 
        DEBUG0(" ");
 
+#ifdef HAVE_PCRE_LIB
+
        DEBUG2("<route\tsrc=\"%s\"\tdst=\"%s\">",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("</route>");
        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\tsrc=\"%s\"\tdst=\"%s\">",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("<link:ctn\tid=\"%s_link_%d\"/>",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("<link:ctn\tid=\"%s_backbone\"/>",cluster_id);
+                       SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_backbone",cluster_id));
+                       SURFXML_START_TAG(link_ctn);
+                       SURFXML_END_TAG(link_ctn);
+
+                       DEBUG2("<link:ctn\tid=\"%s_link_%d\"/>",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("</route>");
+                       SURFXML_END_TAG(route);
+               }
+       }
+       xbt_dynar_free(&tab_elements_num);
+#endif
 
        DEBUG0("</AS>");
        SURFXML_END_TAG(AS);