Add libogc function defs

This commit is contained in:
dborth 2009-05-08 08:13:43 +00:00
parent e9b7ee50bf
commit 2e17ed7186
3 changed files with 67 additions and 1 deletions

View file

@ -708,7 +708,11 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
}
/* 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);
#endif
if ( sock->channel == INVALID_SOCKET ) {
SDLNet_SetError("Couldn't create socket");
goto error_return;
@ -725,7 +729,11 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
sock_addr.sin_port = ip->port;
/* 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,
#endif
sizeof(sock_addr)) == SOCKET_ERROR ) {
SDLNet_SetError("Couldn't connect to remote host");
goto error_return;
@ -745,7 +753,7 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
* http://www.devolution.com/pipermail/sdl/2005-September/070491.html
* --ryan.
*/
#ifndef WIN32
#if !defined WIN32 && !defined HW_RVL
/* allow local address reuse */
{ int yes = 1;
setsockopt(sock->channel, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes));
@ -753,12 +761,20 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
#endif
/* 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,
#endif
sizeof(sock_addr)) == SOCKET_ERROR ) {
SDLNet_SetError("Couldn't bind to local port");
goto error_return;
}
#if defined HW_RVL
if ( net_listen(sock->channel, 5) == SOCKET_ERROR ) {
#else
if ( listen(sock->channel, 5) == SOCKET_ERROR ) {
#endif
SDLNet_SetError("Couldn't listen to local port");
goto error_return;
}
@ -794,7 +810,11 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip)
#ifdef TCP_NODELAY
/* Set the nodelay TCP option for real-time games */
{ 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));
#endif
}
#endif /* TCP_NODELAY */
@ -835,9 +855,15 @@ TCPsocket SDLNet_TCP_Accept(TCPsocket server)
/* Accept a new TCP connection on a server socket */
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,
#endif
#ifdef USE_GUSI_SOCKETS
(unsigned int *)&sock_alen);
#elif defined HW_RVL
(socklen_t *)&sock_alen);
#else
&sock_alen);
#endif
@ -903,7 +929,11 @@ int SDLNet_TCP_Send(TCPsocket sock, const void *datap, int len)
sent = 0;
errno = 0;
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);
#endif
if ( len > 0 ) {
sent += len;
left -= len;
@ -932,7 +962,11 @@ int SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen)
errno = 0;
do {
#if defined HW_RVL
len = net_recv(sock->channel, (char *) data, maxlen, 0);
#else
len = recv(sock->channel, (char *) data, maxlen, 0);
#endif
} while ( errno == EINTR );
sock->ready = 0;

View file

@ -307,6 +307,8 @@ extern UDPsocket SDLNet_UDP_Open(Uint16 port)
// (01/05/03 minami<elsur@aaa.letter.co.jp>
OTSetBlocking( sock->channel );
}
#elif defined HW_RVL
sock->channel = net_socket(AF_INET, SOCK_DGRAM, 0);
#else
sock->channel = socket(AF_INET, SOCK_DGRAM, 0);
#endif /* MACOS_OPENTRANSPORT */
@ -372,7 +374,11 @@ extern UDPsocket SDLNet_UDP_Open(Uint16 port)
sock_addr.sin_port = SDL_SwapBE16(port);
/* 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,
#endif
sizeof(sock_addr)) == SOCKET_ERROR ) {
SDLNet_SetError("Couldn't bind to local port");
goto error_return;
@ -385,7 +391,11 @@ extern UDPsocket SDLNet_UDP_Open(Uint16 port)
#ifdef SO_BROADCAST
/* Allow LAN broadcasts with the socket */
{ 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));
#endif
}
#endif
#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_port = packets[i]->address.port;
sock_addr.sin_family = AF_INET;
#if defined HW_RVL
status = net_sendto(sock->channel,
#else
status = sendto(sock->channel,
#endif
packets[i]->data, packets[i]->len, 0,
(struct sockaddr *)&sock_addr,sock_len);
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_port = binding->address[j].port;
sock_addr.sin_family = AF_INET;
#if defined HW_RVL
status = net_sendto(sock->channel,
#else
status = sendto(sock->channel,
#endif
packets[i]->data, packets[i]->len, 0,
(struct sockaddr *)&sock_addr,sock_len);
if ( status >= 0 )
@ -673,7 +691,11 @@ static int SocketReady(SOCKET sock)
tv.tv_usec = 0;
/* Look! */
#if defined HW_RVL
retval = net_select(sock+1, &mask, NULL, NULL, &tv);
#else
retval = select(sock+1, &mask, NULL, NULL, &tv);
#endif
} while ( errno == EINTR );
#endif /* MACOS_OPENTRANSPORT */
@ -730,11 +752,17 @@ extern int SDLNet_UDP_RecvV(UDPsocket sock, UDPpacket **packets)
}
#else
sock_len = sizeof(sock_addr);
#if defined HW_RVL
packet->status = net_recvfrom(sock->channel,
#else
packet->status = recvfrom(sock->channel,
#endif
packet->data, packet->maxlen, 0,
(struct sockaddr *)&sock_addr,
#ifdef USE_GUSI_SOCKETS
(unsigned int *)&sock_len);
#elif defined HW_RVL
(socklen_t *)&sock_len);
#else
&sock_len);
#endif

View file

@ -200,7 +200,11 @@ int SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout)
tv.tv_usec = (timeout%1000)*1000;
/* Look! */
#if defined HW_RVL
retval = net_select(maxfd+1, &mask, NULL, NULL, &tv);
#else
retval = select(maxfd+1, &mask, NULL, NULL, &tv);
#endif
} while ( errno == EINTR );
/* Mark all file descriptors ready that have data available */