Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete code - PS5 support for the socket API differences #4153

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 1 addition & 111 deletions starboard/shared/modular/starboard_layer_posix_socket_abi_wrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#include <stdlib.h>
#include <string.h>

#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH)
#include <net.h>
#endif
#include "starboard/log.h"

namespace {
Expand Down Expand Up @@ -132,57 +129,20 @@ int platform_hints_to_musl_hints(const struct addrinfo* hints,
SB_EXPORT int __abi_wrap_accept(int sockfd,
musl_sockaddr* addr,
socklen_t* addrlen_ptr) {
#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH)
if (addr != nullptr) {
struct sockaddr new_addr = {};
new_addr.sa_family = addr->sa_family;
new_addr.sa_len = 0;
memcpy(new_addr.sa_data, addr->sa_data, 14);
addr = reinterpret_cast<musl_sockaddr*>(&new_addr);
}
#endif
return accept(sockfd, reinterpret_cast<struct sockaddr*>(addr), addrlen_ptr);
}

SB_EXPORT int __abi_wrap_bind(int sockfd,
const musl_sockaddr* addr,
socklen_t addrlen) {
#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH)
if (addr != nullptr) {
struct sockaddr new_addr = {};
new_addr.sa_family = addr->sa_family;
new_addr.sa_len = 0;
memcpy(new_addr.sa_data, addr->sa_data, 14);
return bind(sockfd, reinterpret_cast<const struct sockaddr*>(&new_addr),
addrlen);
} else {
return bind(sockfd, reinterpret_cast<const struct sockaddr*>(addr),
addrlen);
}
#else
return bind(sockfd, reinterpret_cast<const struct sockaddr*>(addr), addrlen);
#endif
}

SB_EXPORT int __abi_wrap_connect(int sockfd,
const musl_sockaddr* addr,
socklen_t addrlen) {
#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH)
if (addr != nullptr) {
struct sockaddr new_addr = {};
new_addr.sa_family = addr->sa_family;
new_addr.sa_len = 0;
memcpy(new_addr.sa_data, addr->sa_data, 14);
return connect(sockfd, reinterpret_cast<const struct sockaddr*>(&new_addr),
addrlen);
} else {
return connect(sockfd, reinterpret_cast<const struct sockaddr*>(addr),
addrlen);
}
#else
return connect(sockfd, reinterpret_cast<const struct sockaddr*>(addr),
addrlen);
#endif
}

SB_EXPORT int __abi_wrap_getaddrinfo(const char* node,
Expand Down Expand Up @@ -276,21 +236,6 @@ SB_EXPORT void __abi_wrap_freeaddrinfo(struct musl_addrinfo* ai) {

SB_EXPORT int __abi_wrap_getifaddrs(struct ifaddrs** ifap) {
int result = getifaddrs(ifap);
#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH)
struct ifaddrs* ptr = *ifap;
struct ifaddrs* last_ptr = ptr;
while (ptr != nullptr) {
if (ptr->ifa_addr != nullptr) {
musl_sockaddr* musl_addr_ptr =
reinterpret_cast<musl_sockaddr*>(ptr->ifa_addr);
struct sockaddr* addr_ptr =
reinterpret_cast<struct sockaddr*>(ptr->ifa_addr);
uint8_t sa_family = addr_ptr->sa_family;
musl_addr_ptr->sa_family = sa_family;
}
ptr = ptr->ifa_next;
}
#endif
return result;
}

Expand All @@ -302,60 +247,5 @@ SB_EXPORT int __abi_wrap_setsockopt(int socket,
if (socket <= 0) {
return -1;
}
int is_supported = 1;

#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH)

// The value from POSIX
#define MUSL_SOL_SOCKET 1 // level
#define MUSL_SO_REUSEADDR 2
#define MUSL_SO_RCVBUF 8
#define MUSL_SO_SNDBUF 7
#define MUSL_SO_KEEPALIVE 9

#define MUSL_SOL_TCP 6 // level
#define MUSL_TCP_NODELAY 1
#define MUSL_TCP_KEEPIDLE 4
#define MUSL_TCP_KEEPINTVL 5

#define MUSL_IPPROTO_TCP 6 // level

if (level == MUSL_SOL_SOCKET) {
level = SOL_SOCKET;
switch (option_name) {
case MUSL_SO_REUSEADDR:
option_name = SO_REUSEADDR;
break;
case MUSL_SO_RCVBUF:
option_name = SO_RCVBUF;
break;
case MUSL_SO_SNDBUF:
option_name = SO_SNDBUF;
break;
case MUSL_SO_KEEPALIVE:
is_supported = 0;
break;
default:
is_supported = 0;
}
}
if (level == MUSL_IPPROTO_TCP) {
level = IPPROTO_TCP;
switch (option_name) {
case MUSL_TCP_NODELAY:
option_name = SCE_NET_TCP_NODELAY;
break;
default:
is_supported = 0;
}
}
if (level = MUSL_SOL_TCP) {
is_supported = 0;
}
#endif

if (is_supported) {
return setsockopt(socket, level, option_name, option_value, option_len);
}
return 0;
return setsockopt(socket, level, option_name, option_value, option_len);
}
Loading