runjava.jar: build jar using ant

Building with ant requires no changes in the build scripts
when new classes are added. It is a standrd tool to build
java programs.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
RunJava: system class loader should contain application resources

The system classloader should have classes which were
specified in the command line using -cp/-classpath/-jar.
Before this change only runjava.jar was included.

System class loader is queried explicitly by
java.util.logging framework to lookup classes
configred in logging properties file.

To solve this problem a custom system classloader
is set when starting JVM. It delegates to the application
classloader created when java program was started.

It also handles the case when a new java application
is started within the same JVM. Such application
should have its own view of system classes. However
we are able to install only one system classloader
per JVm. To solve this we start each java application
in a separate thread and use InheritableThreadLocal
to hold the application class loader which should be
used as system class loader view for the thread family.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
runjava: move runjava.jar code to a separate directory

Related changes previously made in java/build.xml
were reverted and moved to java/runjava/build.xml

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
runjava: Set source level to 1.7

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
mmu: optimize searching for vmas

Currently we search the entire vma list while looking for a range.  This
is less than optimal.

Define a vma::addr_compare function object that can be used as comparator
with boost::rbtree::equal_range(), and use that to search for both bounds
simultaneously.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
elf: implement tls for shared objects

Unlike tls for the main module, which simply offsets fs:0, shared object
use an indirection scheme since each module gets its own tls base address,
which needs to be found (and initialized) via __get_tls_addr()

Implement __get_tls_addr() and the associated relocation and storage
management.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: build core/run.cc

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
run: add helper for running with a vector<string> argv

Much easier than constructing a traditional argc/argv.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Fix build with GNU Make < 3.82

The 'define' form with '=' was introduced in GNU Make 3.82
and has the same meaning as without.

The default 'make' in Ubuntu 13.04 is stil on 3.81. Let's
drop '=' for better compatibility.

Symptoms:
 make[1]: Entering directory `~/src/osv/build/release'
      CC bsd/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.o
    ../../bsd/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c:28:21:\
 fatal error: solaris.h: No such file or     directory
     #include <solaris.h>
                         ^
    compilation terminated.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
run: save optind across invocations

optind is a global variable that is expected to be zero-initialized by
getopt().  Running one object after another violates this, if both use
getopt().

Fix by saving the value of optind across calls.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Merge branch 'run-fixes'

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: implement sync()

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: define mbstate_t as __mbstate_t

std::streambuf<char> is defined as an "extern template", which means it is
instantiated in the library, not at the point-of-use, in order to reduce
object size and compilation time.

One of its member functions, std::basic_streambuf::seekpos(...) has a
parameter whose type depends on mbstate_t; this embeds the type name into
the mangled function name.

On Linux, mbstate_t is a typedef for __mbstate_t, so the latter type name
is embedded into the mangled function name.  On osv, there is no such typedef,
so mbstate_t is embedded.  This causes lookup to fail when loading a shared
object that uses streambufs.

Fix by defining mbstate_t in the same way as glibc.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: stub eventfd()

Needed by boost.asio.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc: implement epoll_create1()

It's a superset of epoll_create(), so implement the latter in terms of the
former.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
run: switch to cache=none

More realistic.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
run: allow forwarding tcp ports in run.py

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
imgedit: fix large partition chs

Large partitions set head=254, not 255.  Also be more accurate calculating
the exact point of overflow.
build: package zfs.so (the zfs utility) in bootfs

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mkfs: Add stub mkfs()

For the moment, it only creates a zpool, not a filesystem.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>