Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Apr 5, 2024
1 parent d186ea4 commit f172de1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bee/net/fd.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#ifdef _WIN32
#if defined(_WIN32)
# include <cstdint>
#endif

namespace bee::net {
#if defined _WIN32
#if defined(_WIN32)
using fd_t = uintptr_t;
#else
using fd_t = int;
Expand Down
20 changes: 10 additions & 10 deletions bee/net/socket.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if defined _WIN32
#if defined(_WIN32)
// clang-format off
# include <winsock2.h>
// clang-format on
Expand Down Expand Up @@ -246,7 +246,7 @@ namespace bee::net::socket {
#endif

bool close(fd_t s) noexcept {
#if defined _WIN32
#if defined(_WIN32)
const int ok = ::closesocket(s);
#else
const int ok = ::close(s);
Expand Down Expand Up @@ -339,7 +339,7 @@ namespace bee::net::socket {
case protocol::udp6:
return createSocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP, flags);
case protocol::unix:
#if defined _WIN32
#if defined(_WIN32)
if (!supportUnixDomainSocket()) {
return createSocket(PF_INET, SOCK_STREAM, IPPROTO_TCP, flags);
}
Expand Down Expand Up @@ -390,7 +390,7 @@ namespace bee::net::socket {
}

void udp_connect_reset(fd_t s) noexcept {
#if defined _WIN32
#if defined(_WIN32)
DWORD byte_retruned = 0;
bool new_be = false;
::WSAIoctl(s, SIO_UDP_CONNRESET, &new_be, sizeof(new_be), NULL, 0, &byte_retruned, NULL, NULL);
Expand All @@ -400,7 +400,7 @@ namespace bee::net::socket {
}

bool bind(fd_t s, const endpoint& ep) {
#if defined _WIN32
#if defined(_WIN32)
if (!supportUnixDomainSocket() && ep.family() == AF_UNIX) {
return u_bind(s, ep);
}
Expand All @@ -415,7 +415,7 @@ namespace bee::net::socket {
}

fdstat connect(fd_t s, const endpoint& ep) {
#if defined _WIN32
#if defined(_WIN32)
if (!supportUnixDomainSocket() && ep.family() == AF_UNIX) {
return u_connect(s, ep);
}
Expand All @@ -425,7 +425,7 @@ namespace bee::net::socket {
return fdstat::success;
}

#if defined _WIN32
#if defined(_WIN32)
const int error_code = ::WSAGetLastError();
if (error_code == WSAEINPROGRESS || error_code == WSAEWOULDBLOCK)
return fdstat::wait;
Expand Down Expand Up @@ -462,7 +462,7 @@ namespace bee::net::socket {
fdstat accept(fd_t s, fd_t& newfd, fd_flags fd_flags) noexcept {
newfd = acceptEx(s, fd_flags, NULL, NULL);
if (newfd == retired_fd) {
#if defined _WIN32
#if defined(_WIN32)
return fdstat::failed;
#else
if (errno != EAGAIN && errno != ECONNABORTED && errno != EPROTO && errno != EINTR) {
Expand Down Expand Up @@ -555,7 +555,7 @@ namespace bee::net::socket {
if (type != (uint16_t)un_format::pathname) {
return false;
}
#if defined _WIN32
#if defined(_WIN32)
return win::unlink(win::u2w(path).c_str());
#else
return 0 == ::unlink(path.c_str());
Expand All @@ -573,7 +573,7 @@ namespace bee::net::socket {
}

#if defined(_WIN32)
bool unnamed_unix_bind(fd_t s) {
static bool unnamed_unix_bind(fd_t s) {
char tmpdir[MAX_PATH];
int bind_try = 0;
for (;;) {
Expand Down
2 changes: 1 addition & 1 deletion binding/lua_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace bee::lua_platform {
#endif
lua_setfield(L, -2, "Arch");

#ifdef NDEBUG
#if defined(NDEBUG)
lua_pushboolean(L, 0);
#else
lua_pushboolean(L, 1);
Expand Down
2 changes: 1 addition & 1 deletion binding/lua_select.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <bee/lua/binding.h>
#include <binding/binding.h>
#if defined _WIN32
#if defined(_WIN32)
# include <winsock.h>
#else
# include <sys/select.h>
Expand Down

0 comments on commit f172de1

Please sign in to comment.