Add List.h Macros to be used for operating over a list. Other possible macros & functions to operate on lists should be added here.
--- datapath-windows/ovsext/Core/List.h | 36 ++++++++++++++++++++++++++ datapath-windows/ovsext/ovsext.vcxproj | 1 + datapath-windows/ovsext/ovsext.vcxproj.filters | 3 +++ 3 files changed, 40 insertions(+) create mode 100644 datapath-windows/ovsext/Core/List.h diff --git a/datapath-windows/ovsext/Core/List.h b/datapath-windows/ovsext/Core/List.h new file mode 100644 index 0000000..e751e59 --- /dev/null +++ b/datapath-windows/ovsext/Core/List.h @@ -0,0 +1,36 @@ +/* +Copyright 2014 Cloudbase Solutions Srl + +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. +*/ + +#pragma once + +#define OVS_LIST_FOR_EACH_ENTRY(pos, head, member, typeOfPos) \ + for (pos = CONTAINING_RECORD((head)->Flink, typeOfPos, member);\ + &pos->member != (head); \ + pos = CONTAINING_RECORD(pos->member.Flink, typeOfPos, member)) + +#define OVS_LIST_FOR_EACH(structType, pEntry, pHead) \ + for (pEntry = CONTAINING_RECORD((pHead)->Flink, structType, listEntry); \ + &pEntry->listEntry != (pHead); \ + pEntry = CONTAINING_RECORD(pEntry->listEntry.Flink, structType, listEntry)) + +#define OVS_LIST_REMOVE_ALL(pList, Type, destroyFunc) \ + while (!IsListEmpty((pList))) \ + { \ + LIST_ENTRY* pHeadList = RemoveHeadList((pList)); \ + Type* pItem = CONTAINING_RECORD(pHeadList, Type, listEntry); \ + \ + destroyFunc(pItem); \ + } \ No newline at end of file diff --git a/datapath-windows/ovsext/ovsext.vcxproj b/datapath-windows/ovsext/ovsext.vcxproj index 058bd67..a5f82e6 100644 --- a/datapath-windows/ovsext/ovsext.vcxproj +++ b/datapath-windows/ovsext/ovsext.vcxproj @@ -74,6 +74,7 @@ <ClInclude Include="Core\Error.h" /> <ClInclude Include="Core\IpHelper.h" /> <ClInclude Include="Core\Jhash.h" /> + <ClInclude Include="Core\List.h" /> <ClInclude Include="Core\Types.h" /> <ClInclude Include="Core\Util.h" /> <ClInclude Include="Hyper-V\Oid.h" /> diff --git a/datapath-windows/ovsext/ovsext.vcxproj.filters b/datapath-windows/ovsext/ovsext.vcxproj.filters index 587551a..96f48cf 100644 --- a/datapath-windows/ovsext/ovsext.vcxproj.filters +++ b/datapath-windows/ovsext/ovsext.vcxproj.filters @@ -77,6 +77,9 @@ <ClInclude Include="Core\Error.h"> <Filter>Core</Filter> </ClInclude> + <ClInclude Include="Core\List.h"> + <Filter>Core</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="ovsext.rc" /> -- 1.8.3.msysgit.0 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev