Re: RFA: libjava seems to miss some files for win32

Kai Tietz <[email protected]>
Newsgroups gmane.comp.gcc.devel,gmane.comp.gcc.java.devel
Message-ID <[email protected]>
2009/7/18 Dave Korn <[email protected]>:
> Kai Tietz wrote:
>> Hello,
>>
>> I noticed, while trying to build libjava for x64 windows, that the
>> configure script fails to generate link to
>> 'libjava/gnu/java/security/jce/prng/natVMSecureRandomWin32.cc'. This
>> file isn't existing. Is there a fix for this?
>>
>> Thanks in advance for the answer,
>> Kai
>>
>
>  You probably want to post this to the main list rather than -patches!  Also
> the java list, I would suppose.  The bug is strange.  I get nothing from "grep
> -R SecureRandomWin32 libjava/*" in my sandbox (but I'm still on r.149334 from
> 07/07).

Yes, I missed to add java maintainer and the patch here.
I noticed, while trying to build libjava for x64 windows, that the
configure script fails to generate link to
'libjava/gnu/java/security/jce/prng/natVMSecureRandomWin32.cc'. This
file isn't existing.

The attached patch fixes this. The implementation is straight forward,
but works for win32 api. The random value generation could be improved
here.

ChangeLog

2009-07-18  Kai Tietz  <[email protected]>

	* gnu/java/security/jce/prng/natVMSecureRandomWin32.cc: Implementation
	for native win32.

Tested for x86 and x64 mingw targets. Ok for apply?

Cheers,
Kai


-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
libjave_win.diff (text/x-c, 1.3 KB)
Index: gcc/libjava/gnu/java/security/jce/prng/natVMSecureRandomWin32.cc
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ gcc/libjava/gnu/java/security/jce/prng/natVMSecureRandomWin32.cc	2009-07-18 14:35:14.102884300 +0200
@@ -0,0 +1,44 @@
+// natVMSecureRandomPosix.cc - Native part of VMSecureRandom class for POSIX.
+
+/* Copyright (C) 2009 Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <gcj/cni.h>
+#include <java/lang/InternalError.h>
+#include <gnu/java/security/jce/prng/VMSecureRandom.h>
+
+jint
+gnu::java::security::jce::prng::VMSecureRandom::natGenerateSeed(jbyteArray byte_array, jint offset, jint length)
+{
+  static int was_init = 0;
+  int a;
+  jbyte *bytes = elements (byte_array);
+  ssize_t count = 0;
+
+  if (!was_init)
+    {
+      srand (256);
+      was_init = 1;
+    }
+  for (a = 0; a < offset; ++a)
+    bytes++;
+  for (a = 0; a < length; a++, count++)
+   *bytes++= (jbyte) rand ();
+
+  return count;
+}
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.