Using SHORT version of the *_SAFE loops makes the code cleaner and less
error prone. So, use the SHORT version and remove the extra variable
when possible for hmap and all its derived types.
In order to be able to use both long and short versions without changing
the name of the macro for all the clients, overload the existing name
and select the appropriate version depending on the number of arguments.
Acked-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
While trying to benchmark big functions, values could be longer than
12 digits. In this case all of them printed without spaces. It's
hard ot read.
Fixes: 619c3a42dc ("lib: add a hardware performance counter access library")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Greg Rose <gvrose8192@gmail.com>
cgcc, the "sparse" wrapper that OVS uses, can be told the host architecture
or the host OS or both. Until now, OVS has told it the host architecture
because it is fairly common that it doesn't guess it automatically. Until
now, OS has not told it the host OS, assuming that it would get it right.
However, it doesn't--if you tell it the host OS or the host architecture,
it doesn't really have a default for the other. This means that on Linux
(presumably the only OS where sparse works properly for OVS), it was not
defining __linux__, which caused some weird behavior.
This commit adds a flag to the cgcc invocation to make it define __linux__
on Linux, and it fixes some errors that this would otherwise cause.
Acked-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
AC_LANG_PROGRAM(,) uses a program like this:
int main() { return 0; }
but that triggers warnings for -Wstrict-prototypes and for
-Wold-style-definition, since this definition of main() lacks a prototype
and is therefore old-style. This meant that -Wstrict-prototypes and
-Wold-style-definition weren't being turned on for new-enough GCC. This
commit fixes the problem by changing the program that is test-compiled to:
int x;
which doesn't make any compilers mad, as far as I know.
I recently upgraded to GCC 6.1 and just now noticed the issue, so I think
that GCC somewhere between version 4.9 and version 6.1 must have started
warning about main() when it's declared this way.
Also, fix a few functions that lacked prototypes.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
To easily allow both in- and out-of-tree building of the Python
wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to
include/openvswitch. This also requires moving lib/{hmap,shash}.h.
Both hmap.h and shash.h were #include-ing "util.h" even though the
headers themselves did not use anything from there, but rather from
include/openvswitch/util.h. Fixing that required including util.h
in several C files mostly due to OVS_NOT_REACHED and things like
xmalloc.
Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Private variable perf_counters needs to be initialized before
use. Otherwise, perf_counter_init() call will cause crashes.
Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Unit tests "corrupted database log" and "database log with bad
transaction" will fail without this patch.
Reported-by: Ansis Atteka <aatteka@nicira.com>¬
Signed-off-by: Andy Zhou <azhou@nicira.com>
Older Linux prior to version 2.6.32 do not support user mode
performance events, They also don't have 'linux/perf_event.h' header
file. Add check for those older Linux to conditionally compile
perf-counter.c
Reported-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
'size_t' does not allow for catching the case where 'read' returns
an error code, which is a negative number.
Reported-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
Fixes the following warnings from GCC on 32-bit architectures:
../lib/perf-counter.c: In function 'perf_counter_to_ds':
../lib/perf-counter.c:119:19: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t' [-Werror=format]
../lib/perf-counter.c:119:19: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'uint64_t' [-Werror=format]
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
Some arches don't support perf counter and an error message
breaks many tests from the testsuite. Since the software still
runs without it, just inform that perf counters are not available
with using INFO level instead.
Signed-off-by: Flavio Leitner <fbl@redhat.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
[blp@nicira.com removed unneeded \n from log message]
Signed-off-by: Ben Pfaff <blp@nicira.com>
First cut of adding a performance library that provides access to
hardware counters. Please see comments in perf-counter.h for
more details.
Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>