Add libogc function defs
This commit is contained in:
parent
e9b7ee50bf
commit
2e17ed7186
|
@ -708,7 +708,11 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the socket */
|
/* Open the socket */
|
||||||
|
#if defined HW_RVL
|
||||||
|
sock->channel = net_socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
#else
|
||||||
sock->channel = socket(AF_INET, SOCK_STREAM, 0);
|
sock->channel = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
#endif
|
||||||
if ( sock->channel == INVALID_SOCKET ) {
|
if ( sock->channel == INVALID_SOCKET ) {
|
||||||
SDLNet_SetError("Couldn't create socket");
|
SDLNet_SetError("Couldn't create socket");
|
||||||
goto error_return;
|
goto error_return;
|
||||||
|
@ -725,7 +729,11 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
|
||||||
sock_addr.sin_port = ip->port;
|
sock_addr.sin_port = ip->port;
|
||||||
|
|
||||||
/* Connect to the remote host */
|
/* Connect to the remote host */
|
||||||
|
#if defined HW_RVL
|
||||||
|
if ( net_connect(sock->channel, (struct sockaddr *)&sock_addr,
|
||||||
|
#else
|
||||||
if ( connect(sock->channel, (struct sockaddr *)&sock_addr,
|
if ( connect(sock->channel, (struct sockaddr *)&sock_addr,
|
||||||
|
#endif
|
||||||
sizeof(sock_addr)) == SOCKET_ERROR ) {
|
sizeof(sock_addr)) == SOCKET_ERROR ) {
|
||||||
SDLNet_SetError("Couldn't connect to remote host");
|
SDLNet_SetError("Couldn't connect to remote host");
|
||||||
goto error_return;
|
goto error_return;
|
||||||
|
@ -745,7 +753,7 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
|
||||||
* http://www.devolution.com/pipermail/sdl/2005-September/070491.html
|
* http://www.devolution.com/pipermail/sdl/2005-September/070491.html
|
||||||
* --ryan.
|
* --ryan.
|
||||||
*/
|
*/
|
||||||
#ifndef WIN32
|
#if !defined WIN32 && !defined HW_RVL
|
||||||
/* allow local address reuse */
|
/* allow local address reuse */
|
||||||
{ int yes = 1;
|
{ int yes = 1;
|
||||||
setsockopt(sock->channel, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes));
|
setsockopt(sock->channel, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes));
|
||||||
|
@ -753,12 +761,20 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Bind the socket for listening */
|
/* Bind the socket for listening */
|
||||||
|
#if defined HW_RVL
|
||||||
|
if ( net_bind(sock->channel, (struct sockaddr *)&sock_addr,
|
||||||
|
#else
|
||||||
if ( bind(sock->channel, (struct sockaddr *)&sock_addr,
|
if ( bind(sock->channel, (struct sockaddr *)&sock_addr,
|
||||||
|
#endif
|
||||||
sizeof(sock_addr)) == SOCKET_ERROR ) {
|
sizeof(sock_addr)) == SOCKET_ERROR ) {
|
||||||
SDLNet_SetError("Couldn't bind to local port");
|
SDLNet_SetError("Couldn't bind to local port");
|
||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
#if defined HW_RVL
|
||||||
|
if ( net_listen(sock->channel, 5) == SOCKET_ERROR ) {
|
||||||
|
#else
|
||||||
if ( listen(sock->channel, 5) == SOCKET_ERROR ) {
|
if ( listen(sock->channel, 5) == SOCKET_ERROR ) {
|
||||||
|
#endif
|
||||||
SDLNet_SetError("Couldn't listen to local port");
|
SDLNet_SetError("Couldn't listen to local port");
|
||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
@ -794,7 +810,11 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
|
||||||
#ifdef TCP_NODELAY
|
#ifdef TCP_NODELAY
|
||||||
/* Set the nodelay TCP option for real-time games */
|
/* Set the nodelay TCP option for real-time games */
|
||||||
{ int yes = 1;
|
{ int yes = 1;
|
||||||
|
#if defined HW_RVL
|
||||||
|
net_setsockopt(sock->channel, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(yes));
|
||||||
|
#else
|
||||||
setsockopt(sock->channel, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(yes));
|
setsockopt(sock->channel, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(yes));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* TCP_NODELAY */
|
#endif /* TCP_NODELAY */
|
||||||
|
|
||||||
|
@ -835,9 +855,15 @@ TCPsocket SDLNet_TCP_Accept(TCPsocket server)
|
||||||
|
|
||||||
/* Accept a new TCP connection on a server socket */
|
/* Accept a new TCP connection on a server socket */
|
||||||
sock_alen = sizeof(sock_addr);
|
sock_alen = sizeof(sock_addr);
|
||||||
|
#if defined HW_RVL
|
||||||
|
sock->channel = net_accept(server->channel, (struct sockaddr *)&sock_addr,
|
||||||
|
#else
|
||||||
sock->channel = accept(server->channel, (struct sockaddr *)&sock_addr,
|
sock->channel = accept(server->channel, (struct sockaddr *)&sock_addr,
|
||||||
|
#endif
|
||||||
#ifdef USE_GUSI_SOCKETS
|
#ifdef USE_GUSI_SOCKETS
|
||||||
(unsigned int *)&sock_alen);
|
(unsigned int *)&sock_alen);
|
||||||
|
#elif defined HW_RVL
|
||||||
|
(socklen_t *)&sock_alen);
|
||||||
#else
|
#else
|
||||||
&sock_alen);
|
&sock_alen);
|
||||||
#endif
|
#endif
|
||||||
|
@ -903,7 +929,11 @@ int SDLNet_TCP_Send(TCPsocket sock, const void *datap, int len)
|
||||||
sent = 0;
|
sent = 0;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
do {
|
do {
|
||||||
|
#if defined HW_RVL
|
||||||
|
len = net_send(sock->channel, (const char *) data, left, 0);
|
||||||
|
#else
|
||||||
len = send(sock->channel, (const char *) data, left, 0);
|
len = send(sock->channel, (const char *) data, left, 0);
|
||||||
|
#endif
|
||||||
if ( len > 0 ) {
|
if ( len > 0 ) {
|
||||||
sent += len;
|
sent += len;
|
||||||
left -= len;
|
left -= len;
|
||||||
|
@ -932,7 +962,11 @@ int SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen)
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
do {
|
do {
|
||||||
|
#if defined HW_RVL
|
||||||
|
len = net_recv(sock->channel, (char *) data, maxlen, 0);
|
||||||
|
#else
|
||||||
len = recv(sock->channel, (char *) data, maxlen, 0);
|
len = recv(sock->channel, (char *) data, maxlen, 0);
|
||||||
|
#endif
|
||||||
} while ( errno == EINTR );
|
} while ( errno == EINTR );
|
||||||
|
|
||||||
sock->ready = 0;
|
sock->ready = 0;
|
||||||
|
|
|
@ -307,6 +307,8 @@ extern UDPsocket SDLNet_UDP_Open(Uint16 port)
|
||||||
// (01/05/03 minami<elsur@aaa.letter.co.jp>
|
// (01/05/03 minami<elsur@aaa.letter.co.jp>
|
||||||
OTSetBlocking( sock->channel );
|
OTSetBlocking( sock->channel );
|
||||||
}
|
}
|
||||||
|
#elif defined HW_RVL
|
||||||
|
sock->channel = net_socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
#else
|
#else
|
||||||
sock->channel = socket(AF_INET, SOCK_DGRAM, 0);
|
sock->channel = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
#endif /* MACOS_OPENTRANSPORT */
|
#endif /* MACOS_OPENTRANSPORT */
|
||||||
|
@ -372,7 +374,11 @@ extern UDPsocket SDLNet_UDP_Open(Uint16 port)
|
||||||
sock_addr.sin_port = SDL_SwapBE16(port);
|
sock_addr.sin_port = SDL_SwapBE16(port);
|
||||||
|
|
||||||
/* Bind the socket for listening */
|
/* Bind the socket for listening */
|
||||||
|
#if defined HW_RVL
|
||||||
|
if ( net_bind(sock->channel, (struct sockaddr *)&sock_addr,
|
||||||
|
#else
|
||||||
if ( bind(sock->channel, (struct sockaddr *)&sock_addr,
|
if ( bind(sock->channel, (struct sockaddr *)&sock_addr,
|
||||||
|
#endif
|
||||||
sizeof(sock_addr)) == SOCKET_ERROR ) {
|
sizeof(sock_addr)) == SOCKET_ERROR ) {
|
||||||
SDLNet_SetError("Couldn't bind to local port");
|
SDLNet_SetError("Couldn't bind to local port");
|
||||||
goto error_return;
|
goto error_return;
|
||||||
|
@ -385,7 +391,11 @@ extern UDPsocket SDLNet_UDP_Open(Uint16 port)
|
||||||
#ifdef SO_BROADCAST
|
#ifdef SO_BROADCAST
|
||||||
/* Allow LAN broadcasts with the socket */
|
/* Allow LAN broadcasts with the socket */
|
||||||
{ int yes = 1;
|
{ int yes = 1;
|
||||||
|
#if defined HW_RVL
|
||||||
|
net_setsockopt(sock->channel, SOL_SOCKET, SO_BROADCAST, (char*)&yes, sizeof(yes));
|
||||||
|
#else
|
||||||
setsockopt(sock->channel, SOL_SOCKET, SO_BROADCAST, (char*)&yes, sizeof(yes));
|
setsockopt(sock->channel, SOL_SOCKET, SO_BROADCAST, (char*)&yes, sizeof(yes));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef IP_ADD_MEMBERSHIP
|
#ifdef IP_ADD_MEMBERSHIP
|
||||||
|
@ -556,7 +566,11 @@ int SDLNet_UDP_SendV(UDPsocket sock, UDPpacket **packets, int npackets)
|
||||||
sock_addr.sin_addr.s_addr = packets[i]->address.host;
|
sock_addr.sin_addr.s_addr = packets[i]->address.host;
|
||||||
sock_addr.sin_port = packets[i]->address.port;
|
sock_addr.sin_port = packets[i]->address.port;
|
||||||
sock_addr.sin_family = AF_INET;
|
sock_addr.sin_family = AF_INET;
|
||||||
|
#if defined HW_RVL
|
||||||
|
status = net_sendto(sock->channel,
|
||||||
|
#else
|
||||||
status = sendto(sock->channel,
|
status = sendto(sock->channel,
|
||||||
|
#endif
|
||||||
packets[i]->data, packets[i]->len, 0,
|
packets[i]->data, packets[i]->len, 0,
|
||||||
(struct sockaddr *)&sock_addr,sock_len);
|
(struct sockaddr *)&sock_addr,sock_len);
|
||||||
if ( status >= 0 )
|
if ( status >= 0 )
|
||||||
|
@ -607,7 +621,11 @@ int SDLNet_UDP_SendV(UDPsocket sock, UDPpacket **packets, int npackets)
|
||||||
sock_addr.sin_addr.s_addr = binding->address[j].host;
|
sock_addr.sin_addr.s_addr = binding->address[j].host;
|
||||||
sock_addr.sin_port = binding->address[j].port;
|
sock_addr.sin_port = binding->address[j].port;
|
||||||
sock_addr.sin_family = AF_INET;
|
sock_addr.sin_family = AF_INET;
|
||||||
|
#if defined HW_RVL
|
||||||
|
status = net_sendto(sock->channel,
|
||||||
|
#else
|
||||||
status = sendto(sock->channel,
|
status = sendto(sock->channel,
|
||||||
|
#endif
|
||||||
packets[i]->data, packets[i]->len, 0,
|
packets[i]->data, packets[i]->len, 0,
|
||||||
(struct sockaddr *)&sock_addr,sock_len);
|
(struct sockaddr *)&sock_addr,sock_len);
|
||||||
if ( status >= 0 )
|
if ( status >= 0 )
|
||||||
|
@ -673,7 +691,11 @@ static int SocketReady(SOCKET sock)
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
/* Look! */
|
/* Look! */
|
||||||
|
#if defined HW_RVL
|
||||||
|
retval = net_select(sock+1, &mask, NULL, NULL, &tv);
|
||||||
|
#else
|
||||||
retval = select(sock+1, &mask, NULL, NULL, &tv);
|
retval = select(sock+1, &mask, NULL, NULL, &tv);
|
||||||
|
#endif
|
||||||
} while ( errno == EINTR );
|
} while ( errno == EINTR );
|
||||||
#endif /* MACOS_OPENTRANSPORT */
|
#endif /* MACOS_OPENTRANSPORT */
|
||||||
|
|
||||||
|
@ -730,11 +752,17 @@ extern int SDLNet_UDP_RecvV(UDPsocket sock, UDPpacket **packets)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
sock_len = sizeof(sock_addr);
|
sock_len = sizeof(sock_addr);
|
||||||
|
#if defined HW_RVL
|
||||||
|
packet->status = net_recvfrom(sock->channel,
|
||||||
|
#else
|
||||||
packet->status = recvfrom(sock->channel,
|
packet->status = recvfrom(sock->channel,
|
||||||
|
#endif
|
||||||
packet->data, packet->maxlen, 0,
|
packet->data, packet->maxlen, 0,
|
||||||
(struct sockaddr *)&sock_addr,
|
(struct sockaddr *)&sock_addr,
|
||||||
#ifdef USE_GUSI_SOCKETS
|
#ifdef USE_GUSI_SOCKETS
|
||||||
(unsigned int *)&sock_len);
|
(unsigned int *)&sock_len);
|
||||||
|
#elif defined HW_RVL
|
||||||
|
(socklen_t *)&sock_len);
|
||||||
#else
|
#else
|
||||||
&sock_len);
|
&sock_len);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -200,7 +200,11 @@ int SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout)
|
||||||
tv.tv_usec = (timeout%1000)*1000;
|
tv.tv_usec = (timeout%1000)*1000;
|
||||||
|
|
||||||
/* Look! */
|
/* Look! */
|
||||||
|
#if defined HW_RVL
|
||||||
|
retval = net_select(maxfd+1, &mask, NULL, NULL, &tv);
|
||||||
|
#else
|
||||||
retval = select(maxfd+1, &mask, NULL, NULL, &tv);
|
retval = select(maxfd+1, &mask, NULL, NULL, &tv);
|
||||||
|
#endif
|
||||||
} while ( errno == EINTR );
|
} while ( errno == EINTR );
|
||||||
|
|
||||||
/* Mark all file descriptors ready that have data available */
|
/* Mark all file descriptors ready that have data available */
|
||||||
|
|
Reference in a new issue