Skip to content

Commit

Permalink
implement getsockname, getpeername, and getaddrinfo
Browse files Browse the repository at this point in the history
This also includes stubs for `gethostbyname`, `gethostbyaddr`, etc. which were
necessary to get CPython to build.  I believe it will be possible to implement
them all properly at some point, but don't have the bandwidth at the moment.

Finally, this includes a few fixes for issues I missed in earlier PRs that
surfaced when running the CPython `asyncio` test suite.

Signed-off-by: Joel Dice <[email protected]>
Co-authored-by: Dave Bakker <[email protected]>
Signed-off-by: Joel Dice <[email protected]>
  • Loading branch information
dicej and badeend committed Mar 28, 2024
1 parent a2ed34e commit a68bfe4
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 1,489 deletions.
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ LIBC_BOTTOM_HALF_OMIT_SOURCES := \
$(LIBC_BOTTOM_HALF_SOURCES)/accept-wasip2.c \
$(LIBC_BOTTOM_HALF_SOURCES)/shutdown.c \
$(LIBC_BOTTOM_HALF_SOURCES)/sockopt.c \
$(LIBC_BOTTOM_HALF_SOURCES)/poll-wasip2.c
$(LIBC_BOTTOM_HALF_SOURCES)/poll-wasip2.c \
$(LIBC_BOTTOM_HALF_SOURCES)/getsockpeername.c \
$(LIBC_BOTTOM_HALF_SOURCES)/netdb.c
LIBC_BOTTOM_HALF_ALL_SOURCES := $(filter-out $(LIBC_BOTTOM_HALF_OMIT_SOURCES),$(LIBC_BOTTOM_HALF_ALL_SOURCES))
# Omit p2-specific headers from include-all.c test.
INCLUDE_ALL_CLAUSES := -not -name wasip2.h -not -name descriptor_table.h
Expand Down Expand Up @@ -245,6 +247,13 @@ LIBC_TOP_HALF_MUSL_SOURCES = \
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/complex/*.c)) \
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/crypt/*.c)

ifeq ($(WASI_SNAPSHOT), p2)
LIBC_TOP_HALF_MUSL_SOURCES += \
$(addprefix $(LIBC_TOP_HALF_MUSL_SRC_DIR)/, \
network/gai_strerror.c \
)
endif

ifeq ($(THREAD_MODEL), posix)
LIBC_TOP_HALF_MUSL_SOURCES += \
$(addprefix $(LIBC_TOP_HALF_MUSL_SRC_DIR)/, \
Expand Down Expand Up @@ -383,6 +392,10 @@ ASMFLAGS += -matomics
CFLAGS += -I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC)
endif

ifeq ($(WASI_SNAPSHOT), p2)
EXTRA_CFLAGS += -D__wasilibc_use_wasip2
endif

# Expose the public headers to the implementation. We use `-isystem` for
# purpose for two reasons:
#
Expand Down Expand Up @@ -495,7 +508,6 @@ MUSL_OMIT_HEADERS += \
"sys/auxv.h" \
"pwd.h" "shadow.h" "grp.h" \
"mntent.h" \
"netdb.h" \
"resolv.h" \
"pty.h" \
"setjmp.h" \
Expand All @@ -519,6 +531,10 @@ MUSL_OMIT_HEADERS += \
"sys/sysmacros.h" \
"aio.h"

ifeq ($(WASI_SNAPSHOT), p1)
MUSL_OMIT_HEADERS += "netdb.h"
endif

ifeq ($(THREAD_MODEL), single)
# Remove headers not supported in single-threaded mode.
MUSL_OMIT_HEADERS += "pthread.h"
Expand Down
Loading

0 comments on commit a68bfe4

Please sign in to comment.