1 // Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ 2 // 3 // SPDX-License-Identifier: BSD-2-Clause 4 5 #include <common/errno.h> 6 7 #include <sys/socket.h> 8 9 #include <assert.h> 10 #include <wasi/api.h> 11 #include <errno.h> 12 13 static_assert(SHUT_RD == __WASI_SDFLAGS_RD, "Value mismatch"); 14 static_assert(SHUT_WR == __WASI_SDFLAGS_WR, "Value mismatch"); 15 shutdown(int socket,int how)16int shutdown(int socket, int how) { 17 // Validate shutdown flags. 18 if (how != SHUT_RD && how != SHUT_WR && how != SHUT_RDWR) { 19 errno = EINVAL; 20 return -1; 21 } 22 23 __wasi_errno_t error = __wasi_sock_shutdown(socket, how); 24 if (error != 0) { 25 errno = errno_fixup_socket(socket, error); 26 return -1; 27 } 28 return error; 29 } 30