aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-10-28 14:51:23 +0200
committermarha <marha@users.sourceforge.net>2011-10-28 14:51:23 +0200
commitd2a31932bb4eaa04572dcf646a2967c638a47144 (patch)
tree1f3acb099235f6e4f4e500030a016730f30c57a0 /mesalib/src/gallium
parente9348e5fb751ebeba77e622af6d4241be8f1d51e (diff)
parent6f4feafd4d22beaabfb0202e66b0dea9047ee084 (diff)
downloadvcxsrv-d2a31932bb4eaa04572dcf646a2967c638a47144.tar.gz
vcxsrv-d2a31932bb4eaa04572dcf646a2967c638a47144.tar.bz2
vcxsrv-d2a31932bb4eaa04572dcf646a2967c638a47144.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/gallium')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_network.c379
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_network.h49
2 files changed, 216 insertions, 212 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_network.c b/mesalib/src/gallium/auxiliary/util/u_network.c
index d135b590f..45b3691f9 100644
--- a/mesalib/src/gallium/auxiliary/util/u_network.c
+++ b/mesalib/src/gallium/auxiliary/util/u_network.c
@@ -1,188 +1,191 @@
-
-#include "pipe/p_compiler.h"
-#include "util/u_network.h"
-#include "util/u_debug.h"
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-# include <winsock2.h>
-# include <windows.h>
-#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_CYGWIN)
-# include <sys/socket.h>
-# include <netinet/in.h>
-# include <unistd.h>
-# include <fcntl.h>
-# include <netdb.h>
-#else
-# warning "No socket implementation"
-#endif
-
-boolean
-u_socket_init()
-{
-#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
-
- /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
- wVersionRequested = MAKEWORD(1, 1);
-
- err = WSAStartup(wVersionRequested, &wsaData);
- if (err != 0) {
- debug_printf("WSAStartup failed with error: %d\n", err);
- return FALSE;
- }
- return TRUE;
-#elif defined(PIPE_HAVE_SOCKETS)
- return TRUE;
-#else
- return FALSE;
-#endif
-}
-
-void
-u_socket_stop()
-{
-#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- WSACleanup();
-#endif
-}
-
-void
-u_socket_close(int s)
-{
- if (s < 0)
- return;
-
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
- shutdown(s, SHUT_RDWR);
- close(s);
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- shutdown(s, SD_BOTH);
- closesocket(s);
-#else
- assert(0);
-#endif
-}
-
-int u_socket_accept(int s)
-{
-#if defined(PIPE_HAVE_SOCKETS)
- return accept(s, NULL, NULL);
-#else
- return -1;
-#endif
-}
-
-int
-u_socket_send(int s, void *data, size_t size)
-{
-#if defined(PIPE_HAVE_SOCKETS)
- return send(s, data, size, 0);
-#else
- return -1;
-#endif
-}
-
-int
-u_socket_peek(int s, void *data, size_t size)
-{
-#if defined(PIPE_HAVE_SOCKETS)
- return recv(s, data, size, MSG_PEEK);
-#else
- return -1;
-#endif
-}
-
-int
-u_socket_recv(int s, void *data, size_t size)
-{
-#if defined(PIPE_HAVE_SOCKETS)
- return recv(s, data, size, 0);
-#else
- return -1;
-#endif
-}
-
-int
-u_socket_connect(const char *hostname, uint16_t port)
-{
-#if defined(PIPE_HAVE_SOCKETS)
- int s;
- struct sockaddr_in sa;
- struct hostent *host = NULL;
-
- memset(&sa, 0, sizeof(struct sockaddr_in));
- host = gethostbyname(hostname);
- if (!host)
- return -1;
-
- memcpy((char *)&sa.sin_addr,host->h_addr_list[0],host->h_length);
- sa.sin_family= host->h_addrtype;
- sa.sin_port = htons(port);
-
- s = socket(host->h_addrtype, SOCK_STREAM, IPPROTO_TCP);
- if (s < 0)
- return -1;
-
- if (connect(s, (struct sockaddr *)&sa, sizeof(sa))) {
- u_socket_close(s);
- return -1;
- }
-
- return s;
-#else
- assert(0);
- return -1;
-#endif
-}
-
-int
-u_socket_listen_on_port(uint16_t portnum)
-{
-#if defined(PIPE_HAVE_SOCKETS)
- int s;
- struct sockaddr_in sa;
- memset(&sa, 0, sizeof(struct sockaddr_in));
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(portnum);
-
- s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (s < 0)
- return -1;
-
- if (bind(s, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) == -1) {
- u_socket_close(s);
- return -1;
- }
-
- listen(s, 0);
-
- return s;
-#else
- assert(0);
- return -1;
-#endif
-}
-
-void
-u_socket_block(int s, boolean block)
-{
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
- int old = fcntl(s, F_GETFL, 0);
- if (old == -1)
- return;
-
- /* TODO obey block */
- if (block)
- fcntl(s, F_SETFL, old & ~O_NONBLOCK);
- else
- fcntl(s, F_SETFL, old | O_NONBLOCK);
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- u_long iMode = block ? 0 : 1;
- ioctlsocket(s, FIONBIO, &iMode);
-#else
- assert(0);
-#endif
-}
+
+#include "pipe/p_compiler.h"
+#include "util/u_network.h"
+#include "util/u_debug.h"
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+# include <winsock2.h>
+# include <windows.h>
+#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || \
+ defined(PIPE_OS_APPLE) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_SOLARIS)
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <unistd.h>
+# include <fcntl.h>
+# include <netdb.h>
+#else
+# warning "No socket implementation"
+#endif
+
+boolean
+u_socket_init()
+{
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+
+ /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
+ wVersionRequested = MAKEWORD(1, 1);
+
+ err = WSAStartup(wVersionRequested, &wsaData);
+ if (err != 0) {
+ debug_printf("WSAStartup failed with error: %d\n", err);
+ return FALSE;
+ }
+ return TRUE;
+#elif defined(PIPE_HAVE_SOCKETS)
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+void
+u_socket_stop()
+{
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ WSACleanup();
+#endif
+}
+
+void
+u_socket_close(int s)
+{
+ if (s < 0)
+ return;
+
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) \
+ || defined(PIPE_OS_APPLE) || defined(PIPE_OS_SOLARIS)
+ shutdown(s, SHUT_RDWR);
+ close(s);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ shutdown(s, SD_BOTH);
+ closesocket(s);
+#else
+ assert(0);
+#endif
+}
+
+int u_socket_accept(int s)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ return accept(s, NULL, NULL);
+#else
+ return -1;
+#endif
+}
+
+int
+u_socket_send(int s, void *data, size_t size)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ return send(s, data, size, 0);
+#else
+ return -1;
+#endif
+}
+
+int
+u_socket_peek(int s, void *data, size_t size)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ return recv(s, data, size, MSG_PEEK);
+#else
+ return -1;
+#endif
+}
+
+int
+u_socket_recv(int s, void *data, size_t size)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ return recv(s, data, size, 0);
+#else
+ return -1;
+#endif
+}
+
+int
+u_socket_connect(const char *hostname, uint16_t port)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ int s;
+ struct sockaddr_in sa;
+ struct hostent *host = NULL;
+
+ memset(&sa, 0, sizeof(struct sockaddr_in));
+ host = gethostbyname(hostname);
+ if (!host)
+ return -1;
+
+ memcpy((char *)&sa.sin_addr,host->h_addr_list[0],host->h_length);
+ sa.sin_family= host->h_addrtype;
+ sa.sin_port = htons(port);
+
+ s = socket(host->h_addrtype, SOCK_STREAM, IPPROTO_TCP);
+ if (s < 0)
+ return -1;
+
+ if (connect(s, (struct sockaddr *)&sa, sizeof(sa))) {
+ u_socket_close(s);
+ return -1;
+ }
+
+ return s;
+#else
+ assert(0);
+ return -1;
+#endif
+}
+
+int
+u_socket_listen_on_port(uint16_t portnum)
+{
+#if defined(PIPE_HAVE_SOCKETS)
+ int s;
+ struct sockaddr_in sa;
+ memset(&sa, 0, sizeof(struct sockaddr_in));
+
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(portnum);
+
+ s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (s < 0)
+ return -1;
+
+ if (bind(s, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) == -1) {
+ u_socket_close(s);
+ return -1;
+ }
+
+ listen(s, 0);
+
+ return s;
+#else
+ assert(0);
+ return -1;
+#endif
+}
+
+void
+u_socket_block(int s, boolean block)
+{
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) \
+ || defined(PIPE_OS_APPLE) || defined(PIPE_OS_SOLARIS)
+ int old = fcntl(s, F_GETFL, 0);
+ if (old == -1)
+ return;
+
+ /* TODO obey block */
+ if (block)
+ fcntl(s, F_SETFL, old & ~O_NONBLOCK);
+ else
+ fcntl(s, F_SETFL, old | O_NONBLOCK);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ u_long iMode = block ? 0 : 1;
+ ioctlsocket(s, FIONBIO, &iMode);
+#else
+ assert(0);
+#endif
+}
diff --git a/mesalib/src/gallium/auxiliary/util/u_network.h b/mesalib/src/gallium/auxiliary/util/u_network.h
index 5bf18c542..61fe9a3c6 100644
--- a/mesalib/src/gallium/auxiliary/util/u_network.h
+++ b/mesalib/src/gallium/auxiliary/util/u_network.h
@@ -1,24 +1,25 @@
-
-#ifndef _U_NETWORK_H_
-#define _U_NETWORK_H_
-
-#include "pipe/p_compiler.h"
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-# define PIPE_HAVE_SOCKETS
-#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_APPLE)
-# define PIPE_HAVE_SOCKETS
-#endif
-
-boolean u_socket_init(void);
-void u_socket_stop(void);
-void u_socket_close(int s);
-int u_socket_listen_on_port(uint16_t portnum);
-int u_socket_accept(int s);
-int u_socket_connect(const char *host, uint16_t port);
-int u_socket_send(int s, void *data, size_t size);
-int u_socket_peek(int s, void *data, size_t size);
-int u_socket_recv(int s, void *data, size_t size);
-void u_socket_block(int s, boolean block);
-
-#endif
+
+#ifndef _U_NETWORK_H_
+#define _U_NETWORK_H_
+
+#include "pipe/p_compiler.h"
+
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+# define PIPE_HAVE_SOCKETS
+#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_HAIKU) || \
+ defined(PIPE_OS_APPLE) || defined(PIPE_OS_SOLARIS)
+# define PIPE_HAVE_SOCKETS
+#endif
+
+boolean u_socket_init(void);
+void u_socket_stop(void);
+void u_socket_close(int s);
+int u_socket_listen_on_port(uint16_t portnum);
+int u_socket_accept(int s);
+int u_socket_connect(const char *host, uint16_t port);
+int u_socket_send(int s, void *data, size_t size);
+int u_socket_peek(int s, void *data, size_t size);
+int u_socket_recv(int s, void *data, size_t size);
+void u_socket_block(int s, boolean block);
+
+#endif