wasi-libc/libc-bottom-half/cloudlibc/src/libc/sys/socket/shutdown.c
Dan Gohman cab0ec601e Remove __wasilibc_unmodified_upstream markers from libc-bottom-half.
We've already started removing this; this just removes all remaining
ones under the libc-bottom-half directory.

These markers were originally intended to help track upstream changes,
however in practice they created a lot of clutter and weren't that
helpful. And now, upstream cloudlibc is no longer active.
2021-02-04 21:22:15 -08:00

30 lines
668 B
C

// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
//
// SPDX-License-Identifier: BSD-2-Clause
#include <common/errno.h>
#include <sys/socket.h>
#include <assert.h>
#include <wasi/api.h>
#include <errno.h>
static_assert(SHUT_RD == __WASI_SDFLAGS_RD, "Value mismatch");
static_assert(SHUT_WR == __WASI_SDFLAGS_WR, "Value mismatch");
int shutdown(int socket, int how) {
// Validate shutdown flags.
if (how != SHUT_RD && how != SHUT_WR && how != SHUT_RDWR) {
errno = EINVAL;
return -1;
}
__wasi_errno_t error = __wasi_sock_shutdown(socket, how);
if (error != 0) {
errno = errno_fixup_socket(socket, error);
return -1;
}
return error;
}