]> git.proxmox.com Git - wasi-libc.git/blame - libc-bottom-half/cloudlibc/src/libc/sys/socket/shutdown.c
Fix missing errno assignments.
[wasi-libc.git] / libc-bottom-half / cloudlibc / src / libc / sys / socket / shutdown.c
CommitLineData
320054e8
DG
1// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
2//
3// SPDX-License-Identifier: BSD-2-Clause
4
320054e8
DG
5#include <sys/socket.h>
6
7#include <assert.h>
446cb3f1 8#include <wasi/api.h>
320054e8
DG
9#include <errno.h>
10
446cb3f1
DG
11static_assert(SHUT_RD == __WASI_SDFLAGS_RD, "Value mismatch");
12static_assert(SHUT_WR == __WASI_SDFLAGS_WR, "Value mismatch");
320054e8
DG
13
14int shutdown(int socket, int how) {
15 // Validate shutdown flags.
16 if (how != SHUT_RD && how != SHUT_WR && how != SHUT_RDWR) {
17 errno = EINVAL;
18 return -1;
19 }
20
21 __wasi_errno_t error = __wasi_sock_shutdown(socket, how);
22 if (error != 0) {
099caae3 23 errno = error;
320054e8
DG
24 return -1;
25 }
26 return error;
27}