public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Implement jni/Environ from cni; including memory leak.
@ 2008-05-22  0:06 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2008-05-22  0:06 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  d32811fe5f691be4fe7d8491b5129811dbdcd931 (commit)
       via  071f99c3f674bf3f0bc4902b80ec2ec034351ca4 (commit)
      from  fc0e559d9ccf78f7c1f0646d689de31744c29a80 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit d32811fe5f691be4fe7d8491b5129811dbdcd931
Author: Andrew Cagney <cagney@redhat.com>
Date:   Wed May 21 19:49:56 2008 -0400

    Implement jni/Environ from cni; including memory leak.
    
    frysk-sys/frysk/sys/ChangeLog
    2008-05-21  Andrew Cagney  <cagney@redhat.com>
    
    	* Environ.java (putEnvironment(String[])): Change parameter from
    	Object[] to String[].
    	* jni/Environ.cxx: Implement.
    	* cni/Environ.cxx: Update.

commit 071f99c3f674bf3f0bc4902b80ec2ec034351ca4
Author: Andrew Cagney <cagney@redhat.com>
Date:   Wed May 21 19:32:14 2008 -0400

    frysk-sys/ChangeLog
    2008-05-21  Andrew Cagney  <cagney@redhat.com>
    
    	* Makefile.am (JniRunner): Add frysk.sys.termios.
    
    frysk-sys/frysk/sys/termios/ChangeLog
    2008-05-21  Andrew Cagney  <cagney@redhat.com>
    
    	* jni/Mode.cxx: Delete.
    	* jni/Termios.cxx: Implement.
    	* jni/Speed.cxx: Implement.
    	* jni/Special.cxx: Implement.
    	* jni/Output.cxx: Implement.
    	* jni/Local.cxx: Implement.
    	* jni/Input.cxx: Implement.
    	* jni/Flush.cxx: Implement.
    	* jni/Flow.cxx: Implement.
    	* jni/Control.cxx: Implement.
    
    frysk-sys/jnixx/ChangeLog
    2008-05-21  Andrew Cagney  <cagney@redhat.com>
    
    	* JniBindings.java: Add == for Object.

-----------------------------------------------------------------------

Summary of changes:
 frysk-sys/ChangeLog                                |    2 +
 frysk-sys/Makefile.am                              |    1 +
 frysk-sys/frysk/sys/ChangeLog                      |    5 ++
 frysk-sys/frysk/sys/Environ.java                   |    4 +-
 frysk-sys/frysk/sys/cni/Environ.cxx                |    5 +-
 .../sys/{termios/jni/Mode.cxx => jni/Environ.cxx}  |   28 +++++++++-
 frysk-sys/frysk/sys/termios/ChangeLog              |   13 ++++
 frysk-sys/frysk/sys/termios/jni/Control.cxx        |   37 ++++++++++++-
 frysk-sys/frysk/sys/termios/jni/Flow.cxx           |   28 +++++++++-
 frysk-sys/frysk/sys/termios/jni/Flush.cxx          |   27 ++++++++-
 frysk-sys/frysk/sys/termios/jni/Input.cxx          |   38 ++++++++++++-
 frysk-sys/frysk/sys/termios/jni/Local.cxx          |   45 ++++++++++++++-
 frysk-sys/frysk/sys/termios/jni/Output.cxx         |   38 ++++++++++++-
 frysk-sys/frysk/sys/termios/jni/Special.cxx        |   35 +++++++++++-
 frysk-sys/frysk/sys/termios/jni/Speed.cxx          |   53 +++++++++++++++++-
 frysk-sys/frysk/sys/termios/jni/Termios.cxx        |   61 +++++++++++++++++++-
 frysk-sys/jnixx/ChangeLog                          |    2 +
 frysk-sys/jnixx/JniBindings.java                   |    9 +++
 18 files changed, 416 insertions(+), 15 deletions(-)
 rename frysk-sys/frysk/sys/{termios/jni/Mode.cxx => jni/Environ.cxx} (75%)

First 500 lines of diff:
diff --git a/frysk-sys/ChangeLog b/frysk-sys/ChangeLog
index 6536b04..f2e5e9a 100644
--- a/frysk-sys/ChangeLog
+++ b/frysk-sys/ChangeLog
@@ -1,5 +1,7 @@
 2008-05-21  Andrew Cagney  <cagney@redhat.com>
 
+	* Makefile.am (JniRunner): Add frysk.sys.termios.	
+
 	* Makefile.am (JniRunner): Test frysk.expunit, frysk.sys.proc,
 	frysk.sys.TestProcessIdentifier, frysk.sys.TestSignal,
 	frysk.sys.TestSignalSet.
diff --git a/frysk-sys/Makefile.am b/frysk-sys/Makefile.am
index ac8043b..d444764 100644
--- a/frysk-sys/Makefile.am
+++ b/frysk-sys/Makefile.am
@@ -98,6 +98,7 @@ JniRunner: | frysk-sys.jar libfrysk-sys-jni.so
 	echo "    frysk.junit \\"				>> $@.tmp
 	echo "    frysk.rsl \\"					>> $@.tmp
 	echo "    frysk.sys.proc \\"				>> $@.tmp
+	echo "    frysk.sys.termios \\"				>> $@.tmp
 	echo "    frysk.sys.TestProcessIdentifier \\"		>> $@.tmp
 	echo "    frysk.sys.TestSignal \\"			>> $@.tmp
 	echo "    frysk.sys.TestSignalSet \\"			>> $@.tmp
diff --git a/frysk-sys/frysk/sys/ChangeLog b/frysk-sys/frysk/sys/ChangeLog
index ad2a3f3..c2a024d 100644
--- a/frysk-sys/frysk/sys/ChangeLog
+++ b/frysk-sys/frysk/sys/ChangeLog
@@ -1,5 +1,10 @@
 2008-05-21  Andrew Cagney  <cagney@redhat.com>
 
+	* Environ.java (putEnvironment(String[])): Change parameter from
+	Object[] to String[].
+	* jni/Environ.cxx: Implement.
+	* cni/Environ.cxx: Update.
+
 	* jni/Itimer.cxx: Implement.
 
 	* cni/PseudoTerminal.cxx: Delete stray include.
diff --git a/frysk-sys/frysk/sys/Environ.java b/frysk-sys/frysk/sys/Environ.java
index ffbec15..ff4be00 100644
--- a/frysk-sys/frysk/sys/Environ.java
+++ b/frysk-sys/frysk/sys/Environ.java
@@ -113,7 +113,7 @@ public class Environ
         Iterator valueIter = values.iterator();
         Iterator keyIter= keys.iterator();
         int idx = 0;
-        Object[] envs = new String[values.size()];
+        String[] envs = new String[values.size()];
 
         while (keyIter.hasNext()) {
             envs[idx] = (String)keyIter.next() + "=" + valueIter.next();
@@ -124,5 +124,5 @@ public class Environ
 
     native void getEnvironment();
     native void getEnvironment(long environ);
-    native long putEnvironment(Object[] envs);
+    native long putEnvironment(String[] envs);
 }
diff --git a/frysk-sys/frysk/sys/cni/Environ.cxx b/frysk-sys/frysk/sys/cni/Environ.cxx
index 839a861..5c92e5b 100644
--- a/frysk-sys/frysk/sys/cni/Environ.cxx
+++ b/frysk-sys/frysk/sys/cni/Environ.cxx
@@ -65,9 +65,8 @@ frysk::sys::Environ::getEnvironment(jlong environ_p)
 char **new_environ;
 
 jlong
