diff options
Diffstat (limited to 'core')
66 files changed, 389 insertions, 2184 deletions
diff --git a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so Binary files differindex 587fa695259..cfd41f315e8 100644..100755 --- a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so +++ b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so diff --git a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so Binary files differindex 18736e10a2c..4154d0fa6ac 100644..100755 --- a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so +++ b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so diff --git a/core/org.eclipse.cdt.core.linux/build.properties b/core/org.eclipse.cdt.core.linux/build.properties index 587895eb060..833b5a7e6f6 100644 --- a/core/org.eclipse.cdt.core.linux/build.properties +++ b/core/org.eclipse.cdt.core.linux/build.properties @@ -16,6 +16,5 @@ bin.includes = fragment.xml,\ .,\ META-INF/,\ plugin.properties -src.includes = about.html,\ - library/ +src.includes = about.html source.. = src/ diff --git a/core/org.eclipse.cdt.core.linux/library/Makefile b/core/org.eclipse.cdt.core.linux/library/Makefile deleted file mode 100644 index 508cb455a41..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# makefile for libspawner.so - -ifeq ($(JAVA_HOME),) -$(warning JAVA_HOME not set in environment) -endif - -# Defaults which can be overridden. -OS = linux -ARCH = x86_64 - -JDK_INCLUDES= $(JAVA_HOME)/include -JDK_OS_INCLUDES= $(JAVA_HOME)/include/$(OS) - -CC=gcc -CPPFLAGS = -I. -I$(JDK_INCLUDES) -I$(JDK_OS_INCLUDES) -CFLAGS +=-fpic -D_REENTRANT -D_GNU_SOURCE - -INSTALL_DIR = ../../org.eclipse.cdt.core.linux.$(ARCH)/os/$(OS)/$(ARCH) - -LIB_NAME_SPAWNER = libspawner.so -LIB_NAME_FULL_SPAWNER = $(INSTALL_DIR)/libspawner.so -OBJS_SPAWNER=spawner.o io.o exec_unix.o exec_pty.o pfind.o openpty.o - -LIB_NAME_PTY = libpty.so -LIB_NAME_FULL_PTY = $(INSTALL_DIR)/libpty.so -OBJS_PTY= openpty.o pty.o ptyio.o - -OBJS = $(OBJS_SPAWNER) $(OBJS_PTY) - -all: $(LIB_NAME_FULL_SPAWNER) $(LIB_NAME_FULL_PTY) - -rebuild: clean all - -$(LIB_NAME_FULL_SPAWNER) : $(OBJS_SPAWNER) - mkdir -p $(INSTALL_DIR) - $(CC) -g -shared -Wl,-soname,$(LIB_NAME_SPAWNER) $(LDFLAGS) -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER) -lc - -$(LIB_NAME_FULL_PTY): $(OBJS_PTY) - mkdir -p $(INSTALL_DIR) - $(CC) -g -shared -Wl,-soname,$(LIB_NAME_PTY) $(LDFLAGS) -o $(LIB_NAME_FULL_PTY) $(OBJS_PTY) - -clean : - $(RM) $(OBJS_SPAWNER) $(LIB_NAME_FULL_SPAWNER) - $(RM) $(OBJS_PTY) $(LIB_NAME_FULL_PTY) diff --git a/core/org.eclipse.cdt.core.linux/library/PTYInputStream.h b/core/org.eclipse.cdt.core.linux/library/PTYInputStream.h deleted file mode 100644 index e7349272b56..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/PTYInputStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_pty_PTYInputStream */ - -#ifndef _Included_org_eclipse_cdt_utils_pty_PTYInputStream -#define _Included_org_eclipse_cdt_utils_pty_PTYInputStream -#ifdef __cplusplus -extern "C" { -#endif -#undef org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE -#define org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE 2048L -/* Inaccessible static: skipBuffer */ -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: read0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/Spawner.h b/core/org.eclipse.cdt.core.linux/library/Spawner.h deleted file mode 100644 index 02727f98a88..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/Spawner.h +++ /dev/null @@ -1,53 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_spawner_Spawner */ - -#ifndef _Included_org_eclipse_cdt_utils_spawner_Spawner -#define _Included_org_eclipse_cdt_utils_spawner_Spawner -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec0 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec1 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: raise - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise - (JNIEnv *, jobject, jint, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: waitFor - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h b/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h deleted file mode 100644 index ecf8f8c6a78..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerInputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#ifdef __cplusplus -extern "C" { -#endif -#undef com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE -#define com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE 2048L -/* Inaccessible static: skipBuffer */ -/* - * Class: org_elipse_cdt_utils_spawner_SpawnerInputStream - * Method: read0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/SpawnerOutputStream.h b/core/org.eclipse.cdt.core.linux/library/SpawnerOutputStream.h deleted file mode 100644 index 444d71c698c..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/SpawnerOutputStream.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerOutputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/pom.xml b/core/org.eclipse.cdt.core.linux/pom.xml index eacc249a446..625fe2c1fa2 100644 --- a/core/org.eclipse.cdt.core.linux/pom.xml +++ b/core/org.eclipse.cdt.core.linux/pom.xml @@ -15,103 +15,6 @@ <artifactId>org.eclipse.cdt.core.linux</artifactId> <packaging>eclipse-plugin</packaging> - <profiles> - <profile> - <id>build-native.linux.x86_64</id> - <activation> - <property> - <name>native</name> - <value>linux.x86_64</value> - </property> - </activation> - <build> - <plugins> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>natives</id> - <phase>process-resources</phase> - <configuration> - <target> - <exec executable="make" newenvironment="false" dir="./library"> - <arg value="ARCH=x86_64" /> - </exec> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - <execution> - <id>clean-natives</id> - <phase>clean</phase> - <configuration> - <target> - <exec executable="make" newenvironment="false" dir="./library"> - <arg value="ARCH=x86_64" /> - <arg value="clean" /> - </exec> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>build-native.linux.ppc64le</id> - <activation> - <property> - <name>native</name> - <value>linux.ppc64le</value> - </property> - </activation> - <build> - <plugins> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>natives</id> - <phase>process-resources</phase> - <configuration> - <target> - <exec executable="make" newenvironment="false" dir="./library"> - <arg value="ARCH=ppc64le" /> - </exec> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - <execution> - <id>clean-natives</id> - <phase>clean</phase> - <configuration> - <target> - <exec executable="make" newenvironment="false" dir="./library"> - <arg value="ARCH=ppc64le" /> - <arg value="clean" /> - </exec> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - <build> <plugins> <plugin> diff --git a/core/org.eclipse.cdt.core.macosx/build.properties b/core/org.eclipse.cdt.core.macosx/build.properties index 424f3017722..3630460b11f 100644 --- a/core/org.eclipse.cdt.core.macosx/build.properties +++ b/core/org.eclipse.cdt.core.macosx/build.properties @@ -17,6 +17,5 @@ bin.includes = fragment.xml,\ os/,\ META-INF/,\ plugin.properties -src.includes = about.html,\ - library/ +src.includes = about.html source.. = src/ diff --git a/core/org.eclipse.cdt.core.macosx/library/.gitignore b/core/org.eclipse.cdt.core.macosx/library/.gitignore deleted file mode 100644 index f9e528a2229..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.o -/ltmain.sh diff --git a/core/org.eclipse.cdt.core.macosx/library/Makefile b/core/org.eclipse.cdt.core.macosx/library/Makefile deleted file mode 100644 index 62eeec8cdb3..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/Makefile +++ /dev/null @@ -1,135 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2002, 2015 QNX Software Systems and others. -# -# This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 2.0 -# which accompanies this distribution, and is available at -# https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# QNX Software Systems - initial API and implementation -# Alex Blewitt - MacOSX with a 64-bit vm -# Martin Oberhuber (Wind River) - Bug 476709 - Fix change_window_size() -#*******************************************************************************/ - -# makefile for libspawner.so -# See http://developer.apple.com/documentation/Java/Conceptual/Java141Development/Core_APIs/chapter_6_section_4.html - -JAVA_HOME = $(shell echo /Library/Java/JavaVirtualMachines/jdk1.[78].0_*.jdk/Contents/Home) - -# Defaults which can be overridden. -OS = macosx -ARCH_X86 = x86 -ARCH_X86_64 = x86_64 - -CC=gcc -LD=libtool -CPPFLAGS = -I. -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -CFLAGS +=-fPIC -D_REENTRANT - -ARCH_FLAG_X86 = -arch i386 -ARCH_FLAG_X86_64 = -arch x86_64 - -INSTALL_DIR_X86 = ../os/$(OS)/$(ARCH_X86) -INSTALL_DIR_X86_64 = ../os/$(OS)/$(ARCH_X86_64) - -LIB_NAME_FULL_SPAWNER_X86 = $(INSTALL_DIR_X86)/libspawner.jnilib -LIB_NAME_FULL_SPAWNER_X86_64 = $(INSTALL_DIR_X86_64)/libspawner.jnilib -OBJS_SPAWNER_X86 = spawner_$(ARCH_X86).o \ - io_$(ARCH_X86).o \ - exec_unix_$(ARCH_X86).o \ - exec_pty_$(ARCH_X86).o \ - openpty_$(ARCH_X86).o \ - pfind_$(ARCH_X86).o -OBJS_SPAWNER_X86_64 = spawner_$(ARCH_X86_64).o \ - io_$(ARCH_X86_64).o \ - exec_unix_$(ARCH_X86_64).o \ - exec_pty_$(ARCH_X86_64).o \ - openpty_$(ARCH_X86_64).o \ - pfind_$(ARCH_X86_64).o - -LIB_NAME_FULL_PTY_X86 = $(INSTALL_DIR_X86)/libpty.jnilib -LIB_NAME_FULL_PTY_X86_64 = $(INSTALL_DIR_X86_64)/libpty.jnilib -OBJS_PTY_X86 = openpty_$(ARCH_X86).o pty_$(ARCH_X86).o ptyio_$(ARCH_X86).o -OBJS_PTY_X86_64 = openpty_$(ARCH_X86_64).o pty_$(ARCH_X86_64).o ptyio_$(ARCH_X86_64).o - -OBJS_X86 = $(OBJS_SPAWNER_X86) $(OBJS_PTY_X86) $(OBJS_SERIAL_X86) -OBJS_X86_64 = $(OBJS_SPAWNER_X86_64) $(OBJS_PTY_X86_64) $(OBJS_SERIAL_X86_64) - -all: x86 x86_64 - -x86: $(LIB_NAME_FULL_SPAWNER_X86) $(LIB_NAME_FULL_PTY_X86) - -x86_64: $(LIB_NAME_FULL_SPAWNER_X86_64) $(LIB_NAME_FULL_PTY_X86_64) - -rebuild: clean all - -$(LIB_NAME_FULL_SPAWNER_X86) : $(OBJS_SPAWNER_X86) - mkdir -p $(INSTALL_DIR_X86) - $(CC) -dynamiclib $(ARCH_FLAG_X86) -o $(LIB_NAME_FULL_SPAWNER_X86) $(OBJS_SPAWNER_X86) -lc -framework JavaVM - -$(LIB_NAME_FULL_SPAWNER_X86_64) : $(OBJS_SPAWNER_X86_64) - mkdir -p $(INSTALL_DIR_X86_64) - $(CC) -dynamiclib $(ARCH_FLAG_X86_64) -o $(LIB_NAME_FULL_SPAWNER_X86_64) $(OBJS_SPAWNER_X86_64) -lc -framework JavaVM - -$(LIB_NAME_FULL_PTY_X86): $(OBJS_PTY_X86) - mkdir -p $(INSTALL_DIR_X86) - $(CC) -dynamiclib $(ARCH_FLAG_X86) -o $(LIB_NAME_FULL_PTY_X86) $(OBJS_PTY_X86) -lc -framework JavaVM - -$(LIB_NAME_FULL_PTY_X86_64): $(OBJS_PTY_X86_64) - mkdir -p $(INSTALL_DIR_X86_64) - $(CC) -dynamiclib $(ARCH_FLAG_X86_64) -o $(LIB_NAME_FULL_PTY_X86_64) $(OBJS_PTY_X86_64) -lc -framework JavaVM - -spawner_$(ARCH_X86).o: spawner.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ spawner.c - -io_$(ARCH_X86).o: io.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ io.c - -exec_unix_$(ARCH_X86).o: exec_unix.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ exec_unix.c - -exec_pty_$(ARCH_X86).o: exec_pty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ exec_pty.c - -openpty_$(ARCH_X86).o: openpty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ openpty.c - -pfind_$(ARCH_X86).o: pfind.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ pfind.c - -pty_$(ARCH_X86).o: pty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ pty.c - -ptyio_$(ARCH_X86).o: ptyio.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ ptyio.c - -spawner_$(ARCH_X86_64).o: spawner.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ spawner.c - -io_$(ARCH_X86_64).o: io.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ io.c - -exec_unix_$(ARCH_X86_64).o: exec_unix.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ exec_unix.c - -exec_pty_$(ARCH_X86_64).o: exec_pty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ exec_pty.c - -openpty_$(ARCH_X86_64).o: openpty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ openpty.c - -pfind_$(ARCH_X86_64).o: pfind.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ pfind.c - -pty_$(ARCH_X86_64).o: pty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ pty.c - -ptyio_$(ARCH_X86_64).o: ptyio.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ ptyio.c - -clean : - $(RM) $(OBJS_X86) $(LIB_NAME_FULL_SPAWNER_X86) $(LIB_NAME_FULL_PTY_X86) - $(RM) $(OBJS_X86_64) $(LIB_NAME_FULL_SPAWNER_X86_64) $(LIB_NAME_FULL_PTY_X86_64) diff --git a/core/org.eclipse.cdt.core.macosx/library/PTY.h b/core/org.eclipse.cdt.core.macosx/library/PTY.h deleted file mode 100644 index f717942a01d..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/PTY.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_pty_PTY */ - -#ifndef _Included_org_eclipse_cdt_utils_pty_PTY -#define _Included_org_eclipse_cdt_utils_pty_PTY -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: openMaster - * Signature: (Z)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster - (JNIEnv *, jobject, jboolean); - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: change_window_size - * Signature: (III)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size - (JNIEnv *, jobject, jint, jint, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/PTYOutputStream.h b/core/org.eclipse.cdt.core.macosx/library/PTYOutputStream.h deleted file mode 100644 index fb28491060e..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/PTYOutputStream.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_pty_PTYOutputStream */ - -#ifndef _Included_org_eclipse_cdt_utils_pty_PTYOutputStream -#define _Included_org_eclipse_cdt_utils_pty_PTYOutputStream -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/Spawner.h b/core/org.eclipse.cdt.core.macosx/library/Spawner.h deleted file mode 100644 index 02727f98a88..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/Spawner.h +++ /dev/null @@ -1,53 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_spawner_Spawner */ - -#ifndef _Included_org_eclipse_cdt_utils_spawner_Spawner -#define _Included_org_eclipse_cdt_utils_spawner_Spawner -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec0 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec1 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: raise - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise - (JNIEnv *, jobject, jint, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: waitFor - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/SpawnerInputStream.h b/core/org.eclipse.cdt.core.macosx/library/SpawnerInputStream.h deleted file mode 100644 index ecf8f8c6a78..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/SpawnerInputStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerInputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#ifdef __cplusplus -extern "C" { -#endif -#undef com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE -#define com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE 2048L -/* Inaccessible static: skipBuffer */ -/* - * Class: org_elipse_cdt_utils_spawner_SpawnerInputStream - * Method: read0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/SpawnerOutputStream.h b/core/org.eclipse.cdt.core.macosx/library/SpawnerOutputStream.h deleted file mode 100644 index 444d71c698c..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/SpawnerOutputStream.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerOutputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/exec0.h b/core/org.eclipse.cdt.core.macosx/library/exec0.h deleted file mode 100644 index b1e24c44fd6..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/exec0.h +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -#include <unistd.h> -#include <sys/wait.h> -#include <sys/types.h> -#include <signal.h> -#include <errno.h> - -extern pid_t exec0(const char *path, char *const argv[], - char *const envp[], const char *dirpath, - int channels[3] ); - -extern pid_t exec_pty(const char *path, char *const argv[], - char *const envp[], const char *dirpath, - int channels[3], const char *pts_name, int fdm, - int console); - -extern int wait0(pid_t pid); diff --git a/core/org.eclipse.cdt.core.macosx/library/exec_pty.c b/core/org.eclipse.cdt.core.macosx/library/exec_pty.c deleted file mode 100644 index e020053db41..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/exec_pty.c +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2010 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Zabaluev (Nokia) - bug 82744 - * Mikhail Sennikovsky - bug 145737 - *******************************************************************************/ -#include "exec0.h" -#include "openpty.h" -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <libgen.h> -#include <stdlib.h> -#include <termios.h> - -/* from pfind.c */ -extern char *pfind(const char *name, char * const envp[]); - -pid_t -exec_pty(const char *path, char *const argv[], char *const envp[], - const char *dirpath, int channels[3], const char *pts_name, int fdm, int console) -{ - int pipe2[2]; - pid_t childpid; - char *full_path; - - /* - * We use pfind() to check that the program exists and is an executable. - * If not pass the error up. Also execve() wants a full path. - */ - full_path = pfind(path, envp); - if (full_path == NULL) { - fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); - return -1; - } - - /* - * Make sure we can create our pipes before forking. - */ - if (channels != NULL && console) { - if (pipe(pipe2) < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno)); - free(full_path); - return -1; - } - } - - childpid = fork(); - - if (childpid < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno)); - free(full_path); - return -1; - } else if (childpid == 0) { /* child */ - - chdir(dirpath); - - if (channels != NULL) { - int fds; - - if (!console && setsid() < 0) { - perror("setsid()"); - return -1; - } - - fds = ptys_open(fdm, pts_name); - if (fds < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno)); - return -1; - } - - /* Close the read end of pipe2 */ - if (console && close(pipe2[0]) == -1) { - perror("close(pipe2[0]))"); - } - - /* close the master, no need in the child */ - close(fdm); - - if (console) { - set_noecho(fds); - if (setpgid(getpid(), getpid()) < 0) { - perror("setpgid()"); - return -1; - } - } - - /* redirections */ - dup2(fds, STDIN_FILENO); /* dup stdin */ - dup2(fds, STDOUT_FILENO); /* dup stdout */ - if (console) { - dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ - } else { - dup2(fds, STDERR_FILENO); /* dup stderr */ - } - close(fds); /* done with fds. */ - } - - /* Close all the fd's in the child */ - { - int fdlimit = sysconf(_SC_OPEN_MAX); - int fd = 3; - - while (fd < fdlimit) - close(fd++); - } - - if (envp[0] == NULL) { - execv(full_path, argv); - } else { - execve(full_path, argv, envp); - } - - _exit(127); - - } else if (childpid != 0) { /* parent */ - if (console) { - set_noecho(fdm); - } - if (channels != NULL) { - channels[0] = fdm; /* Input Stream. */ - channels[1] = fdm; /* Output Stream. */ - if (console) { - /* close the write end of pipe1 */ - if (close(pipe2[1]) == -1) - perror("close(pipe2[1])"); - channels[2] = pipe2[0]; /* stderr Stream. */ - } else { - channels[2] = fdm; /* Error Stream. */ - } - } - - free(full_path); - return childpid; - } - - free(full_path); - return -1; /*NOT REACHED */ -} -#ifdef __STAND_ALONE__ -int main(int argc, char **argv, char **envp) { - const char *path = "./bufferring_test"; - int channels[3] = { -1, -1, -1}; - int status; - FILE *app_stdin; - FILE *app_stdout; - FILE *app_stderr; - char pts_name[32]; - int fdm; - char buffer[32]; - - fdm = ptym_open(pts_name); - status = exec_pty(path, argv, envp, ".", channels, pts_name, fdm); - if (status >= 0) { - app_stdin = fdopen(channels[0], "w"); - app_stdout = fdopen(channels[1], "r"); - app_stderr = fdopen(channels[2], "r"); - if (app_stdout == NULL || app_stderr == NULL || app_stdin == NULL) { - fprintf(stderr, "PROBLEMS\n"); - } else { - fputs("foo\n", app_stdin); - fputs("bar\n", app_stdin); - while(fgets(buffer, sizeof buffer, app_stdout) != NULL) { - fprintf(stdout, "STDOUT: %s\n", buffer); - } - while(fgets(buffer, sizeof buffer, app_stderr) != NULL) { - fprintf(stdout, "STDERR: %s\n", buffer); - } - } - } - fputs("bye\n", stdout); - close(channels[0]); - close(channels[1]); - close(channels[2]); - return 0; -} -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/exec_unix.c b/core/org.eclipse.cdt.core.macosx/library/exec_unix.c deleted file mode 100644 index 4feb805f15d..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/exec_unix.c +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Sennikovsky - bug 145737 - *******************************************************************************/ -#include "exec0.h" -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <libgen.h> -#include <stdlib.h> - -/* from pfind.c */ -extern char *pfind(const char *name, char * const envp[]); - -pid_t -exec0(const char *path, char *const argv[], char *const envp[], - const char *dirpath, int channels[3]) -{ - int pipe0[2], pipe1[2], pipe2[2]; - pid_t childpid; - char *full_path; - - /* - * We use pfind() to check that the program exists and is an executable. - * If not pass the error up. Also execve() wants a full path. - */ - full_path = pfind(path, envp); - if (full_path == NULL) { - fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); - return -1; - } - - /* - * Make sure we can create our pipes before forking. - */ - if (channels != NULL) { - if (pipe(pipe0) < 0 || pipe(pipe1) < 0 || pipe(pipe2) < 0) { - fprintf(stderr, "%s(%d): returning due to error.\n", - __FUNCTION__, __LINE__); - free(full_path); - return -1; - } - } - - childpid = fork(); - - if (childpid < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", - __FUNCTION__, __LINE__, strerror(errno)); - free(full_path); - return -1; - } else if (childpid == 0) { /* child */ - char *ptr; - - chdir(dirpath); - - if (channels != NULL) { - /* Close the write end of pipe0 */ - if (close(pipe0[1]) == -1) - perror("close(pipe0[1])"); - - /* Close the read end of pipe1 */ - if (close(pipe1[0]) == -1) - perror("close(pipe1[0])"); - - /* Close the read end of pipe2 */ - if (close(pipe2[0]) == -1) - perror("close(pipe2[0]))"); - - /* redirections */ - dup2(pipe0[0], STDIN_FILENO); /* dup stdin */ - dup2(pipe1[1], STDOUT_FILENO); /* dup stdout */ - dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ - } - - /* Close all the fd's in the child */ - { - int fdlimit = sysconf(_SC_OPEN_MAX); - int fd = 3; - - while (fd < fdlimit) - close(fd++); - } - - setpgid(getpid(), getpid()); - - if (envp[0] == NULL) { - execv(full_path, argv); - } else { - execve(full_path, argv, envp); - } - - _exit(127); - - } else if (childpid != 0) { /* parent */ - - char b; - - if (channels != NULL) { - /* close the read end of pipe1 */ - if (close(pipe0[0]) == -1) - perror("close(pipe0[0])"); - - /* close the write end of pipe2 */ - if (close(pipe1[1]) == -1) - perror("close(pipe1[1])"); - - /* close the write end of pipe2 */ - if (close(pipe2[1]) == -1) - perror("close(pipe2[1])"); - - channels[0] = pipe0[1]; /* Output Stream. */ - channels[1] = pipe1[0]; /* Input Stream. */ - channels[2] = pipe2[0]; /* Input Stream. */ - } - - free(full_path); - return childpid; - } - - free(full_path); - return -1; /*NOT REACHED */ -} - - -int wait0(pid_t pid) -{ - int status; - int val = -1; - - if (pid < 0) - return -1; - - for (;;) { - if (waitpid(pid, &status, 0) < 0) { - if (errno == EINTR) { - // interrupted system call - retry - continue; - } - } - break; - } - if (WIFEXITED(status)) { - val = WEXITSTATUS(status); - } - - return val; -} diff --git a/core/org.eclipse.cdt.core.macosx/library/io.c b/core/org.eclipse.cdt.core.macosx/library/io.c deleted file mode 100644 index 17d12ae639d..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/io.c +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002 - 2005 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -#include <jni.h> -#include <stdio.h> -#include <SpawnerInputStream.h> -#include <SpawnerOutputStream.h> -#include <unistd.h> - -/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerInputStream */ -/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerOutputStream */ - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: read0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int fd; - int status; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = read( fd, data, data_len ); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - if (status == 0) { - /* EOF. */ - status = -1; - } else if (status == -1) { - /* Error, toss an exception */ - jclass exception = (*env)->FindClass(env, "java/io/IOException"); - if (exception == NULL) { - /* Give up. */ - return -1; - } - (*env)->ThrowNew(env, exception, "read error"); - } - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: write0 - * Signature: (II)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int status; - int fd; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = write(fd, data, data_len); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} diff --git a/core/org.eclipse.cdt.core.macosx/library/openpty.c b/core/org.eclipse.cdt.core.macosx/library/openpty.c deleted file mode 100644 index 933349220f9..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/openpty.c +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2017 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Zabaluev (Nokia) - bug 82744 - * Corey Ashford (IBM) - bug 272370, bug 272372 - * Martin Oberhuber - [519886] align w/ Linux, support OSX 10.13 - *******************************************************************************/ - -/* _XOPEN_SOURCE is needed to bring in the header for ptsname */ -#define _XOPEN_SOURCE -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <termios.h> -#include <errno.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <grp.h> - -#include <stdlib.h> - -/** - * This is taken from R. W. Stevens book. - * Alain Magloire. - */ - -int ptym_open (char *pts_name); -int ptys_open (int fdm, const char * pts_name); -void set_noecho(int fd); - -int -openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) -{ - char line[20]; - line[0]=0; - *amaster = ptym_open(line); - if (*amaster < 0) - return -1; - *aslave = ptys_open(*amaster, line); - if (*aslave < 0) { - close(*amaster); - return -1; - } - - if (name) - strcpy(name, line); -#ifndef TCSAFLUSH -#define TCSAFLUSH TCSETAF -#endif - if (termp) - (void) tcsetattr(*aslave, TCSAFLUSH, termp); -#ifdef TIOCSWINSZ - if (winp) - (void) ioctl(*aslave, TIOCSWINSZ, (char *)winp); -#endif - return 0; -} - -void -set_noecho(int fd) -{ - struct termios stermios; - if (tcgetattr(fd, &stermios) < 0) { - return ; - } - - /* turn off echo */ - stermios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); - /* Turn off the NL to CR/NL mapping ou output. */ - /*stermios.c_oflag &= ~(ONLCR);*/ - - stermios.c_iflag |= (IGNCR); - - tcsetattr(fd, TCSANOW, &stermios); -} - -int -ptym_open(char * pts_name) -{ - int fdm; - char *ptr; - - strcpy(pts_name, "/dev/ptmx"); - fdm = posix_openpt(O_RDWR|O_NOCTTY); - if (fdm < 0) - return -1; - if (grantpt(fdm) < 0) { /* grant access to slave */ - close(fdm); - return -2; - } - if (unlockpt(fdm) < 0) { /* clear slave's lock flag */ - close(fdm); - return -3; - } - ptr = ptsname(fdm); - if (ptr == NULL) { /* get slave's name */ - close (fdm); - return -4; - } - strcpy(pts_name, ptr); /* return name of slave */ - return fdm; /* return fd of master */ -} - -int -ptys_open(int fdm, const char * pts_name) -{ - int fds; - /* following should allocate controlling terminal */ - fds = open(pts_name, O_RDWR); - if (fds < 0) { - close(fdm); - return -5; - } - -#if defined(TIOCSCTTY) - /* TIOCSCTTY is the BSD way to acquire a controlling terminal. */ - if (ioctl(fds, TIOCSCTTY, (char *)0) < 0) { - // ignore error: this is expected in console-mode - } -#endif - return fds; -} diff --git a/core/org.eclipse.cdt.core.macosx/library/openpty.h b/core/org.eclipse.cdt.core.macosx/library/openpty.h deleted file mode 100644 index 43d2b8bcb97..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/openpty.h +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -#ifndef _OPENPTY_H -#define _OPENPTY_H -int ptym_open (char *pts_name); -int ptys_open (int fdm, const char * pts_name); -void set_noecho(int fd); -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/pfind.c b/core/org.eclipse.cdt.core.macosx/library/pfind.c deleted file mode 100644 index 01b9e5cc054..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/pfind.c +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2011 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Sennikovsky - bug 145737 - * Everton Rufino Constantino (IBM) - bug 237611 - *******************************************************************************/ -/* - * pfind.c - Search for a binary in $PATH. - */ - -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <limits.h> - -#ifndef PATH_MAX -#define PATH_MAX 1024 -#endif - -#define PATH_DEF "PATH=" -const int path_def_len = 5; /* strlen(PATH_DEF); */ - -char * path_val(char * const envp[]) -{ - int i; - if (envp == NULL || envp[0] == NULL) - return getenv("PATH" ); - - for(i = 0; envp[i] != NULL; i++){ - char* p = envp[i]; - if(!strncmp(PATH_DEF, p, path_def_len)){ - return p + path_def_len; - } - } - - return NULL; -} - -char * pfind(const char *name, char * const envp[]) -{ - char *tok; - char *sp; - char *path; - char fullpath[PATH_MAX+1]; - - /* Sanity check. */ - if (name == NULL) { - fprintf(stderr, "pfind(): Null argument.\n"); - return NULL; - } - - /* For absolute name or name with a path, check if it is an executable. */ - if (name[0] == '/' || name[0] == '.') { - if (access(name, X_OK) == 0) { - return strdup(name); - } - return NULL; - } - - /* Search in the PATH environment. */ - path = path_val( envp ); - - if (path == NULL || strlen(path) <= 0) { - fprintf(stderr, "Unable to get $PATH.\n"); - return NULL; - } - - /* The value return by getenv() is readonly */ - path = strdup(path); - - tok = strtok_r(path, ":", &sp); - while (tok != NULL) { - snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", tok, name); - - if (access(fullpath, X_OK) == 0) { - free(path); - return strdup(fullpath); - } - - tok = strtok_r( NULL, ":", &sp ); - } - - free(path); - return NULL; -} - -#ifdef BUILD_WITH_MAIN -int main(int argc, char **argv) -{ - int i; - char *fullpath; - - for (i=1; i<argc; i++) { - fullpath = pfind(argv[i], NULL); - if (fullpath == NULL) - printf("Unable to find %s in $PATH.\n", argv[i]); - else - printf("Found %s @ %s.\n", argv[i], fullpath); - } -} -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/pty.c b/core/org.eclipse.cdt.core.macosx/library/pty.c deleted file mode 100644 index e6ebd9015a2..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/pty.c +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2015 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - * Martin Oberhuber (Wind River) - Bug 476709 - Fix change_window_size() - *******************************************************************************/ -#include "PTY.h" -#include "openpty.h" - -#include <sys/ioctl.h> - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: forkpty - * Signature: ()I - */ -JNIEXPORT jstring JNICALL -Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj, jboolean console) { - jfieldID fid; /* Store the field ID */ - jstring jstr = NULL; - int master = -1; - char line[1024]; /* FIXME: Should be enough */ - jclass cls; - - line[0] = '\0'; - - master = ptym_open(line); - if (master >= 0) { - if (console) { - // turn off echo - set_noecho(master); - } - - /* Get a reference to the obj's class */ - cls = (*env)->GetObjectClass(env, jobj); - - /* Set the master fd. */ - fid = (*env)->GetFieldID(env, cls, "master", "I"); - if (fid == NULL) { - return NULL; - } - (*env)->SetIntField(env, jobj, fid, (jint)master); - - /* Create a new String for the slave. */ - jstr = (*env)->NewStringUTF(env, line); - } - return jstr; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size - (JNIEnv *env, jobject jobj, jint fdm, jint width, jint height) -{ -#ifdef TIOCSWINSZ - struct winsize win; - - win.ws_col = width; - win.ws_row = height; - win.ws_xpixel = 0; - win.ws_ypixel = 0; - - return ioctl(fdm, TIOCSWINSZ, &win); -#else -#error no TIOCSWINSZ - return 0; -#endif -} diff --git a/core/org.eclipse.cdt.core.macosx/library/ptyio.c b/core/org.eclipse.cdt.core.macosx/library/ptyio.c deleted file mode 100644 index e022db11f99..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/ptyio.c +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002 - 2005 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -#include <jni.h> -#include <stdio.h> -#include <PTYInputStream.h> -#include <PTYOutputStream.h> -#include <unistd.h> - -/* Header for class _org_eclipse_cdt_utils_pty_PTYInputStream */ -/* Header for class _org_eclipse_cdt_utils_pty_PTYOutputStream */ - -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: read0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int fd; - int status; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = read( fd, data, data_len ); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - if (status == 0) { - /* EOF. */ - status = -1; - } else if (status == -1) { - /* Error, toss an exception */ - /* Ignore the error for now, the debugger will attempt - * to close this multiple time. */ -#if 0 - jclass exception = (*env)->FindClass(env, "java/io/IOException"); - if (exception == NULL) { - /* Give up. */ - return -1; - } - (*env)->ThrowNew(env, exception, "read error"); -#endif - } - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} - -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: write0 - * Signature: (II)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int status; - int fd; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = write(fd, data, data_len); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} diff --git a/core/org.eclipse.cdt.core.macosx/library/spawner.c b/core/org.eclipse.cdt.core.macosx/library/spawner.c deleted file mode 100644 index 623b1382cf8..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/spawner.c +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Zabaluev (Nokia) - bug 82744 - *******************************************************************************/ -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <signal.h> -#include <string.h> -#include <jni.h> - -#include "exec0.h" -#include <Spawner.h> - - -#define DEBUGIT 0 - - -/* - * Header for class org_eclipse_cdt_utils_spawner_Spawner - */ - - -#if DEBUGIT -static void print_array(char **c_array) -{ - if (c_array) { - char **p = c_array; - for (; *p; p++) { - if (*p) { - fprintf(stderr, " %s", *p); - } - } - } else { - fprintf(stderr, "null"); - } - fprintf(stderr, "\n"); -} -#endif - - -static char **alloc_c_array(JNIEnv * env, jobjectArray j_array) -{ - int i; - jint c_array_size = (*env)->GetArrayLength(env, j_array); - char **c_array = calloc(c_array_size + 1, sizeof(*c_array)); - - if (c_array == NULL) - return NULL; - - for (i = 0; i < c_array_size; i++) { - jstring j_str = - (jstring) (*env)->GetObjectArrayElement(env, j_array, i); - const char *c_str = (*env)->GetStringUTFChars(env, j_str, NULL); - c_array[i] = (char *) strdup(c_str); - (*env)->ReleaseStringUTFChars(env, j_str, c_str); - (*env)->DeleteLocalRef(env, j_str); - } - - return c_array; -} - - -static void free_c_array(char **c_array) -{ - if (c_array) { - char **p = c_array; - for (; *p; p++) { - if (*p) { - free(*p); - } - } - free(c_array); - } -} - - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILorg/eclipse/cdt/utils/pty/PTY;)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv, jstring jdir, jintArray jchannels, - jstring jslaveName, jint masterFD, jboolean console) -{ - jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0); - const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL); - char **cmd = NULL; - char **envp = NULL; - int fd[3]; - pid_t pid = -1; - - if (channels == NULL) - goto bail_out; - - cmd = alloc_c_array(env, jcmd); - if (cmd == NULL) - goto bail_out; - - envp = alloc_c_array(env, jenv); - if (envp == NULL) - goto bail_out; - -#if DEBUGIT - fprintf(stderr, "command:"); - print_array(cmd); - fprintf(stderr, "Envp:"); - print_array(envp); - fprintf(stderr, "dirpath: %s\n", dirpath); - fprintf(stderr, "pts_name: %s\n", pts_name); -#endif - - pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console); - if (pid < 0) - goto bail_out; - - channels[0] = fd[0]; - channels[1] = fd[1]; - channels[2] = fd[2]; - - bail_out: - (*env)->ReleaseIntArrayElements(env, jchannels, channels, 0); - (*env)->ReleaseStringUTFChars(env, jdir, dirpath); - (*env)->ReleaseStringUTFChars(env, jslaveName, pts_name); - if (cmd) - free_c_array(cmd); - if (envp) - free_c_array(envp); - return pid; -} - - -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv * env, jobject jobj, - jobjectArray jcmd, - jobjectArray jenv, - jstring jdir) -{ - const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - char **cmd = NULL; - char **envp = NULL; - pid_t pid = -1; - - cmd = alloc_c_array(env, jcmd); - if (cmd == NULL) - goto bail_out; - - envp = alloc_c_array(env, jenv); - if (envp == NULL) - goto bail_out; - -#if DEBUGIT - fprintf(stderr, "command:"); - print_array(cmd); - fprintf(stderr, "Envp:"); - print_array(envp); - fprintf(stderr, "dirpath: %s\n", dirpath); -#endif - - pid = exec0(cmd[0], cmd, envp, dirpath, NULL); - if (pid < 0) - goto bail_out; - - bail_out: - (*env)->ReleaseStringUTFChars(env, jdir, dirpath); - if (cmd) - free_c_array(cmd); - if (envp) - free_c_array(envp); - return pid; -} - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec0 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv * env, jobject jobj, - jobjectArray jcmd, - jobjectArray jenv, - jstring jdir, - jintArray jchannels) -{ - jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0); - const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - char **cmd = NULL; - char **envp = NULL; - int fd[3]; - pid_t pid = -1; - - if (channels == NULL) - goto bail_out; - - cmd = alloc_c_array(env, jcmd); - if (cmd == NULL) - goto bail_out; - - envp = alloc_c_array(env, jenv); - if (envp == NULL) - goto bail_out; - -#if DEBUGIT - fprintf(stderr, "command:"); - print_array(cmd); - fprintf(stderr, "Envp:"); - print_array(envp); - fprintf(stderr, "dirpath: %s\n", dirpath); -#endif - - pid = exec0(cmd[0], cmd, envp, dirpath, fd); - if (pid < 0) - goto bail_out; - - channels[0] = fd[0]; - channels[1] = fd[1]; - channels[2] = fd[2]; - - bail_out: - (*env)->ReleaseIntArrayElements(env, jchannels, channels, 0); - (*env)->ReleaseStringUTFChars(env, jdir, dirpath); - if (cmd) - free_c_array(cmd); - if (envp) - free_c_array(envp); - return pid; -} - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: raise - * Signature: (II)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv * env, jobject jobj, - jint pid, jint sig) -{ - int status = -1; - - switch (sig) { - case 0: /* NOOP */ - status = killpg(pid, 0); - if(status == -1) { - status = kill(pid, 0); - } - break; - - case 2: /* INTERRUPT */ - status = killpg(pid, SIGINT); - if(status == -1) { - status = kill(pid, SIGINT); - } - break; - - case 9: /* KILL */ - status = killpg(pid, SIGKILL); - if(status == -1) { - status = kill(pid, SIGKILL); - } - break; - - case 15: /* TERM */ - status = killpg(pid, SIGTERM); - if(status == -1) { - status = kill(pid, SIGTERM); - } - break; - - default: - status = killpg(pid, sig); /* WHAT ?? */ - if(status == -1) { - status = kill(pid, sig); /* WHAT ?? */ - } - break; - } - - return status; -} - - - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: waitFor - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv * env, - jobject jobj, jint pid) -{ - return wait0(pid); -} diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib Binary files differindex 50ba6991d48..de7d60029f0 100755 --- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib +++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib Binary files differindex bde561aed62..df51c06cf3c 100755 --- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib +++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib Binary files differindex b18de5e480c..0283c6b798d 100755 --- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib +++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib Binary files differindex 8d8c80bac6e..620bd6bf01d 100755 --- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib +++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib diff --git a/core/org.eclipse.cdt.core.native/build.properties b/core/org.eclipse.cdt.core.native/build.properties index 2e7a449116e..006a08c7bcb 100644 --- a/core/org.eclipse.cdt.core.native/build.properties +++ b/core/org.eclipse.cdt.core.native/build.properties @@ -22,7 +22,8 @@ bin.includes = plugin.properties,\ about.properties,\ plugin.xml src.includes = about.html,\ - schema/ + schema/,\ + native_src/ javadoc.packages = org.eclipse.cdt.utils.*,\ org.eclipse.cdt.utils.pty.*,\ org.eclipse.cdt.utils.spawner.* diff --git a/core/org.eclipse.cdt.core.native/native_src/Makefile b/core/org.eclipse.cdt.core.native/native_src/Makefile new file mode 100644 index 00000000000..36324b888bd --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/Makefile @@ -0,0 +1,140 @@ +#******************************************************************************* +# Copyright (c) 2002, 2015, 2020 QNX Software Systems and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# QNX Software Systems - initial API and implementation +# Torbjörn Svensson - Bug 521515 - Adopted jenkins build +#*******************************************************************************/ + +ifeq ($(JAVA_HOME),) +$(error JAVA_HOME not set in environment) +endif + +OS_DIR_WIN32_X86_64 := ../../org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64 +OS_DIR_LINUX_X86_64 := ../../org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64 +OS_DIR_LINUX_PPC64LE := ../../org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le +OS_DIR_MACOS_X86_64 := ../../org.eclipse.cdt.core.macosx/os/macosx/x86_64 +OS_DIR_MACOS_X86 := ../../org.eclipse.cdt.core.macosx/os/macosx/x86 + + +UNAME = $(shell uname) +ifeq ($(UNAME),Linux) +LIBS = \ + $(OS_DIR_WIN32_X86_64)/starter.exe \ + $(OS_DIR_WIN32_X86_64)/spawner.dll \ + $(OS_DIR_LINUX_X86_64)/libspawner.so \ + $(OS_DIR_LINUX_X86_64)/libpty.so \ + $(OS_DIR_MACOS_X86_64)/libspawner.jnilib \ + $(OS_DIR_MACOS_X86_64)/libpty.jnilib \ + $(OS_DIR_MACOS_X86)/libspawner.jnilib \ + $(OS_DIR_MACOS_X86)/libpty.jnilib +else +ifeq ($(UNAME),Darwin) +LIBS = \ + $(OS_DIR_MACOS_X86_64)/libspawner.jnilib \ + $(OS_DIR_MACOS_X86_64)/libpty.jnilib \ + $(OS_DIR_MACOS_X86)/libspawner.jnilib \ + $(OS_DIR_MACOS_X86)/libpty.jnilib +else +LIBS = \ + $(OS_DIR_WIN32_X86_64)/starter.exe \ + $(OS_DIR_WIN32_X86_64)/spawner.dll +endif +endif + +all: $(LIBS) + +clean : + $(RM) $(LIBS) + +rebuild: clean all + + +# Windows x86_64 +# Windows DLLs have a build timestamp in them. This makes it impossible to have reproducible builds. +# However, x86_64-w64-mingw32-ld on Debian/Ubuntu has a patch that overrides the current date +# using the SOURCE_DATE_EPOCH environment variable. Therefore we set SOURCE_DATE_EPOCH to a +# consistent timestamp that can be reproduced. We base it off of the commit timestamp of the +# most recent git commit in this directory. +$(OS_DIR_WIN32_X86_64)/starter.exe: win/starter.c + mkdir -p $(dir $@) && \ + SOURCE_DATE_EPOCH=$(shell git log -1 --pretty=format:%ct -- .) \ + x86_64-w64-mingw32-gcc -o $@ -Iinclude -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" \ + -DUNICODE \ + win/starter.c \ + -lpsapi + +$(OS_DIR_WIN32_X86_64)/spawner.dll: win/iostream.c win/raise.c win/spawner.c win/Win32ProcessEx.c + mkdir -p $(dir $@) && \ + SOURCE_DATE_EPOCH=$(shell git log -1 --pretty=format:%ct -- .) \ + x86_64-w64-mingw32-gcc -o $@ -Iinclude -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" \ + -DUNICODE \ + win/iostream.c win/raise.c win/spawner.c win/Win32ProcessEx.c \ + -Wl,--kill-at --shared + +# Linux x86_64 +$(OS_DIR_LINUX_X86_64)/libspawner.so: unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c + mkdir -p $(dir $@) && \ + gcc -m64 -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c \ + -shared -lc + +$(OS_DIR_LINUX_X86_64)/libpty.so: unix/openpty.c unix/pty.c unix/ptyio.c + mkdir -p $(dir $@) && \ + gcc -m64 -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + unix/openpty.c unix/pty.c unix/ptyio.c \ + -shared -lc + +# Linux ppc64le +$(OS_DIR_LINUX_PPC64LE)/libspawner.so: unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c + mkdir -p $(dir $@) && \ + gcc -m64 -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c \ + -shared -lc + +$(OS_DIR_LINUX_PPC64LE)/libpty.so: unix/openpty.c unix/pty.c unix/ptyio.c + mkdir -p $(dir $@) && \ + gcc -m64 -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + unix/openpty.c unix/pty.c unix/ptyio.c \ + -shared -lc + +# macos x86_64 +$(OS_DIR_MACOS_X86_64)/libspawner.jnilib: unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c + mkdir -p $(dir $@) && \ + x86_64-apple-darwin17-clang -o $@ -arch x86_64 -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -fPIC \ + -D_REENTRANT \ + unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c \ + -dynamiclib -lc -framework JavaVM + +$(OS_DIR_MACOS_X86_64)/libpty.jnilib: unix/openpty.c unix/pty.c unix/ptyio.c + mkdir -p $(dir $@) && \ + x86_64-apple-darwin17-clang -o $@ -arch x86_64 -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -fPIC \ + -D_REENTRANT \ + unix/openpty.c unix/pty.c unix/ptyio.c \ + -dynamiclib -lc -framework JavaVM + +# macos x86 +$(OS_DIR_MACOS_X86)/libspawner.jnilib: unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c + mkdir -p $(dir $@) && \ + x86_64-apple-darwin17-clang -o $@ -arch i386 -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -fPIC \ + -D_REENTRANT \ + unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c \ + -dynamiclib -lc -framework JavaVM + +$(OS_DIR_MACOS_X86)/libpty.jnilib: unix/openpty.c unix/pty.c unix/ptyio.c + mkdir -p $(dir $@) && \ + x86_64-apple-darwin17-clang -o $@ -arch i386 -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -fPIC \ + -D_REENTRANT \ + unix/openpty.c unix/pty.c unix/ptyio.c \ + -dynamiclib -lc -framework JavaVM diff --git a/core/org.eclipse.cdt.core.linux/library/PTY.h b/core/org.eclipse.cdt.core.native/native_src/include/PTY.h index f717942a01d..d73d5c00e16 100644 --- a/core/org.eclipse.cdt.core.linux/library/PTY.h +++ b/core/org.eclipse.cdt.core.native/native_src/include/PTY.h @@ -23,6 +23,22 @@ JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size (JNIEnv *, jobject, jint, jint, jint); +/* + * Class: org_eclipse_cdt_utils_pty_PTY + * Method: exec2 + * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_exec2 + (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean); + +/* + * Class: org_eclipse_cdt_utils_pty_PTY + * Method: waitFor + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_waitFor + (JNIEnv *, jobject, jint, jint); + #ifdef __cplusplus } #endif diff --git a/core/org.eclipse.cdt.core.macosx/library/PTYInputStream.h b/core/org.eclipse.cdt.core.native/native_src/include/PTYInputStream.h index e7349272b56..7767be6bd8c 100644 --- a/core/org.eclipse.cdt.core.macosx/library/PTYInputStream.h +++ b/core/org.eclipse.cdt.core.native/native_src/include/PTYInputStream.h @@ -7,9 +7,8 @@ #ifdef __cplusplus extern "C" { #endif -#undef org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE -#define org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE 2048L -/* Inaccessible static: skipBuffer */ +#undef org_eclipse_cdt_utils_pty_PTYInputStream_MAX_SKIP_BUFFER_SIZE +#define org_eclipse_cdt_utils_pty_PTYInputStream_MAX_SKIP_BUFFER_SIZE 2048L /* * Class: org_eclipse_cdt_utils_pty_PTYInputStream * Method: read0 diff --git a/core/org.eclipse.cdt.core.linux/library/PTYOutputStream.h b/core/org.eclipse.cdt.core.native/native_src/include/PTYOutputStream.h index fb28491060e..fb28491060e 100644 --- a/core/org.eclipse.cdt.core.linux/library/PTYOutputStream.h +++ b/core/org.eclipse.cdt.core.native/native_src/include/PTYOutputStream.h diff --git a/core/org.eclipse.cdt.core.win32/library/Spawner.h b/core/org.eclipse.cdt.core.native/native_src/include/Spawner.h index 0e10a7b0af5..10750f2e202 100644 --- a/core/org.eclipse.cdt.core.win32/library/Spawner.h +++ b/core/org.eclipse.cdt.core.native/native_src/include/Spawner.h @@ -43,10 +43,10 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 /* * Class: org_eclipse_cdt_utils_spawner_Spawner * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;LILjava/lang/String;IZ)I + * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I */ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels, jstring slaveName, jint fdm, jboolean console); + (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean); /* * Class: org_eclipse_cdt_utils_spawner_Spawner @@ -56,7 +56,6 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise (JNIEnv *, jobject, jint, jint); - /* * Class: org_eclipse_cdt_utils_spawner_Spawner * Method: waitFor diff --git a/core/org.eclipse.cdt.core.win32/library/SpawnerInputStream.h b/core/org.eclipse.cdt.core.native/native_src/include/SpawnerInputStream.h index 294977dfd31..653c5659524 100644 --- a/core/org.eclipse.cdt.core.win32/library/SpawnerInputStream.h +++ b/core/org.eclipse.cdt.core.native/native_src/include/SpawnerInputStream.h @@ -29,19 +29,19 @@ extern "C" { #define com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE 2048L /* Inaccessible static: skipBuffer */ /* - * Class: com_qnx_tools_utils_spawner_SpawnerInputStream + * Class: org_elipse_cdt_utils_spawner_SpawnerInputStream * Method: read0 * Signature: (I[BI)I */ -JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_SpawnerInputStream_read0 +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0 (JNIEnv *, jobject, jint, jbyteArray, jint); /* - * Class: com_qnx_tools_utils_spawner_SpawnerInputStream + * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream * Method: close0 * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_SpawnerInputStream_close0 +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0 (JNIEnv *, jobject, jint); #ifdef __cplusplus diff --git a/core/org.eclipse.cdt.core.win32/library/SpawnerOutputStream.h b/core/org.eclipse.cdt.core.native/native_src/include/SpawnerOutputStream.h index 4ed58014d39..fb3e0354e88 100644 --- a/core/org.eclipse.cdt.core.win32/library/SpawnerOutputStream.h +++ b/core/org.eclipse.cdt.core.native/native_src/include/SpawnerOutputStream.h @@ -25,19 +25,19 @@ extern "C" { #endif /* - * Class: com_qnx_tools_utils_spawner_SpawnerOutputStream + * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream * Method: write0 * Signature: (I[BI)I */ -JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_SpawnerOutputStream_write0 +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0 (JNIEnv *, jobject, jint, jbyteArray, jint); /* - * Class: com_qnx_tools_utils_spawner_SpawnerOutputStream + * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream * Method: close0 * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_SpawnerOutputStream_close0 +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0 (JNIEnv *, jobject, jint); #ifdef __cplusplus diff --git a/core/org.eclipse.cdt.core.linux/library/exec0.h b/core/org.eclipse.cdt.core.native/native_src/unix/exec0.h index 04f363d5e53..04f363d5e53 100644 --- a/core/org.eclipse.cdt.core.linux/library/exec0.h +++ b/core/org.eclipse.cdt.core.native/native_src/unix/exec0.h diff --git a/core/org.eclipse.cdt.core.linux/library/exec_pty.c b/core/org.eclipse.cdt.core.native/native_src/unix/exec_pty.c index e020053db41..e020053db41 100644 --- a/core/org.eclipse.cdt.core.linux/library/exec_pty.c +++ b/core/org.eclipse.cdt.core.native/native_src/unix/exec_pty.c diff --git a/core/org.eclipse.cdt.core.linux/library/exec_unix.c b/core/org.eclipse.cdt.core.native/native_src/unix/exec_unix.c index 4feb805f15d..4feb805f15d 100644 --- a/core/org.eclipse.cdt.core.linux/library/exec_unix.c +++ b/core/org.eclipse.cdt.core.native/native_src/unix/exec_unix.c diff --git a/core/org.eclipse.cdt.core.linux/library/io.c b/core/org.eclipse.cdt.core.native/native_src/unix/io.c index 94f03d63935..94f03d63935 100644 --- a/core/org.eclipse.cdt.core.linux/library/io.c +++ b/core/org.eclipse.cdt.core.native/native_src/unix/io.c diff --git a/core/org.eclipse.cdt.core.linux/library/openpty.c b/core/org.eclipse.cdt.core.native/native_src/unix/openpty.c index cae7dd5684a..2ca02e2278c 100644 --- a/core/org.eclipse.cdt.core.linux/library/openpty.c +++ b/core/org.eclipse.cdt.core.native/native_src/unix/openpty.c @@ -92,7 +92,11 @@ ptym_open(char * pts_name) char *ptr; strcpy(pts_name, "/dev/ptmx"); +#ifdef __APPLE__ + fdm = posix_openpt(O_RDWR|O_NOCTTY); +#else fdm = getpt(); +#endif if (fdm < 0) return -1; if (grantpt(fdm) < 0) { /* grant access to slave */ diff --git a/core/org.eclipse.cdt.core.linux/library/openpty.h b/core/org.eclipse.cdt.core.native/native_src/unix/openpty.h index 234a306415d..234a306415d 100644 --- a/core/org.eclipse.cdt.core.linux/library/openpty.h +++ b/core/org.eclipse.cdt.core.native/native_src/unix/openpty.h diff --git a/core/org.eclipse.cdt.core.linux/library/pfind.c b/core/org.eclipse.cdt.core.native/native_src/unix/pfind.c index dd7abddf2f6..dd7abddf2f6 100644 --- a/core/org.eclipse.cdt.core.linux/library/pfind.c +++ b/core/org.eclipse.cdt.core.native/native_src/unix/pfind.c diff --git a/core/org.eclipse.cdt.core.linux/library/pty.c b/core/org.eclipse.cdt.core.native/native_src/unix/pty.c index ce25c965919..edb87661eb5 100644 --- a/core/org.eclipse.cdt.core.linux/library/pty.c +++ b/core/org.eclipse.cdt.core.native/native_src/unix/pty.c @@ -57,7 +57,7 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj, jboole JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size (JNIEnv *env, jobject jobj, jint fdm, jint width, jint height) { -#ifdef TIOCGWINSZ +#ifdef TIOCSWINSZ struct winsize win; win.ws_col = width; @@ -67,6 +67,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size return ioctl(fdm, TIOCSWINSZ, &win); #else +#error no TIOCSWINSZ return 0; #endif } diff --git a/core/org.eclipse.cdt.core.linux/library/ptyio.c b/core/org.eclipse.cdt.core.native/native_src/unix/ptyio.c index e022db11f99..e022db11f99 100644 --- a/core/org.eclipse.cdt.core.linux/library/ptyio.c +++ b/core/org.eclipse.cdt.core.native/native_src/unix/ptyio.c diff --git a/core/org.eclipse.cdt.core.linux/library/spawner.c b/core/org.eclipse.cdt.core.native/native_src/unix/spawner.c index 623b1382cf8..623b1382cf8 100644 --- a/core/org.eclipse.cdt.core.linux/library/spawner.c +++ b/core/org.eclipse.cdt.core.native/native_src/unix/spawner.c diff --git a/core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c b/core/org.eclipse.cdt.core.native/native_src/win/Win32ProcessEx.c index 1554983330a..7b6bcc13699 100644 --- a/core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c +++ b/core/org.eclipse.cdt.core.native/native_src/win/Win32ProcessEx.c @@ -17,15 +17,14 @@ * This is a JNI implementation of spawner *******************************************************************************/ -#include "stdafx.h" #include <string.h> #include <stdlib.h> #include <process.h> -#include "Spawner.h" - -#include "jni.h" -#include "io.h" +#include <tchar.h> +#include <windows.h> +#include <jni.h> +#include "Spawner.h" #define PIPE_SIZE 512 // Size of pipe buffer #define MAX_CMD_SIZE 2049 // Initial size of command line @@ -103,7 +102,9 @@ static int nCounter = 0; // We use it to build unique synchronization object nam // [out] channels - streams handlers ///////////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels, jstring slaveName, jint fdm, jboolean console) { @@ -128,7 +129,9 @@ void ensureSize(wchar_t** ptr, int* psize, int requiredLength) } } +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels) { @@ -186,9 +189,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 // Create pipe names EnterCriticalSection(&cs); - swprintf(inPipeName, L"\\\\.\\pipe\\stdin%08i%010i", pid, nCounter); - swprintf(outPipeName, L"\\\\.\\pipe\\stdout%08i%010i", pid, nCounter); - swprintf(errPipeName, L"\\\\.\\pipe\\stderr%08i%010i", pid, nCounter); + swprintf(inPipeName, sizeof(inPipeName)/sizeof(inPipeName[0]), L"\\\\.\\pipe\\stdin%08i%010i", pid, nCounter); + swprintf(outPipeName, sizeof(outPipeName)/sizeof(outPipeName[0]), L"\\\\.\\pipe\\stdout%08i%010i", pid, nCounter); + swprintf(errPipeName, sizeof(errPipeName)/sizeof(errPipeName[0]), L"\\\\.\\pipe\\stderr%08i%010i", pid, nCounter); nLocalCounter = nCounter; ++nCounter; LeaveCriticalSection(&cs); @@ -210,13 +213,13 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 } #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Opened pipes: %s, %s, %s\n"), inPipeName, outPipeName, errPipeName); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Opened pipes: %s, %s, %s\n"), inPipeName, outPipeName, errPipeName); OutputDebugStringW(buffer); #endif - nCmdTokens = env->GetArrayLength(cmdarray); - nEnvVars = env->GetArrayLength(envp); + nCmdTokens = (*env)->GetArrayLength(env, cmdarray); + nEnvVars = (*env)->GetArrayLength(env, envp); pCurProcInfo = createProcInfo(); @@ -227,11 +230,11 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 } // Construct starter's command line - swprintf(eventBreakName, L"SABreak%04x%08x", pid, nLocalCounter); - swprintf(eventWaitName, L"SAWait%004x%08x", pid, nLocalCounter); - swprintf(eventTerminateName, L"SATerm%004x%08x", pid, nLocalCounter); - swprintf(eventKillName, L"SAKill%04x%08x", pid, nLocalCounter); - swprintf(eventCtrlcName, L"SACtrlc%04x%08x", pid, nLocalCounter); + swprintf(eventBreakName, sizeof(eventBreakName)/sizeof(eventBreakName[0]), L"SABreak%04x%08x", pid, nLocalCounter); + swprintf(eventWaitName, sizeof(eventWaitName)/sizeof(eventWaitName[0]), L"SAWait%04x%08x", pid, nLocalCounter); + swprintf(eventTerminateName, sizeof(eventTerminateName)/sizeof(eventTerminateName[0]), L"SATerm%04x%08x", pid, nLocalCounter); + swprintf(eventKillName, sizeof(eventKillName)/sizeof(eventKillName[0]), L"SAKill%04x%08x", pid, nLocalCounter); + swprintf(eventCtrlcName, sizeof(eventCtrlcName)/sizeof(eventCtrlcName[0]), L"SACtrlc%04x%08x", pid, nLocalCounter); pCurProcInfo->eventBreak = CreateEventW(NULL, FALSE, FALSE, eventBreakName); if(NULL == pCurProcInfo->eventBreak || GetLastError() == ERROR_ALREADY_EXISTS) @@ -244,16 +247,16 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 pCurProcInfo->eventKill = CreateEventW(NULL, FALSE, FALSE, eventKillName); pCurProcInfo->eventCtrlc = CreateEventW(NULL, FALSE, FALSE, eventCtrlcName); - swprintf(szCmdLine, L"\"%sstarter.exe\" %i %i %s %s %s %s %s ", path, pid, nLocalCounter, eventBreakName, eventWaitName, eventTerminateName, eventKillName, eventCtrlcName); + swprintf(szCmdLine, nCmdLineLength, L"\"%sstarter.exe\" %i %i %s %s %s %s %s ", path, pid, nLocalCounter, eventBreakName, eventWaitName, eventTerminateName, eventKillName, eventCtrlcName); nPos = wcslen(szCmdLine); // Prepare command line for(i = 0; i < nCmdTokens; ++i) { - jstring item = (jstring)env->GetObjectArrayElement(cmdarray, i); - jsize len = env->GetStringLength(item); + jstring item = (jstring)(*env)->GetObjectArrayElement(env, cmdarray, i); + jsize len = (*env)->GetStringLength(env, item); int nCpyLen; - const wchar_t * str = (const wchar_t *)env->GetStringChars(item, 0); + const wchar_t * str = (const wchar_t *)(*env)->GetStringChars(env, item, 0); if(NULL != str) { int requiredSize= nPos+len+2; @@ -275,13 +278,13 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 nPos += nCpyLen; szCmdLine[nPos] = _T(' '); ++nPos; - env->ReleaseStringChars(item, (const jchar *)str); + (*env)->ReleaseStringChars(env, item, (const jchar *)str); } } szCmdLine[nPos] = _T('\0'); #ifdef DEBUG_MONITOR - swprintf(buffer, _T("There are %i environment variables \n"), nEnvVars); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("There are %i environment variables \n"), nEnvVars); OutputDebugStringW(buffer); #endif // Prepare environment block @@ -291,9 +294,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 szEnvBlock = (wchar_t *)malloc(nBlkSize * sizeof(wchar_t)); for(i = 0; i < nEnvVars; ++i) { - jstring item = (jstring)env->GetObjectArrayElement(envp, i); - jsize len = env->GetStringLength(item); - const wchar_t * str = (const wchar_t *)env->GetStringChars(item, 0); + jstring item = (jstring)(*env)->GetObjectArrayElement(env, envp, i); + jsize len = (*env)->GetStringLength(env, item); + const wchar_t * str = (const wchar_t *)(*env)->GetStringChars(env, item, 0); if(NULL != str) { while((nBlkSize - nPos) <= (len + 2)) // +2 for two '\0' @@ -306,20 +309,20 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 return 0; } #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Realloc environment block; new length is %i \n"), nBlkSize); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Realloc environment block; new length is %i \n"), nBlkSize); OutputDebugStringW(buffer); #endif } #ifdef DEBUG_MONITOR - swprintf(buffer, _T("%s\n"), str); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("%s\n"), str); OutputDebugStringW(buffer); #endif wcsncpy(szEnvBlock + nPos, str, len); nPos += len; szEnvBlock[nPos] = _T('\0'); ++nPos; - env->ReleaseStringChars(item, (const jchar *)str); + (*env)->ReleaseStringChars(env, item, (const jchar *)str); } } szEnvBlock[nPos] = _T('\0'); @@ -329,11 +332,11 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 if (dir != 0) { - const wchar_t * str = (const wchar_t *)env->GetStringChars(dir, 0); + const wchar_t * str = (const wchar_t *)(*env)->GetStringChars(env, dir, 0); if(NULL != str) { cwd = wcsdup(str); - env->ReleaseStringChars(dir, (const jchar *)str); + (*env)->ReleaseStringChars(env, dir, (const jchar *)str); } } @@ -417,7 +420,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 if(what != WAIT_OBJECT_0) // CreateProcess failed { #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Process %i failed\n"), pi.dwProcessId); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Process %i failed\n"), pi.dwProcessId); OutputDebugStringW(buffer); #endif cleanUpProcBlock(pCurProcInfo); @@ -434,7 +437,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 file_handles[0] = (int)stdHandles[0]; file_handles[1] = (int)stdHandles[1]; file_handles[2] = (int)stdHandles[2]; - env->SetIntArrayRegion(channels, 0, 3, (jint *)file_handles); + (*env)->SetIntArrayRegion(env, channels, 0, 3, (jint *)file_handles); // do the cleanup so launch the according thread // create a copy of the PROCESS_INFORMATION as this might get destroyed @@ -464,7 +467,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 // [in] envp - array of environment variables // [in] dir - working directory ///////////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir) { @@ -494,18 +499,18 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 sa.bInheritHandle = TRUE; - nCmdTokens = env->GetArrayLength(cmdarray); - nEnvVars = env->GetArrayLength(envp); + nCmdTokens = (*env)->GetArrayLength(env, cmdarray); + nEnvVars = (*env)->GetArrayLength(env, envp); nPos = 0; // Prepare command line for(i = 0; i < nCmdTokens; ++i) { - jstring item = (jstring)env->GetObjectArrayElement(cmdarray, i); - jsize len = env->GetStringLength(item); + jstring item = (jstring)(*env)->GetObjectArrayElement(env, cmdarray, i); + jsize len = (*env)->GetStringLength(env, item); int nCpyLen; - const wchar_t * str = (const wchar_t *)env->GetStringChars(item, 0); + const wchar_t * str = (const wchar_t *)(*env)->GetStringChars(env, item, 0); if(NULL != str) { int requiredSize= nPos+len+2; @@ -527,7 +532,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 nPos += nCpyLen; szCmdLine[nPos] = _T(' '); ++nPos; - env->ReleaseStringChars(item, (const jchar *)str); + (*env)->ReleaseStringChars(env, item, (const jchar *)str); } } @@ -540,9 +545,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 nPos = 0; for(i = 0; i < nEnvVars; ++i) { - jstring item = (jstring)env->GetObjectArrayElement(envp, i); - jsize len = env->GetStringLength(item); - const wchar_t * str = (const wchar_t *)env->GetStringChars(item, 0); + jstring item = (jstring)(*env)->GetObjectArrayElement(env, envp, i); + jsize len = (*env)->GetStringLength(env, item); + const wchar_t * str = (const wchar_t *)(*env)->GetStringChars(env, item, 0); if(NULL != str) { while((nBlkSize - nPos) <= (len + 2)) // +2 for two '\0' @@ -559,7 +564,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 nPos += len; szEnvBlock[nPos] = _T('\0'); ++nPos; - env->ReleaseStringChars(item, (const jchar *)str); + (*env)->ReleaseStringChars(env, item, (const jchar *)str); } } szEnvBlock[nPos] = _T('\0'); @@ -570,11 +575,11 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 if (dir != 0) { - const wchar_t * str = (const wchar_t *)env->GetStringChars(dir, 0); + const wchar_t * str = (const wchar_t *)(*env)->GetStringChars(env, dir, 0); if(NULL != str) { cwd = wcsdup(str); - env->ReleaseStringChars(dir, (const jchar *)str); + (*env)->ReleaseStringChars(env, dir, (const jchar *)str); } } @@ -648,7 +653,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 // [in] uid - unique process ID // [in] signal - signal to raise ///////////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise (JNIEnv * env, jobject process, jint uid, jint signal) { @@ -668,7 +675,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise } #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Spawner received signal %i for process %i\n"), signal, pCurProcInfo -> pid); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Spawner received signal %i for process %i\n"), signal, pCurProcInfo -> pid); OutputDebugStringW(buffer); #endif @@ -689,7 +696,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise break; case SIG_TERM: #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Spawner received TERM signal for process %i\n"), + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Spawner received TERM signal for process %i\n"), pCurProcInfo -> pid); OutputDebugStringW(buffer); #endif @@ -702,7 +709,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise case SIG_KILL: #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Spawner received KILL signal for process %i\n"), + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Spawner received KILL signal for process %i\n"), pCurProcInfo -> pid); OutputDebugStringW(buffer); #endif @@ -739,7 +746,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise // Arguments: (see Spawner.java) // [in] uid - unique process ID ///////////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor (JNIEnv * env, jobject process, jint uid) { @@ -785,13 +794,13 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor ///////////////////////////////////////////////////////////////////////////////////// void ThrowByName(JNIEnv *env, const char *name, const char *msg) { - jclass cls = env->FindClass(name); + jclass cls = (*env)->FindClass(env, name); if (cls != 0) /* Otherwise an exception has already been thrown */ - env->ThrowNew(cls, msg); + (*env)->ThrowNew(env, cls, msg); /* It's a good practice to clean up the local references. */ - env->DeleteLocalRef(cls); + (*env)->DeleteLocalRef(env, cls); } @@ -916,7 +925,7 @@ void _cdecl waitProcTermination(void* pv) { cleanUpProcBlock(pInfo + i); #ifdef DEBUG_MONITOR - swprintf(buffer, _T("waitProcTermination: set PID %i to 0\n"), + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("waitProcTermination: set PID %i to 0\n"), pi->dwProcessId); OutputDebugStringW(buffer); #endif diff --git a/core/org.eclipse.cdt.core.win32/library/iostream.c b/core/org.eclipse.cdt.core.native/native_src/win/iostream.c index 3b8d11259d4..7fcfaf90d18 100644 --- a/core/org.eclipse.cdt.core.win32/library/iostream.c +++ b/core/org.eclipse.cdt.core.native/native_src/win/iostream.c @@ -16,15 +16,12 @@ * This is a part of JNI implementation of spawner * Includes implementation of JNI methods (see Spawner.java) *******************************************************************************/ -#include "stdafx.h" #include <string.h> #include <stdlib.h> -#include "spawner.h" -#include "SpawnerInputStream.h" -#include "SpawnerOutputStream.h" +#include <jni.h> +#include <windows.h> -#include "jni.h" -#include "io.h" +#include "Spawner.h" //#define READ_REPORT @@ -38,7 +35,9 @@ void ThrowByName(JNIEnv *env, const char *name, const char *msg); * Method: read0 * Signature: (I)I */ +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0 (JNIEnv * env, jobject proc, jint fd, jbyteArray buf, jint len) { @@ -142,7 +141,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_rea } } if(nNumberOfBytesRead > 0) - env->SetByteArrayRegion(buf, nBuffOffset, nNumberOfBytesRead, tmpBuf); + (*env)->SetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesRead, tmpBuf); else break; nBuffOffset += nNumberOfBytesRead; @@ -152,7 +151,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_rea { // Is there data left in the pipe? DWORD bytesAvailable = 0; - if (!::PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &bytesAvailable, NULL) + if (!PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &bytesAvailable, NULL) || bytesAvailable == 0) // No bytes left break; @@ -174,7 +173,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_rea * Method: close0 * Signature: (I)I */ +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0 (JNIEnv * env, jobject proc, jint fd) { @@ -192,7 +193,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_clo return (rc ? GetLastError() : 0); } +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0 (JNIEnv * env, jobject proc, jint fd) { @@ -210,7 +213,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_ava * Method: write0 * Signature: (I[BI)I */ +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0 (JNIEnv * env, jobject proc, jint fd, jbyteArray buf, jint len) { @@ -222,7 +227,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_wr { DWORD nNumberOfBytesToWrite = min(len - nBuffOffset, BUFF_SIZE); DWORD nNumberOfBytesWritten; - env->GetByteArrayRegion(buf, nBuffOffset, nNumberOfBytesToWrite, tmpBuf); + (*env)->GetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesToWrite, tmpBuf); if(0 == WriteFile((HANDLE)fd, tmpBuf, nNumberOfBytesToWrite, &nNumberOfBytesWritten, NULL)) { char * lpMsgBuf; @@ -252,7 +257,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_wr * Method: close0 * Signature: (I)I */ +#ifdef __cplusplus extern "C" +#endif JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0 (JNIEnv * env, jobject proc, jint fd) { diff --git a/core/org.eclipse.cdt.core.win32/library/raise.c b/core/org.eclipse.cdt.core.native/native_src/win/raise.c index e34a8259d39..b908b159d0b 100644 --- a/core/org.eclipse.cdt.core.win32/library/raise.c +++ b/core/org.eclipse.cdt.core.native/native_src/win/raise.c @@ -15,11 +15,10 @@ * * This is a part of JNI implementation of spawner *******************************************************************************/ -#include "stdafx.h" -#include "Spawner.h" - +#include <jni.h> +#include <windows.h> -#include "jni.h" +#include "Spawner.h" extern void JNICALL ThrowByName(JNIEnv *env, const char *name, const char *msg); @@ -90,6 +89,7 @@ int interruptProcess(int pid) HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); if (proc != NULL) { + typedef BOOL WINAPI (*DebugBreakProcessFunc)(HANDLE); DebugBreakProcessFunc pDebugBreakProcess = (DebugBreakProcessFunc)procaddr; success = (*pDebugBreakProcess)(proc); CloseHandle(proc); diff --git a/core/org.eclipse.cdt.core.win32/library/spawner.c b/core/org.eclipse.cdt.core.native/native_src/win/spawner.c index c4d52bb8a41..ba3e27f2c44 100644 --- a/core/org.eclipse.cdt.core.win32/library/spawner.c +++ b/core/org.eclipse.cdt.core.native/native_src/win/spawner.c @@ -16,16 +16,19 @@ * This is a part of JNI implementation of spawner *******************************************************************************/ -#include "stdafx.h" -#include "spawner.h" +#include <tchar.h> +#include <windows.h> +#include "Spawner.h" CRITICAL_SECTION cs; wchar_t path[MAX_PATH + 1] = {_T('\0') }; // Directory where spawner.dll is located +#if __cplusplus extern "C" +#endif BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved diff --git a/core/org.eclipse.cdt.core.win32/library/starter/starter.cpp b/core/org.eclipse.cdt.core.native/native_src/win/starter.c index 30dfe2f078b..6284f75586f 100644 --- a/core/org.eclipse.cdt.core.win32/library/starter/starter.cpp +++ b/core/org.eclipse.cdt.core.native/native_src/win/starter.c @@ -24,6 +24,7 @@ #include <tchar.h> #include <stdio.h> #include <psapi.h> +#include <stdbool.h> //#define DEBUG_MONITOR #define MAX_CMD_LINE_LENGTH (2049) @@ -99,7 +100,7 @@ bool isCygwin(HANDLE process) { bool runCygwinCommand(wchar_t * command) { wchar_t cygcmd[1024]; - swprintf(cygcmd, L"%s\\%s", cygwinBin, command); + swprintf(cygcmd, sizeof(cygcmd)/sizeof(cygcmd[0]), L"%s\\%s", cygwinBin, command); STARTUPINFO si; ZeroMemory(&si, sizeof(si)); @@ -210,9 +211,9 @@ int main() { wchar_t outPipeName[PIPE_NAME_LENGTH]; wchar_t errPipeName[PIPE_NAME_LENGTH]; - swprintf(inPipeName, L"\\\\.\\pipe\\stdin%08i%010i", parentPid, nCounter); - swprintf(outPipeName, L"\\\\.\\pipe\\stdout%08i%010i", parentPid, nCounter); - swprintf(errPipeName, L"\\\\.\\pipe\\stderr%08i%010i", parentPid, nCounter); + swprintf(inPipeName, sizeof(inPipeName)/sizeof(inPipeName[0]), L"\\\\.\\pipe\\stdin%08i%010i", parentPid, nCounter); + swprintf(outPipeName, sizeof(outPipeName)/sizeof(outPipeName[0]), L"\\\\.\\pipe\\stdout%08i%010i", parentPid, nCounter); + swprintf(errPipeName, sizeof(errPipeName)/sizeof(errPipeName[0]), L"\\\\.\\pipe\\stderr%08i%010i", parentPid, nCounter); #ifdef DEBUG_MONITOR swprintf(buffer, _T("Pipes: %s, %s, %s\n"), inPipeName, outPipeName, errPipeName); OutputDebugStringW(buffer); @@ -230,7 +231,7 @@ int main() { (INVALID_HANDLE_VALUE == (stdHandles[2] = CreateFileW(errPipeName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, &sa)))) { #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Failed to open pipe %i, %i, %i: %i\n"), stdHandles[0], stdHandles[1], stdHandles[2], GetLastError()); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Failed to open pipe %i, %i, %i: %i\n"), stdHandles[0], stdHandles[1], stdHandles[2], GetLastError()); OutputDebugStringW(buffer); #endif CloseHandle(stdHandles[0]); @@ -246,7 +247,7 @@ int main() { !SetStdHandle(STD_OUTPUT_HANDLE, stdHandles[1]) || !SetStdHandle(STD_ERROR_HANDLE, stdHandles[2])) { #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Failed to reassign standard streams: %i\n"), GetLastError()); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Failed to reassign standard streams: %i\n"), GetLastError()); OutputDebugStringW(buffer); #endif CloseHandle(stdHandles[0]); @@ -267,7 +268,7 @@ int main() { OutputDebugStringW(_T("Starter: Environment\n")); for (wchar_t * lpszVariable = (wchar_t *) lpvEnv; *lpszVariable; lpszVariable+=wcslen(lpszVariable) + 1) { - swprintf(buffer, _T("%s\n"), lpszVariable); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("%s\n"), lpszVariable); OutputDebugStringW(buffer); } @@ -275,7 +276,7 @@ int main() { } #endif #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Starting: %s\n"), szCmdLine); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Starting: %s\n"), szCmdLine); OutputDebugStringW(buffer); #endif // Create job object @@ -317,7 +318,7 @@ int main() { if (f) { #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Process %i started\n"), pi.dwProcessId); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Process %i started\n"), pi.dwProcessId); OutputDebugStringW(buffer); #endif SetEvent(waitEvent); // Means that process has been spawned @@ -327,7 +328,7 @@ int main() { if(NULL != hJob) { if(!AssignProcessToJobObject(hJob, pi.hProcess)) { #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Cannot assign process %i to a job\n"), pi.dwProcessId); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Cannot assign process %i to a job\n"), pi.dwProcessId); OutputDebugStringW(buffer); DisplayErrorMessage(); #endif @@ -344,13 +345,13 @@ int main() { case WAIT_OBJECT_0 + 0: // SIGINT case WAIT_OBJECT_0 + 4: // CTRL-C #ifdef DEBUG_MONITOR - swprintf(buffer, _T("starter (PID %i) received CTRL-C event\n"), currentPID); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("starter (PID %i) received CTRL-C event\n"), currentPID); OutputDebugStringW(buffer); #endif if ((event == (WAIT_OBJECT_0 + 0)) && isCygwin(h[1])) { // Need to issue a kill command wchar_t kill[1024]; - swprintf(kill, L"kill -SIGINT %d", pi.dwProcessId); + swprintf(kill, sizeof(kill)/sizeof(kill[0]), L"kill -SIGINT %d", pi.dwProcessId); if (!runCygwinCommand(kill)) { // fall back to console event GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); @@ -365,7 +366,7 @@ int main() { case WAIT_OBJECT_0 + 1: // App terminated normally // Make it's exit code our exit code #ifdef DEBUG_MONITOR - swprintf(buffer, _T("starter: launched process has been terminated(PID %i)\n"), + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("starter: launched process has been terminated(PID %i)\n"), pi.dwProcessId); OutputDebugStringW(buffer); #endif @@ -382,13 +383,13 @@ int main() { { const wchar_t* signal = (event == WAIT_OBJECT_0 + 2) ? L"TERM" : L"KILL"; #ifdef DEBUG_MONITOR - swprintf(buffer, _T("starter received %s event (PID %i)\n"), signal, currentPID); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("starter received %s event (PID %i)\n"), signal, currentPID); OutputDebugStringW(buffer); #endif if (isCygwin(h[1])) { // Need to issue a kill command wchar_t kill[1024]; - swprintf(kill, L"kill -%s %d", signal, pi.dwProcessId); + swprintf(kill, sizeof(kill)/sizeof(kill[0]), L"kill -%s %d", signal, pi.dwProcessId); if (!runCygwinCommand(kill)) { // fall back to console event GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); @@ -424,7 +425,7 @@ int main() { } } else { #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Cannot start: %s\n"), szCmdLine); + swprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), _T("Cannot start: %s\n"), szCmdLine); OutputDebugStringW(buffer); DisplayErrorMessage(); diff --git a/core/org.eclipse.cdt.core.native/pom.xml b/core/org.eclipse.cdt.core.native/pom.xml new file mode 100644 index 00000000000..02bc3bf9137 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/pom.xml @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2018 Red Hat, Inc. and others. + This program and the accompanying materials + are made available under the terms of the Eclipse Public License 2.0 + which accompanies this distribution, and is available at + https://www.eclipse.org/legal/epl-2.0/ + + SPDX-License-Identifier: EPL-2.0 + + Contributors: + Mat Booth (Red Hat) - initial implementation +--> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.cdt</groupId> + <artifactId>cdt-parent</artifactId> + <version>10.0.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <version>6.0.0-SNAPSHOT</version> + <artifactId>org.eclipse.cdt.core.native</artifactId> + <packaging>eclipse-plugin</packaging> + + <profiles> + <profile> + <id>build-native.all</id> + <activation> + <property> + <name>native</name> + <value>all</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>natives</id> + <phase>process-resources</phase> + <configuration> + <target> + <exec executable="make" newenvironment="false" failOnError="true" dir="./native_src"> + <arg value="rebuild" /> + </exec> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>build-native.docker</id> + <activation> + <property> + <name>native</name> + <value>docker</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>natives</id> + <phase>process-resources</phase> + <configuration> + <target> + <exec executable="docker" newenvironment="false" failOnError="true"> + <!-- docker run -\-rm -t -v $(git rev-parse -\-show-toplevel):/work -w /work/$(git rev-parse -\-show-prefix) quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest make -C native_src rebuild --> + <arg value="run" /> + <arg value="--rm" /> + <arg value="-t" /> + <arg value="-v" /> + <arg value="${project.basedir}/../..:/work" /> + <arg value="-w" /> + <arg value="/work/core/org.eclipse.cdt.core.native" /> + <arg value="quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest" /> + <arg value="make" /> + <arg value="-C" /> + <arg value="native_src" /> + <arg value="rebuild" /> + </exec> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> diff --git a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll Binary files differindex 3dba4a71679..7b6555c4a1a 100755 --- a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll +++ b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll diff --git a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe Binary files differindex 9816ad5427e..fd0fd34a53f 100755 --- a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe +++ b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe diff --git a/core/org.eclipse.cdt.core.win32/library/.gitignore b/core/org.eclipse.cdt.core.win32/library/.gitignore index 4d4ec54ac04..2105ba251e3 100644 --- a/core/org.eclipse.cdt.core.win32/library/.gitignore +++ b/core/org.eclipse.cdt.core.win32/library/.gitignore @@ -1,3 +1,4 @@ +/build /ipch/ *.obj *.idb diff --git a/core/org.eclipse.cdt.core.win32/library/Makefile b/core/org.eclipse.cdt.core.win32/library/Makefile deleted file mode 100644 index 76bb655800f..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# makefile for libspawner.so - -ifeq ($(JAVA_HOME),) -$(error JAVA_HOME not set in environment) -endif - -# Defaults which can be overridden. -OS = win32 -ARCH = x86 - -JDK_INCLUDES= "$(JAVA_HOME)/include" -JDK_OS_INCLUDES= "$(JAVA_HOME)/include/$(OS)" - -CC=g++ -DEBUG_FLAGS = -D_UNICODE -DDEBUG_MONITOR -DREAD_REPORT -CFLAGS = -DUNICODE -I$(JDK_INCLUDES) -I$(JDK_OS_INCLUDES) -CXX=g++ -CXXFLAGS=$(CFLAGS) - -INSTALL_DIR = ../../org.eclipse.cdt.core.$(OS).$(ARCH)/os/$(OS)/$(ARCH) - -LIB_NAME_SPAWNER = spawner.dll -LIB_NAME_FULL_SPAWNER = $(INSTALL_DIR)/spawner.dll -OBJS_SPAWNER=StdAfx.o Win32ProcessEx.o iostream.o raise.o spawner.o - -all: $(LIB_NAME_FULL_SPAWNER) - -rebuild: clean all - -$(LIB_NAME_FULL_SPAWNER) : $(OBJS_SPAWNER) - $(CC) -Wl,--kill-at -shared -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER) -lpsapi - -clean : - $(RM) $(OBJS_SPAWNER) diff --git a/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk b/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk deleted file mode 100644 index aeb5c889190..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk +++ /dev/null @@ -1,60 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2011 Marc-Andre Laperle -# -# This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 2.0 -# which accompanies this distribution, and is available at -# https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# Marc-Andre Laperle - initial API and implementation -#******************************************************************************* - -# Makefile (nmake) for Core fragment on Windows x86_64 - -OS = win32 -ARCH = x86_64 - -JDK_INCLUDES= "$(JAVA_HOME)\include" -JDK_OS_INCLUDES= "$(JAVA_HOME)\include/$(OS)" - -CC=cl -DEBUG_FLAGS = -DDEBUG_MONITOR -DREAD_REPORT -CFLAGS = /TP /I$(JDK_INCLUDES) /I$(JDK_OS_INCLUDES) /EHs /nologo -CFLAGS_UNICODE = /D "_UNICODE" /D "UNICODE" $(CFLAGS) - -INSTALL_DIR = ..\..\org.eclipse.cdt.core.$(OS).$(ARCH)\os\$(OS)\$(ARCH) - -DLL_SPAWNER = spawner.dll -OBJS_SPAWNER=StdAfx.obj Win32ProcessEx.obj iostream.obj raise.obj spawner.obj - -EXE_STARTER = starter.exe -OBJS_STARTER=starter/starter.obj - -.c.obj: - cl /c $(CFLAGS_UNICODE) $*.c /Fo$@ - -.cpp.obj: - cl /c $(CFLAGS_UNICODE) $*.cpp /Fo$@ - -spawner: $(OBJS_SPAWNER) - link /dll /nologo /out:$(DLL_SPAWNER) $(OBJS_SPAWNER) User32.lib - -starter: $(OBJS_STARTER) - link /nologo /out:$(EXE_STARTER) $(OBJS_STARTER) Psapi.Lib Shell32.lib - -all: spawner starter - -clean: - del *.obj *.lib *.exp *.exe *.dll starter\*.obj - -rebuild: clean all - -install: all - copy *.dll $(INSTALL_DIR) - copy *.exe $(INSTALL_DIR) - -uninstall: - del $(INSTALL_DIR)\*.dll $(INSTALL_DIR)\*.exe diff --git a/core/org.eclipse.cdt.core.win32/library/Readme64.txt b/core/org.eclipse.cdt.core.win32/library/Readme64.txt deleted file mode 100644 index 2fb8b08feee..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/Readme64.txt +++ /dev/null @@ -1,26 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2011 Marc-Andre Laperle -# -# This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 2.0 -# which accompanies this distribution, and is available at -# https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -# Contributors: -# Marc-Andre Laperle - initial API and implementation -#******************************************************************************* - -How to build the Win32 x86_64 core fragment: - -1. Prerequisites -- Install Windows SDK 7.1. If the SDK is not installed in the default location or if you want to try a different SDK, modify setenv64.bat accordingly. -- Make sure your JAVA_HOME environment variable is set and points to a 64 bit JDK (C:\Program Files\Java\jdkX.X.X not C:\Program Files (x86)\Java\jdkX.X.X ) - -2. Build and install -- In a command prompt, execute setenv64.bat. -The command prompt should turn to a different color and print a message about targeting x64. -- Execute build64.bat -This will build the dlls and executables, copy them to org.eclipse.cdt.core.win32.x86_64\os\win32\x86_64 then clean the build directories. -Optionally, you can use nmake /f Makefile_x86_64.mk TARGET directly. Refer to Makefile_x86_64.mk for valid targets. diff --git a/core/org.eclipse.cdt.core.win32/library/StdAfx.c b/core/org.eclipse.cdt.core.win32/library/StdAfx.c deleted file mode 100644 index ea8e1023e93..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/StdAfx.c +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - * - * StdAfx.c - * - * This is a part of JNI implementation of spawner - *******************************************************************************/ -// stdafx.cpp : source file that includes just the standard includes -// spawner.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/core/org.eclipse.cdt.core.win32/library/StdAfx.h b/core/org.eclipse.cdt.core.win32/library/StdAfx.h deleted file mode 100644 index c176fed0ad0..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/StdAfx.h +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * QNX Software Systems - initial API and implementation - * - * StdAfx.h - * - * This is a part of JNI implementation of spawner - *******************************************************************************/ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__9D84F180_36E5_47D6_96AB_22723242789C__INCLUDED_) -#define AFX_STDAFX_H__9D84F180_36E5_47D6_96AB_22723242789C__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -// Insert your headers here -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include <tchar.h> - -#include <windows.h> - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__9D84F180_36E5_47D6_96AB_22723242789C__INCLUDED_) diff --git a/core/org.eclipse.cdt.core.win32/library/build64.bat b/core/org.eclipse.cdt.core.win32/library/build64.bat deleted file mode 100644 index f866c8befc0..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/build64.bat +++ /dev/null @@ -1,14 +0,0 @@ -@rem *************************************************************************** -@rem Copyright (c) 2011 Marc-Andre Laperle and others. -@rem This program and the accompanying materials -@rem are made available under the terms of the Eclipse Public License 2.0 -@rem which accompanies this distribution, and is available at -@rem https://www.eclipse.org/legal/epl-2.0/ -em -em SPDX-License-Identifier: EPL-2.0 -@rem -@rem Contributors: -@rem Marc-Andre Laperle - initial API and implementation -@rem *************************************************************************** - -nmake /f Makefile_x86_64.mk /NOLOGO install clean
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/setenv64.bat b/core/org.eclipse.cdt.core.win32/library/setenv64.bat deleted file mode 100644 index dfe68b7394a..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/setenv64.bat +++ /dev/null @@ -1 +0,0 @@ -"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\setenv.cmd" /x64 /2003 /Release
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/starter/Makefile b/core/org.eclipse.cdt.core.win32/library/starter/Makefile deleted file mode 100644 index 54c92c5b829..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/starter/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -OS = win32 -ARCH = x86 - -TARGET = $(INSTALL_DIR)/starter.exe - -OBJS = starter.o - -LIBS = -lpsapi - -CXX = g++ -CXXFLAGS = -DUNICODE - -INSTALL_DIR = ../../../org.eclipse.cdt.core.$(OS).$(ARCH)/os/$(OS)/$(ARCH) - -all: $(TARGET) - -rebuild: clean all - -clean : - $(RM) $(OBJS) - -$(TARGET) : $(OBJS) - $(CXX) -o $(TARGET) $(OBJS) $(LIBS) |