libc: add inet_addr, inet_aton

The code is taken from musl-libc.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: Add support IP socket options

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
virtio-net: enable multicast

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vmxnet3: enable multicast

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
eventfd: add eventfd support

eventfd is an object used for event notification. Eventfd object
maintains a counter, which can be read or written to using normal read
or write system call. Depending on how eventfd is created, read may
either wipe out counter or reduce it by 1. If a read or write cannot be
services immediately then the execution is blocked until an event
occurs to unblock the execution. For example: read on eventfd would be
blocked if the counter is 0, similarly write on it would be blocked if
counter is ULLONG_MAX-1. Writing to an eventfd unblocks any reader
waiting for it.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: add eventfd unit test

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Remove unnecessary #include

Remove an include of "api/assert.h" from osv/debug.hh. This was not
only unnecessary, it also needlessly causes problems when a program
(such as the httpserver module) combines the host header files and OSv's,
and both <assert.h> and "api/assert.h" end up being used, and they have
a slightly different definition of __assert_fail.

This include was added in commit b40cb27a but I don't know why.
It doesn't seem needed.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: Add API for iterating over all threads

We currently don't provide any method of iterating over all threads (something
which, "top" would like to do, for example). thread_map and thread_map_mutex
are private to sched.cc, and should stay that way.

So this patch provides a new function with_all_friends(f), which iterates
over all threads and calls the given std::function for each one. The
function is supposed to be safe (a thread will not be freed while someone
is running f on it), but it is inefficient as it holds thread_map_mutex
throughout the entire iteration, so it should currently only be used for
debugging purposes, e.g., for implementing "top".

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
random: hw source of entropy should be conditionally registered

The hardware source of entropy should be only registered when
available, e.g. virtio-rng.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
random: Avoid uneeded buffer allocation/deletion

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>