Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2006-04-27 16:16:09 +0000
committerMarkus Schorn2006-04-27 16:16:09 +0000
commit8272805b36b67b9ff569349292cb36493c207acc (patch)
tree8ce7840c92b011e6fd06a9884b0051bc47041a11
parent488356be7df7f9ab91bf4ce3bb58ad28061554db (diff)
downloadorg.eclipse.cdt-8272805b36b67b9ff569349292cb36493c207acc.tar.gz
org.eclipse.cdt-8272805b36b67b9ff569349292cb36493c207acc.tar.xz
org.eclipse.cdt-8272805b36b67b9ff569349292cb36493c207acc.zip
Changes to source to fix 119618, binaries to be compiled.
-rw-r--r--core/org.eclipse.cdt.core.linux/library/io.c28
-rw-r--r--core/org.eclipse.cdt.core.win32/library/iostream.c12
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java13
3 files changed, 53 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.linux/library/io.c b/core/org.eclipse.cdt.core.linux/library/io.c
index 6070f33f29..f63fca7710 100644
--- a/core/org.eclipse.cdt.core.linux/library/io.c
+++ b/core/org.eclipse.cdt.core.linux/library/io.c
@@ -14,6 +14,10 @@
#include <SpawnerOutputStream.h>
#include <unistd.h>
+#define INT_MAX 2147483647
+
+JNIEXPORT jint JNICALL JVM_Available(jint fd, jlong *pbytes);
+
/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerInputStream */
/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerOutputStream */
@@ -71,6 +75,30 @@ Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv * env,
return close(fd);
}
+JNIEXPORT jint JNICALL
+Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0(JNIEnv * env,
+ jobject jobj,
+ jint fd)
+{
+ jlong ret;
+
+ if (JVM_Available(fd, &ret)) {
+ if (ret > INT_MAX) {
+ ret = (jlong) INT_MAX;
+ }
+ return (jint)ret;
+ }
+
+ /* Error, toss an exception */
+ jclass exception = (*env)->FindClass(env, "java/io/IOException");
+ if (exception == NULL) {
+ /* Give up. */
+ return -1;
+ }
+ (*env)->ThrowNew(env, exception, NULL);
+ return 0;
+}
+
/*
* Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream
* Method: write0
diff --git a/core/org.eclipse.cdt.core.win32/library/iostream.c b/core/org.eclipse.cdt.core.win32/library/iostream.c
index 163a3a8b95..7beda1cdbc 100644
--- a/core/org.eclipse.cdt.core.win32/library/iostream.c
+++ b/core/org.eclipse.cdt.core.win32/library/iostream.c
@@ -168,6 +168,18 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_clo
return (rc ? GetLastError() : 0);
}
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0
+ (JNIEnv * env, jobject proc, jint fd)
+{
+ int nAvail = 0;
+
+ if (0 == PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nAvail, NULL)) {
+ // error
+ return 0;
+ }
+ return nAvail;
+}
+
/*
* Class: SpawnerOutputStream
* Method: write0
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java
index 49a8fdda2a..f19a4c5299 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java
@@ -43,6 +43,7 @@ class SpawnerInputStream extends InputStream {
* @see InputStream#read(byte[], int, int)
*/
public int read(byte[] buf, int off, int len) throws IOException {
+ available();
if (buf == null) {
throw new NullPointerException();
} else if (
@@ -78,11 +79,23 @@ class SpawnerInputStream extends InputStream {
fd = -1;
}
+ public int available() throws IOException {
+ try {
+ return available0(fd);
+ }
+ catch (UnsatisfiedLinkError e) {
+ // for those platforms that do not implement available0
+ return super.available();
+ }
+ }
+
private native int read0(int fileDesc, byte[] buf, int len) throws IOException;
private native int close0(int fileDesc) throws IOException;
+ private native int available0(int fileDesc) throws IOException;
static {
System.loadLibrary("spawner"); //$NON-NLS-1$
}
+
}

Back to the top