summaryrefslogtreecommitdiffstats
path: root/src/vlib/CMakeLists.txt
AgeCommit message (Expand)AuthorFilesLines
2020-05-20vlib: mmap process stacksDamjan Marion1-0/+12
2020-04-28vlib: startup multi-arch variant configurationRay Kinsella1-0/+2
2020-04-27vlib: deprecate i2c and cjDave Barach1-4/+0
2020-04-13buffers: configurable buffer fault injectorDave Barach1-0/+8
2020-03-31vlib: move pci api types from vnet/pci to vlib/pciJakub Grajciar1-0/+7
2019-12-09vlib: improve test coverageDave Barach1-1/+0
2019-06-24vlib: packet tracer support for pkt thread handoffsDave Barach1-0/+1
2019-03-28Punt InfraNeale Ranns1-0/+4
2019-03-13Move the punt/drop nodes into vlibNeale Ranns1-0/+4
2019-01-01buffers: remove unused codeDamjan Marion1-1/+0
2018-12-19vlib: support Hyper-v/Azure VMBusStephen Hemminger1-1/+20
2018-10-23Numa-aware, growable physical memory allocator (pmalloc)Damjan Marion1-1/+1
2018-10-01API / CLI event-log tracingDave Barach1-3/+0
2018-09-17STATS: Dynamically mapped shared memory segmentOle Troan1-0/+1
2018-09-07cmake: set packaging component for different filesDamjan Marion1-1/+5
2018-08-26cmake: add add_vpp_library and add_vpp_executable macrosDamjan Marion1-11/+5
2018-08-17CMake as an alternative to autotools (experimental)Damjan Marion1-0/+98
{ color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <vppinfra/ptclosure.h>

__clib_export u8 **
clib_ptclosure_alloc (int n)
{
  u8 **rv = 0;
  u8 *row;
  int i;

  ASSERT (n > 0);

  vec_validate (rv, n - 1);
  for (i = 0; i < n; i++)
    {
      row = 0;
      vec_validate (row, n - 1);

      rv[i] = row;
    }
  return rv;
}

__clib_export void
clib_ptclosure_free (u8 ** ptc)
{
  u8 *row;
  int n = vec_len (ptc);
  int i;

  ASSERT (n > 0);

  for (i = 0; i < n; i++)
    {
      row = ptc[i];
      vec_free (row);
    }
  vec_free (ptc);
}

void
clib_ptclosure_copy (u8 ** dst, u8 ** src)
{
  int i, n;
  u8 *src_row, *dst_row;

  n = vec_len (dst);

  for (i = 0; i < vec_len (dst); i++)
    {
      src_row = src[i];
      dst_row = dst[i];
      clib_memcpy (dst_row, src_row, n);
    }
}

/*
 * compute the positive transitive closure
 * of a relation via Warshall's algorithm.
 *
 * Ref:
 * Warshall, Stephen (January 1962). "A theorem on Boolean matrices".
 * Journal of the ACM 9 (1): 11–12.
 *
 * foo[i][j] = 1 means that item i
 * "bears the relation" to item j.
 *
 * For example: "item i must be before item j"
 *
 * You could use a bitmap, but since the algorithm is
 * O(n**3) in the first place, large N is inadvisable...
 *
 */

__clib_export u8 **
clib_ptclosure (u8 ** orig)
{
  int i, j, k;
  int n;
  u8 **prev, **cur;

  n = vec_len (orig);
  prev = clib_ptclosure_alloc (n);
  cur = clib_ptclosure_alloc (n);

  clib_ptclosure_copy (prev, orig);

  for (k = 0; k < n; k++)
    {
      for (i = 0; i < n; i++)
	{
	  for (j = 0; j < n; j++)
	    {
	      cur[i][j] = prev[i][j] || (prev[i][k] && prev[k][j]);
	    }
	}
      clib_ptclosure_copy (prev, cur);
    }
  clib_ptclosure_free (prev);
  return cur;
}



/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */