This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: _Jv_pipe instead of ::pipe


Hi People,

This patch fixes this issue:

http://gcc.gnu.org/ml/java-patches/2003-q4/msg00136.html

I commented on this here:

http://gcc.gnu.org/ml/java-patches/2003-q4/msg00138.html

The patch opts for the second solution:

>- a quicker and dirtier solution would be to define _Jv_Pipe in both
>  win32.h and posix.h and provide implementations for these in
>  both win32.cc and posix.cc. I was so relieved to eradicate all of
>  these, though, so doing this would be a step backward.

Upon reflection (the human kind), I concluded that _Jv_pipe isn't
as bad as all that because we're not dealing with networking here.
The Win32 _pipe implementation is similar, and unlike the Windows
Sockets functions, sets errno just like on UNIX, etc. In my initial
post, I was thinking that the pipe stuff was analagous to the networking
stuff, but now I don't think it is. This doesn't necessarily rule out
forking the code later for other reasons, though.

I've tested the Linux native and MinGW cross builds, but only
for successful compilation and linking since this code isn't
finished yet.

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/

ChangeLog
2003-10-17  Mohan Embar  <gnustuff@thisiscool.com>

	* win32.cc: (_Jv_pipe) Implemented.
	* gnu/java/nio/natPipeImpl.cc: (nativeInit) Use
	_Jv_pipe instead of ::pipe.
	* include/posix.h: (_Jv_pipe) New inline.
	* include/win32.h: (_Jv_pipe) New declaration.
	
Index: win32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/win32.cc,v
retrieving revision 1.16
diff -u -2 -r1.16 win32.cc
--- win32.cc	29 Aug 2003 04:21:00 -0000	1.16
+++ win32.cc	17 Oct 2003 04:51:28 -0000
@@ -13,4 +13,5 @@
 #include <sys/timeb.h>
 #include <stdlib.h>
+#include <fcntl.h>
 
 #include <java/lang/ArithmeticException.h>
@@ -342,3 +343,9 @@
     }
   return r;      
+}
+
+int
+_Jv_pipe (int filedes[2])
+{
+  return _pipe (filedes, 4096, _O_BINARY);
 }
Index: gnu/java/nio/natPipeImpl.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/natPipeImpl.cc,v
retrieving revision 1.1
diff -u -2 -r1.1 natPipeImpl.cc
--- gnu/java/nio/natPipeImpl.cc	12 Oct 2003 13:39:07 -0000	1.1
+++ gnu/java/nio/natPipeImpl.cc	17 Oct 2003 04:51:30 -0000
@@ -27,5 +27,5 @@
   int filedes [2];
 
-  if (::pipe (filedes) < 0)
+  if (_Jv_pipe (filedes) < 0)
     throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
 
Index: include/posix.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/posix.h,v
retrieving revision 1.21
diff -u -2 -r1.21 posix.h
--- include/posix.h	7 Jul 2003 14:11:09 -0000	1.21
+++ include/posix.h	17 Oct 2003 04:51:31 -0000
@@ -179,3 +179,10 @@
 #endif /* DISABLE_JAVA_NET */
 
+// Wraps ::pipe
+static inline int
+_Jv_pipe (int filedes[2])
+{
+  return ::pipe (filedes);
+}
+
 #endif /* __JV_POSIX_H__ */
Index: include/win32.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/win32.h,v
retrieving revision 1.22
diff -u -2 -r1.22 win32.h
--- include/win32.h	29 Aug 2003 04:21:00 -0000	1.22
+++ include/win32.h	17 Oct 2003 04:51:31 -0000
@@ -96,4 +96,5 @@
 extern jlong _Jv_platform_gettimeofday ();
 extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *);
+extern int _Jv_pipe (int filedes[2]);
 
 inline void




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]