configure: Include pthread-win32 libraries for Windows build.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Signed-off-by: Saurabh Shah <ssaurabh@vmware.com>
Co-authored-by: Saurabh Shah <ssaurabh@vmware.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovsdb: Do not look for symbolic links for db creation in Windows.

We start with not supporting symbolic links for database
creation in Windows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
stdio: fseeko for Windows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovsdb: fsync() for Windows.

There is no fsync() in Windows. But there is a _commit()
which does the same thing.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
windows/netinet: Add some #defines needed for Windows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
bfd: Remove unnecessary include of netlink header.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
.gitignore: Ignore visual studio created files.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofp-actions: Relax build assertion condition for ofpact_nest struct.

struct ofpact has enums that are packed in case of __GNUC__.
This packing does not occur for visual studio. For 'struct ofpact_nest',
we are currently expecting that "struct ofpact actions[]" has an offset of
8 bytes.  This condition won't be true in compilers where enums are
not packed.

It is good enough if struct ofpact actions[] starts at an offset which is
a multiple of OFPACT_ALIGNTO.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
BUILD.Windows: Build idl headers separately.

idl headers won't be built, if we build individual executables
e..g., "make ovsbd/ovsdb-server.exe". According to
http://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html
we may have to add the headers as dependecies for every executables.

Currently the lack of a ovs-appctl port to Windows prevents us from
running just a "make". We plan to get ovs-appctl port done soon. Till
then, call out that the idl headers need to be built separately.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
timeval: Sleep instead of poll().

The WSAPoll() function, which is similar to poll() doesnot
simply sleep when the fd array is NULL. So use Sleep() instead.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
automake: Use route-table-stub for Windows.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
stream-fd-windows: Fix compilation error.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
netdev-vport: Don't look for ovs-monitor-ipsec's pid file.

We do not have pidfiles in Windows. And we do not yet have support
for ipsec tunnels. This lets us move forward with compilation.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovs-atomic-gcc4+: Fix parenthesization in atomic_read_explicit().

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
compiler: New macro for defining aligned structs.

This is broken out into a separate commit because it adds new MSVC
specific code and I don't have MSVC around to test whether it's correct.

CC: Gurucharan Shetty <gshetty@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
util: New macro PAD_SIZE.

PAD_SIZE(x,y) is a little shorter and may have a more obvious meaning
than ROUND_UP(x,y) - x.

I intend to add more users in an upcoming comment.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
util: Move CACHE_LINE_SIZE here.

It will come in handy elsewhere in upcoming commits.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
ovs-atomic: Factor type declarations out of most implementations.

This reduces duplicate code.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
ovs-atomic: Use raw types, not structs, when locks are required.

Until now, the GCC 4+ and pthreads implementations of atomics have used
struct wrappers for their atomic types.  This had the advantage of allowing
a mutex to be wrapped in, in some cases, and of better type-checking by
preventing stray uses of atomic variables other than through one of the
atomic_*() functions or macros.  However, the mutex meant that an
atomic_destroy() function-like macro needed to be used.  The struct wrapper
also made it impossible to define new atomic types that were compatible
with each other without using a typedef.  For example, one could not simply
define a macro like
    #define ATOMIC(TYPE) struct { TYPE value; }
and then have two declarations like:
    ATOMIC(void *) x;
    ATOMIC(void *) y;
and do anything with these objects that require type-compatibility, even
"&x == &y", because the two structs are not compatible.  One can do it
through a typedef:
    typedef ATOMIC(void *) atomic_voidp;
    atomic_voidp x, y;
but that is inconvenient, especially because of the need to invent a name
for the type.

This commit aims to ease the problem by getting rid of the wrapper structs
in the cases where the atomic library used them.  It gets rid of the
mutexes, in the cases where they are still needed, by using a global
array of mutexes instead.

This commit also defines the ATOMIC macro described above and documents
its use in ovs-atomic.h.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
ovs-atomic-pthreads: Use global shared locks for atomic_flag also.

This will eliminate the need for atomic_flag_destroy().

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>