-frysk::sys::Environ::putEnvironment(jobjectArray envs)
-{
-  jstring* env_member = (jstring*)elements(envs);
+frysk::sys::Environ::putEnvironment(jstringArray envs) {
+  jstring* env_member = elements(envs);
   int envs_length = JvGetArrayLength(envs);
   new_environ = (char**)JvMalloc(sizeof(void*) * (envs_length + 1));
   for (int i = 0; i < envs_length; i++) 
diff --git a/frysk-sys/frysk/sys/termios/jni/Mode.cxx b/frysk-sys/frysk/sys/jni/Environ.cxx
similarity index 75%
rename from frysk-sys/frysk/sys/termios/jni/Mode.cxx
rename to frysk-sys/frysk/sys/jni/Environ.cxx
index 21809d1..89d4cf1 100644
--- a/frysk-sys/frysk/sys/termios/jni/Mode.cxx
+++ b/frysk-sys/frysk/sys/jni/Environ.cxx
@@ -37,5 +37,31 @@
 // version and license this file solely under the GPL without
 // exception.
 
-// Stub to for generation of corresponding header.
 #include "jni.hxx"
+
+#include "jnixx/elements.hxx"
+
+using namespace java::lang;
+using namespace frysk::sys;
+
+void
+Environ::getEnvironment(jnixx::env env) {
+  extern char **environ;
+  int env_idx;
+  for (env_idx = 0; environ[env_idx]; env_idx++) 
+    addEnviron(env, String::NewStringUTF(env, environ[env_idx]));
+}
+
+void
+Environ::getEnvironment(jnixx::env env, jlong environ_p) {
+  int env_idx;
+  char ** environ = (char **) environ_p;
+  for (env_idx = 0; environ[env_idx]; env_idx++) 
+    addEnviron(env, String::NewStringUTF(env, environ[env_idx]));
+}
+
+jlong
+Environ::putEnvironment(jnixx::env env, jnixx::array<String> envs) {
+  // FIXME: This clearly leaks memory!
+  return (jlong)strings2chars(env, envs);
+}
diff --git a/frysk-sys/frysk/sys/termios/ChangeLog b/frysk-sys/frysk/sys/termios/ChangeLog
index ad99061..2660012 100644
--- a/frysk-sys/frysk/sys/termios/ChangeLog
+++ b/frysk-sys/frysk/sys/termios/ChangeLog
@@ -1,3 +1,16 @@
+2008-05-21  Andrew Cagney  <cagney@redhat.com>
+
+	* jni/Mode.cxx: Delete.
+	* jni/Termios.cxx: Implement.
+	* jni/Speed.cxx: Implement.
+	* jni/Special.cxx: Implement.
+	* jni/Output.cxx: Implement.
+	* jni/Local.cxx: Implement.
+	* jni/Input.cxx: Implement.
+	* jni/Flush.cxx: Implement.
+	* jni/Flow.cxx: Implement.
+	* jni/Control.cxx: Implement.
+
 2008-05-14  Andrew Cagney  <cagney@redhat.com>
 
 	* Termios.java (termios): Change type to "long"; pass value to
diff --git a/frysk-sys/frysk/sys/termios/jni/Control.cxx b/frysk-sys/frysk/sys/termios/jni/Control.cxx
index b358932..d5f303f 100644
--- a/frysk-sys/frysk/sys/termios/jni/Control.cxx
+++ b/frysk-sys/frysk/sys/termios/jni/Control.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2008, Red Hat Inc.
+// Copyright 2007, 2008, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -37,4 +37,39 @@
 // version and license this file solely under the GPL without
 // exception.
 
+#include <sys/types.h>
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+
 #include "jni.hxx"
+
+#include "jnixx/exceptions.hxx"
+
+using namespace java::lang;
+using namespace frysk::sys::termios;
+
+static tcflag_t
+toFlag(jnixx::env env, Control mode) {
+  runtimeException(env, "untested termios input mode");
+}
+
+void
+Control::set(jnixx::env env, jlong t, bool on) {
+  tcflag_t flag = toFlag(env, *this);
+  struct termios* termios = (struct termios*) t;
+  if (on)
+    termios->c_cflag |= flag;
+  else
+    termios->c_cflag &= ~flag;
+}
+
+bool
+Control::get(jnixx::env env, jlong t) {
+  tcflag_t flag = toFlag(env, *this);
+  struct termios* termios = (struct termios*) t;
+  if (termios->c_cflag & flag)
+    return true;
+  else
+    return false;
+}
diff --git a/frysk-sys/frysk/sys/termios/jni/Flow.cxx b/frysk-sys/frysk/sys/termios/jni/Flow.cxx
index b358932..0556a9a 100644
--- a/frysk-sys/frysk/sys/termios/jni/Flow.cxx
+++ b/frysk-sys/frysk/sys/termios/jni/Flow.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2008, Red Hat Inc.
+// Copyright 2007, 2008, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -37,4 +37,30 @@
 // version and license this file solely under the GPL without
 // exception.
 
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+
 #include "jni.hxx"
+
+#include "jnixx/exceptions.hxx"
+
+using namespace java::lang;
+using namespace frysk::sys::termios;
+
+void
+Flow::flow(jnixx::env env, frysk::sys::FileDescriptor fd, Flow f) {
+  int flow;
+  if (f == Flow::GetOUTPUT_OFF(env))
+    flow = TCOOFF;
+  else if (f == Flow::GetOUTPUT_ON(env))
+    flow = TCOON;
+  else if (f == Flow::GetINPUT_OFF(env))
+    flow = TCIOFF;
+  else if (f == Flow::GetINPUT_ON(env))
+    flow = TCION;
+  else
+    runtimeException(env, "Unknown flow control");
+  if (::tcflow(fd.getFd(env), flow) < 0)
+    errnoException(env, errno, "tcflow", "fd %d", (int)(fd.getFd(env)));
+}
diff --git a/frysk-sys/frysk/sys/termios/jni/Flush.cxx b/frysk-sys/frysk/sys/termios/jni/Flush.cxx
index b358932..d8cefe3 100644
--- a/frysk-sys/frysk/sys/termios/jni/Flush.cxx
+++ b/frysk-sys/frysk/sys/termios/jni/Flush.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2008, Red Hat Inc.
+// Copyright 2007, 2008, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -37,4 +37,29 @@
 // version and license this file solely under the GPL without
 // exception.
 
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+
 #include "jni.hxx"
+
+#include "jnixx/exceptions.hxx"
+
+using namespace java::lang;
+using namespace frysk::sys::termios;
+
+void
+Flush::flush(jnixx::env env, frysk::sys::FileDescriptor fd, Flush q)
+{
+  int queue;
+  if (q == Flush::GetINPUT(env))
+    queue = TCIFLUSH;
+  else if (q == Flush::GetOUTPUT(env))
+    queue = TCOFLUSH;
+  else if (q == Flush::GetINPUT_OUTPUT(env))
+    queue = TCIOFLUSH;
+  else
+    runtimeException(env, "Unrecognized flush queue; untested");
+  if (::tcflush(fd.getFd(env), queue) < 0)
+    errnoException(env, errno, "tcflush", "fd %d", (int)(fd.getFd(env)));
+}
diff --git a/frysk-sys/frysk/sys/termios/jni/Input.cxx b/frysk-sys/frysk/sys/termios/jni/Input.cxx
index b358932..07c97a9 100644
--- a/frysk-sys/frysk/sys/termios/jni/Input.cxx
+++ b/frysk-sys/frysk/sys/termios/jni/Input.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2008, Red Hat Inc.
+// Copyright 2007, 2008, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -37,4 +37,40 @@
 // version and license this file solely under the GPL without
 // exception.
 
+#include <sys/types.h>
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+
 #include "jni.hxx"
+
+#include "jnixx/exceptions.hxx"
+
+using namespace java::lang;
+using namespace frysk::sys::termios;
+
+static tcflag_t
+toFlag(jnixx::env env, Input mode) {
+  runtimeException(env, "untested termios input mode");
+}
+
+void
+Input::set(jnixx::env env, jlong t, bool on) {
+  tcflag_t flag = toFlag(env, *this);
+  struct termios* termios = (struct termios*) t;
+  if (on)
+    termios->c_iflag |= flag;
+  else
+    termios->c_iflag &= ~flag;
+}
+
+
+bool
+Input::get(jnixx::env env, jlong t) {
+  tcflag_t flag = toFlag(env, *this);
+  struct termios* termios = (struct termios*) t;
+  if (termios->c_lflag & flag)
+    return true;
+  else
+    return false;
+}
diff --git a/frysk-sys/frysk/sys/termios/jni/Local.cxx b/frysk-sys/frysk/sys/termios/jni/Local.cxx
index b358932..4b996df 100644
--- a/frysk-sys/frysk/sys/termios/jni/Local.cxx
+++ b/frysk-sys/frysk/sys/termios/jni/Local.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2008, Red Hat Inc.
+// Copyright 2007, 2008, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -37,4 +37,47 @@
 // version and license this file solely under the GPL without
 // exception.
 
+#include <sys/types.h>
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+
 #include "jni.hxx"
+
+#include "jnixx/exceptions.hxx"
+
+using namespace java::lang;
+using namespace frysk::sys::termios;
+
+static tcflag_t
+toFlag(jnixx::env env, Local mode) {
+  tcflag_t flag;
+  if (mode == Local::GetECHO_INPUT(env))
+    flag = ECHO;
+  else if (mode == Local::GetCANONICAL(env))
+    flag = ICANON;
+  else
+    runtimeException(env, "untested termios input mode");
+  return flag;
+}
+
+void
+Local::set(jnixx::env env, jlong t, bool on) {
+  tcflag_t flag = toFlag(env, *this);
+  struct termios* termios = (struct termios*) t;
+  if (on)
+    termios->c_lflag |= flag;
+  else
+    termios->c_lflag &= ~flag;
+}
+
+
+bool
+Local::get(jnixx::env env, jlong t) {
+  tcflag_t flag = toFlag(env, *this);
+  struct termios* termios = (struct termios*) t;
+  if (termios->c_lflag & flag)
+    return true;
+  else
+    return false;
+}
diff --git a/frysk-sys/frysk/sys/termios/jni/Output.cxx b/frysk-sys/frysk/sys/termios/jni/Output.cxx
index b358932..c5cf839 100644
--- a/frysk-sys/frysk/sys/termios/jni/Output.cxx
+++ b/frysk-sys/frysk/sys/termios/jni/Output.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2008, Red Hat Inc.
+// Copyright 2007, 2008, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -37,4 +37,40 @@
 // version and license this file solely under the GPL without
 // exception.
 
+#include <sys/types.h>
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+
 #include "jni.hxx"
+
+#include "jnixx/exceptions.hxx"
+
+using namespace java::lang;
+using namespace frysk::sys::termios;
+
+static tcflag_t
+toFlag(jnixx::env env, Output mode) {
+  runtimeException(env, "untested termios input mode");
+}
+
+void
+Output::set(jnixx::env env, jlong t, bool on) {
+  tcflag_t flag = toFlag(env, *this);
+  struct termios* termios = (struct termios*) t;
+  if (on)
+    termios->c_oflag |= flag;
+  else
+    termios->c_oflag &= ~flag;
+}
+
+
+bool
+Output::get(jnixx::env env, jlong t) {
+  tcflag_t flag = toFlag(env, *this);
+  struct termios* termios = (struct termios*) t;
+  if (termios->c_oflag & flag)
+    return true;
+  else
+    return false;
+}
diff --git a/frysk-sys/frysk/sys/termios/jni/Special.cxx b/frysk-sys/frysk/sys/termios/jni/Special.cxx
index b358932..8d6afc1 100644
--- a/frysk-sys/frysk/sys/termios/jni/Special.cxx
+++ b/frysk-sys/frysk/sys/termios/jni/Special.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2008, Red Hat Inc.
+// Copyright 2007, 2008, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -37,4 +37,37 @@
 // version and license this file solely under the GPL without
 // exception.
 
+#include <sys/types.h>
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+
 #include "jni.hxx"
+
+#include "jnixx/exceptions.hxx"
+
+using namespace java::lang;
+using namespace frysk::sys::termios;
+
+static int
+toIndex(jnixx::env env, Special special)
+{
+  if (special == Special::GetNON_CANONICAL_READ_MINIMUM(env))
+    return VMIN;
+  else
+    runtimeException(env, "untested termios special control character");
+}
+
+void
+Special::set(jnixx::env env, jlong t, jchar val) {
+  int i = toIndex(env, *this);
+  struct termios* termios = (struct termios*)t;
+  termios->c_cc[i] = val;
+}
+
+jchar
+Special::get(jnixx::env env, jlong t) {
+  int i = toIndex(env, *this);
+  struct termios* termios = (struct termios*) t;
+  return (jchar) (termios->c_cc[i]);
+}
diff --git a/frysk-sys/frysk/sys/termios/jni/Speed.cxx b/frysk-sys/frysk/sys/termios/jni/Speed.cxx
index b358932..513cc28 100644
--- a/frysk-sys/frysk/sys/termios/jni/Speed.cxx
+++ b/frysk-sys/frysk/sys/termios/jni/Speed.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2008, Red Hat Inc.
+// Copyright 2007, 2008, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it


hooks/post-receive
--
frysk system monitor/debugger


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-22  0:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-22  0:06 [SCM] master: Implement jni/Environ from cni; including memory leak cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).