[GRASS-dev] winGRASS: debugging vector db issues

Paul Kelly paul-grass at stjohnspoint.co.uk
Mon Feb 26 06:51:58 EST 2007


On Mon, 26 Feb 2007, Glynn Clements wrote:

> Paul Kelly wrote:
>
>> Moritz, WELL DONE! Using a static libxdr.a with nothing changed from the
>> link Glynn posted (sorry can't remember where I downloaded it from)

It was from the link posted here:
http://grass.itc.it/pipermail/grass-dev/2006-October/026857.html
to xdr-4.0-mingw2.tar.gz

> Ah. I solved the _fmode issues locally by patching my MinGW headers,
> specifically the O_* definitions in <fcntl.h>:
>
> 	#define	O_RDONLY	(_O_RDONLY | _O_BINARY)
> 	#define O_WRONLY	(_O_WRONLY | _O_BINARY)
> 	#define O_RDWR		(_O_RDWR | _O_BINARY)
>
> If libxdr.a is the one which I built, it will probably have binary I/O
> hard-coded into it. We still need a more general solution, though.
> AFAICT, every executable should get linked against $(FMODE_OBJ)
> automatically on Windows; the rules in Module.make use it, and
> Makefiles which have their own linking rules normally list it
> explicitly.

No, the libxdr.a used was one I built myself from the source at the above 
link. I notice it contains (in xdr_stdio.c):

#if defined(__CYGWIN32__) || defined(__MINGW32__)
#include <stdlib.h>
#include <fcntl.h>
unsigned int _CRT_fmode = _O_BINARY;
#endif

which probably explains why it works when compiled statically. But then 
all parts of GRASS should be linking against $(FMODE_OBJ) - perhaps parts 
of the database drivers aren't though? Will hopefully have time to look 
into it later.
Also attached is the diff of the changes I made to the above XDR package 
to get it to compile as a DLL.

Paul
-------------- next part --------------
diff -ur xdr-orig/Makefile.in xdr-pk/Makefile.in
--- xdr-orig/Makefile.in	Fri Nov 18 16:13:16 2005
+++ xdr-pk/Makefile.in	Mon Dec 11 22:18:34 2006
@@ -19,24 +19,27 @@
 
 HDRS = rpc/types.h rpc/xdr.h
 
-all xdrlib: libxdr.a
+all xdrlib: libxdr.dll
 
 libxdr.a: ${OBJS}
 	@echo "building libxdr.a"
 	${AR} cru libxdr.a ${OBJS}
 
-install: $(HDRS) libxdr.a
+libxdr.dll: ${OBJS}
+	@echo "building libxdr.dll"
+	${CC} -shared -o libxdr.dll ${OBJS} -lwsock32
+
+install: $(HDRS) libxdr.dll
 	@echo "Creating RPC header directory"
-	-mkdir -p ${prefix}/include/rpc && \
-		chmod 755 ${prefix}/include/rpc
+	-mkdir -p -m 755 ${prefix}/include/rpc
 	@echo "Installing XDR header files"
 	-set -x;for i in $(HDRS) ; do \
 		(install -c -m 644 $$i ${prefix}/include/rpc) done
 	@echo "Installing XDR library"
-	install -c -m 644 libxdr.a ${prefix}/lib
-	${RANLIB} ${prefix}/lib/libxdr.a
+	-mkdir -p -m 755 ${prefix}/lib
+	install -c -m 644 libxdr.dll ${prefix}/lib
 
 
 clean:
-	rm -f *.o libxdr.a
+	rm -f *.o libxdr.dll
 
diff -ur xdr-orig/xdr_array.c xdr-pk/xdr_array.c
--- xdr-orig/xdr_array.c	Fri Nov 18 16:13:16 2005
+++ xdr-pk/xdr_array.c	Mon Dec 11 22:06:28 2006
@@ -41,6 +41,8 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include <rpc/types.h>
 #include <rpc/xdr.h>
@@ -95,7 +97,7 @@
 					"xdr_array: out of memory\n");
 				return (FALSE);
 			}
-			bzero(target, nodesize);
+			memset(target, 0, (size_t)nodesize);
 			break;
 
 		case XDR_FREE:
diff -ur xdr-orig/xdr_mem.c xdr-pk/xdr_mem.c
--- xdr-orig/xdr_mem.c	Fri Nov 18 16:13:16 2005
+++ xdr-pk/xdr_mem.c	Mon Dec 11 22:09:45 2006
@@ -42,6 +42,7 @@
  *
  */
 
+#include <string.h>
 
 #include <rpc/types.h>
 #include <rpc/xdr.h>
@@ -126,7 +127,7 @@
 
 	if ((xdrs->x_handy -= len) < 0)
 		return (FALSE);
-	bcopy(xdrs->x_private, addr, len);
+	memmove(addr, xdrs->x_private, (size_t)len);
 	xdrs->x_private += len;
 	return (TRUE);
 }
@@ -140,7 +141,7 @@
 
 	if ((xdrs->x_handy -= len) < 0)
 		return (FALSE);
-	bcopy(addr, xdrs->x_private, len);
+	memmove(xdrs->x_private, addr, (size_t)len);
 	xdrs->x_private += len;
 	return (TRUE);
 }
diff -ur xdr-orig/xdr_rec.c xdr-pk/xdr_rec.c
--- xdr-orig/xdr_rec.c	Fri Nov 18 16:13:16 2005
+++ xdr-pk/xdr_rec.c	Mon Dec 11 22:10:58 2006
@@ -49,6 +49,9 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 #include <rpc/types.h>
 #include <rpc/xdr.h>
 //#include <netinet/in.h>
@@ -279,7 +282,7 @@
 	while (len > 0) {
 		current = (u_int)rstrm->out_boundry - (u_int)rstrm->out_finger;
 		current = (len < current) ? len : current;
-		bcopy(addr, rstrm->out_finger, current);
+		memmove(rstrm->out_finger, addr, (size_t)current);
 		rstrm->out_finger += current;
 		addr += current;
 		len -= current;
@@ -530,7 +533,7 @@
 			continue;
 		}
 		current = (len < current) ? len : current;
-		bcopy(rstrm->in_finger, addr, current);
+		memmove(addr, rstrm->in_finger, (size_t)current);
 		rstrm->in_finger += current;
 		addr += current;
 		len -= current;
diff -ur xdr-orig/xdr_reference.c xdr-pk/xdr_reference.c
--- xdr-orig/xdr_reference.c	Fri Nov 18 16:13:16 2005
+++ xdr-pk/xdr_reference.c	Mon Dec 11 22:05:35 2006
@@ -41,6 +41,8 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <rpc/types.h>
 #include <rpc/xdr.h>
 
@@ -77,7 +79,7 @@
 				    "xdr_reference: out of memory\n");
 				return (FALSE);
 			}
-			bzero(loc, (int)size);
+			memset(loc, 0, (size_t)size);
 			break;
 	}
 


More information about the grass-dev mailing list