Skip to content

Commit dffd093

Browse files
Fix libsocket typedef name
Port googleprojectzero#515 to win32.
1 parent 4706170 commit dffd093

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

Sources/libsocket/include/libsocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#endif
2323

2424
#if defined(_WIN32)
25-
typedef SOCKET socket_t;
25+
typedef SOCKET libsocket_t;
2626

2727
// We need C11 or newer due to the use of `_Generic`. Windows does not have a
2828
// signed size type, so we construct the equivalent type by inspecting the type

Sources/libsocket/socket-win32.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ static void __attribute__((__destructor__, __used__)) libsocket_fini(void) {
4444
(void)WSACleanup();
4545
}
4646

47-
socket_t socket_listen(const char *address, uint16_t port) {
48-
socket_t sock = socket(AF_INET, SOCK_STREAM, 0);
47+
libsocket_t socket_listen(const char *address, uint16_t port) {
48+
libsocket_t sock = socket(AF_INET, SOCK_STREAM, 0);
4949
if (sock == INVALID_SOCKET)
5050
return INVALID_SOCKET;
5151

@@ -68,8 +68,8 @@ socket_t socket_listen(const char *address, uint16_t port) {
6868
return sock;
6969
}
7070

71-
socket_t socket_accept(socket_t sock) {
72-
socket_t client = accept(sock, NULL, NULL);
71+
libsocket_t socket_accept(libsocket_t sock) {
72+
libsocket_t client = accept(sock, NULL, NULL);
7373
if (client == INVALID_SOCKET)
7474
return INVALID_SOCKET;
7575

@@ -82,7 +82,7 @@ socket_t socket_accept(socket_t sock) {
8282
return client;
8383
}
8484

85-
socket_t socket_connect(const char *address, uint16_t port) {
85+
libsocket_t socket_connect(const char *address, uint16_t port) {
8686
struct addrinfo ai;
8787
ZeroMemory(&ai, sizeof(ai));
8888
ai.ai_family = AF_UNSPEC;
@@ -96,7 +96,7 @@ socket_t socket_connect(const char *address, uint16_t port) {
9696
if (getaddrinfo(address, port_str, &ai, &ai_list))
9797
return INVALID_SOCKET;
9898

99-
socket_t sock;
99+
libsocket_t sock;
100100
struct addrinfo *ai_cur;
101101
for (ai_cur = ai_list; ai_cur; ai_cur = ai_cur->ai_next) {
102102
sock = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol);
@@ -124,7 +124,7 @@ socket_t socket_connect(const char *address, uint16_t port) {
124124
return sock;
125125
}
126126

127-
ssize_t socket_send(socket_t sock, const uint8_t *data, size_t length) {
127+
ssize_t socket_send(libsocket_t sock, const uint8_t *data, size_t length) {
128128
assert(length <= INT_MAX && "unable to send > INT_MAX bytes");
129129
ssize_t remaining = length;
130130
while (remaining) {
@@ -137,16 +137,16 @@ ssize_t socket_send(socket_t sock, const uint8_t *data, size_t length) {
137137
return length;
138138
}
139139

140-
ssize_t socket_recv(socket_t sock, uint8_t *buffer, size_t length) {
140+
ssize_t socket_recv(libsocket_t sock, uint8_t *buffer, size_t length) {
141141
assert(length <= INT_MAX && "unable to receive >INT_MAX bytes");
142142
return recv(sock, (char *)buffer, length, 0);
143143
}
144144

145-
int socket_shutdown(socket_t socket) {
145+
int socket_shutdown(libsocket_t socket) {
146146
return shutdown(socket, SD_BOTH);
147147
}
148148

149-
int socket_close(socket_t socket) {
149+
int socket_close(libsocket_t socket) {
150150
return closesocket(socket);
151151
}
152152

0 commit comments

Comments
 (0)