Add Cosmopolitan Libc Platform (#2598)

This PR adds the Cosmopolitan Libc platform enabling compatibility with multiple
x86_64 operating systems with the same binary. The platform is similar to the
Linux platform, but for now only x86_64 with interpreter modes are supported.

The only major change to the core is `posix.c/convert_errno()` was rewritten to use
a switch statement. With Cosmopolitan errno values depend on the currently
running operating system, and so they are non-constant and cannot be used in array
designators. However, the `cosmocc` compiler allows non-constant case labels in
switch statements, enabling the new version.

And updated wamr-test-suites script to add `-j <platform>` option. The spec tests
can be ran via `CC=cosmocc ./test_wamr.sh -j cosmopolitan -t classic-interp`
or `CC=cosmocc ./test_wamr.sh -j cosmopolitan -t fast-interp`.
This commit is contained in:
Gavin Hayes
2023-10-04 09:55:37 -04:00
committed by GitHub
parent 8987432f36
commit d8ee771e28
11 changed files with 512 additions and 94 deletions

View File

@ -799,7 +799,7 @@ os_socket_set_ip_add_membership(bh_socket_t socket,
{
assert(imr_multiaddr);
if (is_ipv6) {
#ifdef IPPROTO_IPV6
#if defined(IPPROTO_IPV6) && !defined(BH_PLATFORM_COSMOPOLITAN)
struct ipv6_mreq mreq;
for (int i = 0; i < 8; i++) {
((uint16_t *)mreq.ipv6mr_multiaddr.s6_addr)[i] =
@ -837,7 +837,7 @@ os_socket_set_ip_drop_membership(bh_socket_t socket,
{
assert(imr_multiaddr);
if (is_ipv6) {
#ifdef IPPROTO_IPV6
#if defined(IPPROTO_IPV6) && !defined(BH_PLATFORM_COSMOPOLITAN)
struct ipv6_mreq mreq;
for (int i = 0; i < 8; i++) {
((uint16_t *)mreq.ipv6mr_multiaddr.s6_addr)[i] =