bionic's numbers and layouts are Linux's, so on Linux most of libc passes to the host as it is. The bridge also builds for FreeBSD, macOS and Windows x64, where they differ:
bridge/host.c's, one branch for each host: the code window's reservation at its
fixed address (MAP_FIXED_NOREPLACE on Linux, MAP_GUARD | MAP_FIXED | MAP_EXCL on FreeBSD, a hint that must hold
on macOS, VirtualAlloc(MEM_RESERVE) on Windows), the table and the stacks as lazy memory, a thread's id, pread,
the kernel's checked copies of guest memory (process_vm_readv on Linux, mach_vm_read_overwrite on macOS, a pipe
on FreeBSD, ReadProcessMemory on Windows) and an epoll set (epoll, kqueue, or WSAPoll over sockets)./proc files everywhere, as an Android device shows them (hle_proc.c): cmdline (the package),
comm, status (no tracer), stat, maps (the guest's libraries) and the exe link (app_process64), of
/proc/self and the app's pid. A Unity game's protection reads cmdline, status and exe, and when they fail
(FreeBSD mounts no /proc) it goes on with a wrong key: its asset headers decrypted into garbage and it crashed.
On Linux it read the JVM's own. Other /proc paths are the host's.rand and random everywhere: the BSD additive feedback generator that bionic's and glibc's rand are,
in the bridge, as FreeBSD's and macOS's rand are other generators. A game that seeds it with a constant and makes a
decryption's key from its numbers needs this sequence: with FreeBSD's, a Unity game decrypted its asset headers
into garbage and crashed on a self-relative offset in one.MADV_DONTNEED everywhere: a private anonymous range reads as zero pages again after it. Garbage collectors
hand such pages out again as zero memory: a Unity game's il2cpp collector did, and on FreeBSD, whose advice keeps
the contents, a string builder's first chunk got a stale field for its null link and the game crashed in managed
code. The HLE of mmap, mprotect and munmap records the guest's private anonymous mappings with their access,
and host_dontneed maps fresh zero pages over the recorded parts (a new anonymous MAP_FIXED mapping, or a decommit
and commit on Windows). Linux keeps its own advice.gnu_host_errno, gnuabi/kernel/errno.c). strerror, strerror_r, perror
and %m give bionic's texts (hle_error_text): the host C library's are other words, in the user's language.
libm's functions (hle_libm.c) leave it as it was, as bionic's do (its math_errhandling is MATH_ERREXCEPT),
where the host's may set it (glibc's log(0) sets ERANGE).hle_libm.c) has every function of double and float, and of their complex numbers, that bionic's has:
the host's, and bionic's own where they differ or the host lacks one. ilogb gives bionic's FP_ILOGB0 and
FP_ILOGBNAN (-INT_MAX and INT_MAX, where glibc's on x86 are INT_MIN), remquo 31 bits of the quotient (glibc's
3), nan the tag's digits as msun reads them, lgamma its sign in bionic's signgam; rint, nearbyint,
lrint and llrint round as the guest's FPCR
says, and a conversion out of range saturates as FCVTZS does, with FPSR's flags. lround, fmax and fmin are
AArch64's FCVTAS, FMAXNM and FMINNM (+0 above -0), and a NaN made from numbers (sqrt(-1)) is AArch64's
default NaN, whose sign is clear where x86's is set. fenv.h's functions read and write the guest's FPCR and FPSR
in bionic's numbers (FE_INEXACT is 0x10, FE_UPWARD 1), and traps are refused, as Android's kernel enables none.
bionic's functions of long double, IEEE's quadruple precision on AArch64, are not there: no host type holds one.setlocale, newlocale and uselocale are bionic's (hle_libc.c): a name only sets MB_CUR_MAX, 4 or 1, a
locale_t is bionic's struct of it, and the host's locale is never set. The host's is the user's, which the JVM
sets for the process (a decimal comma, other names of days, other words), so a host call into guest code
(bridge_call) runs its thread in the C locale until it returns: C.UTF-8 on Linux, whose multibyte functions
serve the guest's. Windows' C runtime keeps the C locale, as no part of the process sets another.gnuabi/abi/file.h
(struct stat, the open flags), gnuabi/abi/net.h (families, flags, options, sockaddr_in and sockaddr_in6)
and common/network/net_host.h (the stack's constants as the host's). The adapters in hle_posix.c also convert
the mmap and msync flags, fcntl's commands and struct flock, the requests of ioctl, struct dirent, struct
statfs and the poll events. getaddrinfo, getnameinfo and gethostbyname are the stack's on every host, whose
flags and errors are bionic's. Offline (the Network setting), another machine's name is EAI_NODATA, as Android
answers without a network. localhost is 127.0.0.1 alone, once, as Android's hosts file has it (::1 is
ip6-localhost there).hle_thread.c).SIGRTMIN + 4 on Linux and FreeBSD (tgkill,
thr_kill) and SIGUSR1 on macOS (pthread_kill), which HotSpot leaves alone on each (it takes SIGSEGV,
SIGBUS, SIGFPE, SIGILL, SIGPIPE, SIGQUIT and SIGUSR2). Windows has no signals: an APC, which runs only
when the thread waits alertably. A thread in another wait takes its signal as its HLE call returns.hle_call takes a function's parameter classes: the four JNI
functions that set a float or double field, and the five Vulkan commands with a float parameter (vulkan_core.h).
long is 32 bits there (strtol is strtoll, ftell is _ftelli64) and wchar_t 16 (the wide functions are
the bridge's, in UTF-8 as bionic's). The CRT's free takes only malloc's blocks, so a block aligned past 16 bytes
is kept in a table. mmap is VirtualAlloc and file views. select, socketpair, readlink, fchmod and
alarm report ENOSYS or EOPNOTSUPP, and a socket is a Winsock SOCKET, which read, write and close tell
from a CRT descriptor.FreeBSD's and macOS's branches are written from those systems' manuals and have not been compiled. Windows' files
compile with clang --target=x86_64-w64-mingw32 -fsyntax-only and the mingw-w64 headers.
Made from docs/platforms/android-apps/native.md at 69237645142c. GPL-3.0-or-later.