changeset 12317:67adec29dee0 octave-forge

Applied Windows compatibility patch for John Donoghue.
author i7tiol
date Wed, 15 Jan 2014 20:55:07 +0000
parents 89c99ed9b01f
children 320ea1bd0b61
files main/database/src/Makefile.in main/database/src/converters.cc main/database/src/wrap_endian.h
diffstat 3 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/main/database/src/Makefile.in	Wed Jan 15 20:37:42 2014 +0000
+++ b/main/database/src/Makefile.in	Wed Jan 15 20:55:07 2014 +0000
@@ -1,6 +1,11 @@
 # We rely on g++ features, configure assures CXX=g++.
 CXX := @CXX@
 
+EXTRALIBS = 
+ifeq ($(OS),Windows_NT)
+  EXTRALIBS = -lws2_32
+endif
+
 ifndef CXXFLAGS
 CXXFLAGS_NSA := "-g -O2 -fno-strict-aliasing"
 else
@@ -12,7 +17,7 @@
            pq_update_types.o pq_lo.o pq_conninfo.o __pq_internal_exit__.o
 
 pq_interface.oct: $(OBJECTS)
-	@MKOCTFILE@ -o pq_interface.oct -L`@PG_CONFIG@ --libdir` -lpq $(OBJECTS)
+	@MKOCTFILE@ -o pq_interface.oct -L`@PG_CONFIG@ --libdir` -lpq $(OBJECTS) $(EXTRALIBS)
 
 converters.o: converters.cc converters.h wrap_endian.h
 	CXX=$(CXX) CXXFLAGS=$(CXXFLAGS_NSA) @MKOCTFILE@ -I`@PG_CONFIG@ --includedir` -c converters.cc
--- a/main/database/src/converters.cc	Wed Jan 15 20:37:42 2014 +0000
+++ b/main/database/src/converters.cc	Wed Jan 15 20:55:07 2014 +0000
@@ -25,7 +25,11 @@
 
 #include <libpq-fe.h>
 
+#ifdef __WIN32__
+#include <winsock2.h>
+#else
 #include <sys/socket.h> // for AF_INET, needed in network address types
+#endif
 
 #include "converters.h"
 #include "pq_connection.h"
--- a/main/database/src/wrap_endian.h	Wed Jan 15 20:37:42 2014 +0000
+++ b/main/database/src/wrap_endian.h	Wed Jan 15 20:55:07 2014 +0000
@@ -32,7 +32,27 @@
  
 #else
 
+#ifdef __MINGW32__
+#include <winsock2.h>
+
+#define htobe16(x) htons(x)
+#define htole16(x) (x)
+#define be16toh(x) ntohs(x)
+#define le16toh(x) (x)
+ 
+#define htobe32(x) htonl(x)
+#define htole32(x) (x)
+#define be32toh(x) ntohl(x)
+#define le32toh(x) (x)
+ 
+#define htobe64(x) (((uint64_t)htonl((uint32_t)(x>>32)))|(((uint64_t)htonl(x&0xFFFFFFFF))<<32LL))
+#define htole64(x) (x)
+#define be64toh(x) (((uint64_t)ntohl((uint32_t)(x>>32)))|(((uint64_t)ntohl(x&0xFFFFFFFF))<<32LL))
+#define le64toh(x) (x)
+ 
+#else
 #include <endian.h>
+#endif
 
 #endif