changed udp.c to properly detect compiling on windows with tcc

master
bx 2021-12-29 00:36:21 +00:00
parent 6b3c8210b5
commit 91f280ba3a
1 changed files with 6 additions and 6 deletions

12
udp.c
View File

@ -8,7 +8,7 @@
* store from ip + port in message ? * store from ip + port in message ?
*/ */
#ifdef __WIN32__ #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
#else #else
#include <sys/socket.h> #include <sys/socket.h>
@ -26,13 +26,13 @@
#undef while #undef while
// G l o b a L E v i L // // G l o b a L E v i L //
#ifdef __WIN32__ #ifdef _WIN32
static SOCKET udp_sock; static SOCKET udp_sock;
#else #else
static int udp_sock; static int udp_sock;
#endif #endif
#ifdef __WIN32__ #ifdef _WIN32
void udp_init(Ampler_state *state) { void udp_init(Ampler_state *state) {
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsastartup // https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsastartup
WSADATA wsa; WSADATA wsa;
@ -71,7 +71,7 @@ void udp_init(Ampler_state *state) {
} }
#endif #endif
#ifdef __WIN32__ #ifdef _WIN32
void udp_quit(Ampler_state *state) { void udp_quit(Ampler_state *state) {
closesocket(udp_sock); closesocket(udp_sock);
WSACleanup(); WSACleanup();
@ -82,7 +82,7 @@ void udp_quit(Ampler_state *state) {
} }
#endif #endif
#ifdef __WIN32__ #ifdef _WIN32
void recv_packet(Ampler_state *state) { void recv_packet(Ampler_state *state) {
char discard_buf[32] = { 0 }; // for dropped packets char discard_buf[32] = { 0 }; // for dropped packets
char *buf = discard_buf; char *buf = discard_buf;
@ -128,7 +128,7 @@ void recv_packet(Ampler_state *state) {
} }
#endif #endif
#ifdef __WIN32__ #ifdef _WIN32
void udp_frame(Ampler_state *state) { void udp_frame(Ampler_state *state) {
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select // https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select
fd_set recv_fd_set; fd_set recv_fd_set;