2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 12:58:00 +00:00

8 Commits

Author SHA1 Message Date
Ben Pfaff
994bfc2985 Automatically verify that OVS header files work OK in C++ also.
This should help address a recurring problem.

This change makes the OVS header files, when parsed by a C++ compiler,
require C++11 or later.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
2017-07-31 16:03:38 -07:00
Ben Pfaff
cc3ef00887 compiler: Use C11 build assertions with new enough GCC or Clang.
Until now, the BUILD_ASSERT and BUILD_ASSERT_DECL macros have used OVS's
home-grown build assertion strategy.  This commit switches them to using
C11 build assertions with compilers that support them.  The semantics are
the same, but C11 build assertions yield clearer error messages when they
fail.

This commit also reorders the definitions a bit to make it easier to
follow.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
2017-03-16 21:01:54 -07:00
Ben Pfaff
b70e697679 cmap: New macro CMAP_INITIALIZER, for initializing an empty cmap.
Sometimes code is much simpler if we can statically initialize data
structures.  Until now, this has not been possible for cmap-based data
structures, so this commit introduces a CMAP_INITIALIZER macro.

This works by adding a singleton empty cmap_impl that simply forces the
first insertion into any cmap that points to it to allocate a real
cmap_impl.  There could be some risk that rogue code modifies the
singleton, so for safety it is also marked 'const' to allow the linker to
put it into a read-only page.

This adds a new OVS_ALIGNED_VAR macro with GCC and MSVC implementations.
The latter is based on Microsoft webpages, so developers who know Windows
might want to scrutinize it.

As examples of the kind of simplification this can make possible, this
commit removes an initialization function from ofproto-dpif-rid.c and a
call to cmap_init() from tnl-neigh-cache.c.  An upcoming commit will add
another user.

CC: Jarno Rajahalme <jarno@ovn.org>
CC: Gurucharan Shetty <guru@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
2016-05-09 16:42:56 -07:00
Ben Warren
b44aaaaff8 Misc cleanup with "util.h" header files
Removed redundant #includes and moved some macros to different file
scope

Signed-off-by: Ben Warren <ben@skyportsystems.com>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-04-14 10:17:25 -07:00
Ben Warren
3467a4d3d3 util: Move build assertion macros to compiler.h.
Signed-off-by: Ben Warren <ben@skyportsystems.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-03-30 13:25:26 -07:00
Ben Pfaff
4b7396908d compiler: Don't require constructor names to be globally unique in MSVC.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
2016-02-10 18:08:16 -08:00
Ben Pfaff
08e50968df compiler: Document OVS_CONSTRUCTOR.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
2016-02-10 18:08:06 -08:00
Thomas Graf
cab5044987 lib: Move compiler.h to <openvswitch/compiler.h>
The following macros are renamed to avoid conflicts with other headers:
 * WARN_UNUSED_RESULT to OVS_WARN_UNUSED_RESULT
 * PRINTF_FORMAT to OVS_PRINTF_FORMAT
 * NO_RETURN to OVS_NO_RETURN

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-12-15 14:14:47 +01:00