blob: 5ade7e97a506de769355828b07ce11b474729f89 [file]
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// Linux implementation of bind.
///
//===----------------------------------------------------------------------===//
#include "src/sys/socket/bind.h"
#include "hdr/types/socklen_t.h"
#include "hdr/types/struct_sockaddr.h"
#include "src/__support/OSUtil/linux/syscall_wrappers/bind.h"
#include "src/__support/common.h"
#include "src/__support/libc_errno.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, bind,
(int socket, const struct sockaddr *address,
socklen_t address_len)) {
auto result = linux_syscalls::bind(socket, address, address_len);
if (!result.has_value()) {
libc_errno = result.error();
return -1;
}
return result.value();
}
} // namespace LIBC_NAMESPACE_DECL