Make roken build on windows

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
This commit is contained in:
Asanka Herath
2009-11-24 21:42:02 -08:00
committed by Love Hornquist Astrand
parent c4b95f7330
commit d00f9984a5
168 changed files with 3688 additions and 607 deletions

View File

@@ -40,7 +40,7 @@
* Set `sa' to the unitialized address of address family `af'
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_any (struct sockaddr *sa, int af)
{
switch (af) {
@@ -74,7 +74,7 @@ socket_set_any (struct sockaddr *sa, int af)
* set `sa' to (`ptr', `port')
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port)
{
switch (sa->sa_family) {
@@ -108,7 +108,7 @@ socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port)
* Return the size of an address of the type in `sa'
*/
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_addr_size (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -120,7 +120,7 @@ socket_addr_size (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
break;
UNREACHABLE(return 0);
}
}
@@ -128,7 +128,7 @@ socket_addr_size (const struct sockaddr *sa)
* Return the size of a `struct sockaddr' in `sa'.
*/
size_t ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
socket_sockaddr_size (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -140,7 +140,7 @@ socket_sockaddr_size (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
break;
UNREACHABLE(return 0);
}
}
@@ -148,7 +148,7 @@ socket_sockaddr_size (const struct sockaddr *sa)
* Return the binary address of `sa'.
*/
void * ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
socket_get_address (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -164,7 +164,7 @@ socket_get_address (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
break;
UNREACHABLE(return NULL);
}
}
@@ -172,7 +172,7 @@ socket_get_address (const struct sockaddr *sa)
* Return the port number from `sa'.
*/
int ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
socket_get_port (const struct sockaddr *sa)
{
switch (sa->sa_family) {
@@ -188,7 +188,7 @@ socket_get_port (const struct sockaddr *sa)
#endif
default :
errx (1, "unknown address family %d", sa->sa_family);
break;
UNREACHABLE(return 0);
}
}
@@ -196,7 +196,7 @@ socket_get_port (const struct sockaddr *sa)
* Set the port in `sa' to `port'.
*/
void ROKEN_LIB_FUNCTION
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_port (struct sockaddr *sa, int port)
{
switch (sa->sa_family) {
@@ -221,8 +221,8 @@ socket_set_port (struct sockaddr *sa, int port)
/*
* Set the range of ports to use when binding with port = 0.
*/
void ROKEN_LIB_FUNCTION
socket_set_portrange (int sock, int restr, int af)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_portrange (rk_socket_t sock, int restr, int af)
{
#if defined(IP_PORTRANGE)
if (af == AF_INET) {
@@ -247,8 +247,8 @@ socket_set_portrange (int sock, int restr, int af)
* Enable debug on `sock'.
*/
void ROKEN_LIB_FUNCTION
socket_set_debug (int sock)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_debug (rk_socket_t sock)
{
#if defined(SO_DEBUG) && defined(HAVE_SETSOCKOPT)
int on = 1;
@@ -262,8 +262,8 @@ socket_set_debug (int sock)
* Set the type-of-service of `sock' to `tos'.
*/
void ROKEN_LIB_FUNCTION
socket_set_tos (int sock, int tos)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_tos (rk_socket_t sock, int tos)
{
#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
if (setsockopt (sock, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof (int)) < 0)
@@ -276,8 +276,8 @@ socket_set_tos (int sock, int tos)
* set the reuse of addresses on `sock' to `val'.
*/
void ROKEN_LIB_FUNCTION
socket_set_reuseaddr (int sock, int val)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_reuseaddr (rk_socket_t sock, int val)
{
#if defined(SO_REUSEADDR) && defined(HAVE_SETSOCKOPT)
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&val,
@@ -290,10 +290,28 @@ socket_set_reuseaddr (int sock, int val)
* Set the that the `sock' should bind to only IPv6 addresses.
*/
void ROKEN_LIB_FUNCTION
socket_set_ipv6only (int sock, int val)
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
socket_set_ipv6only (rk_socket_t sock, int val)
{
#if defined(IPV6_V6ONLY) && defined(HAVE_SETSOCKOPT)
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&val, sizeof(val));
#endif
}
/**
* Create a file descriptor from a socket
*
* While the socket handle in \a sock can be used with WinSock
* functions after calling socket_to_fd(), it should not be closed
* with rk_closesocket(). The socket will be closed when the associated
* file descriptor is closed.
*/
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
socket_to_fd(rk_socket_t sock, int flags)
{
#ifndef _WIN32
return sock;
#else
return _open_osfhandle((intptr_t) sock, flags);
#endif
}