shared/hashmap.h: fix comment

An early version used underscore prefixes for internal functions, but
the current version uses the prefix "internal_".
configure.ac: add a generic --enable-debug, replace --enable-hashmap-debug

There will be more debugging options later.
 --enable-debug will enable them all.
 --enable-debug=hashmap will enable only hashmap debugging.

Also rename the C #define to ENABLE_DEBUG_* pattern.
journal: add debug mode for mmap-cache (--enable-debug=mmap-cache)

This is useful for exposing unsafe access to mmapped objects after
the context that they were mapped in was already moved.

For example:
journal_file_move_to_object(f1, OBJECT_DATA, p1, &o1);
journal_file_move_to_object(f2, OBJECT_DATA, p2, &o2);
t = o1->object.type; /* this usually works, but is unsafe */
journal: map objects to context set by caller, not by actual object type

When the caller of journal_file_move_to_object() specifies type==0,
the object header is at first mapped in context 0. Then after the header
is checked, the whole object is mapped in a context determined by
the actual object type (which is not even range-checked using
type_to_context()). This looks wrong. It should map in the
caller-specified context.

An old comment in sd_journal_enumerate_unique() supports this view:
    /* We do not use the type context here, but 0 instead,
     * so that we can look at this data object at the same
     * time as one on another file */
Clearly the expectation was that the data object will remain mapped
in context 0 without being pushed away by mapping other objects in
context OBJECT_DATA.

I suspect that this was the real bug that got fixed by ae97089d49
"journal: fix access to munmapped memory in sd_journal_enumerate_unique".
In other words, journal_file_object_keep/release are superfluous after
applying this patch.
journal: remove journal_file_object_keep/release functions

The only user is sd_journal_enumerate_unique() and, as explained in
the previous commit (fed67c38e3 "journal: map objects to context set by
caller, not by actual object type"), the use of them there is now
superfluous. Let's remove them.

This reverts major parts of commits:
  ae97089d49 journal: fix access to munmapped memory in
             sd_journal_enumerate_unique
  06cc69d44c sd-journal: fix sd_journal_enumerate_unique skipping values

Tested with an "--enable-debug" build and "journalctl --list-boots".
It gives the expected number of results. Additionally, if I then revert
the previous commit ("journal: map objects to context set by caller, not
to actual object type"), it crashes with SIGSEGV, as expected.
journal: move type_to_context() to journal-file.c

It has no other callers. It does not need to be in the header file.
journal: consistently allow type==0 to mean "any type"

If type==0 and a non-NULL object were given as arguments to
journal_file_hmac_put_object(), its object type check would fail and it
would return -EBADMSG.

All existing callers use either a positive type or -1. Still, for
behavior consistency with journal_file_move_to_object() let's allow
type 0 to pass.
journal: consistently use OBJECT_<type> names instead of numbers

Note that numbers 0 and -1 are both replaced with OBJECT_UNUSED,
because they are treated the same everywhere (e.g. type_to_context()
translates them both to 0).
journal: have a named enum ObjectType
journal: push type_to_context conversion down to journal_file_move_to()
journal: delete unused function mmap_cache_close_context

This never had any callers. Contexts are freed when the MMapCache is
freed.
journal: replace contexts hashmap with a plain array

try_context() is such a hot path that the hashmap lookup is expensive.

The number of contexts is small - it is the number of object types.
Using a hashmap is overkill. A plain array will do.

Before:
$ time ./journalctl --since=2014-06-01 --until=2014-07-01 > /dev/null

real    0m9.445s
user    0m9.228s
sys     0m0.213s

After:
$ time ./journalctl --since=2014-06-01 --until=2014-07-01 > /dev/null
real    0m5.438s
user    0m5.266s
sys     0m0.170s