Fix lack of locking in libc in file and memstream related operations

Spotted by Nadav: libc.threaded field is not set but is used in
several 'if' statements when setting the lock_owner field.

When 'libc.threaded' is false then 'lock_owner' of a FILE is set to a
special value which indicates no locking. This field is initially set
to 0 and the original musl code had a logic which upon creation of the
first thread set it to true and adjusted 'lock_owner' field of all
open files to the value of libc.main_thread.  In OSv we had no such
logic which resulted in no locking of the FILE structure.

This patch fixes the issue by using threaded mode from the very
beginning. We also do not rely anymore on posix thread existence so
that stdlib can be used very early in the boot process without
unexpected behavior. It is used (rightfully or not) for example in
ramdisk_init(). We do not have to hold the pthread id in the
'lock_owner' field because the mutex already tracks the owner and we
can do the check using 'mutex_owned()' function.

This patch also gets rid of a magic value STDIO_SINGLETHREADED, which
is of type pthread_t and was used to disable locking when it was known
to be not necessary. A new field is introduced named 'no_locking'
which serves this purpose.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Introduce test for libc locking

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>